wpftimespanscichart

Plotting a SciChart series with a TimeSpan X-Axis when the plotted TimeSpan value is greater than 24 hours


I have a SciChart surface that is bound to an ObservableCollection<IRenderableSeriesViewModel> named TrendSeries. My DataSeries type is XyDataSeries<TimeSpan, double>.

My X-Axis is showing correctly when my timespan range is less than 24 hours. When I plot points that have a TimeSpan value of greater than 24 hours, the X-Axis (Time) incorrectly shows a range of 00:00:00 to 00:00:00.
How can I get my X-Axis to show correctly when I am plotting values with a TimeSpan greater than 24 hours?

SciChart Surface

<s:SciChartSurface RenderableSeries="{s:SeriesBinding TrendSeries}">

        <!-- Define X Axis -->
        <s:SciChartSurface.XAxis>
            <s:TimeSpanAxis AxisTitle="Time"
                            AutoRange="Always" GrowBy="0.1, 0.1"
                            AxisAlignment="Bottom"/>
        </s:SciChartSurface.XAxis>

        <!-- Define Y Axis -->
        <s:SciChartSurface.YAxis>
            <s:NumericAxis AxisTitle="Value" AutoRange="Always" GrowBy="0.1, 0.1"/>
        </s:SciChartSurface.YAxis>

</s:SciChartSurface>

Solution

  • this is a similar problem to this one: SciChart WPF Y-Axis and Data labels do hot have precision and show the same number

    Essentially what you're seeing is the default TextFormatting on the TimeSpanAxis is set to "-hh:mm:ss"

    Changing this to another .NET Formatting string, or dynamically changing it using the techniques presented in this answer will give you the desired behaviour