[英]Timeline chart with hours instead of date
我想設置一個像這樣的時間線圖表https://apexcharts.com/javascript-chart-demos/timeline-charts/multi-series/但不是日期作為 x 標簽只有小時。
我已經用時間戳定義了我的日期
data: [
{
x: 'Maintenance',
y: [
1601361625000, // for example 2020-09-29 08:14:32
1601383225000 // for example 2020-09-29 13:25:01
]
},
{ ... }
]
像這樣的 xasis 標簽
xaxis: {
type: 'datetime',
labels: {
formatter: function (value, timestamp) {
return moment(timestamp, "hh:mm");
},
}
}
但我仍然得到日期而不是小時數。 這可能嗎? 謝謝
事實證明,文檔不正確,它說明了formatter
功能:
/**
* Allows users to apply a custom formatter function to xaxis labels.
*
* @param { String } value - The default value generated
* @param { Number } timestamp - In a datetime series, this is the raw timestamp
* @param { index } index of the tick / currently executing iteration in xaxis labels array
*/
然而事實並非如此,第一個參數是timestamp
,第二個是index
,沒有第三個。 所以實際上這個會起作用:
return moment(value).format("HH:mm");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.