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

Answered
1
0

I have a simple columns chart. The user can use a button that will basically change the data entirely.

The chartsurface has SeriesSource binded. Reassigning the series is changing the data on the chart, but the X-Axis is not being refreshed, so the data is showing up on the wrong part of the chart.

I uploaded 2 images to show the problem. In the “after” image, the long column should actually be at the “10+” label. If I open the same data in a new chart it shows correctly.

What’s the best method to entirely refresh a chart’s data?

Thanks in advance

Images
  • You must to post comments
Best Answer
1
0

It sounds like your chart is using its default AutoRange behaviour of AutoRange.Auto to detect when to range. Take a look at this article: AutoRange.Never vs AutoRange.Auto vs AutoRange.Always

The default state of the chart is AutoRange.Auto, which means ‘When I start up, autorange the chart if it does not have a valid VisibleRange’.

When you set new data on the chart the old VisibleRange exists on the axis, so the axis believes it is valid. There are a few ways to solve this:

  1. set AutoRange.Always on the axis. This will force it to reset its range each time data changes, but you will not be able to zoom in using Modifiers (since AutoRange overrides mouse-zoom).

  2. call ScIChartSurface.ZoomExtents(), or use a ViewportManager to reset zoom after setting data. In an MVVM scenario this is tricky since you don’t know when the data has bound and you need to zoom to fit after the data is bound.

Give the above suggestions a try and let me know your feedback in the comments.

  • cabdo
    I had to use the second method through a system of events, and by using low priority invokation after the binding, and it did work. Thanks!
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.