English 中文(简体)
2. 高档
原标题:highcharts correct json input

USDTAED:Now with the following Code, the json is welling better ,

但是,如果把 cur子放在表面上,一看能够显示系列名称和价值的工具,这些栏目就没有显示在最初的负荷上。 然而,如果浏览器窗户重新使用,则栏目出现。 i 在经过更新的Chart(Chart)之后,试图添加图表;但确实帮助我干iv如下:

<div id="container" style="min-width: 400px ; height: 650; margin:0 auto"></div>

任何想法都请? 而且,不能在黑手提上重新提出这一问题,并且用法、草原和火ox(所有这些都表明这种奇怪的行为)来测试这一问题。

            var chart;
            options = {
                chart: {
                    renderTo:  container ,
                    type:  column ,
                },
                title: {
                    text:  Some title 
                },
                subtitle: {
                    text:  subtitle 
                },
                xAxis: {
                    categories: [],
                    title: {
                        text: null
                    }
                },
                yAxis: {
                    min: 0,
                    title: {
                        text:  y-Axis ,
                        align:  high 
                    }
                },
                tooltip: {
                    formatter: function() {
                        return    + this.series.name +  :   + this.y +    ;
                    }
                },
                plotOptions: {
                    bar: {
                        dataLabels: {
                            enabled: true
                        }
                    }
                },
                legend: {
                    layout:  vertical ,
                    align:  right ,
                    verticalAlign:  top ,
                    x: -100,
                    y: 100,
                    floating: true,
                    borderWidth: 1,
                    backgroundColor:  #FFFFFF ,
                    shadow: true
                },
                credits: {
                    enabled: false
                },
                series: 
                []
            };
            $(document).ready(function() {
                chart= new Highcharts.Chart(options)
                console.log("calling update chart");    
                updateChart();
            });

            function updateChart() {
                $.ajax({
                    type: "GET",
                    url: "test.json",
                    async: false,
                    dataType: "json",
                    success: function(data){
                        console.log(data);


                        var i=0;
                        $.each(data,function(index,item){
                            console.log(data.Chart1[index]);
                            console.log("i value is "+i);
                            chart.addSeries(data.Chart1[index]);
                            i++;
                        });

                    }
                });
            }
            }

我的json投入文件如下:

            [
                        {
                            name:  name1 ,
                            y: [32.6,16.6,1.5]
                        }, {
                            name:  name2 ,
                            y: [6.7,0.2,0.6]
                        }, {
                            name:  name3 ,
                            y: [1,3.7,0.7]
                        }, {
                            name:  name4 ,
                            y: [20.3,8.8,9.5]
                        },{
                            name:  name5 ,
                            y: [21.5,10,7.2]
                        }, {
                            name:  name6 ,
                            y: [1.4,1.8,3.7]
                        }, {
                            name:  name7 ,
                            y: [8.1,0,0]
                        }, {
                            name:  name8 ,
                            y: [28.9,8.9,6.6]
                        }
                    ]
最佳回答

http://www.un.org/Depts/DGACM/index_spanish.htm

var chart = null,
    options = {
        chart: {
            renderTo:  container ,
            type:  column 
        },
        title: {
            text:  Some title 
        },
        subtitle: {
            text:  subtitle 
        },
        xAxis: {
            categories: [],
            title: {
                text: null
            }
        },
        yAxis: {
            min: 0,
            title: {
                text:  y-Axis ,
                align:  high 
            }
        },
        tooltip: {
            formatter: function() {
                return    + this.series.name +  :   + this.y +    ;
            }
        },
        plotOptions: {
            bar: {
                dataLabels: {
                    enabled: true
                }
            }
        },
        legend: {
            layout:  vertical ,
            align:  right ,
            verticalAlign:  top ,
            x: -100,
            y: 100,
            floating: true,
            borderWidth: 1,
            backgroundColor:  #FFFFFF ,
            shadow: true
        },
        credits: {
            enabled: false
        },
        series: []
    };
$(document).ready(function() {
    updateChart();
});

function updateChart() {
    $.getJSON( test.json , function(data) {

        // check if the chart s already rendered
        if (!chart) {
            // if it s not rendered you have to update your options
            options.series = data;
            chart = new Highcharts.Chart(options);
        } else {
            // if it s rendered you have to update dinamically
            jQuery.each(data, function(seriePos, serie) {
                chart.series[seriePos].setData(serie, false);
            });
            chart.redraw();
        }
    });
}

http://jsfiddle.net/ricardolohmann/64W4/“rel=”nofollow”

问题回答

暂无回答




相关问题
JQuery/MVC Search Issue

I have inherited a piece of work where the entry screen shows a summary of 20 calculated variables. E.g. Var A (250), Var B (79). Clicking on any of these links takes the user to a view with a ...

jQuery quicksearch plug-in tinkering with JSON

I ve implemented the quicksearch plugin by Rik Lomas and I love it for an application in a custom CMS I m building. I was wondering though, since I m going to have a bizillion items in the table if ...

JSON with classes?

Is there a standardized way to store classes in JSON, and then converting them back into classes again from a string? For example, I might have an array of objects of type Questions. I d like to ...

PHP json_decode question

i m trying to use json_decode to combine a few json objects and then re-encode it. my json looks like: { "core": { "segment": [ { "id": 7, "...

Converting JSON data to Java object

I want to be able to access properties from a JSON string within my Java action method. The string is available by simply saying myJsonString = object.getJson(). Below is an example of what the string ...

热门标签