ANSWER如何設置和WinRT的XAML工具包圖表
感謝菲利普獲得線系列顏色,終於讓我找到方法來設置顏色。我只需要在DataPointStyle
中添加Background
屬性。我在這裏發佈我的答案。還發現了一種如何修改默認工具提示的方法。
Showing lines with different colors on a Silverlight Toolkit’s LineChart?
Using a custom ToolTip in Silverlight charting
<charting:LineSeries.DataPointStyle>
<Style TargetType="charting:LineDataPoint">
<Setter Property="Width" Value="17" />
<Setter Property="Height" Value="17" />
<Setter Property="Background" Value="Lime"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="charting:LineDataPoint">
<Grid>
<ToolTipService.ToolTip>
<ContentControl Content="{Binding Value,Converter={StaticResource MyConv},ConverterParameter=TEST}"/>
</ToolTipService.ToolTip>
<Ellipse Fill="Lime" Stroke="Lime" StrokeThickness="3" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</charting:LineSeries.DataPointStyle>
問題1
我創建多線圖系列的圖表英寸現在WinRT XAML Toolkit以隨機方式爲每個系列分配顏色。我爲數據點使用自定義樣式,所以當我使用顏色隨機性消失的自定義樣式時。那麼我該如何設置或獲得隨機顏色的系列?如果我可以獲得顏色,那麼我可以在數據點中使用該顏色,如果我可以設置顏色,那麼我將自己生成隨機顏色。
問題2
而且同時將鼠標懸停在數據點的工具提示顯示相關的價值,但我想告訴更多的細節我怎樣才能做到這一點?
這是我的自定義樣式的代碼。
<charting:Chart x:Name="LineChart" Title="Line Chart" Margin="70,0">
<charting:LineSeries
Title="Population 1"
IndependentValueBinding="{Binding Name}"
DependentValueBinding="{Binding Value}"
IsSelectionEnabled="True">
<charting:LineSeries.DataPointStyle>
<Style TargetType="charting:LineDataPoint">
<Setter Property="Width" Value="17" />
<Setter Property="Height" Value="17" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="charting:LineDataPoint">
<Ellipse Fill="Green" Stroke="Green" StrokeThickness="3" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</charting:LineSeries.DataPointStyle>
</charting:LineSeries>
<charting:LineSeries
Title="Population 2"
IndependentValueBinding="{Binding Name}"
DependentValueBinding="{Binding Value}"
IsSelectionEnabled="True" Foreground="Blue">
<charting:LineSeries.DataPointStyle>
<Style TargetType="charting:LineDataPoint">
<Setter Property="Width" Value="17" />
<Setter Property="Height" Value="17" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="charting:LineDataPoint">
<Ellipse Fill="Red" Stroke="Red" StrokeThickness="3" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</charting:LineSeries.DataPointStyle>
</charting:LineSeries>
</charting:Chart>
圖表與隨機顏色(NO CUSTOM數據點STYLE)
圖表與NO隨機顏色(具有自定義數據點STYLE)[你可以看到這兩個線具有黃色顏色]