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
95
XamDataChart - zoom xaxis & yaxis min and max values
posted

Hi,

I am using XamDataChart with zoom options. Once i zoom the chart how can i find the min & max values of x & y axis ?

Let me know.

Thanks

Raghu

 

 

Parents
No Data
Reply
  • 1400
    Suggested Answer
    Offline posted

    Hello Raghu,

    In order to get min and max values for x and y axis, you need to use the following code. Note that there is difference for calculating min/max for x and y axes:

    In code-behind:

    double xAxisVisibleMinimum = 0, xAxisVisibleMaximum = 0, yAxisVisibleMinimum = 0, yAxisVisibleMaximum = 0;
    Rect windowRect = this.DataChart.WindowRect;
    
    NumericYAxis yAxis = ((NumericYAxis)this.DataChart.Axes["numericYAxis"]);
    Grid yAxisPlotArea = ((FrameworkElement)yAxis.Parent).Parent as Grid;
    if (yAxisPlotArea != null)
    {
        Rect viewportRect = new Rect(0, 0, yAxisPlotArea.ActualWidth, yAxisPlotArea.ActualHeight);
        yAxisVisibleMinimum = yAxis.GetUnscaledValue(viewportRect.Bottom, windowRect, viewportRect);
        yAxisVisibleMaximum = yAxis.GetUnscaledValue(viewportRect.Top, windowRect, viewportRect);
    }
    
    NumericXAxis xAxis = ((NumericXAxis)this.DataChart.Axes["numericXAxis"]);
    Grid xAxisPlotArea = ((FrameworkElement)xAxis.Parent).Parent as Grid;
    if (xAxisPlotArea != null)
    {
        Rect viewportRect = new Rect(0, 0, xAxisPlotArea.ActualWidth, xAxisPlotArea.ActualHeight);
        xAxisVisibleMinimum = xAxis.GetUnscaledValue(viewportRect.Left, windowRect, viewportRect);
        xAxisVisibleMaximum = xAxis.GetUnscaledValue(viewportRect.Right, windowRect, viewportRect);
    }
    

     

     

    XAML code used in above code snippet:

        <ig:XamDataChart x:Name="DataChart"  >
                <ig:XamDataChart.Axes>
                    <ig:NumericXAxis x:Name="numericXAxis"  >
                        <ig:NumericXAxis.LabelSettings>
                            <ig:AxisLabelSettings Location="OutsideBottom" Extent="40" />
                            </ig:NumericXAxis.LabelSettings>
                    </ig:NumericXAxis>
                    <ig:NumericYAxis x:Name="numericYAxis" >
                            <ig:NumericYAxis.LabelSettings>
                                <ig:AxisLabelSettings Location="OutsideLeft" Extent="60" />
                            </ig:NumericYAxis.LabelSettings>
                        </ig:NumericYAxis>
                </ig:XamDataChart.Axes>
                <ig:XamDataChart.Series>
                    <ig:ScatterSplineSeries XMemberPath="X" 
                                            YMemberPath="Y" 
                                            ItemsSource="{StaticResource Data}" 
                                            XAxis="{Binding ElementName=numericXAxis}" 
                                            YAxis="{Binding ElementName=numericYAxis}" >
                    </ig:ScatterSplineSeries>
                </ig:XamDataChart.Series>
            </ig:XamDataChart >
    

     

    Let me know if you have more questions about it. 

    Thank you,

    Martin

Children
No Data