[英]Make dynamic Y-axis max value and tick interval of highchart using php
I have created Highchart form php table. 我创建了Highchart表格php表。 Right now Y-axis max.
现在,Y轴最大值 and interval values are fixed.
和间隔值是固定的。 How can I make them dynamic using last four records.
如何使用最近的四个记录使它们动态。 Say max.
说最大 value is 20 from query then intervals will be 5. For max value I got query which returns max.
查询的值是20,则间隔将是5。对于最大值,我得到了返回最大值的查询。 value from 2 column and last 4 records.
2列和最后4条记录中的值。 Mysql query:
MySQL查询:
SELECT GREATEST(MAX(step1), MAX(step2)) FROM workflow1 ORDER BY id DESC LIMIT 4
Highchart script: 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();
}
}
}); });
If you don't define specific values for min
, max
, or tickInterval
, Highcharts will automatically adjust the axis' maximum value and tick intervals based on the current data available. 如果未为
min
, max
或tickInterval
定义特定的值,Highcharts将根据当前可用数据自动调整轴的最大值和刻度间隔。
The dynamic update Highcharts demo shows how this works (though you may have to wait a bit before it goes above 1 in the example): https://www.highcharts.com/demo/dynamic-update 动态更新Highcharts演示演示了它的工作原理(尽管在示例中您可能需要稍等片刻才能超过1): https : //www.highcharts.com/demo/dynamic-update
Glad this was helpful for you! 很高兴这对您有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.