With the chart control, drawing is easy. You can set the attribute series as needed. You can add a series by drawing multiple lines. The charttype can be used to control the line, pie, or chart, and saveimage can be used to directly Save the image.
Another recommended connection: http://www.cnblogs.com/gaoweipeng/archive/2010/04/06/1704879.html
Using system;
Using system. Data;
Using system. test;
Using system. drawing;
Using system. Drawing. imaging;
Using system. Windows. forms;
Namespace chartdemo
{
Public partial class form2: Form
{
Public form2 ()
{
Initializecomponent ();
}
Private void form2_load (Object sender, eventargs E)
{
// Chart1.series.
Datatable dt = default (datatable );
Dt = createdatatable ();
// Set the chart data source
Chart1.datasource = DT;
// Set the Y axis of the chart.
Chart1.series [0]. yvaluemembers = "volume1 ";
Chart1.series [1]. yvaluemembers = "volume2 ";
// Set the corresponding item on the X axis of the chart.
Chart1.series [0]. xvaluemember = "date ";
// Bind data
Chart1.databind ();
// Save the image
Chart1.saveimage (@ "E: \ 1.bmp", imageformat. BMP );
}
Private datatable createdatatable ()
{
Datatable dt = new datatable ();
DT. Columns. Add ("date ");
DT. Columns. Add ("volume1 ");
DT. Columns. Add ("volume2 ");
Datarow Dr;
Dr = DT. newrow ();
Dr ["date"] = "Jan ";
Dr ["volume1"] = 3731;
Dr [& quot; volume2 & quot;] = 4101;
DT. Rows. Add (DR );
Dr = DT. newrow ();
Dr ["date"] = "FEB ";
Dr ["volume1"] = 6024;
Dr [& quot; volume2 & quot;] = 4324;
DT. Rows. Add (DR );
Dr = DT. newrow ();
Dr ["date"] = "Mar ";
Dr ["volume1"] = 4935;
Dr [& quot; volume2 & quot;] = 2935;
DT. Rows. Add (DR );
Dr = DT. newrow ();
Dr ["date"] = "APR ";
Dr ["volume1"] = 4466;
Dr [& quot; volume2 & quot;] = 5644;
DT. Rows. Add (DR );
Return DT;
}
}
}