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
1855
XamDataChart - I need to access the dates that are currenlty visible in my chart
posted

I have a Xamdatachart bound to a datatable, the x axis is datetime.  I am using the XamZoombar to zoom in on the data.  This i working fine.  However I need to run a function which marks the data being shown in the chart with a value. My question is how do i find the start and end date of the visible data in the Xamdatachart.  If i can find these dates i can then pass them to my function.

  • 17475
    Offline posted

    Hello Pete, 

    I have been looking into your scenario and I could suggest you using GetUnscaledValue method in order to get maximum and minimum displayed datetime value. Here is a code snippet how this could be achieved:

                CategoryDateTimeXAxis xAxis = ((CategoryDateTimeXAxis)this.chart.Axes["XAxis"]); 

                var viewport = new Rect(0, 0, xAxis.ActualWidth, chart.Axes.OfType<NumericYAxis>().First().ActualHeight);

                var windowRect = this.chart.WindowRect; 

                var minVal = xAxis.GetUnscaledValue(0, new ScalerParams(windowRect, viewport, xAxis.IsInverted));

                DateTime min = new DateTime((long)minVal);

                var maxVal = xAxis.GetUnscaledValue(xAxis.ActualWidth, new ScalerParams(windowRect, viewport, xAxis.IsInverted));

                DateTime max = new DateTime((long)maxVal);

    I hope this helps. If you have any questions on the matter, do not hesitate to ask.