我试图使用WPF工具包(System.Windows.Controls.DataVisualization.Toolkit.dll)在WPF中显示饼图。
图表本身是通过在我的XAML中执行以下操作来创建的:
<DVC:Chart BorderThickness="0" Title="Arbeitsverteilung" Grid.Column="0" Grid.Row="0" Background="Teal" x:Name="workDist" >
<DVC:Chart.Series>
<DVC:PieSeries
IndependentValuePath="Key"
DependentValuePath="Value"
VerticalAlignment="Top"
HorizontalAlignment="Stretch"/>
</DVC:Chart.Series>
</DVC:Chart>
并使用以下方法设置DataSource:
private void LoadData()
{
((PieSeries)workDist.Series[0]).ItemsSource =
new KeyValuePair<string, int>[] {
new KeyValuePair<string, int> ("Mario", 12),
new KeyValuePair<string, int> ("Ahner", 14)};
}
这似乎可以很好地解决一个问题:它只显示图表的图例,而不显示图表本身:
我已经读过一些教程了,但是每个人都和我完全一样,而且效果很好。
如果有人能帮我就好了!
发布于 2017-04-01 14:39:34
取出顶部垂直排列:
<DVC:Chart BorderThickness="0" Title="Arbeitsverteilung" Grid.Column="0" Grid.Row="0" Background="Teal" x:Name="workDist" >
<DVC:Chart.Series>
<DVC:PieSeries
IndependentValuePath="Key"
DependentValuePath="Value"
HorizontalAlignment="Stretch"
/>
</DVC:Chart.Series>
</DVC:Chart>
https://stackoverflow.com/questions/43160702
复制相似问题