在IE中没有显示的Highcharts JSON图

时间:2013-06-15 12:41:50

标签: internet-explorer canvas highcharts

我目前正在使用Highcharts包使用Highcharts包动态创建图形。一切都在游泳,直到我决定测试网络开发者最好的朋友IE。惊喜,惊喜,它不喜欢我的代码。我的代码可以在下面看到,以及我的数据样本,让您了解我正在使用的内容:

<html lang="en">
<head>
    <title>Preprocessing Test</title>

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="http://code.highcharts.com/highcharts.js"></script>
    <script type="text/javascript" src="http://code.highcharts.com/modules/exporting.js"></script>
    <link href="chemistry.css" rel="stylesheet" type="text/css" media="screen" />
    <script type="text/javascript">
      $(document).ready(function() {

    var options = {
        chart: {
        renderTo: 'container',
        defaultSeriesType: 'spline',
        zoomType: 'x',
    },
            plotOptions: {
                spline: {
                    lineWidth: 3,
                    states: {
                        hover: {
                            lineWidth: 1
                        }
                    },
                    tooltip: {
                        backgroundColor: '#FCFFC5',
                        borderColor: 'black',
                        borderRadius: 10,
                        borderWidth: 3
                        },
                         marker: {
                             enabled: false,
                             states: {
                                  hover: {
                                     enabled: true,
                                     symbol: 'circle',
                                      radius: 2,
                                     lineWidth: 1,

                                 }
                             }
                         }
                    }
             },
         title: {
              text: 'Preprocessed Example'
         },
         xAxis: {   
                 categories: [],
                 labels: {
                        step: 1
                 },
                 turboThreshold: 2000,
                 title: {
                 text: 'Test'
                         }

         },
         yAxis: {
             title: {
                 text: 'Test'
              }
         },
         series: [{
             data:[],
             name: 'Test'
         }]
     };
          $.getJSON('files/nmr/Trimethylbenzene_test.json', function(data) {
            options.series[0].data = data;
             var chart = new Highcharts.Chart(options);
        });

     });
          </script>
     </head>
     <body>

         <div style="height: 400px;min-width:300px;" id="container"></div>

     </body>
     </html>

然后是我的JSON文件的几行示例:

[
   [-4.16606,-2.535],
   [-4.16574,-1.787],
   [-4.16543,0.465],
   [-4.16511,1.98],
   [-4.1648,1.303],
   [-4.16449,-0.787],
   [-4.16417,-1.571],
   [-4.16386,-1.797],
   [-4.16354,-2.251],
   [-4.16323,-1.614],
   [16.40641,-7.857]
 ]

知道为什么它不能在IE中运行吗?

1 个答案:

答案 0 :(得分:2)

我的猜测是IE在javascript对象末尾的尾随逗号时会窒息:

                    marker: {
                         enabled: false,
                         states: {
                              hover: {
                                 enabled: true,
                                 symbol: 'circle',
                                  radius: 2,
                                 lineWidth: 1, <-- IE doesn't like that comma!
                             }
                         }
                     }

删除它和其他类似的东西。