Highcharts JSON负载问题(Highcharts JSON load issue)

2019-11-01 01:00发布

我有一个样品Highchart说我尝试加载JSON数据没有任何的运气。 我看到的萤火,但图表栏和行的数据返回不拿得出。 你可以在这里看到我的图表jsfiddle.net 。 我知道我失去了一些东西,但我似乎不能把我的手指上。 任何帮助将不胜感激,谢谢提前。

这是我的代码:

$(function() {
var options = {
    chart: {
        renderTo: 'container',
        zoomType: 'xy'
    },
    title: {
        text: 'JSON Chart'
    },
    subtitle: {
        text: '2012 vs 2011'
    },
    credits: false,
    xAxis: [{
        categories:['1','2','3','4','5','6','7','8','9','10']
    }],
    yAxis: [{ // Primary yAxis
        min: 0,
        max: 15000,
        tickInterval: 1000,
    labels: {
        formatter: function() {
            return Highcharts.numberFormat(this.value, 0);
        },
        style: {
        color: '#89A54E'
        }
    },
    title: {
        text: '2012',
        style: {
            color: '#89A54E'
        }
    }
    }, { // Secondary yAxis
        min: 0,
        max: 15000,
        tickInterval: 1000,
    labels: {
        formatter: function() {
           return Highcharts.numberFormat(this.value, 0);
        },
        style: {
            color: '#4572A7'
        }
    },
    title: {
        text: '2011',
        style: {
            color: '#4572A7'
        }
    },                        
    opposite: true
    }],
    tooltip: {
        formatter: function() {
           return Highcharts.numberFormat(this.y, 0);
        }
    },
    legend: {
        layout: 'vertical',
        align: 'left',
        x: 80,
        verticalAlign: 'top',
        y: 40,
        floating: true,
        backgroundColor: '#FFFFFF'
    },
    series: [{
        name: '2011',
        type: 'column',
        yAxis: 1,
        data: []        
    }, {
        name: '2012',
        type: 'spline',
        data: []
       }]
     };
});
$.getJSON('data.cfm', function(json) {
options.series = json;               
var chart = new Highcharts.Chart(options);
})

下面是data.cfm返回:

[[9233,14837,11442,8080,10302,5373,2450,9612,18656,8999],[7963,7845,8646,5130,2570,8936,17487,9141,6728,6046]];

Answer 1:

Shoulnt是什么?

    options.series[0].data=json[0];
    options.series[1].data=json[1];


Answer 2:

这可能是有用的: http://livecoding.gabrielflor.it/3351656



文章来源: Highcharts JSON load issue
标签: highcharts