如何更改图表.NET C#的视角和标签值

Geo*_*rge 7 c# 3d angle pie-chart

简短的介绍

我正在使用特定应用程序的图表,我需要将渲染的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";
Run Code Online (Sandbox Code Playgroud)

基本上我使用HistoryModel.getSecondPersonWithValues();to get对查询数据库中的数据,Dictionary<string, decimal>其中keyperson,ammount.


问题#1

我需要的是能够将标记的标签从人名更改为ammounts或添加另一个具有相同颜色的ammounts标签(参见图像). 在此输入图像描述


问题#2

另一个问题是我需要改变3D饼图的视角.也许这很简单,我只是不知道所需的属性,或者我可能需要覆盖一些油漆事件.无论哪种方式都会受到任何影响.

在此先感谢乔治.

Geo*_*rge 1

问题 #1 的解决方案

添加新标签并填充自定义值会有所帮助。另外我改变了Series.IsValueShownAsLabel = true;


问题 #2 的解决方案

我应该先设置ChartArea.Area3DStyle.IsClustered = true;然后再设置ChartArea.Area3DStyle.Inclination;

  • 不错...相当不错...我正在寻找“Ìnclination”属性。执行 `chart.ChartAreas["ChartArea1"].Area3DStyle.Inclination = 50;` 使饼图看起来更好!感谢您分享您的发现!:) (2认同)