The prerequisite for successful running is that the Office must be installed
Default. aspx page
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Asp: Image id = "image1" runat = "server"/> </div>
</Form>
</Body>
Write in the Aspx. CS File
When introducing a space, you must add references to the bin file.
Using Microsoft. Office. InterOP. owc11; (introduce space)
Microsoft Office XP Web Components (add reference)
Private void makelinechart ()
{
// Y axis
String [] dataname = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday "};
// Data of the first Curve
Int [] DATA = {0, 10, 20,100, 40, 50, 60 };
// Data of the second Curve
Int [] data1 ={ 100, 50, 41, 86 };
// Data of the Third Curve
Int [] data2 = {10, 50,100, 30, 50, 60 };
String strvalue1 = "";
String strvalue = "";
String strvalue2 = "";
String strcateory = "";
// Obtain the data cyclically and format it in the format required by owc10 (Add '/t ')
For (INT I = 0; I <dataname. length; I ++)
{
Strcateory + = dataname [I] + '/T ';
}
For (INT I = 0; I <data. length; I ++)
{
Strvalue + = data [I]. tostring () + '/T ';
}
For (INT I = 0; I <data1.length; I ++)
{
Strvalue1 + = data1 [I]. tostring () + '/T ';
}
For (INT I = 0; I <data2.length; I ++)
{
Strvalue2 + = data2 [I]. tostring () + '/T ';
}
Owc10.chartspaceclass MySpace = new owc10.chartspaceclass (); // create a chartspace object to place the chart
Owc10.chchart MyChart = MySpace. charts. Add (0); // Add a chart to the chartspace object. The add method returns the chart object.
MyChart. type = owc10.chartcharttypeenum. chcharttypecolumnclustered; // specify the linear chart type.
MyChart. haslegend = true; // specifies whether a legend is required for a chart.
MyChart. hastitle = true; // specify the title.
MyChart. Title. Caption = "transaction curve chart"; // chart name
// Graph description of x/y axes
MyChart. Axes [0]. hastitle = true;
MyChart. Axes [0]. Title. Caption = "quantity"; // horizontal axis name
MyChart. Axes [1]. hastitle = true;
MyChart. Axes [1]. Title. Caption = "date"; // vertical axis name
// Add a series)
MyChart. seriescollection. Add (0 );
// Specify the name of a series.
MyChart. seriescollection [0]. setdata (owc10.chartdimensionsenum. chdimseriesnames, (INT) owc10.chartspecialperformancesenum. chdataliteral, "buy ");
// Category of a specified Series
MyChart. seriescollection [0]. setdata (owc10.chartdimensionsenum. chdimcategories, (INT) owc10.chartspecialperformancesenum. chdataliteral, strcateory );
// Specify the specific value
MyChart. seriescollection [0]. setdata (owc10.chartdimensionsenum. chdimvalues, (INT) owc10.chartspecialperformancesenum. chdataliteral, strvalue );
// Add a series
MyChart. seriescollection. Add (1 );
// Specify the name of a series.
MyChart. seriescollection [1]. setdata (owc10.chartdimensionsenum. chdimseriesnames, (INT) owc10.chartspecialperformancesenum. chdataliteral, "");
// Category of a specified Series
MyChart. seriescollection [1]. setdata (owc10.chartdimensionsenum. chdimcategories, (INT) owc10.chartspecialperformancesenum. chdataliteral, strcateory );
// Specify the specific value
MyChart. seriescollection [1]. setdata (owc10.chartdimensionsenum. chdimvalues, (INT) owc10.chartspecialperformancesenum. chdataliteral, strvalue1 );
// Add a series
MyChart. seriescollection. Add (2 );
// Specify the name of a series.
MyChart. seriescollection [2]. setdata (owc10.chartdimensionsenum. chdimseriesnames, (INT) owc10.chartspecialperformancesenum. chdataliteral, "total deals ");
// Category of a specified Series
MyChart. seriescollection [2]. setdata (owc10.chartdimensionsenum. chdimcategories, (INT) owc10.chartspecialperformancesenum. chdataliteral, strcateory );
// Specify the specific value
MyChart. seriescollection [2]. setdata (owc10.chartdimensionsenum. chdimvalues, (INT) owc10.chartspecialperformancesenum. chdataliteral, strvalue2 );
// Output as a GIF File
String strabsolutepath = (server. mappath (".") + @ "/image/tempchart.gif ";
Response. Write (strabsolutepath );
MySpace. exportpicture (strabsolutepath, "GIF", 300,300); // output chart
// Create the relative path of the GIF File
String strrelativepath = "image/tempchart.gif ";
// Add the image to the image
Image1.imageurl = strrelativepath;
}
Public void lixing ()
{
// Chart type Enumeration
Owc11.chartcharttypeenum [] charttypes = new owc11.chartcharttypeenum []
{
Chartcharttypeenum. chcharttypecolumnclustered,
Chartcharttypeenum. chcharttypecolumn3d,
Chartcharttypeenum. chcharttypebarclustered,
Chartcharttypeenum. chcharttypebar3d,
Chartcharttypeenum. chcharttypearea,
Chartcharttypeenum. chcharttypearea3d,
Chartcharttypeenum. chcharttypedoughnut,
Chartcharttypeenum. chcharttypelinestacked,
Chartcharttypeenum. chcharttypeline3d,
Chartcharttypeenum. chcharttypelinemarkers,
Chartcharttypeenum. chcharttypepie,
Chartcharttypeenum. chcharttypepie3d,
Chartcharttypeenum. chcharttyperadarsmoothline,
Chartcharttypeenum. chcharttypesmoothline
};
String [] charttypesch = new string [] {"vertical bar chart", "3D vertical bar chart", "Horizontal Bar Chart", "3D horizontal bar chart ", "area Statistical Chart", "3D area Statistical Chart", "Hollow pie chart", "line Statistical Chart", "3D line Statistical Chart", "line Statistical Chart with points", "Pie Chart ", "3D pie chart", "mesh Statistical Chart", "arc Statistical Chart "};
}
Protected void page_load (Object sender, eventargs E)
{
Makelinechart ();
}