2
Im將我的圖表代碼從visifire遷移到Toolkit。我想知道Visifire to Toolkit的ColorSet屬性[樣本值Caravan,Picasso ..]的計數器部分。Silverlight 4:Chart Toolkit顏色集
有沒有?
TIA
Im將我的圖表代碼從visifire遷移到Toolkit。我想知道Visifire to Toolkit的ColorSet屬性[樣本值Caravan,Picasso ..]的計數器部分。Silverlight 4:Chart Toolkit顏色集
有沒有?
TIA
首先,您需要複製Visifire顏色集中的顏色代碼。它們在文件 (Visifire source code)\Common\SLVisifireCharts\ColorSets.xaml
或here中定義。
ColorSet
屬性的副本是Palette
屬性,該屬性需要複雜的資源字典。下面是Caravan
顏色集的例子:
<SolidColorBrush x:Key="color1" Color="#58706d" />
<SolidColorBrush x:Key="color2" Color="#4b5757" />
<SolidColorBrush x:Key="color3" Color="#7c8a6e" />
<SolidColorBrush x:Key="color4" Color="#b0b087" />
<SolidColorBrush x:Key="color5" Color="#e3e3d1" />
<datavis:ResourceDictionaryCollection x:Key="CaravanPalette">
<ResourceDictionary>
<Style x:Key="DataPointStyle" TargetType="Control" >
<Setter Property="Background" Value="{StaticResource color1}"/>
</Style>
</ResourceDictionary>
<ResourceDictionary>
<Style x:Key="DataPointStyle" TargetType="Control" >
<Setter Property="Background" Value="{StaticResource color2}"/>
</Style>
</ResourceDictionary>
<ResourceDictionary>
<Style x:Key="DataPointStyle" TargetType="Control" >
<Setter Property="Background" Value="{StaticResource color3}"/>
</Style>
</ResourceDictionary>
<ResourceDictionary>
<Style x:Key="DataPointStyle" TargetType="Control" >
<Setter Property="Background" Value="{StaticResource color4}"/>
</Style>
</ResourceDictionary>
<ResourceDictionary>
<Style x:Key="DataPointStyle" TargetType="Control" >
<Setter Property="Background" Value="{StaticResource color5}"/>
</Style>
</ResourceDictionary>
</datavis:ResourceDictionaryCollection>
而且它應用於圖表如此:
<chart:Chart Palette="{StaticResource CaravanPalette}">
雖然我已經申請了相同的顏色,該工具包圖表不同了很多,有相當鮮豔的顏色:
我可以更改列的模板,但我不是設計師,結果還是一樣:
<Style x:Key="columnStyle" TargetType="Control">
<Setter Property="Background" Value="Orange"/>
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="chart:ColumnDataPoint">
<Border
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Opacity="0"
x:Name="Root">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0:0:0.1"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver">
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="MouseOverHighlight"
Storyboard.TargetProperty="Opacity"
To="0.6"
Duration="0"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="SelectionStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0:0:0.1"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="Unselected"/>
<VisualState x:Name="Selected">
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="SelectionHighlight"
Storyboard.TargetProperty="Opacity"
To="0.6"
Duration="0"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="RevealStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0:0:0.5"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="Shown">
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="Root"
Storyboard.TargetProperty="Opacity"
To="1"
Duration="0"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Hidden">
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="Root"
Storyboard.TargetProperty="Opacity"
To="0"
Duration="0"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid Background="{TemplateBinding Background}">
<Rectangle x:Name="SelectionHighlight" Fill="Red" Opacity="0"/>
<Rectangle x:Name="MouseOverHighlight" Fill="White" Opacity="0"/>
</Grid>
<ToolTipService.ToolTip>
<ContentControl Content="{TemplateBinding FormattedDependentValue}"/>
</ToolTipService.ToolTip>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<datavis:ResourceDictionaryCollection x:Key="CaravanPalette">
<ResourceDictionary>
<Style x:Key="DataPointStyle" TargetType="Control" BasedOn="{StaticResource columnStyle}">
<Setter Property="Background" Value="{StaticResource color1}"/>
</Style>
</ResourceDictionary>
<ResourceDictionary>
<Style x:Key="DataPointStyle" TargetType="Control" BasedOn="{StaticResource columnStyle}">
<Setter Property="Background" Value="{StaticResource color2}"/>
</Style>
</ResourceDictionary>
<ResourceDictionary>
<Style x:Key="DataPointStyle" TargetType="Control" BasedOn="{StaticResource columnStyle}">
<Setter Property="Background" Value="{StaticResource color3}"/>
</Style>
</ResourceDictionary>
<ResourceDictionary>
<Style x:Key="DataPointStyle" TargetType="Control" BasedOn="{StaticResource columnStyle}">
<Setter Property="Background" Value="{StaticResource color4}"/>
</Style>
</ResourceDictionary>
<ResourceDictionary>
<Style x:Key="DataPointStyle" TargetType="Control" BasedOn="{StaticResource columnStyle}">
<Setter Property="Background" Value="{StaticResource color5}"/>
</Style>
</ResourceDictionary>
</datavis:ResourceDictionaryCollection>
而且最後一句話:工具箱圖表不會呈現不同顏色的單一系列。如果圖例中有1個項目 - 所有類別將是相同的顏色。而這種行爲是不能改變的。
它不是那麼明顯,因爲大篷車colorset有5種顏色,而工具包圖表需要16個。該屬性被稱爲「調色板」,但遷移並不明顯。我會在一小時內創建一個例子。 – vorrtex 2011-04-11 17:56:19