Winform & amp; Devexpress Chart getting started, winfrom

Source: Internet
Author: User

Getting started with Winform & Devexpress Chart, winfrom

I. Chart (Winform)

To use the chart control, you must first understand the chart area (ChartArea), XY axis (AxisX, AxisY), data point (Series), Title (Title), and Legend (Legend) the hierarchical relationship between the two.

Figure 1: column chart

From figure 1, you can have a simple understanding of the composition of the Chart control. 1. The chart area (ChartArea) shows from figure 1 that the data points and XY axes belong to ChartArea, where the main data is displayed. 2. The role of the XY axis (AxisX, AxisY) XY axis is needless to say. For specific settings, refer to the Code in the Demo. 3. The data point (Series) pie chart, scatter chart, and column chart are all set by the Series attribute. 4. Title and Legend (Legend) are not described much. They are mainly used to set relevant attributes. Code above:
1 /// <summary> 2 // Pie Chart 3 /// </summary> 4 private void ChartPie () 5 {6 // ChartArea 7 ChartArea chartArea = new ChartArea () 8 {9 Name = "PieArea", 10 BorderWidth = 0, 11 BorderDashStyle = ChartDashStyle. notSet, 12}; 13 chartBar. chartAreas. clear (); 14 chartBar. chartAreas. add (chartArea); 15 // Series16 Series seriesBookA = new Series () 17 {18 ChartArea = "PieArea", 19 Name = "book A sales", 20 Color = Color. red, 21 Legend = "LegendBook", 22 Tag = "BookASaleCount", 23 ChartType = SeriesChartType. pie, 24 XAxisType = AxisType. primary, 25 XValueType = ChartValueType. dateTime, 26 IsValueShownAsLabel = true, 27 Label = "# VALY (# PERCENT {P0})", 28}; 29 chartBar. series. clear (); 30 chartBar. series. add (seriesBookA); 31 // Point32 double [] value = {580}; 33 DataPoint dataPoint = new DataPoint () 34 {35 Name = "book A sales volume ", 36 Color = Color. red, 37 YValues = value, 38 LegendText = "book A sales volume:" + value [0], 39}; 40 if (chartBar. series. count> 0) 41 {42 chartBar. series [0]. points. clear (); 43 chartBar. series [0]. points. add (dataPoint); 44 value = new double [] {700}; 45 chartBar. series [0]. points. add (new DataPoint () 46 {47 Name = "book B sales", 48 Color = Color. blue, 49 YValues = value, 50 LegendText = "book B sales volume:" + value [0], 51}); 52 value = new double [] {300}; 53 chartBar. series [0]. points. add (new DataPoint () 54 {55 Name = "book C sales", 56 Color = Color. pink, 57 YValues = value, 58 LegendText = "book C sales volume:" + value [0], 59}); 60} 61 // Title62 Title mainTitle = new Title () 63 {64 Name = "MainTitle", 65 Text = "book sales", 66 Font = new Font ("", 12, FontStyle. regular, GraphicsUnit. pixel), 67 ForeColor = Color. blue, 68 Docking = Docking. top, 69 IsDockedInsideChartArea = true, 70}; 71 chartBar. titles. clear (); 72 chartBar. titles. add (mainTitle); 73 // Legend74 Legend legend = new Legend () 75 {76 Name = "LegendBook", 77 LegendStyle = LegendStyle. table, 78 Docking = Docking. bottom, 79}; 80 chartBar. legends. clear (); 81 chartBar. legends. add (legend); 82}

 

Ii. ChartControl (Devexpress)

The ChartControl usage of Dev is similar to that of Winform, but it is more flexible.

 

For specific code, click Download.

 

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.