Issue with chart display when used zoom scrollbar.

3 posts, 0 answers
  1. alex.z
    alex.z avatar
    5 posts
    Member since:
    Jul 2007

    Posted 03 Mar 2014 Link to this post

    Hi. Please help to find solution. I tried to use following sample application attached here in thread below.
    Here I see same issue which I can't resolve in mine application.

    To reproduce it please do following:
    1. Open sample app.
    2. Select with mouse some part of chart, then release mouse.
    Now notice values on that Y-axis are changed, but chart line not fit region from top to bottom. There is lot of space to top or bottom, depends on which initial area was selected.
    3. Now touch scrollbar and move it a bit. You see that now chart line fit region completely.

    Question here. Is there any way to force chart redraw asap after zoomed with mouse, so chart line will fit new Y-axis.

    Thanks in advance.
  2. Martin
    Martin avatar
    1042 posts

    Posted 04 Mar 2014 Link to this post

    Hello Alex,

    To resolve this issue you can change the values of the VerticalAxis Maximum and Minimum properties in the ZoomChanged event handler of the chart instead of the SelectionChanged of the PanZoomBar. Here is an example in code:
    public MainWindow()
        this.RadChart1.ZoomChanged += this.RadChart1_ZoomChanged;
    private void RadChart1_ZoomChanged(object sender, ChartZoomChangedEventArgs e)
        double pixelsPerElem = this.RadChart1.PlotAreaClip.Width * this.RadChart1.Zoom.Width / Context.Count;
        int firstElem = (int)(-this.RadChart1.PanOffset.X / pixelsPerElem);
        int lastElem = firstElem + (int)(this.RadChart1.PlotAreaClip.Width / pixelsPerElem);
        lastElem = lastElem <= Context.Count ? lastElem : Context.Count;
        var visibleRange = Context.GetRange(firstElem, lastElem - firstElem).Select(pd => pd.YVal);
        var yAxisVisibleMinValue = visibleRange.Min();
        var yAxisVisibleMaxValue = visibleRange.Max();
        var yAxis = this.RadChart1.VerticalAxis as LinearAxis;
        yAxis.Minimum = yAxisVisibleMinValue;
        yAxis.Maximum = yAxisVisibleMaxValue;


    DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

  3. DevCraft R3 2016 release webinar banner
  4. alex.z
    alex.z avatar
    5 posts
    Member since:
    Jul 2007

    Posted 07 Mar 2014 in reply to Martin Link to this post

    Thank you very much for this. Issue resolved now.
Back to Top