This article describes how to implement the effect of a three-dimensional pie chart in the "catering system" developmentCodeAnd the attached example, I believe that friends in need can easily use! Project, as follows:
The system. Drawing. piechart. piechartcontrol control is implemented. The piecharthelper class is as follows:
Code
Using System;
Using System. collections;
Using System. drawing;
Using System. text;
/// <Summary>
/// Three-dimensional pie chart operations
/// </Summary>
Public Class Piecharthelper
{
/// <Summary>
/// Pie Chart initialization settings
/// </Summary>
/// <Param name = "piechart"> </param>
Public Static Void Init_piechart (system. Drawing. piechart. piechartcontrol piechart)
{
Piechart. edgecolortype = System. Drawing. piechart. edgecolortype. Contrast;
Piechart. edgelinewidth = 1 ; // Set the border line width of the pie Block
// The pie chart (upper and lower left) is 5 away from the border (the border of the piechart control ).
Piechart. leftmargin = 5f;
Piechart. rightmargin = 5f;
Piechart. topmargin = 5f;
Piechart. bottommargin = 5f;
Piechart. fitchart = True ;
Piechart. slicerelativeheight = 0.15f ; // Set the width (height) of the pie Block
Piechart. initialangle = 30 ;
Piechart. shadowstyle = System. Drawing. piechart. shadowstyle. gradualshadow;
Piechart. backcolor = System. Drawing. color. transparent;
}
/// <Summary>
/// Set the values of each pie chart item
/// </Summary>
/// <Param name = "piechart"> </param>
/// <Param name = "valarray"> </param>
Public Static Void Setpiechartcontrol_values (system. Drawing. piechart. piechartcontrol piechart, Decimal [] Valarray)
{
Piechart. Values = Valarray;
}
/// <Summary>
/// Set the color of each pie chart.
/// </Summary>
/// <Param name = "piechart"> </param>
/// <Param name = "colarray"> </param>
Public Static Void Setpiechartcontrol_colors (system. Drawing. piechart. piechartcontrol piechart, color [] colarray)
{
Arraylist colors = New Arraylist ();
Foreach (Color col In Colarray)
{
Colors. Add (color. fromargb ( 125 , Col ));
}
Piechart. colors = (Color []) colors. toarray ( Typeof (Color ));;
}
/// <Summary>
/// Set the text of each pie chart item
/// </Summary>
/// <Param name = "piechart"> </param>
/// <Param name = "textarray"> </param>
Public Static Void Setpiechartcontrol_texts (system. Drawing. piechart. piechartcontrol piechart, String [] Textarray)
{
Piechart. Texts = Textarray;
}
/// <Summary>
/// Set text prompts for various pie chart items
/// </Summary>
/// <Param name = "piechart"> </param>
/// <Param name = "tiparray"> </param>
Public Static Void Setpiechartcontrol_tooltips (system. Drawing. piechart. piechartcontrol piechart, String [] Tiparray)
{
Piechart. tooltips = Tiparray;
}
}
Source code example download