Highcharts如何将数据从服务器传递到图表

时间:2016-01-21 16:16:51

标签: javascript jquery json highcharts

这是示例Highcharts中的代码:

$(document).ready(function () {
            $(function () {
                $('#container').highcharts({
                    chart: {
                        type: 'column',
                        margin: 75,
                        options3d: {
                            enabled: true,
                            alpha: 10,
                            beta: 25,
                            depth: 70
                        }
                    },
                    title: {
                        text: '@Model.FirstName'
                    },
                    plotOptions: {
                        column: {
                            depth: 25
                        }
                    },
                    xAxis: {
                        categories: Highcharts.getOptions().lang.shortMonths
                    },
                    yAxis: {
                        title: {
                            text: null
                        }
                    },
                    series: [{
                        name: 'Sales',
                        data: [2, 3, null, 4, 0, 5, 1, 4, 6, 3]
                    }],
                    credits: {
                        enabled: false
                    },
                });
            });
        });

我想传递系列"数据:[2,3,null,4,0,5,1,4,6,3]"和类别:" Highcharts.getOptions()。lang.shortMonths"从服务器。我该怎么办?

1 个答案:

答案 0 :(得分:2)

您可以通过Ajax请求数据并致电Select Case

chart.addSeries