[英]WPF Toolkit Chart - Custom tooltip - show complex dependent value
I have the following chart: 我有以下图表:
<cht:Chart ...>
<cht:Chart.Series>
<cht:LineSeries Name="LineSeries" Title="a"
DependentValueBinding="{Binding Path=Value}"
IndependentValueBinding="{Binding Path=Key}"
ItemsSource="{Binding Path=SourceCollection}"
IsSelectionEnabled="True"
DataPointStyle="{DynamicResource SmallPointStyle}">
</cht:LineSeries>
</cht:Chart.Series>
</cht:Chart>
And the DataPointStyle: 和DataPointStyle:
<Style TargetType="cht:LineDataPoint">
<Setter Property="Width" Value="2" />
<Setter Property="Height" Value="2" />
<Setter Property="DependentValueStringFormat" Value="{}{0:0.00}"/>
</Style>
<Style x:Key="SmallPointStyle" TargetType="cht:LineDataPoint" BasedOn="{StaticResource {x:Type cht:LineDataPoint}}">
<Setter Property="BorderBrush" Value="Orange"/>
<Setter Property="Background" Value="Orange"/>
</Style>
The source collection is a list of KeyValuePair. 源集合是KeyValuePair的列表。 The application works fine.
该应用程序运行正常。
I encountered a problem because i want to use a collection of KeyValuePair> where doubleA is the data extracted and the doubleB is a normalised value of doubleA, based on a range. 我遇到了一个问题,因为我想使用KeyValuePair>的集合,其中doubleA是提取的数据,而doubleB是基于范围的doubleA的规范化值。 so i need to change the LineSeries to be:
所以我需要将LineSeries更改为:
<cht:Chart ...>
<cht:Chart.Series>
<cht:LineSeries Name="LineSeries" Title="a"
DependentValueBinding="{Binding Path=Value.Value}"
IndependentValueBinding="{Binding Path=Key}"
ItemsSource="{Binding Path=SourceCollection}"
IsSelectionEnabled="True"
DataPointStyle="{DynamicResource SmallPointStyle}">
</cht:LineSeries>
</cht:Chart.Series>
</cht:Chart>
It works as i expected, but i need to show in the tooltip the real value (Value.Key), not the DependentValue. 它按我的预期工作,但是我需要在工具提示中显示真实值(Value.Key),而不是DependentValue。 is there anyway to accomplish that?
反正有做到这一点吗?
See this blog post for one possible solution. 请参阅此博客文章以获取一种可能的解决方案。
You find the LineSeries data point style that you have to override here . 您可以在此处找到必须重写的LineSeries数据点样式。 However, keep in mind that when you override the template you will not get any random colors anymore.
但是,请记住,当您覆盖模板时,将不再获得任何随机颜色。
Good luck! 祝好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.