Hello,
I am trying to make my xAxes values to be in datetime, specifically i want to try and get the seconds since my graph will be 20 seconds worth of data.
I checked the Javascript examples however all of them resulted in a wrong date
// ? Getting start Date
const startDate = new Date(timestamp).getTime()
// ? yValues Array size
const totalPoints = yValues.length
// ? Getting end Date
const endDate = startDate + (totalPoints - 1) * 64
// ? xValues Array. startDate + i * 64 ms
const xValues = Array.from({ length: totalPoints }, (_, i) => startDate + i * 64)
// ? xAxes
const xAxes = new CategoryAxis(wasmContext, {
defaultXStart: startDate,
defaultXStep: 64,
defaultXEnd: endDate,
labelProvider: new SmartDateLabelProvider(),
axisAlignment: EAxisAlignment.Bottom,
autoRange: EAutoRange.Always,
drawMajorGridLines: false,
drawMinorGridLines: false,
})
sciChartSurface.xAxes.add(xAxes)
xyDataSeries = new XyDataSeries(wasmContext, { xValues, yValues })
Notes:
– xValues array consists of 320 values from start date to end date going up by 64ms
– Yes all the values of xValues are correct, console logged and checked them manually
– I tried DateTimeNumericAxis but it resulted in the same thing as the below screenshot
- hamza hajar asked 6 months ago
- You must login to post comments
The key think to know is that (for historical reasons no-one can remember) scichart.js expects date values for axes to be in seconds, not milliseconds, so just divide everything by 1000 and the formatting will then give you the values you expect.
Regards
David
- David Burleigh answered 6 months ago
- You must login to post comments
Please login first to submit.