Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
130
Maximize/Set the limit on Zoom. Customize behavior of X axis labels.
posted

Dear Infragistics Support team,

I have been using xamDataChart to present live data, and have 3 questions regarding this since I was unable to find the solution neither in SampleBrowser nor on this Forum. I am receiving data every second and representing it with LineSeries. 600 data points are the maximum to be shown - Starting from 10 minutes into the chart I am deleting the oldest point and showing the new one.

1. Is there a way to set the limits for the zooming? Let's say I want 1 second (on X axis) to be the maximum. Or maybe to have 5x, 10x zoom i.e.? The best solution would be to set the limit on both Horizontal and Vertical Zoom.

2. I have left the Interval and MinorInterval of the CategoryXAxis to be automatically set (Strokes are set) because the performance is better than when using MinorInterval=1. Although the behavior is very nice at the moment, I would ideally change the density of the labels dynamically -  first it could be every point, then every 10th, then every 30th etc. As soon as I zoom in I would show label for every second again.

3. Is it possible to make automatically zooming in after the 60seconds? So, I would have a maximum of 600 datapoints but would force a window of 60 datapoints. 

(the third point is the least important and basically a backup for point 2)


Chart Example is shown at the screenshot.


Thank you very much in advance,
Milan 

Parents
  • 34510
    Verified Answer
    Offline posted

    Hi Milan,

    1.) The XamDataChart doesn't restrict the zooming level so you'll have to restrict it yourself.  You can do this by handling the WindowRectChanged event and then setting the XamDataChart.WindowRect to the specific size you want.  WindowRect is a rectangle that represents the current view of the chart and it's values range from 0 to 1.  Since it is a rectangle it has an X and Y value which represent where in the chart the top left of the view should be.  Width and Height control the size of the view.

    So with this knowledge it's possible to restrict the zoom level to some desired range just by updating the WindowRect with new values.

    2.) This is definitely doable.  You can use the CategoryXAxis.UnscaleValue method in order to find out what the minimum and maximum visible data points are and then adjust the axis Interval accordingly.  For example:

    var minimumVisibleIndex = (int)xAxis.UnscaleValue(dataChart.Viewport.X);
    var maximumVisibleIndex = (int)xAxis.UnscaleValue(dataChart.Viewport.Width);

    var distance = maximumVisibleIndex - minimumVisibleIndex;
    if (distance < 10) // if 10 points are visible
     xAxis.Interval = 1;
    else if (distance < 50) // if 50 points are visible
     xAxis.Interval = 5;

    3.) This is another instance where updating the WindowRect could get this working for you.  For example, if you had 600 data points and you only wanted 60 visible you would set the WindowRect.Width to 0.1 (60 / 600).

    Let me know if you have any questions.

Reply Children