我想获取数据并显示它的x值,因为我得到的就是我想要显示的,有时我在图表上传时不知道数据(我在一段时间后从服务器获取它)
问题highchart将x轴中的值显示为日期时间,
附加jsfiddle,在xaxis中我不需要任何转换,我想将值显示为“08:00”“09:00”等等..
https://jsfiddle.net/4scqnpy5/
Highchart 将其转换为 00:00:00:001 00:00:00:002 00:00:00:003
Highcharts.stockChart('容器', {
scrollbar: {
barBackgroundColor: 'gray',
barBorderRadius: 7,
barBorderWidth: 0,
buttonBackgroundColor: 'gray',
buttonBorderWidth: 0,
buttonArrowColor: 'yellow',
buttonBorderRadius: 7,
rifleColor: 'yellow',
trackBackgroundColor: 'white',
trackBorderWidth: 1,
trackBorderColor: 'silver',
trackBorderRadius: 7
},
navigation: {
buttonOptions: {
enabled: false
}
},
navigator: {
enabled: false
},
rangeSelector: {
selected: 1
},
series: [{
name: 'hours',
data: [
["New York", 100],
["09:00", 200],
["Pariz", 300],
["1100", 150]
]
}]
});
最佳答案
我认为这应该代表时间?如果是这样,您需要使用 Date.UTC()
Highcharts.stockChart('container', {
scrollbar: {
barBackgroundColor: 'gray',
barBorderRadius: 7,
barBorderWidth: 0,
buttonBackgroundColor: 'gray',
buttonBorderWidth: 0,
buttonArrowColor: 'yellow',
buttonBorderRadius: 7,
rifleColor: 'yellow',
trackBackgroundColor: 'white',
trackBorderWidth: 1,
trackBorderColor: 'silver',
trackBorderRadius: 7
},
navigation: {
buttonOptions: {
enabled: false
}
},
navigator: {
enabled: false
},
rangeSelector: {
selected: 1
},
series: [{
name: 'hours',
data: [
[Date.UTC(0, 0, 0, 8, 00), 100],
[Date.UTC(0, 0, 0, 9, 00), 200],
[Date.UTC(0, 0, 0, 10, 00), 300],
[Date.UTC(0, 0, 0, 11, 00), 150]
]
}]
});
<script src="https://code.highcharts.com/stock/highstock.js"></script>
<script src="https://code.highcharts.com/stock/modules/exporting.js"></script>
<div id="container" style="height: 900px; min-width: 600px"></div>
关于javascript - highchart - 将 xaxis 中的值显示为我从图表数据中获得的值,无需转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42517239/