Hi
I have this chart with some data in it ranging for a few days. I need to have the XAxisLabel format set to something like this when zoomed out:
Label="{}{TimeStamp:dddd MMMM dd}"
But when I zoom in I want the time only
Label="{}{TimeStamp:T}"
Is this possible without too much code behind? I hope for a simple property I have overlooked :-)
Hello Solomonfried,
Thank you for your reply. I have been looking into your quesiton and the label binding is triggered when the the zooming of the XamDataChart is changed. When you change the zoom level with the zoombars of the XamDataChart the label binding is also triggered. I assume that you wish to have the labels updated immediately when you start dragging the zoombar. If this is correct, you can do that by setting the WindowsResponce property of the XamDataChart to Immediate. Setting this property will force the XamDataChart to change the zooming immediately when you start changing the zoom level from the zoombar. I have modified the sample application that I have previously attached to the thread and also created a video of the result.
Please let me know if you need any further assistance on the matter.
Sincerely,
Krasimir, MCPD
Developer Support Supervisor - XAML
Infragistics
www.infragistics.com/support
This solution is what I was looking for in my application. However I need my label to change as the user changes the zoomBar. How can I force the Label to rebind so that the Binding Converter is called.
Hello Genvej,
I am just checking if you require any further assistance on the matter.
Krasimir
Developer Support Engineer
Here's something else that may be helpful to you. It's considerably more complicated because it tries to include more information in the first label displayed:
http://community.infragistics.com/forums/p/52624/274026.aspx#274026
Thank you for your reply. I am very glad that the sample was helpful for you. I have further investigate this approach and if you wish to dynamically set the Label to show dates when the range of the axis is more than a day and to time when it is a day or less I can suggest binding the label to the axes itself, the XamDataChart and the WindowRect.Width of the XamDataChart, using a MultiBinding. Using the GetUnscaledValue method of the CategoryDateTimeXAxis, in the MultiValueConverter, you can get the actual minimum and maximum value that is displayed in the CategoryDateTimeXAxis. After getting the min and max date you can see what is the amount of days that this interval covers and return the appropriate value for the Label property. Here is the how you can get the values in the converter:
C#:
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { CategoryDateTimeXAxis axis = values[0] as CategoryDateTimeXAxis; XamDataChart chart = values[1] as XamDataChart; var viewport = new Rect( 0, 0, axis.ActualWidth, chart.Axes.OfType<NumericYAxis>().First().ActualHeight); var window = chart.WindowRect; //Getting the minimum displayed datetime var minVal = axis.GetUnscaledValue(0, new ScalerParams(window, viewport, axis.IsInverted)); DateTime min = new DateTime((long)minVal); //Getting the maximum displayed datetime var maxVal = axis.GetUnscaledValue(axis.ActualWidth, new ScalerParams(window, viewport, axis.IsInverted)); DateTime max = new DateTime((long)maxVal); //Calculating the range, coverted by the axis TimeSpan axisRange = max - min; if (axisRange.Days > 0) return "{Date:dddd MMMM dd}"; else return "{Date:T}"; }
I have modified the sample application I have sent you in order to demonstrates this approach.