Highcharts折线图向下钻取无法正常工作

时间:2018-09-17 11:48:14

标签: javascript charts highcharts

在我的应用程序中,我有一个折线图,显示了多个部门几年来员工人数的变化。然后,当我单击一个数据系列(例如:部门A)时,我需要显示该所选部门的详细信息。我已经添加了dw dwon代码并将数据向下钻取到图表定义。似乎无法正常工作。我在这里找不到问题所在。有没有一种解决方法。示例代码如下。

spin

Select round(TaxableAmount,0) as t, round(((TaxValue*100)/TaxPercentage),0)as t2 from VoucherTaxDetail where 
TaxPercentage<>0 and TaxableAmount>0 and TableName in('TVPayment','Payment') group by transactionId having t<>t2 

1 个答案:

答案 0 :(得分:2)

首先,您必须在NS = [1, 0, 0] print(qn[tuple(NS)]) 中添加drilldown.js

HTML

<script src="https://code.highcharts.com/modules/drilldown.js"></script>对象在输入JSON对象中输入错误。它应该来自drilldown。下面是正确的格式。请查看代码段。

series
$(function() {
  var chart = new Highcharts.Chart({
    chart: {
      renderTo: "container-main-bar",
      type: "line"
    },
    title: {
      text: null
    },
    series: [{
      "name": "Department A",
      "data": [{
          "name": "Month1",
          "y": 27,
          "drilldown": "levelA2"
        },
        {
          "name": "Month2",
          "y": 24,
          "drilldown": "levelA2"
        },
        {
          "name": "Month3",
          "y": 22,
          "drilldown": "levelA2"
        },
        {
          "name": "Month4",
          "y": 26,
          "drilldown": "levelA2"
        },
        {
          "name": "Month5",
          "y": 21,
          "drilldown": "levelA2"
        },
        {
          "name": "Month6",
          "y": 22,
          "drilldown": "levelA2"
        },
        {
          "name": "Month7",
          "y": 23,
          "drilldown": "levelA2"
        },
        {
          "name": "Month8",
          "y": 24,
          "drilldown": "levelA2"
        },
        {
          "name": "Month9",
          "y": 21,
          "drilldown": "levelA2"
        },
        {
          "name": "Month10",
          "y": 20,
          "drilldown": "levelA2"
        },
        {
          "name": "Month11",
          "y": 22,
          "drilldown": "levelA2"
        },
        {
          "name": "Month12",
          "y": 25,
          "drilldown": "levelA2"
        },
        {
          "name": "Month13",
          "y": 23,
          "drilldown": "levelA2"
        },
        {
          "name": "Month14",
          "y": 24,
          "drilldown": "levelA2"
        },
        {
          "name": "Month15",
          "y": 25,
          "drilldown": "levelA2"
        },
        {
          "name": "Month16",
          "y": 26,
          "drilldown": "levelA2"
        },
        {
          "name": "Month17",
          "y": 24,
          "drilldown": "levelA2"
        },
        {
          "name": "Month18",
          "y": 23,
          "drilldown": "levelA2"
        },
        {
          "name": "Month19",
          "y": 23,
          "drilldown": "levelA2"
        },
        {
          "name": "Month20",
          "y": 25,
          "drilldown": "levelA2"
        },
        {
          "name": "Month21",
          "y": 25,
          "drilldown": "levelA2"
        },
        {
          "name": "Month22",
          "y": 25,
          "drilldown": "levelA2"
        },
        {
          "name": "Month23",
          "y": 25,
          "drilldown": "levelA2"
        },
        {
          "name": "Month24",
          "y": 25,
          "drilldown": "levelA2"
        }
      ]
 } ],
 
      "drilldown": {
        "series": [{
          "name": 'Headcount',
          "id": 'levelA2',
          "data": [{
              "name": "Month1",
              "y": 10,
            },
            {
              "name": "Month2",
              "y": 12,
            },
            {
              "name": "Month3",
              "y": 11,
            },
            {
              "name": "Month4",
              "y": 10,
            },
            {
              "name": "Month5",
              "y": 9,
            },
            {
              "name": "Month6",
              "y": 8,
            },
            {
              "name": "Month7",
              "y": 10,
            },
            {
              "name": "Month8",
              "y": 12,
            },
            {
              "name": "Month9",
              "y": 11,
            },
            {
              "name": "Month10",
              "y": 13,
            },
            {
              "name": "Month11",
              "y": 14,
            },
            {
              "name": "Month12",
              "y": 10,
            },
            {
              "name": "Month13",
              "y": 9,
            },
            {
              "name": "Month14",
              "y": 8,
            },
            {
              "name": "Month15",
              "y": 11,
            },
            {
              "name": "Month16",
              "y": 10,
            },
            {
              "name": "Month17",
              "y": 9,
            },
            {
              "name": "Month18",
              "y": 10,
            },
            {
              "name": "Month19",
              "y": 11,
            },
            {
              "name": "Month20",
              "y": 12,
            },
            {
              "name": "Month21",
              "y": 13,
            },
            {
              "name": "Month22",
              "y": 10,
            },
            {
              "name": "Month23",
              "y": 11,
            },
            {
              "name": "Month24",
              "y": 12,
            }
          ]
        }]
      },
    
    xAxis: {
      categories: [{
          "name": "2013",
          "categories": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
        },
        {
          "name": "2014",
          "categories": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
        },
        {
          "name": "2015",
          "categories": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
        },
        {
          "name": "2016",
          "categories": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
        },
        {
          "name": "2017",
          "categories": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
        },
        {
          "name": "2018",
          "categories": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
        }
      ]
    },
    yAxis: [{ // Primary yAxis
      title: {
        text: 'No. of Employees'
      },
    }],
  });
});