Silverlight 4:图表工具包颜色集

发布于 2024-10-31 23:06:27 字数 124 浏览 3 评论 0原文

我正在将我的图表代码从 visifire 迁移到 Toolkit。我想知道Visifire的ColorSet属性[样本值Caravan,Picasso..]与Toolkit的对应部分。

有吗?

TIA

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.

Is there any?

TIA

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

划一舟意中人 2024-11-07 23:06:27

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

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 个项目 - 所有类别都将具有相同的颜色。并且这种行为是无法改变的。

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.

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>

And it is applied to the chart so:

<chart:Chart Palette="{StaticResource CaravanPalette}">

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

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>

enter image description here

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文