fix: kline time display in Beijing time (UTC+8)
This commit is contained in:
parent
072592145f
commit
4f0cc7c393
@ -39,10 +39,28 @@ function chartOptions(height: number) {
|
|||||||
horzLines: { color: "#f1f5f9" },
|
horzLines: { color: "#f1f5f9" },
|
||||||
},
|
},
|
||||||
crosshair: { mode: 1 },
|
crosshair: { mode: 1 },
|
||||||
|
localization: {
|
||||||
|
timeFormatter: (ts: number) => {
|
||||||
|
// UTC+8 北京时间
|
||||||
|
const d = new Date((ts + 8 * 3600) * 1000);
|
||||||
|
const Y = d.getUTCFullYear();
|
||||||
|
const M = String(d.getUTCMonth() + 1).padStart(2, "0");
|
||||||
|
const D = String(d.getUTCDate()).padStart(2, "0");
|
||||||
|
const h = String(d.getUTCHours()).padStart(2, "0");
|
||||||
|
const m = String(d.getUTCMinutes()).padStart(2, "0");
|
||||||
|
return `${Y}-${M}-${D} ${h}:${m}`;
|
||||||
|
},
|
||||||
|
},
|
||||||
timeScale: {
|
timeScale: {
|
||||||
borderColor: "#e2e8f0",
|
borderColor: "#e2e8f0",
|
||||||
timeVisible: true,
|
timeVisible: true,
|
||||||
secondsVisible: false,
|
secondsVisible: false,
|
||||||
|
tickMarkFormatter: (ts: number) => {
|
||||||
|
const d = new Date((ts + 8 * 3600) * 1000);
|
||||||
|
const h = String(d.getUTCHours()).padStart(2, "0");
|
||||||
|
const m = String(d.getUTCMinutes()).padStart(2, "0");
|
||||||
|
return `${h}:${m}`;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
rightPriceScale: { borderColor: "#e2e8f0" },
|
rightPriceScale: { borderColor: "#e2e8f0" },
|
||||||
height,
|
height,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user