0

我有以下图表:

<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>

和数据点样式:

<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>

源集合是 KeyValuePair 的列表。该应用程序工作正常。

我遇到了一个问题,因为我想使用 KeyValuePair> 的集合,其中 doubleA 是提取的数据,而 doubleB 是基于范围的 doubleA 的标准化值。所以我需要将 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>

它按我的预期工作,但我需要在工具提示中显示实际值(Value.Key),而不是 DependentValue。有没有办法做到这一点?

4

1 回答 1

0

有关一种可能的解决方案,请参阅此博客文章

您可以在此处找到必须覆盖的 LineSeries 数据点样式。但是,请记住,当您覆盖模板时,您将不再获得任何随机颜色。

祝你好运!

于 2013-05-28T07:44:59.133 回答