add price change and improve time format

This commit is contained in:
c9s 2022-06-27 16:50:01 +08:00
parent c9aed1e21b
commit ec86d49135
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -648,7 +648,10 @@ const createLegendUpdater = (legend: HTMLDivElement, prefix: string) => {
const createOHLCLegendUpdater = (legend: HTMLDivElement, prefix: string) => {
return (param: any, time : any) => {
if (param) {
legend.innerHTML = prefix + ` O: ${param.open} H: ${param.high} L: ${param.low} C: ${param.close} T: ${new Date(time * 1000)}`;
const change = param.close - param.open
const t = new Date(time * 1000)
const dateStr = moment(t).format("MMM Do YY hh:mm:ss A Z");
legend.innerHTML = prefix + ` O: ${param.open} H: ${param.high} L: ${param.low} C: ${param.close} CHG: ${change} T: ${dateStr}`;
} else {
legend.innerHTML = prefix + ' O: - H: - L: - C: - T: -';
}