I have a WPF app using the MVVM pattern. I am using an XY line chart with date-based data. I was previously using a DateTimeAxis to display the data and had the VisibleRange property bound to a DateRange property in my view model. The app has a feature where the user can click buttons to quickly select a visible range i.e. 1 day, 1 month, 6 months, etc. I was just setting the value of the visible range property in my view model to update the chart. That was all working great.
But the chart is showing financial data, so I needed to switch over to the CategoryDateTimeAxis to remove gaps in the data. Now my VisibleRange binding no longer works. I get an error saying “Object must be of type DateTime”. I have read other posts and understand that this is because the CategoryDateTimeAxis uses an IndexRange instead of a DateRange for its VisibleRange.
My question is: is there a way for me to still set the desired visible range using date values in my view model and have it converted to an IndexRange so the chart will show the correct data?
- sdamge asked 7 years ago
- last active 7 years ago
I have several chart panes that share a mouse group and a shared visual range (I inject the shared visual range of type IRange in the constructor of the pane view model). I then set the XAxis visual range to the shared visual range inside each pane view model. However, when I use either of the below approaches outside of the pane view model to adjust the min and max of shared visual range, the Xaxis.VisualRange of each pane does not reflect that change.
Approach A: _sharedVisualRange.Min = ….; _sharedVisualRange.Max = …
Approach B: _sharedVisualRange.SetMinMax(….)
Neither approach actually impacts the XAxis.VisualRange.Min/Max.
Initially when I created the XAxis in code I set its VisualRange equal to the shared visual range that was injected via constructor, like :
XAxis = new CategoryDateTimeAxis()
VisualRange = _sharedVisualRange,
Please note that all the above refers to code in the view model. I bind the XAxis in the pane view model to the XAxis of the surface in xaml.
My entire synchronization heavily relies on the assumption of this working, but it does not.
- bbmat asked 4 years ago
- last active 4 years ago
What is the best way to form List with my formatted dates in the View Model and just put in my implementation of CategoryLabelProviderBase?
Can an AxisBase implementation help me in this case?
- Iliya Mashin asked 11 months ago
- last active 11 months ago