Interactive Time-Price Chart - Editor
Example showing historical time-price data visualization.
Result = interactive chart that loads instantaneously.
With regular chart solutions, this takes several seconds to load and often you can't even zoom in.
const lcjsTrader = require('@lightningchart/lcjs-trader')
const lcjs = require('@lightningchart/lcjs')
const { AxisTickStrategies, emptyFill } = lcjs
lcjsTrader.trader(TRADER_LICENSE).then((trader) => {
const lc = trader.lightningChart()
const chart = lc
.ChartXY({
defaultAxisX: { type: 'linear-highPrecision' },
})
.setTitle('10 years 5 min price data with data gaps')
.setCursorMode('show-nearest')
const axisX = chart.getDefaultAxisX().setTickStrategy(AxisTickStrategies.DateTime)
const axisY = chart.getDefaultAxisY().setTitle('Price (€)')
const lineSeries = chart
.addPointLineAreaSeries({schema: { x: { pattern: 'progressive' }, y: { pattern: null } }})
.setName('Symbol name')
.setAreaFillStyle(emptyFill)
.setPointFillStyle(emptyFill)
chart.setUserInteractions({ zoom: { wheel: false } })
// Generate some random data to show for demonstration.
// This is time-price data for 1 stock symbol over 10 years with precision of 5 minutes during opening hours [9:30, 16:00].
let priceData = [] // Array<{ x: number, y: number }>
let pricePrev = 100
for (let d = 0; d < 10 * 365; d += 1) {
const date = new Date(2010, 0, d)
date.setHours(9, 30, 0)
const tStart = date.getTime()
date.setHours(16, 0, 0)
const tEnd = date.getTime()
for (let x = tStart; x <= tEnd; x += 5 * 60 * 1000) {
const y = Math.abs(pricePrev + 0.1 * (Math.random() * 2 - 1))
pricePrev = y
priceData.push({ x, y })
}
priceData.push({ x: tEnd + 1, y: Number.NaN })
}
lineSeries.appendJSON(priceData)
})
Example showing historical time-price data visualization.
Result = interactive chart that loads instantaneously.
With regular chart solutions, this takes several seconds to load and often you can't even zoom in.