相同的js highcharts显示不一样

时间:2013-05-27 09:50:48

标签: javascript jsp highcharts

我使用highcharts显示日期,现在我生成js代码如下:

$(function () {
    var chart;
    $(document).ready(function () {
            chart = new Highcharts.Chart({
                    chart: {
                        renderTo: 'container',
                        type: 'column',
                        borderWidth: 1
                    },
                    title: {
                        text: '终端类型统计'
                    },
                    xAxis: {
                        categories: ['Apple', 'Samsung Electronics Co.,Ltd', 'HTC Corporation', 'Hon Hai Precision Ind. Co.,Ltd.', 'Intel Corporate', 'Xiaomi Technology,Inc.', 'Liteon Technology Corporation', 'Huawei Technologies Co., Ltd', 'Murata Manufactuaring Co.,Ltd.', 'Azurewave Technologies, Inc.', 'Huawei Device Co., Ltd', 'zte corporation', 'Lenovo Mobile Communication Technology Ltd.', 'GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP.,LTD.', 'Azurewave', 'XIAOMI CORPORATION', 'Sony Ericsson Mobile Communications AB', 'Yulong Computer Telecommunication Scientific(shenzhen)Co.,Lt', 'AcSiP Technology Corp.', 'BBK Electronics Corp., Ltd.', '其他'],
                        labels: {
                            rotation: -25,
                            align: 'right',
                            style: {
                                fontSize: '13px',
                                fontFamily: 'Verdana, sans-serif'
                            }
                        }
                    },
                    yAxis: {
                        title: {
                            text: '数据统计'
                        }
                    },
                    plotOptions: {
                        column: {
                            colorByPoint: true,
                            dataLabels: {
                                enabled: true,
                                rotation: -90,
                                y: 25,
                                color: '#F4F4F4',
                                formatter: function () {
                                    return Highcharts.numberFormat(this.y, 0);
                                },
                                x: 10,
                                style: {
                                    fontWeight: 'bold'
                                }
                            }
                        }
                    },
                    lang: {
                        decimalPoint: '.',
                        downloadPNG: '下载PNG图片',
                        downloadJPEG: '下载JPG图片',
                        downloadPDF: '下载PDF文件'
                    },
                    series: [{
                            showInLegend: false,
                            data: [581476, 407696, 277894, 247696, 168586, 138802, 126082, 93168, 76234, 51568, 51512, 50654, 49026, 47092, 44944, 43188, 41268, 40900, 39408, 38172, 580090],
                            dataLabels: {
                                enabled: true,
                                rotation: -90,
                                color: '#FFFFFF',
                                align: 'right',
                                x: -3,
                                y: 10,
                                formatter: function () {
                                    return this.y;
                                },
                                style: {
                                    fontSize: '13px',
                                    fontFamily: 'Verdana, sans-serif'
                                }
                            }
                        }
                    ]
                });
        });
})

它应该显示为this,但在我的页面中[显示如下]即8(https://i.minus.com/irfUdeWCLEGPD.png)! 任何想法?
ps:,:它在FireFox中运行良好。

1 个答案:

答案 0 :(得分:0)

如果小提琴有效,请仔细检查您的代码,因为在这种情况下很难提供帮助。检查您的chrome控制台或firebug,并确保页面上的其他JavaScript代码不会干扰。

根据http://json.parser.online.fr/您在图表中使用的JSON对象是可以的。至少我找不到任何奇怪的东西......你使用相同的Highcharts版本吗?