WPF Time Chart with absolute or relative time option

心已入冬 提交于 2021-02-11 12:30:08

问题


I have a time chart that shows measurements of temperature over time.

I would like to be able to display either absolute time or relative time, which is spent time from a defined starting point (so a TimeSpan).

The data points are DateTime in absolute and temperature, I would like to avoid rewriting all the time series with relative value each time the user change.

So far my goal was to create a converter for formatting the X-Axis labels with the time and handle the logic in there, passing the starting point as a parameter and whether it should be displayed as absolute or relative values.

The Converter handling care to calculate relative values.

So Far my xamls looks like:

        <telerik:RadCartesianChart.HorizontalAxis>
            <telerik:DateTimeCategoricalAxis>
                <telerik:DateTimeCategoricalAxis.LabelTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Converter={StaticResource TimeChartConverter}, 
                        ConverterParameter=<<<????>>>}" />
                    </DataTemplate>
                </telerik:DateTimeCategoricalAxis.LabelTemplate>
                </telerik:DateTimeCategoricalAxis>
        </telerik:RadCartesianChart.HorizontalAxis>

Which works, the issue is how to pass the starting time to the converter, it seems the parameter is not bindable, is there any tricks to achieve this?

来源:https://stackoverflow.com/questions/65957651/wpf-time-chart-with-absolute-or-relative-time-option

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!