Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

WPF Graph - format of AxisDateTime

Solved!
Go to solution

Hello.

I am using NI Graphs in my WPF application. The graphs are binded to ChartCollection <TimeSpan, double>. Here is my graph XAML code and the picture:

 

<ni:Graph x:Name="graph_temperatures" PreferIndexData="False" RenderMode="Raster">
     <ni:Graph.Axes>
          <ni:AxisDateTime Orientation="Horizontal"/>
          <ni:AxisDouble Label="Temperature [°C]" Orientation="Vertical" Range="0, 100, System.Double"/>
     </ni:Graph.Axes>

</ni:Graph>

 

2017-08-29_09h48_33.png

 

And I would like to change default format of datetime axis to be like this: "hh:mm:ss". How can I easily do it please?

Thank you for support.

Jakub

0 Kudos
Message 1 of 3
(2,950 Views)
Solution
Accepted by topic author Zelva

You can control the format of the division labels through the LabelPresenter property on the MajorDivisions of the axis. In XAML:

 

<ni:Graph x:Name="graph_temperatures" PreferIndexData="False" RenderMode="Raster">
    <ni:Graph.Axes>
        <ni:AxisDateTime Orientation="Horizontal">
            <ni:AxisDateTime.MajorDivisions>
                <ni:RangeLabeledDivisions LabelPresenter="hh:mm:ss" />
            </ni:AxisDateTime.MajorDivisions>
        </ni:AxisDateTime>
        <ni:AxisDouble Label="Temperature [°C]" Orientation="Vertical" Range="0, 100, System.Double"/>
    </ni:Graph.Axes>
</ni:Graph>
~ Paul H
0 Kudos
Message 2 of 3
(2,924 Views)

It works. Thank you very much for quick help.

0 Kudos
Message 3 of 3
(2,915 Views)