gpt4 book ai didi

javascript - 使用php制作highchart的动态Y轴最大值和刻度间隔

转载 作者:行者123 更新时间:2023-11-29 10:39:47 26 4
gpt4 key购买 nike

我已经创建了 Highchart 表单 php 表。现在Y轴最大。和间隔值是固定的。我怎样才能使用最后四条记录使它们动态化。说最大。查询中的值为 20,则间隔将为 5。对于最大值,我得到返回最大值的查询。来自 2 列和最后 4 条记录的值。Mysql查询:

 SELECT GREATEST(MAX(step1), MAX(step2)) FROM workflow1 ORDER BY id DESC LIMIT 4

Highcharts 脚本:

<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();
}
}

});

最佳答案

如果您没有为 minmaxtickInterval 定义具体值,Highcharts 将自动调整轴的最大值并基于当前可用数据的刻度间隔。

动态更新 Highcharts 演示展示了其工作原理(尽管在示例中您可能需要等待一段时间才能超过 1):https://www.highcharts.com/demo/dynamic-update

很高兴这对您有帮助!

关于javascript - 使用php制作highchart的动态Y轴最大值和刻度间隔,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45709360/

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