2

我在 WPF 中的 chartingToolkit:AreaSeries 遇到了一个奇怪的问题:

这是我用来构建图表的代码:

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    xmlns:datavis="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    xmlns:chartingprimitives="clr-namespace:System.Windows.Controls.DataVisualization.Charting.Primitives;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    x:Class="leartWPF.ButtonTest"
    x:Name="Window"
    Title="ButtonTest"
    Width="640" Height="480">

    <Grid x:Name="LayoutRoot">
        <chartingToolkit:Chart Margin="56,91,50,72" Title="Chart Title" DataContext="{Binding ElementName=Window, Mode=OneWay}">
                <chartingToolkit:Chart.Template>
                    <ControlTemplate TargetType="{x:Type chartingToolkit:Chart}">
                        <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
                            <Grid>
                                <chartingprimitives:EdgePanel Name="ChartArea" Style="{TemplateBinding ChartAreaStyle}" Grid.Row="1" Margin="0">
                                    <Grid Panel.ZIndex="-1" Style="{TemplateBinding PlotAreaStyle}" />
                                    <Border Panel.ZIndex="10" BorderBrush="#FF919191" BorderThickness="1" />
                                </chartingprimitives:EdgePanel>
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </chartingToolkit:Chart.Template>

                <chartingToolkit:LineSeries
                    ItemsSource="{Binding Path=Data}"
                    IndependentValuePath="Date"
                    DependentValuePath="Value"/>
                <chartingToolkit:AreaSeries
                    ItemsSource="{Binding Path=Data}"
                    IndependentValueBinding="{Binding Date}"
                    DependentValueBinding="{Binding Value}">
                    <chartingToolkit:AreaSeries.Background>
                        <RadialGradientBrush Center="0.075,0.015" GradientOrigin="-0.1,-0.1" RadiusY="0.9" RadiusX="1.05">
                        <GradientStop Color="#FFB5D2ED" Offset="1"/>
                        <GradientStop Color="#FF1E4C78"/>
                    </RadialGradientBrush>
                    </chartingToolkit:AreaSeries.Background>
                </chartingToolkit:AreaSeries>
        </chartingToolkit:Chart>
    </Grid>
</Window>

#FFB5D2ED 和 #FF1E4C78 都是蓝色。

#FFB5D2ED 和 #FF1E4C78 都是蓝色

这是实际图表的样子:

错误颜色图表

为什么我会得到这个,我该如何改变颜色?

4

1 回答 1

0

我希望这可以帮助你:

   <ch:Chart Margin="56,21,50,72" Title="MyChart" DataContext="{Binding ElementName=Window, Mode=OneWay}" >
                    <ch:Chart.Palette>
                        <datavis:ResourceDictionaryCollection>
                            <ResourceDictionary>
                                <Style x:Key="DataPointStyle" TargetType="Control">
                                    <Setter Property="Background" Value="Blue"/>
                                </Style>
                            </ResourceDictionary>
                            <ResourceDictionary>
                                <Style x:Key="DataPointStyle" TargetType="Control">
                                    <Setter Property="Background" Value="Green"/>
                                </Style>
                            </ResourceDictionary>
                            <ResourceDictionary>
                                <Style x:Key="DataPointStyle" TargetType="Control">
                                    <Setter Property="Background" Value="Red"/>
                                </Style>
                            </ResourceDictionary>
                        </datavis:ResourceDictionaryCollection>
                    </ch:Chart.Palette>

                    <ch:AreaSeries Name="PersonnelArea" ItemsSource="{Binding Path=Key}" IndependentValueBinding="{Binding Key}" DependentValueBinding="{Binding Value}"/>

                    <ch:AreaSeries Name="DefaultArea" ItemsSource="{Binding Path=Key}" IndependentValueBinding="{Binding Key}" DependentValueBinding="{Binding Value}" />
                </ch:Chart>
于 2013-07-08T05:05:18.143 回答