Articles in this section
Category / Section

How to set the milliseconds label format for axis and trackball label in Xamarin.Forms Chart?

1 min read

You can set the milliseconds label format for axis labels and trackball axis labels by using LabelFormat  property of LabelStyle and TrackballLabelStyle in ChartAxis. The following code illustrates how to set the milliseconds label format for axis and trackball axis labels.

XAML:

<chart:SfChart.PrimaryAxis>
    <chart:DateTimeAxis ShowTrackballInfo="True">
        <chart:DateTimeAxis.LabelStyle>
        <chart:ChartAxisLabelStyle LabelFormat="MM/dd/yyyy (HH:mm:ss.fff)" />
        </chart:DateTimeAxis.LabelStyle>
        <chart:DateTimeAxis.TrackballLabelStyle>
            <chart:ChartTrackballAxisLabelStyle LabelFormat="MM/dd/yyyy (HH:mm:ss.fff)"/>
        </chart:DateTimeAxis.TrackballLabelStyle>
    </chart:DateTimeAxis>
</chart:SfChart.PrimaryAxis>
. . .
 
<chart:SfChart.ChartBehaviors>
    <chart:ChartTrackballBehavior />
</chart:SfChart.ChartBehaviors>

 

C#:

DateTimeAxis dateTimeAxis = new DateTimeAxis();
dateTimeAxis.ShowTrackballInfo = true;
dateTimeAxis.LabelStyle.LabelFormat = "MM/dd/yyyy (HH:mm:ss.fff)";
dateTimeAxis.TrackballLabelStyle.LabelFormat = "MM/dd/yyyy (HH:mm:ss.fff)";
chart.PrimaryAxis = dateTimeAxis;
. . .
 
ChartTrackballBehavior trackballBehavior = new ChartTrackballBehavior();
chart.ChartBehaviors.Add(trackballBehavior);

Output:

Label format for axis and trackball axis labels

 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied