/// <summary>
/// 生成统计图表
/// </summary>
private void MakeLineChart()
{
//Y坐标轴
string[] DataName = { "星期一","星期二","星期三","星期四","星期五","星期六","星期日" };
//第一条曲线的数据
int [] Data = { 0,10,20,100,40,50,60 };
//第二条曲线的数据
int[] Data1 = {100,50,41,86};
//第三条曲线的数据
int [] Data2 = { 10,50,100,30,50,60 };
string strValue1 = "";
string strValue = "";
string strValue2 = "";
string strCateory = "";
//循环取得数据并格式化为OWC需要的格式,(加'\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';
}
//创建ChartSpace对象来放置图表
OWC.ChartSpace mySpace = new OWC.ChartSpaceClass();
//在ChartSpace对象中添加图表,Add方法返回chart对象
OWC.WCChart myChart = mySpace.Charts.Add(0);
//指定图表的类型为线性图
myChart.Type = OWC.ChartChartTypeEnum.chChartTypeSmoothLine;
//指定图表是否需要图例
myChart.HasLegend = true;
//给定标题
myChart.HasTitle = true;
myChart.Title.Caption = "交易曲线图";
//给定X\Y轴的图示说明
myChart.Axes[0].HasTitle = true;
myChart.Axes[0].Title.Caption = "数量";
myChart.Axes[1].HasTitle = true;
myChart.Axes[1].Title.Caption = "日期";
//添加一个series
myChart.SeriesCollection.Add(0);
//给定series的名字
myChart.SeriesCollection[0].SetData( OWC.ChartDimensionsEnum.chDimSeriesNames,(int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral,"购买" );
//给定series的分类
myChart.SeriesCollection[0].SetData( OWC.ChartDimensionsEnum.chDimCategories,(int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral,strCateory );
//给定具体值
myChart.SeriesCollection[0].SetData( OWC.ChartDimensionsEnum.chDimValues,(int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral,strValue );
//添加一个series
myChart.SeriesCollection.Add(1);
//给定series的名字
myChart.SeriesCollection[1].SetData( OWC.ChartDimensionsEnum.chDimSeriesNames,(int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral,"出售" );
//给定series的分类
myChart.SeriesCollection[1].SetData( OWC.ChartDimensionsEnum.chDimCategories,(int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral,strCateory );
//给定具体值
myChart.SeriesCollection[1].SetData( OWC.ChartDimensionsEnum.chDimValues,(int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral,strValue1 );
//添加一个series
myChart.SeriesCollection.Add(2);
//给定series的名字
myChart.SeriesCollection[2].SetData( OWC.ChartDimensionsEnum.chDimSeriesNames,(int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral,"总成交" );
//给定series的分类
myChart.SeriesCollection[2].SetData( OWC.ChartDimensionsEnum.chDimCategories,(int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral,strCateory );
//给定具体值
myChart.SeriesCollection[2].SetData( OWC.ChartDimensionsEnum.chDimValues,(int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral,strValue2 );
//输出成GIF文件
string strAbsolutePath = ( Server.MapPath(".") ) + @"\Images\tempChart.gif";
mySpace.ExportPicture( strAbsolutePath,"GIF",300,300 );
//创建GIF文件的相对路径
string strRelativePath = "../Images/tempChart.gif";
//把图片添加到Image
Image.ImageUrl = strRelativePath;
}//end