繁体   English   中英

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

[英]How to change the view angle and label value of a chart .NET C#

简短的介绍

我正在使用特定应用程序的图表,我需要将渲染的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();来查询数据库中的数据HistoryModel.getSecondPersonWithValues(); 获取成对Dictionary<string, decimal>其中keypersonammount


问题#1

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


问题#2

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

在此先感谢乔治。

问题#1的解决方案

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


问题#2的解决方案

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

使用xlhart.Rotationxlchart.Elevation

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM