Hi,
I currently am displaying Date on the x-Axis is the the format of MMM-YY. My data spans up to 20, 30 years so this is a very useful format. In the last 5 years my data is being collected daily so my end users want to be able to zoom into a segment of the chart and view the daily data.
When the users zoom in, I would like the X-Axis Date Labels to dynamically switch to a DD-MMM-YY format. Ideally if my end users zoomed in further to a point the X-Axis Date Label would switch to Date/Time format.
Any suggestions would be appreciated.
Thanks
Hi Krasimir,
Is there any to achieve this by extending / sub classing the axis or the chart itself ?
I don't want to hook into event in MVVM pattern break the app (xamDataChart1.Axes[0]) when someone in the future updates the view.
[Edit :] Sorry I was looking for wpf XamDataChart!
Thanks,
Vasu
Sorry for the delay, travelling. Your answer worked for me. I appreciate your response.
Hello,
I am just checking if my last reply was helpful for you.
If you require any further assistance please do not hesitate to ask.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
I have created a sample application for you that demonstrates an approach for changing the X axis format if the XamDataChart is zoomed to a given level. In order to implement this functionality you can handle the Loaded event of the XamDataChart and in the event handler to handle the ZoomChanged event of the HorizontalZoombar like this:
private void xamDataChart1_Loaded(object sender, RoutedEventArgs e) { (sender as XamDataChart).HorizontalZoombar.ZoomChanged += new EventHandler<ZoomChangedEventArgs>(HorizontalZoombar_ZoomChanged); }
In the event handler for the ZoomChanged event you can add the logic for changing the Label format using the NewRange property of the ZoomChangedEventArgs. In the attached example the format is changed if the Maximum – Minimum properties of the NewRange is less than 0.1 as follows:
void HorizontalZoombar_ZoomChanged(object sender, ZoomChangedEventArgs e) { double zoom = e.NewRange.Maximum - e.NewRange.Minimum; if (zoom < 0.1) { xamDataChart1.Axes[0].Label = "{Label: dd MMM yyyy}"; } else { xamDataChart1.Axes[0].Label = "{Label: MMM-yy}"; } }
If you need any further assistance please do not hesitate to ask.