Pre loader

Question regarding format change issue when zoomed in on DateTimeAxis

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

Answered
1
0

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.

Version
8.0.0.27672-beta
  • Lee Ji Un
    Thank you for answer. I found what I wanted. Setting the SubDayTextFormatting option solved what I wanted.
  • You must to post comments
Best Answer
1
1

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

  • You must to post comments
1
0

Thank you for answer.
I found what I wanted.
Setting the SubDayTextFormatting option solved what I wanted.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.