我在思考 MS 工具包图表,但无法弄清楚如何更改区域的颜色。我需要动态填充图表,这意味着我不知道面积图将有多少部分。
这是我的代码。
var a = new AreaSeries
{
Title = "a",
IndependentValuePath = "Key",
DependentValuePath = "Value",
Background = Brushes.Plum
};
我试图改变前景和背景,没有骰子。
mcChart.Series.Add(a);
a = new AreaSeries
{
Title = "b",
IndependentValuePath = "Key",
DependentValuePath = "Value",
Background = Brushes.Peru
};
mcChart.Series.Add(a);
填写图表。
((AreaSeries)mcChart.Series[0]).ItemsSource = new[]
{
new KeyValuePair<string, int>("1", 100),
new KeyValuePair<string, int>("2", 180),
new KeyValuePair<string, int>("3", 110),
new KeyValuePair<string, int>("4", 95),
new KeyValuePair<string, int>("5", 40),
new KeyValuePair<string, int>("6", 95)
};
((AreaSeries)mcChart.Series[1]).ItemsSource = new[]
{
new KeyValuePair<string, int>("1", 150),
new KeyValuePair<string, int>("2", 280),
new KeyValuePair<string, int>("3", 310),
new KeyValuePair<string, int>("4", 195),
new KeyValuePair<string, int>("5", 340),
new KeyValuePair<string, int>("6", 195)
};
我是 wpf 的新手,我无法弄清楚这有什么问题。
这是 XAML
<chartingToolkit:Chart
Width="600" Height="450"
Name="mcChart"
Background="LightBlue"
Foreground="DarkBlue"
Title="Area Chart">
</chartingToolkit:Chart>
如何更改区域 a 和区域 b 的颜色。现在,即使我设置了背景和前景,它们也是默认颜色。
谢谢。