Highcharts JSON加载问题 [英] Highcharts JSON load issue

查看:97
本文介绍了Highcharts JSON加载问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个示例Highchart,我试图在没有任何运气的情况下加载JSON数据.我在Firebug中看到了数据返回,但图表栏和折线未绘制.您可以在 jsfiddle.net 上看到我的图表.我知道我想念一些东西,但似乎无法将手指放在上面.任何帮助将不胜感激,在此先感谢您.

I have a sample Highchart that I'm try to load JSON data without any luck. I see the data return in firebug but the chart bar and line doesn't get drawn. You can see my chart here jsfiddle.net. I know I'm missing something, but I can't seem to put my fingers on it. Any help would greatly appreciated, thank you in advance.

这是我的代码:

$(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返回的内容:

Here's what data.cfm return:

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

推荐答案

应该吗?

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

这篇关于Highcharts JSON加载问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆