WPF Charting Documentation - SciChart WPF Charts SDK v5.x
Axis Labels - TextFormatting and CursorTextFormatting

Axis TextFormatting

All Axis obey standard .NET Formatting strings via the AxisCore.TextFormatting property.

e.g. some examples include:

Axis TextFormatting
Copy Code
<DateTimeAxis TextFormatting="dd-MMM-yyyy" SubDayTextFormatting="HH:mm:ss"/>
<TimeSpanAxis TextFormatting="HH:mm:ss"/> 
<NumericAxis TextFormatting="0.000###"/> 
<NumericAxis TextFormatting="n2"/>
<NumericAxis TextFormatting="n4"/> 
<NumericAxis TextFormatting="E"/>
<NumericAxis TextFormatting="$0.00"/>

 

For a full list of standard .NET Formatting strings take a look at the pages

NOTE: You can also have full control over TextFormatting with the LabelProvider API

Axis CursorTextFormatting

The AxisCore.CursorTextFormatting property defines how text is formatted for cursor labels. To change the CursorTextFormatting, use a standard .NET Formatting string as follows:

Axis CursorTextFormatting
Copy Code
<DateTimeAxis CursorTextFormatting="dd-MMM-yyyy" />
<TimeSpanAxis CursorTextFormatting="HH:mm:ss"/> 
<NumericAxis CursorTextFormatting="0.000###"/>
<NumericAxis CursorTextFormatting="n2"/>
<NumericAxis CursorTextFormatting="n4"/> 
<NumericAxis CursorTextFormatting="E"/> 
<NumericAxis CursorTextFormatting="$0.00"/>

 

NOTE: You can also have full control over TextFormatting with the LabelProvider API

 

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.

Dynamically Changing TextFormatting
Copy Code
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

 

See Also

SciChart Basics

 

 


SCICHART ® is a Registered Trademark in the UK, US and EEC. Copyright SciChart Ltd 2011-2018.

Email us to give feedback!