Statistical graphics a wide variety, there are histogram, line chart, sector chart, and so on, and statistical graphics drawing methods are also many, there are statistical graphics flash production, there are Crystal Reports to generate statistical graphics, special drawing software production, there are programming languages produced by themselves; here we use C # to make three of the most classic charts: histogram , line and sector charts; Since it is statistical, of course, data is needed, the data presented here is stored in SQL Server2000, and three statistical graphs are dynamically generated. The column chart I will attach the production steps, the other two charts directly attached to the source code.
Description: The demand is different, the statistical drawing after the display effect is not the same, for example, the main demand of the histogram here is to compare the number of each period and the number of people through the difference, so will put two pillars together will make the comparison results at a glance. So you can draw flexibly as needed.
One. Drawing of a bar chart.
The drawing steps are as follows:
1. Define the class to use for the drawing.
Defining drawing Classes
2. Draw the picture frame.
draw a picture frame
3. Draw horizontal coordinate lines
Draw horizontal coordinate lines
4. Drawing vertical Coordinate lines
draw a vertical coordinate line
5. Draw Horizontal Values
Draw Horizontal Values
6. Drawing Ordinate values
Draw Ordinate
7. Define the data in the array storage database
to define an array of stored statistics
8. Read the number of registrations and the number of people passing through the database
reading Data
9. Storing the read data in an array
storing data in an array
10. Define brushes and brush preparation drawings
preparing to draw a bar chart
11. Draw a histogram based on the values in the array
Draw a bar chart
12. Output the graphic to the page.
to output a page to a page
Final Bar chart:
Full code for histogram:
Draw the complete code for a histogram chart
Two. Drawing of a polyline chart
Effect:
Full code for Line chart:
complete code for a line chart
Three. Drawing of Sector charts
:
Full code:
drawing of fan-shaped charts
The chart here is output directly to the Web page, if you need to make a chart that needs to be displayed on WinForm. Refer to what I wrote earlier:
Super cool Image effect (with demo; C # Finish) C # making WordArt from a blog of Distant Dreams
C # Plotting charts (histogram, line chart, fan-shaped chart)