Silverlight 4:图表工具包颜色集 [英] Silverlight 4: Chart Toolkit Color Set

查看:181
本文介绍了Silverlight 4:图表工具包颜色集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将我的图表代码从visifire迁移到Toolkit。我想知道Visifire到Toolkit的ColorSet属性(样例值Caravan,Picasso ..)的计数器部分。

Im migrating my Chart code from visifire to Toolkit. I would like to know the counter part of ColorSet property[sample value Caravan,Picasso..] of Visifire to Toolkit.

有没有?

TIA

推荐答案

首先,您需要从Visifire颜色集中复制颜色代码。它们在文件
(Visifire源代码)\Common\SLVisifireCharts\ColorSets.xaml 此处

At first you need to copy color codes from a Visifire color set. They are defined in the file (Visifire source code)\Common\SLVisifireCharts\ColorSets.xaml or here.

ColorSet 属性的对应部分是 Palette 属性,它需要复杂的资源字典。下面是 Caravan 颜色集的示例:

The counterpart of the ColorSet property is the Palette property, which takes complex dictionary of resources. Here is the example for the Caravan color set:

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

虽然我应用了相同的颜色,但是工具包图表有很多不同, b $ b

Although I have applied the same colors, the toolkit chart differs a lot and has rather bright colors:

我可以更改列的模板,但我不是设计师,结果仍然不同:

I can change the template of the column, but I'm not designer and the result is still different:

    <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个项目 - 所有类别将是相同的颜色。此行为不能更改。

And one last remark: toolkit chart doesn't render different colors for a single series. If you have 1 item in the legend - all categories will be the same color. And this behavior can't be changed.

这篇关于Silverlight 4:图表工具包颜色集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆