[英]Make dynamic Y-axis max value and tick interval of highchart using php
我創建了Highchart表格php表。 現在,Y軸最大值 和間隔值是固定的。 如何使用最近的四個記錄使它們動態。 說最大 查詢的值是20,則間隔將是5。對於最大值,我得到了返回最大值的查詢。 2列和最后4條記錄中的值。 MySQL查詢:
SELECT GREATEST(MAX(step1), MAX(step2)) FROM workflow1 ORDER BY id DESC LIMIT 4
Highchart腳本:
<script>
Highcharts.chart('container', {
data: {
table: 'datatable'
},
credits: {
enabled: false
},
chart: {
type: 'column'
},
title: {
text: 'Results',
style: {
color: '#FF00FF',
fontWeight: 'bold'
}
},
legend: {
layout: 'horizontal',
align: 'right',
verticalAlign: 'top',
y: 50,
padding: 3,
itemMarginTop: 5,
itemMarginBottom: 5,
itemStyle: {
lineHeight: '14px'
}
},
yAxis: {
min: 0,
max: 100,
tickInterval: 20,
allowDecimals: false,
title: {
text: 'Time in Sec.'
}
},
tooltip: {
formatter: function () {
return '<b>' + this.series.name + '</b><br/>' +
this.point.y + ' ' + this.point.name.toLowerCase();
}
}
});
如果未為min
, max
或tickInterval
定義特定的值,Highcharts將根據當前可用數據自動調整軸的最大值和刻度間隔。
動態更新Highcharts演示演示了它的工作原理(盡管在示例中您可能需要稍等片刻才能超過1): https : //www.highcharts.com/demo/dynamic-update
很高興這對您有所幫助!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.