asp.net 2.0 using OWC to generate a chart

Source: Internet
Author: User
Tags count

In asp.net 2.0, you can easily see the chart using the OWC component of MS Office 2003 to display the graphic. In engineering, first add a reference to Microsoft Office Web Components 11.0, and then use MICROSOFT.OFFICE.INTEROP.OWC11;

1. Generate Column Chart

//Creates a value for the X coordinate, representing the month


int[] Month = new Int[3] {1, 2, 3};


//Creates a value for Y coordinates that represents sales


double[] Count = new Double[3] {120,240,220};


//Create chart Space


ChartSpace mychartspace = new ChartSpace ();


//Add a Chart object to the chart space


ChChart mychart = mychartSpace.Charts.Add (0);


//Set chart type, this example uses cylindrical


MyChart. Type = chartcharttypeenum.chcharttypecolumnclustered;


//Set some properties of the chart


//Do you need a legend


MyChart. HasLegend = true;


//Do you need a theme


MyChart. HasTitle = true;


//subject content


MyChart. Title.caption = "A quarterly summary";


//Set x,y coordinates


MyChart. Axes[0]. HasTitle = true;


MyChart. Axes[0]. Title.caption = "month";


MyChart. AXES[1]. HasTitle = true;


MyChart. AXES[1]. Title.caption = "Sales";


//Add three chart blocks


MyChart. SeriesCollection.Add (0);


MyChart. SeriesCollection.Add (0);


MyChart. SeriesCollection.Add (0);


//Set the properties of the chart block


//Title


MyChart. Seriescollection[0]. Caption = "January";


//x The value attribute of the coordinate


MyChart. Seriescollection[0]. SetData (Chartdimensionsenum.chdimcategories,


(int) chartspecialdatasourcesenum.chdataliteral, month[0]);


//y The value attribute of the coordinate


MyChart. Seriescollection[0]. SetData (Chartdimensionsenum.chdimvalues,


(int) chartspecialdatasourcesenum.chdataliteral, count[0]);


//Second block


MyChart. SERIESCOLLECTION[1]. Caption = "February";


//x The value attribute of the coordinate


MyChart. SERIESCOLLECTION[1]. SetData (Chartdimensionsenum.chdimcategories,


(int) Chartspecialdatasourcesenum.chdataliteral, month[1]);


//y The value attribute of the coordinate


MyChart. SERIESCOLLECTION[1]. SetData (Chartdimensionsenum.chdimvalues,


(int) chartspecialdatasourcesenum.chdataliteral, count[1]);


//Third block


MyChart. SERIESCOLLECTION[2]. Caption = "March";


//x The value attribute of the coordinate


MyChart. SERIESCOLLECTION[2]. SetData (Chartdimensionsenum.chdimcategories,


(int) chartspecialdatasourcesenum.chdataliteral, month[2]);


//y The value attribute of the coordinate


MyChart. SERIESCOLLECTION[2]. SetData (Chartdimensionsenum.chdimvalues,


(int) chartspecialdatasourcesenum.chdataliteral, count[2]);


//Generate picture


mychartspace.exportpicture (Server.MapPath (".") + @ "\test.jpg", "JPG", 500, 450);


//Load Picture


Image1.imageurl = Server.MapPath (".") + @ "\test.jpg";


}

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.