I've got an issue where I'm loading in sec by sec data into a DataChart and using a DateTime based X-axis. The min-max values for the axis are set to a period of 5 days apart.
What I'm wanting to do is when the user looks at all 5 days, the X-axis Label is formatted by "dd/MM/yy" but as they zoom in, the formatting changes to say the hours in the day (i.e. HH:mm:ss). Now I realise I can set the label formatting at run-time easily enough, but is there any trigger/event for when a user zooms in using the mouse? And it would also need to advise what the datetime width of the chart is to determine the correct formatting to apply.
Any help would be appreciated. This functionality is quite common in date/time based charting especially with tiny scales of data to display over large periods (i.e. years).
Sorry for the delay in reply, you may also find this helpful:
http://community.infragistics.com/forums/p/52624/274026.aspx#274026
It was authored for WPF so its possible it needs some adjusting for Silverlight, let me know if you find it interesting or have issues with it.
Hope this helps!
-Graham
Sorry for writing this post myself, but others might find it helpful.
I finally got it working using:
var statDate = new DateTime(Convert.ToInt64(StartSelectionX));
This returns the user zoomed (selected) start date on the chart and the same for the end. This allows you then to reset the Labels on the X-Axis to be formatted how ever you like.
I just read a thread: http://community.infragistics.com/forums/p/44025/242600.aspx#242600
Which means using the example, I can manually interven and grab the values that determine the best Label formatting to apply (based on the zoomed region). My only problem is as I'm using a CategoryDateTimeXAxis type x-axis, the X values come back a little weird (as decimal and not DateTime)
Using the below code from the above example (I changes a couple of small things), Can someone tell me how to convert to X -axis values to DateTime? An example of an x-axis value is: 6.34532..... which is around 7pm.
private void OnAttemptedScaleChanged(
DependencyPropertyChangedEventArgs e)
{
if ((Rect)e.NewValue != _selectedRect &&
(Rect)e.OldValue != Rect.Empty &&
!_recursing)
_selectedRect = (Rect)e.NewValue;
_recursing = true;
//xmDataChart.WindowRect = (Rect)e.OldValue;
_recursing = false;
Rect viewportRect = new Rect(0, 0, 1, 1);
CategoryDateTimeXAxis x = xmDataChart.Axes[1] as CategoryDateTimeXAxis;
NumericYAxis y = xmDataChart.Axes["yAxis"] as NumericYAxis;
StartSelectionX = x.GetUnscaledValue(0, _selectedRect, viewportRect);
EndSelectionX = x.GetUnscaledValue(1, _selectedRect, viewportRect);
StartSelectionY = y.GetUnscaledValue(0, _selectedRect, viewportRect);
EndSelectionY = y.GetUnscaledValue(1, _selectedRect, viewportRect);
}