简介
我正在使用图表来完成特定应用程序,需要更改渲染的3D饼图的视角以及将自动标签的值从饼状图标签名称更改为相应的饼状图数值。
这是图表的样子:
初始化
这是我的初始化方式:
Dictionary<string, decimal> secondPersonsWithValues = HistoryModel.getSecondPersonWithValues();
decimal[] yValues = new decimal[secondPersonsWithValues.Values.Count]; //VALUES
string[] xValues = new string[secondPersonsWithValues.Keys.Count]; //LABELS
secondPersonsWithValues.Keys.CopyTo(xValues, 0);
secondPersonsWithValues.Values.CopyTo(yValues, 0);
incomeExpenseChart.Series["Default"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Pie;
incomeExpenseChart.Series["Default"].Points.DataBindXY(xValues, yValues);
incomeExpenseChart.ChartAreas["Default"].Area3DStyle.Enable3D = true;
incomeExpenseChart.Series["Default"].CustomProperties = "PieLabelStyle=Outside";
incomeExpenseChart.Legends["Default"].Enabled = true;
incomeExpenseChart.ChartAreas["Default"].Area3DStyle.LightStyle = System.Windows.Forms.DataVisualization.Charting.LightStyle.Realistic;
incomeExpenseChart.Series["Default"]["PieDrawingStyle"] = "SoftEdge";
基本上,我正在使用
HistoryModel.getSecondPersonWithValues();
从数据库查询数据,以获得成对的 Dictionary<string, decimal>
,其中 key 是 person,value 是 ammount。
问题#1
我需要做的是能够将标记的标签从 person names 更改为 ammounts 或者添加另一个带有相同颜色的 ammounts 标签(请参见图像)。
问题#2
另一个问题是我需要改变 3D 饼图的视角。也许这很简单,我只是不知道所需的 property,或者我需要覆盖一些绘图事件。无论哪种方式都将受到赞赏。
提前感谢 George。
chart.ChartAreas["ChartArea1"].Area3DStyle.Inclination = 50;
,饼图看起来更好了!感谢您分享您的发现! :) - Leniel Maccaferri