![](/img/trans.png)
[英]Highcharts datetime axis, how to disable time part (show only dates)?
[英]Show marker symbol at a timestamp on datetime axis in highcharts
我希望在日期時間 x 軸上針對時間戳顯示標記符號,highcharts 是否支持此功能?
我正在嘗試在圖表加載上標記符號,如下所示,但這並沒有按預期工作,因為我們需要根據時間戳顯示點。 這就是我到目前為止所擁有的。
chart: {
type: 'column',
marginTop: 50,
height: '220px',
animation: false,
events: {
load() {
const xAxis = this.xAxis[0],
yAxis = this.yAxis[0],
r = 5,
y = yAxis.toPixels(0),
x = xAxis.toPixels(10);
console.log(xAxis);
console.log(yAxis);
this.renderer.text('', x, y + r, 'circle')
.css({
transform: 'translate(-50%, -50%)'
}).add().toFront();
this.renderer.circle(x, y, r).attr({
fill: '#01a982',
}).add().toFront();
}
}
}
正如 API 所說,您需要根據軸單位傳遞值。 在datetime
時間軸的情況下,它是一個timestamp
。
API 參考: https ://api.highcharts.com/class-reference/Highcharts.Axis#toPixels
events: {
load() {
const xAxis = this.xAxis[0],
yAxis = this.yAxis[0],
r = 5,
y = yAxis.toPixels(0),
x = xAxis.toPixels(this.series[0].data[0].x);
this.renderer.circle(x, y, r).attr({
fill: '#01a982',
}).add().toFront();
}
}
演示: https ://jsfiddle.net/BlackLabel/5geqbs8m/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.