SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

1
1

Hi,

I would like to achieve dynamic loading finely sampled data from db when user zooms in.

For example I would like to display 1 month of data sampled by day (one sample per each day). As user zooms in to day-level, I would like to load data only for visible day but sampled in finer resolution (for example one sample per minute). User could zoom in further to seconds or milliseconds details.

I could probable detect displayed time range and load data with corresponding sampling and switch the dataset bound to the control.

But after that the control will be bound only to visible portion of time interval and user will not be able to zoom out back to coarser level of detail (ie whole month).

Is there a way how to do this?

Thanks,
Petr

  • You must to post comments
1
0

Hi Andrew,

thanks for quick response. I tried to implement simple version of virtualizing sample. I’m just loading data for visible range + some surroundings before and after the interval, so user could move within data without reloading after each pixel. I’m resampling the range if zoom changes to twice or half.

I’m attaching my quick sample, so anybody could use it as a reference. Sample contains simple data generator of “fractal” sine function.

I could imagine that sample could be easily extended by many ways – for example async loading of data.

I had found SciChart library few days ago and I must say it looks very impressive.

Thanks,
Petr

Attachments
  • Andrew
    Hi Petr,Thanks a lot for contributing that, I'm sure anyone else who wants to implement virtualization in SciChart will be grateful for this!Some comments for other users / suggestions for yourself- I ran your app and it wasn't immediately apparent what it did. I noticed that when zooming/panning the dataset was not changed, but when dragging the XAxis to scale, the DataSeries was being cleared/recreated with new data at a finer granularity. Ok nice- I would suggest using RubberBandXyZoomModifier with IsAnimated=false to do the granularity / DataSeries changes. E.g. when user zooms in, you get one Axis.VisibleRangeChanged event, get new data and reload series- I noticed that double click using ZoomExtentsModifier didn't really work, as SciChart is only zooming to extents on the data that it already has. I would suggest subscribing to SciChartSurface.MouseDoubleClick (remov the ZoomExtentsModifier) and manually reload the DataSeries with the original low-detail data, then call SciChartSurface.ZoomExtents(). This should achieve the effect you want.Ok good stuff! Feel free to post if you have any questionsAndrew
  • pal
    Hi Andrew,I like that data resampling is transparent to user, in fact he did not notice when dataset is regenerated. In real world usage reloading dataset takes some time, but I think that async loading could work good here. Do I understand correctly, that data could be changed from non-UI thread?I'll try RubberBandXyZoomModifier with IsAnimated=fall as you suggested.Yes double click is not handled, but this could be done easily.I'll try to rewrite the sample with MVVM approach, but I'm not sure how to hook viewmodel to VisibleRangeChanged event?Regards, Petr
  • Andrew
    Hi Petr,Yes, you can load data on a background thread. Drawing operations are throttled and queued internally and decoupled from the DataSeries.Append so no need to call this method on the UI Thread.I would recommend performing block updates inside a SciChartSurface.SuspendUpdates() call. If you want you can pass the SciChartSurface as ISuspendable to your viewmodel to achieve this in MVVM, or, use the similar API DataSeriesSet.SuspendUpdates().Async loading is definitely the way to go - you may also be able to achieve something like putting a loading animation over the screen using the CustomAnnotation type, with CoordinateMode=Relative, X1,Y1=0.5 and HorizontalAnchorPoint / VerticalAnchorPoint = Center (will place annotation in centre of screen),Best regards, Andrew
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.