How to implement the pie chart line chart of C # drawing

Source: Internet
Author: User

This paper is an example of how to implement the pie chart line chart of C # drawing, which is a very practical technique in C # programming. Share to everyone for your reference. The specific methods are analyzed as follows:

The control that displays the image is defined as follows:

Public PlaceHolder PlaceHolder1;

The category names for each image are as follows:

PictureType Figure Type 5 chcharttypebarclustered clustered bar 0 NULL

PictureType Figure Type 7 chcharttypebarclustered3d three-dimensional clustered bar 0 NULL

PictureType Graphic type 6 chcharttypebarstacked stacked bar Figure 0 NULL

PictureType Figure type 8 chcharttypebarstacked3d three-dimensional stacked bar 0 NULL

PictureType graphic Type 1 chcharttypecolumnclustered clustered column Figure 0 NULL

PictureType graphic Type 3 chChartTypeColumnClustered3D three-dimensional clustered column figure 0 NULL

PictureType Figure Type 2 chcharttypecolumnstacked stacked histogram 1 NULL

PictureType graphic Type 4 chcharttypecolumnstacked3d three-dimensional stacked column Figure 0 NULL

PictureType graphic type Chcharttypeline line figure 0 NULL

PictureType Figure type Chcharttypelinemarkers data point line 0 NULL

PictureType Figure type chcharttypelinestacked stacked line 0 NULL

PictureType Figure type Chcharttypelinestackedmarkers stacked data point line 0 NULL

PictureType Graphics Category Chcharttypepie pie chart 1 NULL

PictureType Graphics category Chcharttypepie3d Three-dimensional pie chart 0 NULL

PictureType Graphics category chcharttypepieexploded Split pie figure 0 NULL

PictureType Graphics category Chcharttypepieexploded3d split three-dimensional pie chart 0 NULL

PictureType Graphic Type 9 Chcharttypesmoothline smoothing line Figure 0 NULL

PictureType graphic Type chcharttypesmoothlinemarkers data point smoothing line figure 0 NULL

PictureType graphic Type one by one chcharttypesmoothlinestacked stacking smooth line figure 0 NULL

PictureType graphic type chcharttypesmoothlinestackedmarkers stacked data smoothing line Figure 0 NULL

Here's how to take an image:

</summary>///<param name= "DBDTVIEWWRK" > Data passed </param>///<param name= "StrAbsolutePath" > Absolute path </param>///<param name= "Strrelativepath" > Relative path </param>///<param name= "ChartType" > The chart format to be drawn (pie chart or line chart, etc.) </param>///<param name= "strtitle" > Statistic name </param>public void Painttoimage ( DataTable dbdtviewwrk, String Strabsolutepath, String Strrelativepath, ChartChartTypeEnum ChartType, String strtitle) {s  Tring Strseriesname = "Legend";  Storage Item string[] Itemsname = new String[dbdtviewwrk.rows.count];  Storage data string[] Itemscount = new String[dbdtviewwrk.rows.count];  Scale unit int iunit = 1;  Maximum value int imaxvalue = 0;  string strxdata = String.Empty; string strydata = String.Empty; An array assignment for (int i = 0; i < DbDtViewWrk.Rows.Count; i++) {itemsname[i] = dbdtviewwrk.rows[i][0]. ToString (); The field name to be counted itemscount[i] = dbdtviewwrk.rows[i][5].  ToString ();//The field data to be counted}//Specify a specific string for the x-axis to display the data//String strxdata = String.Empty; foreach (String strdatA in Itemsname) {Strxdata + = strdata + "\ T";  }//String strydata = String.Empty; Specify a specific string for the y-axis so that the x-axis corresponds to foreach (String strvalue in Itemscount) {Strydata + = strvalue + "\ T"; if (int. Parse (strvalue) > Imaxvalue) {imaxvalue = Int. Parse (strvalue);  }} if (Imaxvalue >) {iunit = IMAXVALUE/10;  }//Create ChartSpace object to place the chart chartspace layspace = new Chartspaceclass ();  Add a chart to the ChartSpace object ChChart insertchart = laySpace.Charts.Add (0);  Base Color InsertChart.PlotArea.Interior.Color = "white"; Specifies the type of chart to draw.  The type can be owc.chartcharttypeenum enumerated by the Insertchart.type = charttype;//Column chart//Specifies whether the chart requires a legend callout Insertchart.haslegend = true;  insertchart.barwidth = 0;  InsertChart.Legend.Position = Chartlegendpositionenum.chlegendpositionbottom; Insertchart.hastitle = true;//Add a caption to the chart InsertChart.Title.Caption = strtitle;//Title name//Add a diagram description for the x, Y axis if (charttype.tostring (). IndexOf ("charttypepie") = =-1) {insertchart.axes[0]. Font.Size = 11; X-axis insertchart.axes[1]. Font.Size = 11; Y-Axis InsertcharT.legend.font.size = 11; Insertchart.axes[0]. HasTitle = true; Insertchart.axes[0]. Title.caption = "";//month insertchart.axes[1]. HasTitle = true; INSERTCHART.AXES[1]. Scaling.splitminimum = 200; INSERTCHART.AXES[1]. title.caption = "Quantity"; INSERTCHART.AXES[1]. MajorUnit = Iunit; Scale unit setting insertchart.axes[1].  Scaling.minimum = 0;//min tick = 0}//Add a series INSERTCHART.SERIESCOLLECTION.ADD (0); The name of the given series family insertchart.seriescollection[0].  SetData (chartdimensionsenum.chdimseriesnames, + (int) chartspecialdatasourcesenum.chdataliteral, strSeriesName);  Given classification strxdata = strxdata.substring (0, strxdata.length-1); Insertchart.seriescollection[0].  SetData (chartdimensionsenum.chdimcategories, + (int) chartspecialdatasourcesenum.chdataliteral, strXdata);  Given value Strydata = strydata.substring (0, strydata.length-1); Insertchart.seriescollection[0].  SetData (chartdimensionsenum.chdimvalues, (int) chartspecialdatasourcesenum.chdataliteral, strydata); Add label ChDataLabels DLS = Insertchart.seriescollecTion[0].  Datalabelscollection.add (); if (charttype.tostring (). IndexOf ("Charttypepie")! =-1) {DLs. Position = Chartdatalabelpositionenum.chlabelpositioncenter; Dls. Haspercentage = false; Dls. HasValue = false; Dls. HasCategoryName = false; Specifies whether the chart requires a legend callout Insertchart.haslegend = true;  InsertChart.Legend.Position = Chartlegendpositionenum.chlegendpositionbottom;  }//Output file.  int iimagelength = 0;  int iimagewidth = 0; Get Set//iimagelength = int from config file.  Parse (webconfigurationmanager.appsettings["showimagelength"]); iimagewidth = Int.  Parse (webconfigurationmanager.appsettings["Showimagewidth"]);  Iimagelength = 450;  Iimagewidth = 300; String strimagename = charttype.tostring () + "_" + guid.newguid ().  ToString ("N") + ". png";  Layspace.exportpicture (Strabsolutepath + strimagename, "PNG", 450, 300); Add a picture to placeholder and display string strimagetag = "

I hope this article is helpful to everyone's C # programming.

In addition to the Declaration,Running GuestArticles are original, reproduced please link to the form of the address of this article
How to implement the pie chart line chart of C # drawing

This address: http://www.paobuke.com/develop/c-develop/pbk23481.html






Related content C # using Windows services to send mail based on Fineui Grid control Add right-click menu C # Implementation method of converting scientific notation (E) to normal numeric value C # read system font color and size
C # handles JSON string instance parsing C # recursively traverse form all TextBox controls and set TextBox events workaround for non-regular form and windowsformshost control compatibility in WPF C # Simple multithreaded synchronization and priority usage instances

How to implement the pie chart line chart of C # drawing

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.