我使用highcharts显示来自mySQL的数据,但我只能打印一些数据。我发现这是因为我需要使用setExtremes。有人可以请帮助我,以便我改变我的代码,以便解除我的所有数据吗? 任何帮助将不胜感激!
我的工作代码(但仅显示一些数据):
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" / >
<meta http-equiv="refresh" content="150">
<title>Fukt/Temp/Tryck</title>
<script type="text/javascript" src="includes/js/jquery-3.2.1.min.js">
</script>
<script type="text/javascript">
$(document).ready(function() {
var options = {
chart: {
zoomType: 'xy',
alignTicks: false,
renderTo: 'container',
type: 'line',
marginRight: 80,
marginBottom: 55
},
title: {
text: 'Temp och Fukt',
x: -20 //center
},
xAxis: {
crosshair: true,
type: 'datetime',
tickInterval: 80,
labels: {
format: '{value: %H:%M}',
dateTimeLabelFormats: {
day: '%H:%M'
}
}
},
yAxis: [{
title: {
tickInterval: 0.1,
text: '°C/%',
rotation: 0,
},
labels: {
overflow: 'justify'
}
},
{
title: {
tickInterval: 0.1,
text: '°C/%',
rotation: 0,
},
linkedTo:0,
opposite:true
}],
tooltip: {
shared: true
},
legend: {
enabled: true,
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom',
borderWidth: 0
},
series: []
}
$.getJSON("datatemphumi.php", function(json) {
options.xAxis.categories = json[3]['data'];
options.series[0] = json[1];
options.series[1] = json[2];
chart = new Highcharts.Chart(options);
});
});
</script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
</head>
<body>
<div id="container" style="min-width: 400px; height: 400px; margin: 0
auto"></div>
</body>
</html>
我从datatemphumi.php获得的内容:https://pastebin.com/bunAhzXV
我想要实现的示例代码:https://www.highcharts.com/blog/news/48-loading-millions-of-points-in-highcharts/
答案 0 :(得分:0)
从我检查的内容来看,有多个类别而非实际点数。除非您强制使用,否则不会显示没有分数的类别。例如,您可以使用max
属性或之前提到的setExtremes
函数。
API参考:
https://api.highcharts.com/highcharts/xAxis.max
https://api.highcharts.com/class-reference/Highcharts.Axis.html#setExtremes
例:
http://jsfiddle.net/nzoy4sqe/ - 使用max