javascript - 如何在中间而不是底部显示数据,而其中一个数据的值有很大差异。highcharts.js
解决方案
我通过在 yAxis 中设置索引来解决它,该索引在 series.yAxis 中的顺序应该相同。
通过这种方式,我可以将数据分组并独立于其他具有巨大差异的数据。
这是样本
Highcharts.chart('container', {
"chart": {
"alignTicks": false,
"zoomType": false
},
"title": {
"text": "裝置即時資訊",
"floating": false,
"align": "left"
},
"xAxis": [{
"categories": ["INV01", "INV02", "INV03", "INV04", "INV05", "INV06", "INV07", "INV08", "INV09", "INV10", "INV11"],
"crosshair": true,
"index": 0,
"isX": true
}],
"tooltip": {
"shared": true
},
"legend": {
"layout": "horizontal",
"align": "right",
"x": 0,
"verticalAlign": "top",
"y": 0,
"floating": true,
"backgroundColor": "#FFFFFF"
},
"plotOptions": {
"line": {
"dataLabels": {
"enabled": true,
"format": "{point.y:,.2f}"
}
},
"column": {
"dataLabels": {
"enabled": true,
"format": "{point.y:,.2f}"
}
}
},
"yAxis": [{
"gridLineColor": "transparent",
"labels": {
"format": "{value} kWh",
"enabled": false
},
"title": {
"text": ""
},
"opposite": false,
"index": 0
}, {
"gridLineColor": "transparent",
"labels": {
"format": "{value} kWh",
"style": {},
"enabled": false
},
"title": {
"text": "",
"style": {}
},
"opposite": false,
"index": 1
}, {
"gridLineColor": "transparent",
"labels": {
"format": "{value} kW",
"style": {},
"enabled": false
},
"title": {
"text": "",
"style": {}
},
"opposite": false,
"index": 2
}],
"series": [{
"name": "累積發電量 (kWh)",
"data": [140212.2, 139949.6, 139821.4, 133556.8, 140040.4, 140997.8, 139240.4, 130340.6, 139336.7, 142920.5, 92437.5],
"tooltip": {
"valueSuffix": "",
"pointFormat": "<span style=\"color:{point.color}\">●</span> {series.name}: <b>{point.y:,.1f} kWh</b><br/>"
},
"type": "column",
"yAxis": 0
}, {
"name": "今日發電量 (kWh)",
"data": [44, 41, 42, 41, 46, 48, 47, 44, 43, 45, 29],
"tooltip": {
"valueSuffix": "",
"pointFormat": "<span style=\"color:{point.color}\">●</span> {series.name}: <b>{point.y:,.1f} kWh</b><br/>"
},
"type": "line",
"yAxis": 1
}, {
"name": "交流發電功率 (kW)",
"data": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"tooltip": {
"valueSuffix": "",
"pointFormat": "<span style=\"color:{point.color}\">●</span> {series.name}: <b>{point.y:,.1f} kW</b><br/>"
},
"type": "line",
"yAxis": 2
}, {
"name": "直流發電功率 (kW)",
"data": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"tooltip": {
"valueSuffix": "",
"pointFormat": "<span style=\"color:{point.color}\">●</span> {series.name}: <b>{point.y:,.1f} kW</b><br/>"
},
"type": "line",
"yAxis": 2
}]
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 400px"></div>
推荐阅读
- asp.net - Visual Studio 2015 中 Web 参考处的问号图标
- linux - linux排序的奇怪行为
- javascript - 使用 SVG.js 选择文本元素
- reactjs - 为什么在获取 API 数据时会出现 403 禁止?
- asp.net-core-mvc - 有条件地允许点击提交按钮
- php - 在 wampserver 中使用 mysql 数据库的 PHP 项目
- go - 如何调用 golang struct 字段的函数?
- python - 如何在 Python 中为特定类型的字母数字单词创建正则表达式
- sql - 将数据透视表的结果集分成多列
- symfony - 具有 arraycollection 的教义更新实体不删除项目