Linear chart example:
Using Microsoft. Office. Interop. Owc11;
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 axis
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 (".") + @ "\ Images \ tempChart.gif ";
Response. Write (strAbsolutePath );
MySpace. ExportPicture (strAbsolutePath, "GIF", 300,300); // output chart
// Create the relative path of the GIF File
String strRelativePath = "Images/tempChart.gif ";
// Add the Image to the Image
Image1.ImageUrl = strRelativePath;
}
}
}