XAML:
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
Title="Window1" Height="467" Width="531" xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit" xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit">
DependentValuePath="Value"
IndependentValuePath="Key"
Title="Pet Preference" IsSelectionEnabled="True" />
C#
chart.DataContext = new KeyValuePair<string, int>[] {
new KeyValuePair<string, int>("Dog", 30),
new KeyValuePair<string, int>("Cat", 25),
new KeyValuePair<string, int>("Rat", 5),
new KeyValuePair<string, int>("Hampster", 8),
new KeyValuePair<string, int>("Rabbit", 12) };
效果图:
http://hi.csdn.net/space-66030-do-album-picid-499553.html
把 PieSeries 改成 ColumnSeries
http://hi.csdn.net/space-66030-do-album-picid-499554.html
改成: LineSeries
http://hi.csdn.net/space-66030-do-album-picid-499555.html