gpt4 book ai didi

javascript - 为什么 python-highcharts 制作的钻取图不起作用?

转载 作者:行者123 更新时间:2023-12-02 21:44:21 25 4
gpt4 key购买 nike

我正在尝试使用 python-highcharts包来生成钻取柱形图。我已经运行了 drilldown example * 在该存储库上,它给了我以下代码:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link href="https://www.highcharts.com/highslide/highslide.css" rel="stylesheet" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="https://code.highcharts.com/6/highcharts.js"></script>
<script type="text/javascript" src="https://code.highcharts.com/6/highcharts-more.js"></script>
<script type="text/javascript" src="https://code.highcharts.com/6/modules/heatmap.js"></script>
<script type="text/javascript" src="https://code.highcharts.com/6/modules/exporting.js"></script>
<script type="text/javascript" src="https://code.highcharts.com/modules/drilldown.js"></script>
</head>
<body style="margin:0;padding:0">
<div id="container" style="width:850px;height:400px;">Loading....</div>


<script>
$(function(){





Highcharts.setOptions({"global": {}, "lang": {}});
var option = {"chart": {"renderTo": "container", "width": 850, "height": 400, "type": "column"}, "colors": {}, "credits": {"enabled": false}, "drilldown": {}, "exporting": {}, "labels": {}, "legend": {"enabled": false}, "loading": {}, "navigation": {}, "pane": {}, "plotOptions": {"series": {"borderWidth": 0, "dataLabels": {"enabled": true, "format": "{point.y:.1f}%"}}}, "series": {}, "subtitle": {"text": "Click the columns to view versions. Source: <a href=\"http://netmarketshare.com\">netmarketshare.com</a>."}, "title": {"text": "Browser market shares. January, 2015 to May, 2015"}, "tooltip": {"headerFormat": "<span style=\"font-size:11px\">{series.name}</span><br>", "pointFormat": "<span style=\"color:{point.color}\">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>"}, "xAxis": {"type": "category"}, "yAxis": {"title": {"text": "Total percent market share"}}};


var drilldowndata = [{"data": [["v11.0", 24.13], ["v8.0", 17.2], ["v9.0", 8.11], ["v10.0", 5.33], ["v6.0", 1.06], ["v7.0", 0.5]], "type": "column", "name": "Microsoft Internet Explorer", "id": "Microsoft Internet Explorer"}, {"data": [["v40.0", 5], ["v41.0", 4.32], ["v42.0", 3.68], ["v39.0", 2.96], ["v36.0", 2.53], ["v43.0", 1.45], ["v31.0", 1.24], ["v35.0", 0.85], ["v38.0", 0.6], ["v32.0", 0.55], ["v37.0", 0.38], ["v33.0", 0.19], ["v34.0", 0.14], ["v30.0", 0.14]], "type": "column", "name": "Chrome", "id": "Chrome"}, {"data": [["v35", 2.76], ["v36", 2.32], ["v37", 2.31], ["v34", 1.27], ["v38", 1.02], ["v31", 0.33], ["v33", 0.22], ["v32", 0.15]], "type": "column", "name": "Firefox", "id": "Firefox"}, {"data": [["v8.0", 2.56], ["v7.1", 0.77], ["v5.1", 0.42], ["v5.0", 0.3], ["v6.1", 0.29], ["v7.0", 0.26], ["v6.2", 0.17]], "type": "column", "name": "Safari", "id": "Safari"}, {"data": [["v12.x", 0.34], ["v28", 0.24], ["v27", 0.17], ["v29", 0.16]], "type": "column", "name": "Opera", "id": "Opera"}];
option.drilldown.series = drilldowndata;


var chart = new Highcharts.Chart(option);

var data = [{"data": [{"name": "Microsoft Internet Explorer", "y": 56.33, "drilldown": "Microsoft Internet Explorer"}, {"name": "Chrome", "y": 24.030000000000005, "drilldown": "Chrome"}, {"name": "Firefox", "y": 10.38, "drilldown": "Firefox"}, {"name": "Safari", "y": 4.77, "drilldown": "Safari"}, {"name": "Opera", "y": 0.9100000000000001, "drilldown": "Opera"}, {"name": "Proprietary or Undetectable", "y": 0.2, "drilldown": null}], "type": "column", "name": "Brands", "colorByPoint": true}];
var dataLen = data.length;
for (var ix = 0; ix < dataLen; ix++) {
chart.addSeries(data[ix]);
}









});
</script>

</body>
</html>

在最近的浏览器(最新的 Google Chrome)中打开时,会绘制图表,但向下钻取功能不起作用。我看过其他工作示例,例如 this one但无法弄清楚为什么我的代码不起作用。

为什么这段代码没有制作正确的向下钻取图表以及如何修复它?

*请注意,由于我希望图表位于单个文件中,因此我已将 python 脚本的最后一行 (H.htmlcontent) 替换为 H.save_file("test_hc") .

最佳答案

您的模块版本不兼容:

<script type="text/javascript" src="https://code.highcharts.com/modules/drilldown.js"></script>

应该是:

<script type="text/javascript" src="https://code.highcharts.com/6/modules/drilldown.js"></script>
<小时/>

现场演示: http://jsfiddle.net/BlackLabel/6m4e8x0y/4878/

关于javascript - 为什么 python-highcharts 制作的钻取图不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60297629/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com