首页 > 解决方案 > 来自mysql的Highcharts钻取数据

问题描述

我试图对我的图表使用类似于以下的钻取方法:https ://www.highcharts.com/demo/column-drilldown/sand-signika%5d%5b1%5d 。但我想深入了解年、月、周和日的数据。我该如何执行?这是我的代码:

$query = "SELECT sum(product_total) as total, YEAR(`date`) as year FROM confirm_order_product GROUP BY YEAR(date) ORDER BY date";

$result = $mysqli->query($query);

while($row = $result->fetch_array(MYSQLI_ASSOC))
{
    $salestotal[] = $row['total'];
    $sdate[] = $row['year'];
}
$salesdate = json_encode($sdate, JSON_NUMERIC_CHECK);
$sales = json_encode($salestotal, JSON_NUMERIC_CHECK);

容器:

  $(function() {
    $('#container').highcharts({
      chart: {
        type: 'column'
      },
      title: {
        text: 'Sales Report'
      },
      xAxis: {
        categories: <?php echo $salesdate; ?>

      },
      yAxis: {
        title: {
          text: 'Value'
        },
              },
      tooltip: {
        valuePrefix: '₱'
      },

      series: [{
        name: 'Sales',
        colorByPoint: true,
        data:<?php echo $sales; ?>,


}],


    });
  });

这仅每年显示。

标签: mysqlhighcharts

解决方案


推荐阅读