highchart图表显示问题

左手键盘右手鼠标 发布于 2014/04/11 10:43
阅读 1K+
收藏 1

highchart写了个图表

页面刚进入时不显示图表的数据 横纵坐标都没有

F12按一下就能把数据什么的都刷出来了 其他任何操作都没有

无法截图靠

代码如下:

 //列数据
                        var chartData = new Array();
                        //列名
                        var chartCol = new Array();
                        //年份
                        var chartYear = new Array();
                        //异步获取数据
                        function getChartData(){
                            $.ajax({
                                type: "POST",
                                url: "${ctx}/rawDataChart.do",
                                dataType: 'json',
                                async: false,
                                data: "id=Material_synthesize",
                                success: function(data){
                                    //将后台数据封装到数组中
                                    var text = $.parseJSON(data.toString());
                                    //数组第一位是列名
                                    chartCol = text[0];
                                    //从数组第2个元素开始是数据
                                    for (var i = 1; i < text.length; i++) {
                                        //获得一组数据此时第一个数据时年份
                                        var map = text[i];
                                        chartYear.push(parseFloat(map[0]));
                                        //从第2个开始是真实数据
                                        var dataArr = [];
                                        for (var j = 1; j < map.length; j++) {
                                            dataArr.push(parseFloat(map[j]))
                                        }
                                        //将每组数据添加上
                                        chartData.push(dataArr);
                                    }
                                }
                            }, 'json');
                        }
                        
                        //绘制图表方法
                        function drawChart(){
                            $('#container').highcharts({
                                chart: {
                                    type: 'column',
                                    height: 500,
                                    width: 2000
                                },
                                //标题
                                title: {
                                    text: 'Monthly Average Rainfall'
                                },
                                //副标题
                                subtitle: {
                                    text: 'Source: WorldClimate.com'
                                },
                                //横坐标
                                xAxis: {
                                    categories: chartCol,
                                    labels: {
                                        align: 'right',
                                        rotation: 315,
                                        style: {
                                            color: 'black'
                                        }
                                    }
                                },
                                //纵坐标
                                yAxis: {
                                    min: 0,
                                    title: {
                                        text: '产值/可比价'
                                    }
                                },
                                //提示
                                tooltip: {},
                                plotOptions: {
                                    column: {
                                        pointPadding: 0.2,
                                        borderWidth: 0
                                    }
                                },
                                //数据
                                series: []
                            });
                            //将数据添加到图表
                            var chart = $('#container').highcharts();
                            // 初始化设置chart的series源
                            for (var i = chartData.length - 1; i > -1; i--) {
                                chart.addSeries({
                                    id: i,
                                    name: chartYear[i] + '年',
                                    data: chartData[i]
                                }, false);
                            }
                            //chart.redraw();
                        }
                        $(document).ready($(function(){
                            //初始化获得图表数据
                            getChartData();
                            // 绘制统计图
                            drawChart();
                        }));

求解释求解决办法(PS:MD原来一直是好的用了美工的页面以后成这样了..也不会CSS这事也没法问美工的问题)

加载中
返回顶部
顶部