Simple use of chartcontrol in Dev

Source: Internet
Author: User
Tags dbase

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:

 

 

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.