回复 3楼gw0506的帖子
上面是显示效果。
我的代码
var vdata = new VersionInfo[4];
vdata[0] = new VersionInfo()
{
Name = "Internet Explorer",
Version = "IE10",
Value = 20
};
vdata[1] = new VersionInfo()
{
Name = "Internet Explorer",
Version = "IE9",
Value = 50
};
vdata[2] = new VersionInfo()
{
Name = "Internet Explorer",
Version = "IE10",
Value = 15
};
vdata[3] = new VersionInfo()
{
Name = "Firefox",
Version = "FF12",
Value = 15
};
chart.BeginUpdate();
chart.Data.ItemsSource = vdata;
chart.Data.ItemNameBinding = new Binding("Name");
chart.Aggregate = Aggregate.Sum;
// first series - total by browser
var ds1 = new DataSeries()
{
ValueBinding = new Binding("Value"),
PointLabelTemplate = (DataTemplate)Resources["lbl"],
};
ds1.PlotElementLoaded += (PlotElementLoaded);
chart.Data.Children.Add(ds1);
// second series - browser versions
var ds2 = new DataSeries()
{
ItemsSource = vdata, // own data source(no aggregates)
ValueBinding = new Binding("Value"),
PointLabelTemplate = (DataTemplate)Resources["lbl1"],
};
ds2.PlotElementLoaded += (PlotElementLoaded);
chart.Data.Children.Add(ds2);
// chart type and direction
chart.ChartType = ChartType.PieStacked;
PieOptions.SetDirection(chart, SweepDirection.Counterclockwise);
chart.EndUpdate();
问题就是显示的图片根本不是我的数据源啊,好像没起作用 |