Here, we will use datatable as an example.
// Table structure
Datatable newdtb = new datatable ();
Newdtb. Columns. Add ("ID", typeof (INT ));
Newdtb. Columns. Add ("proname", typeof (string ));
Newdtb. Columns. Add ("proprice", typeof (decimal ));
Newdtb. Columns. Add ("trade_date", typeof (string ));
Newdtb. Columns ["ID"]. autoincrement = true;
// Table Record
Random ran = new random ();
For (INT I = 1; I <10; I ++)
{
Int randkey = ran. Next (10,999 9); // 10 ~ Number between 9999
Decimal DBASE = convert. todecimal (ran. nextdouble (); // 0 ~ Any number between 1
Datarow newrow = newdtb. newrow ();
Newrow ["trade_date"] = I. tostring () + "month ";
Newrow ["proprice"] = convert. todecimal (randkey * DBASE). tostring ("0.0 #"));
Newdtb. Rows. Add (newrow );
}
This. chartcontrol1.series. Clear ();
// Create a series
Series sr = new series ("Fund statistics", viewtype. Line); // name and Icon type
// Set the series Style
Sr. argumentscaletype = scaletype. Qualitative; // qualitative
Sr. valuescaletype = scaletype. Numerical; // numeric type
Sr. pointoptions. pointview = pointview. argumentandvalues; // displays the information and data.
Sr. pointoptions. valuenumericoptions. format = numericformat. percent; // percent representation
Sr. pointoptions. valuenumericoptions. Precision = 0; // The number before the percent sign does not match the decimal point
// Bind the data source
Sr. datasource = newdtb. defaultview; // newdtb is the obtained data (it can be a table in the database or a datatable)
Sr. argumentdatamember = "trade_date"; // bound text information (name) (horizontal coordinate axis)
Sr. valuedatamembers [0] = "proprice"; // bound value (data) (coordinate vertical axis)
// Style
Sr. View. Color = color. Red; // color
// Add to statistics Graph
This. chartcontrol1.series. Add (SR );
// Legend settings
Simplediagram3d digoal = new simplediagram3d ();
Digoal. runtimerotation = true;
Digoal. runtimescrolling = true;
Digoal. runtimezooming = true;
// Set the chart title
Charttitle Ct = new charttitle ();
Ct. Text = "Shenma company capital Statistical Chart ";
Ct. textcolor = color. Black; // color
Ct. font = new font ("tahoma", 12); // font
Ct. Dock = charttitledockstyle. Top; // dock above
Ct. Alignment = stringalignment. Center; // center display
This. chartcontrol1.titles. Add (CT );
Chartcontrol1.legend. Visible = true; // unrealistic indicator chart
After the effect is achieved: