從來就得到了下面的代碼:WPF餅圖填充
private void LoadPieChartData()
{
LinkedList<String> kostenstellen = rep.GetKostenstellen();
for (int i = 0; i < kostenstellen.Count; i++)
{
((ColumnSeries)PieChart.Series[i]).ItemsSource = new KeyValuePair<string, double>[]{
new KeyValuePair<string,double>(kostenstellen.ElementAt(i), i+1)
};
}
}
}
我的XAML看起來是這樣的:
<DVC:Chart HorizontalAlignment="Left" Margin="625,44,0,0" Name="PieChart" VerticalAlignment="Top" Height="276" Width="256" >
<DVC:Chart.Series>
<DVC:PieSeries Title="FirstPiece" ItemsSource="{Binding LoadPieChartData}" IndependentValueBinding="{Binding Path=Key}" DependentValueBinding="{Binding Path=Value}" />
<DVC:PieSeries Title="SecondPiece" ItemsSource="{Binding LoadPieChartData}" IndependentValueBinding="{Binding Path=Key}" DependentValueBinding="{Binding Path=Value}" />
</DVC:Chart.Series>
</DVC:Chart>
我的問題是,在我的for循環可籌集最多到大約20個。所以,我需要大約20個PieSeries,據我所知,創造動態是不可能的。
我該如何管理?
你真的想要不同的系列,或者你只是想顯示一個最多20段的圖表? – madd0