chart.Reset(true);
List<KeyValuePair<object, double>> kvps = new List<KeyValuePair<object, double>>();
y = new double[10] { 1, 2,3,4, 5,6,7,8,9,10 };
double[] b = new double[6] { 30,40,50,60,70,80 };
kvps.Add(new KeyValuePair<object, double>("1m", 30));
kvps.Add(new KeyValuePair<object, double>("2m", 40));
kvps.Add(new KeyValuePair<object, double>("3m", 50));
kvps.Add(new KeyValuePair<object, double>("6m", 60));
kvps.Add(new KeyValuePair<object, double>("7m", 70));
kvps.Add(new KeyValuePair<object, double>("8m", 80));
chart.Data.Children.Add(
new XYDataSeries() { ValuesSource = y,XValuesSource=b }
);
chart.ChartType=ChartType.Line;
chart.View.AxisX.ItemsSource = kvps;
代码这样可以了。但是数据量大的时候会很慢
|