C # PieChart of chart
Using System. web. UI. dataVisualization. charting; using System. drawing; namespace Chart. AJAX {public partial class Export_AJAX: System. web. UI. page {void CreateChart () {string [] xValues = {0-20, 20-30, 30-40, 40-50, 50-60,> 60, unknow }; int [] yValues = {5, 18, 45, 17, 2, 1,162}; // ChartAreas, Series, and Legends are basically set to Character Chart Chart1 = new Chart (); Chart1.ChartAreas. add (ChartArea1); // Chart1.Legends, a region set of tables. add (Legends1); // Chart1.Series. add (Series1); // data sequence set // set Chart character Chart1.Width = 770; Chart1.Height = 400; Title title Title = new title (); Title. text = titleStr; title. alignment = ContentAlignment. middleCenter; title. font = new System. drawing. font (Trebuchet MS, 14F, FontStyle. bold); Chart1.Titles. add (title); // set ChartArea1 ------------------------------------------------------------------------ Chart1.ChartAreas [ChartArea1]. area3DStyle. enable3D = is3D; Chart1.ChartAreas [0]. axisX. interval = 1; // set Legends --------------------------------------------------------------------------- // Chart1.Legends [Legends1]. dockedToChartArea = ChartArea1; // The data is displayed in the rule table. // Chart1.Legends [Legends1]. docking = Docking. bottom; // the position indicated by the self-signed signature // the background color Chart1.Legends [Legends1]. backColor = Color. fromArgb (235,235,235); // oblique background Chart1.Legends [Legends1]. backHatchStyle = ChartHatchStyle. darkDownwardDiagonal; Chart1.Legends [Legends1]. borderWidth = 1; Chart1.Legends [Legends1]. borderColor = Color. fromArgb (200,200,200); // set Series1 ------------------------------------------------------------------------- Chart1.Series [Series1]. chartType = SeriesChartType. pie; // Chart1.Series [Series1]. chartType = SeriesChartType. doughnut; Chart1.Series [Series1]. points. dataBindXY (xValues, yValues); Chart1.Series [Series1]. legendText = # VALX: [# PERCENT {P1}]; // x percent + percentage Chart1.Series [Series1]. label = # VALX # PERCENT {P1}; // x percent + percentage // Chart1.Series [Series1]. labelForeColor = Color. fromArgb (0, 90,255); // subject color // Chart1.Series [Series1]. font = new System. drawing. font (Trebuchet MS, 10, System. drawing. fontStyle. bold); Chart1.Series [Series1]. points. findMaxByValue (). labelForeColor = Color. red; // Chart1.Series [Series1]. points. findMaxByValue (). color = Color. red; // Chart1.Series [Series1]. points. findMaxByValue () [Exploded] = true; Chart1.Series [Series1]. borderColor = Color. fromArgb (255,101,101,101); // Chart1.Series [Series1] [bytes] = 80; // when ChartType is Doughnut, Set Doughnut hole size // Chart1.Series [Series1] [PieLabelStyle] = Inside; // The numeric value indicates Chart1.Series [Series1] [PieLabelStyle] = Outside; // The numeric value is displayed outside bytes. // Chart1.Series [Series1] [PieLabelStyle] = Disabled; // The numeric value is not displayed. // set the numeric value, chart1.Series [Series1] [PieDrawingStyle] = Default; // Chart1.Series [Series1] [PieDrawingStyle] = SoftEdge; // Chart1.Series [Series1] [PieDrawingStyle] = Concave; // Random rnd = new Random (); // digital region colors // foreach (DataPoint point in Chart1.Series [Series1]. points) // {// pie colors // point. color = Color. fromArgb (150, rnd. next (0,255), rnd. next (0,255), rnd. next (0,255); //} Page. controls. add (Chart1 );}}}