Highcharts显示多行(系列)数据

时间:2017-06-20 08:47:07

标签: highcharts

我试图用4行数据来创建图表。我遇到的问题是因为我无法显示数据。

我的JSON:

[{"Average":["Apr","May","Jun","Jul"],"Good":["Apr","May","Jun","Jul"],"Excellent":["Apr","May","Jun","Jul"],"Not used":["Jan","Apr","May","Jun","Jul"]},{"name":"Poor","data":[1,2]},{"name":"Average","data":[1,1,4,1]},{"name":"Good","data":[1,1,4,1]},{"name":"Excellent","data":[1,1,4,1]},{"name":"Not used","data":[1,1,2,4,1]}]

我的代码:

$(function () {
var categories=[];
var data2 =[];
var chart;
$(document).ready(function() {

        $.getJSON("../charts/1-2-4-overall_year_chart.php?From=<?php echo $YearStart;?>&To=<?php echo $YearEnd;?>", function(json) { 
        $.each(json,function(i,el) { 
        if (el.name=="Month") 
        categories = el.data; 
        else data2.push(el); 
        }); 


        $('#container1').highcharts({
            chart: {
                renderTo: 'container',
                type: 'line',
                marginTop: 25,
                marginRight: 25,
                marginBottom: 25,
                plotBackgroundColor: '#FCFFC5',
                style: {
                    fontFamily: 'serif',
                    fontSize: '8px',
                }
            },

        title: {
            text: ''
        },

        colors: [
        '#ff0000',
        '#f49004',
        '#3abf05',
        '#8b8c8a',
        ],


        subtitle: {
            text: ''
        },

         xAxis: {
            categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        },

        yAxis: {
            title: {
                text: 'Percentage %'
            }
        },

        plotOptions: {
            line: {
                dataLabels: {
                    enabled: true
            },
        enableMouseTracking: false
         }
        },

        series: [{
            data2: [{
                name: 'Detractor',
                color: '#00FF00',
                y: 1
            }, {
                name: 'Passive',
                color: '#FF00FF',
                y: 5
            }]
        }], 

        credits: {
            enabled: false
        },          

        lang: {
            noData: "No data"
        },
        noData: {
            style: {
                fontWeight: 'normal',
                fontSize: '12px',
                color: '#303030'
            }
        },
     });
    });
 });
});

任何人都可以看到我出错的地方。 非常感谢你的时间。

0 个答案:

没有答案