我创建了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();
}
}
});
答案 0 :(得分:1)
如果您没有为db.getCollection('sample').aggregate([
// unwind the products array
{ $unwind: '$products' },
// filter out any products which have a populated 'click' attribute
{ $match: { 'products.click': { $exists: false } } },
// only select the product id
{ $project: { 'products._id': 1 } },
// group the results by the parent document id merging the filtered product ids for each document into a new attribute: productIds
{ $group : { _id: '$_id', productIds: {$addToSet: '$products'} } }
])
,min
或max
定义具体值,则Highcharts会根据当前可用数据自动调整轴的最大值和节拍间隔。
动态更新Highcharts演示展示了它是如何工作的(尽管在示例中它超过1之前可能需要稍等一下):https://www.highcharts.com/demo/dynamic-update
很高兴这对你有帮助!