ArticleDirectory
- Line chart
- Column chart
- Pie Chart
Amcharts is a powerful chart control that supports JavaScript and falsh display methods and multiple clients such as. net. This document demonstrates the use of amcharts in Asp.net.
Line chart
View code
// Line
For ( Int I = 0 ; I < 7 ; I ++)
{
Linechartgraph line = New Linechartgraph ();
Line. Bullet = linechartbullettypes. Square;
Line. forecolor = color. fromname (common. enumerate. linecolor [I]); // Line color
Line. datasource = dthour; // Data Source
Line. dataseriesitemidfield = " Hour " ; // Coordinate field
Line. datavaluefield = " CNT " ; // Value Field
Line. Title = datetime. Now. adddays (-I). tostring ( " Mm-dd " ); // Line name
Line. databind ();
Chart. graphs. Add (line );//Add a line to the main control
}
Chart. datasource = dthour;//Data Source
Chart. dataseriesidfield ="Hour";//X coordinate field
Chart. databind ();
View code
// Common attributes
Chart. xgridapproxlinecount = 30 // Coordinate point on the X axis, not fully displayed by default
Column chart
View code
// Pillar
Columnchartgraph column = New Columnchartgraph ();
Column. datasource = dt_op; // Data Source
Column. dataseriesitemidfield = " DT " ; // Field
Column. datavaluefield = " CNT " ; // Value
Column. Title = linename [I]; // Column name
Column. databind ();
Chart. graphs. Add (column );//Add a bar chart
//Bind Master Control
Chart. datasource = dt_op;
Chart. dataseriesidfield ="DT";
Chart. databind ();
View code
// Common attributes
Chart. columndatalabelformatstring = " {Value} " ; // Data display on the column
Chart. columndatalabelposition = columndatalabelpositions. abve; // Location
Chart. Depth = 5 ; // Stereoscopy
Chart. valuesmin = 200 ; // Minimum start value
You can add two or more columns to facilitate data comparison. One column can be displayed proportionally by segment.
Chart. columntype = columnchartcolumntypes. stacked;
Pie Chart
Chat_mcc.datasource = dtapp; // Data Source
Chat_mcc.datatitlefield = " ID " ; // Field
Chat_mcc.datavaluefield = " CNT " ;
Chat_mcc.databind ();
- amchart. net controls are developed quickly. It is convenient to dynamically generate code in combination with Code , But Flash is not supported on some platforms.
- the Javascript display of amchart is not restricted by the platform, but the configuration is relatively troublesome. A single icon requires a separate data file and configuration file
- some other controls, such as webchart, automatically generate a static image, which affects access when multiple servers are synchronized (SLB).