How to change the viewing angle and label value of a .NET C # chart

Short description

I use charts for a specific application, where I need to change the viewing angle of the displayed three-dimensional pie chart and the value of automatic marks from the names of the pie marks to the corresponding pie values.

What the chart looks like: Pie chart


Initialization

This is how I initialize it:

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"; 

Basically, I request data from a database using HistoryModel.getSecondPersonWithValues(); to get pairs like Dictionary<string, decimal> , where the key is the person and the value is the quantity.


Problem number 1

I need to be able to change the labeled labels from the names of people for the number or add another label with the same colors (see image). enter image description here


Problem number 2

Another problem is that I need to change the viewing angle of the 3D chart. Maybe it's very simple, and I just don’t know the property I need, or maybe I need to override some kind of drawing event. In any case, any methods could be used.

Thanks in advance, George.

+7
source share
2 answers

The solution to problem number 1

It helped to add a new shortcut and padding with custom values. Also, I changed Series.IsValueShownAsLabel = true;


The solution to problem number 2

I had to set ChartArea.Area3DStyle.IsClustered = true; and then set ChartArea.Area3DStyle.Inclination;

+1
source

Use xlhart.Rotation and xlchart.Elevation .

0
source

All Articles