为什么 highcharts 呈现(几乎)空的 svg?它创建了一个大小合适的带有属性的 div 和带有嵌套 desc 标记的 svg 标记,如下所示,但没有图表。
输出
...
<div id="commissions-chart" data-highcharts-chart="0">
<div class="highcharts-container skies" id="highcharts-0" style="position: relative; overflow: hidden; width: 1627px; height: 400px; text-align: left; line-height: normal; z-index: 0; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Verdana, Arial, Helvetica, sans-serif; font-size: 12px;">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="1627" height="400">
<desc>Created with Highstock 1.3.1</desc>
<defs></defs>
</svg>
</div>
</div>
...
<script src="/assets/jquery172.min.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery.ui.192.min.js?body=1" type="text/javascript"></script>
<script src="/assets/z_highstock/1 first/highstock.js?body=1" type="text/javascript"></script>
<script src="/assets/z_highstock/2 second/highcharts-more.js?body=1" type="text/javascript"></script>
<script src="/assets/zz_my_charts.js?body=1" type="text/javascript"></script>
...
图表脚本(Highcharts 示例脚本)
$.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function(data) {
// Create the chart
$('#commissions-chart').highcharts('StockChart', {
rangeSelector : {
selected : 1
},
title : {
text : 'AAPL Stock Price'
},
series : [{
name : 'AAPL',
data : data,
tooltip: {
valueDecimals: 2
}
}]
});
});
控制台错误
Uncaught TypeError: Cannot read property 'defaultView' of undefined jquery172.min.js:5