This is a migrated thread and some comments may be shown as answers.

Issue with chart display when used zoom scrollbar.

2 Answers 56 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
alex.z
Top achievements
Rank 1
alex.z asked on 03 Mar 2014, 11:34 AM
Hi. Please help to find solution. I tried to use following sample application attached here in thread below.
http://www.telerik.com/forums/y-axis-values-on-radcartesianchart-with-zoom
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 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 04 Mar 2014, 04:23 PM
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()
{
    InitializeComponent();
     
    ...
     
    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;
}

Regards,
Martin
Telerik

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!

0
alex.z
Top achievements
Rank 1
answered on 07 Mar 2014, 10:54 AM
Thank you very much for this. Issue resolved now.
Tags
ChartView
Asked by
alex.z
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
alex.z
Top achievements
Rank 1
Share this question
or