public static Series MeterReadingsToPieChart(IEnumerable<Dictionary<string, double>> readings)
{
object[] points = ? // I dont know how can I create this array from readings.
Series series = new Series
{
Type = ChartTypes.Pie,
Name = "",
Data = new Data(points)
};
return series;
}
我想从上面的代码
动态创建以下内容Series series = new Series
{
Type = ChartTypes.Pie,
Name = "",
Data = new Data(new object[]
{
new object[] { "Gaziemir", 45.0 },
new object[] { "Bornova", 26.8 },
new object[] { "Forum Bornova", 8.5 }
})
};
你能说明一个起点吗?
由于
答案 0 :(得分:3)
要匹配底部的代码,那就是:
object[][] points = readings.Select(
pair => new object[] { pair.Key, pair.Value }).ToArray();
Series series = new Series
{
Type = ChartTypes.Pie,
Name = "",
Data = new Data(points))
};
但是,我个人认为object[][]
不是最好的选择......