Ensure candlestick chart works with either our own date formats as well as timestamps

This commit is contained in:
Andrew Kingston 2020-11-05 13:27:29 +00:00
parent 4754f7e0b9
commit 732685ec60
1 changed files with 2 additions and 1 deletions

View File

@ -59,8 +59,9 @@
.xType("datetime") .xType("datetime")
// Add data // Add data
const parseDate = d => (isNaN(d) ? Date.parse(d).valueOf() : parseInt(d))
const chartData = data.map(row => ({ const chartData = data.map(row => ({
x: row[dateColumn], x: parseDate(row[dateColumn]),
y: [row[openColumn], row[highColumn], row[lowColumn], row[closeColumn]], y: [row[openColumn], row[highColumn], row[lowColumn], row[closeColumn]],
})) }))
builder = builder.series([{ data: chartData }]) builder = builder.series([{ data: chartData }])