2017-07-04 43 views
1

很高興認識你。 我的圖表出現問題。禁用的點不隱藏。 [Highcharts]

我有一個DB與一些招聘過程數據。該過程具有許多狀態:「已結束」,「正在工作」,「待機」,「已取消」。這個過程只有一次。

我需要使用堆積列,因爲如果使用正常的一個,它讓我小酒吧。

我已經得到了我想要的所有東西,但是當我點擊圖例時,如果沒有極端情況,數據類別仍然存在。

Here the gif showing what I mean

而這裏的代碼:

var ch = Highcharts.chart('barChartContainer', { 
    chart: { 
     type: 'column' 
    }, 
    credits: { 
     enabled:false 
    }, 
    title: { 
     text: 'Detalles' 
    }, 

    xAxis:{ 
     type: "category" 
    }, 
    yAxis: { 
     min: 0, 
     title: { 
      text: 'Tiempo (dias)' 
     } 
    }, 
    tooltip: { 
     headerFormat: '<span style="font-size:10px"></span><table>', 
     pointFormat: '<tr><td style="color:{point.color};padding:0">Tiempo: </td>' + 
      '<td style="padding:0"><b>{point.y} dias</b></td></tr>', 
     footerFormat: '</table>', 
     shared: true, 
     useHTML: true 
    }, 
    plotOptions: { 
     column: { 
      stacking: "normal", 
      pointPadding: 0.2, 
      borderWidth: 0, 
      events: { 
         legendItemClick: function() { 
          return this.visible ? 'visible' : 'hidden'; 
         } 
         }}} 

    }); 

    var seriesArray = []; 
<?php 
$sqlEstados = mysqli_query($con,"SELECT DISTINCT (estado) as nombre_estado from proceso order by nombre_estado"); 
while ($rowEstados = mysqli_fetch_array($sqlEstados)){ 
    ?> ch.addSeries({name:"<?php echo $rowEstados['nombre_estado']?>", color: " <?php echo $rowEstados['nombre_estado'] == "FINALIZADO" ? '#00C851' : ($rowEstados['nombre_estado'] == "WORKING" ? '#ffbb33' : (($rowEstados['nombre_estado'] == "PARADO" ? '#ff4444' : '#33b5e5'))); ?>"}); 
<?php 
} //INFLANDO LAS SERIES 03/07/2017 -> QUEDA INFLAR LAS CATEGORIAS CON OTRA FUNCION QUE DEVUELVA [[nombre,valor]] 
$sql = mysqli_query($con,"SELECT timestampdiff(DAY,fecha_creacion, IFNULL(fecha_cerrado,NOW())) as t_diff_dias, (SELECT MAX(timestampdiff(DAY,fecha_creacion, IFNULL(fecha_cerrado,NOW()))) from proceso where not (estado='FINALIZADO' and fecha_cerrado IS NULL)) as max_dias, id_proceso, proceso,estado from proceso where not (estado='FINALIZADO' and fecha_cerrado IS NULL) ORDER BY id_proceso desc"); 
while ($rowSQL = mysqli_fetch_array($sql)) 
{ 
    $var; 
    switch ($rowSQL['estado']) { 
    case 'FINALIZADO': 
     $var = 1; 
     break; 
    case 'WORKING': 
     $var = 3; 
     break; 
    case 'PARADO': 
     $var = 2; 
     break; 
    default: 
     $var = 0; 
     break; 
    } 
echo "ch.series[".$var."].addPoint([\"".$rowSQL['proceso']."\",".$rowSQL['t_diff_dias']."]);"; 
} 
?> 

謝謝你的建議。

編輯:謝謝你,我嘗試了不同的東西。但我很感謝你的支持

回答

0

從列中刪除事件也堆積, 它默認工作。 如果您的序列數據是好的話,會有沒有問題

series: [ 
      { 
     name: 'A1', 
    data: [0,2,0,58,3] 
    }, 
      { 
     name: 'A2', 
    data: [0,22,0,42,0] 
    }, 
      { 
     name: 'A3', 
    data: [0,2,0,11,0] 
    }, 
] 

這在x軸5個的數據列和3個系列。 只是如果你需要檢查,我的海圖編,忽略額外的代碼

var q=jQuery.noConflict(); 
q(function() { 
    q('#container3').highcharts({ 

chart: { 
     type: 'column' 
    }, 
    title: { 
     text: 'Staff Stats ' 
    }, 
    xAxis: { 
     categories: [ 
      'Done', 
      'New', 
      'Working', 
      'Pending', 
      'Calls', 
     ], 
     crosshair: true 
    }, 
    yAxis: { 
     min: 0, 
     title: { 
      text: 'Stats ' 
     } 
    }, 
    tooltip: { 
     headerFormat: '<span style="font-size:10px">{point.key}</span><table>', 
     pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' + 
      '<td style="padding:0"><b>{point.y:.1f}</b></td></tr>', 
     footerFormat: '</table>', 
     shared: true, 
     useHTML: true 
    }, 
    plotOptions: { 
     column: { 
      pointPadding: 0, 
      borderWidth: 0 
     } 
    }, 
    series: [ 
     { 
     name: 'A1', 
     data: [0,2,0,58,3] 
     }, 
     { 
     name: 'A2', 
     data: [0,22,0,42,0] 
     }, 
     { 
     name: 'A3', 
     data: [0,2,0,11,0] 
     }, 
    ] 
    }); 
}); 
+0

謝謝您的回答,但不正是我想要的。該系列是動態接收的,也沒有類別。 該系列是「工作」,「待機」等...數據接收招聘過程和時間。但是,當我嘗試在圖表中間或不在極端情況下隱藏系列時,「類別」仍然存在 – UnsignedFoo

+0

當您點擊圖例時,您不需要特殊事件來隱藏欄或條,它應該默認工作。 –

+0

我刪除了它,沒有任何變化。中間條消失,但數據名仍在x軸上。 如果我沒有堆疊,我的酒吧變成小塊 – UnsignedFoo