The format of the set DateTimeAxis x-axis is (“yyyy-MM-dd hh:mm:ss”), but when the chart is enlarged, if the range is short, it changes to (“hh:mm:ss”). I want to display year/month/day information as well, even if the range is short. Please answer with the MVVM model.
- Lee Ji Un asked 1 year ago
- last edited 1 year ago
-
Thank you for answer. I found what I wanted. Setting the SubDayTextFormatting option solved what I wanted.
- You must login to post comments
Hi there,
It’s possible to dynamically change Axis.TextFormatting
depending on zoom using one of two APIs in SciChart WPF.
Please see the article Axis Labels – TextFormatting and CursorTextFormatting
Dynamically Changing TextFormatting The DateTimeAxis and CategoryDateTimeAxis types have TextFormatting and
SubDayTextFormatting properties. These are designed to show an
alternative TextFormatting when the range of the axis is less than one
day.If you require finer grained control over the Axis TextFormatting,
say, as you zoom, you can subscribe to Axis.VisibleRangeChanged and
dynamically change the TextFormatting.e.g.
var axis = new NumericAxis(); axis.VisibleRangeChanged += (s, e) => { if (!e.IsAnimating) { if ((newRange.Max - newRange.Min) < 0.001) ((AxisBase)s).TextFormatting = "E"; else if ((newRange.Max - newRange.Min) < 1.0) ((AxisBase)s).TextFormatting = "0.000"; else ((AxisBase)s).TextFormatting = "0"; } };
NOTE: You can also have full control over TextFormatting with the LabelProvider API. With this API you can create a class that inherits a base class and can override label text for the axis.
I will talk to the team and see if we can provide an example of how to dynamically change axis text formatting on a Date Axis along with the MVVM API.
Best regards
Andrew
- Andrew Burnett-Thompson answered 1 year ago
- You must login to post comments
Thank you for answer.
I found what I wanted.
Setting the SubDayTextFormatting option solved what I wanted.
- Lee Ji Un answered 1 year ago
- last edited 1 year ago
-
Glad you found the answer!
- You must login to post comments
Please login first to submit.