Pre loader

Time ranges for seconds data

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

I am working with this chart and data on a seconds level/granularity and plotting tens of thousands or sometimes hundreds of thousands of seconds of data. SciChart is doing something weird with the time range on zooming in and out. Are there ways to control what the DateTimeAxis displays?

time data:

2024-09-06 08:55:55
2024-09-06 08:48:58
2024-09-06 08:40:06
2024-09-06 08:30:42
2024-09-06 08:26:53
2024-09-06 08:22:41
2024-09-06 08:20:49
2024-09-06 08:17:39
2024-09-06 08:17:03

function updateChartInitial(data) {
        const timestamps = new Float64Array(data.map(d => new Date(d.timestamp).getTime()));
        const prices = new Float64Array(data.map(d => d.trade_price));
        const volumes = new Float64Array(data.map(d => d.agg_volume));

        // Clear previous data and append new data to priceSeries
        priceSeries.dataSeries.clear();
        priceSeries.dataSeries.appendRange(timestamps, prices);

        // Clear previous data and append new data to volumeSeries
        volumeSeries.dataSeries.clear();
        volumeSeries.dataSeries.appendRange(timestamps, volumes);

        // Set Y-axis range based on price data
        const minPrice = Math.min(...prices);
        const maxPrice = Math.max(...prices);
        yAxisPrice.visibleRange = new NumberRange(minPrice, maxPrice);

        sciChartSurface.zoomExtents();
    }

Is there some need to convert to milliseconds and / 1000 or something like this?

Regards
Matt

Version
Latest https://cdn.jsdelivr.net/npm/scichart/index.min.js
Images
  • You must to post comments
0
0

Hi

For lost-in-the-distant-past reasons, SciChart’s DateTime formatting expects timestamps in seconds, so you need new Date(d.timestamp).getTime() / 1000

Regards
David

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.