通过google我搜索出来,利用owc可以,确实,我用owc生成了柱形等,但就是生成 不了柱形百分比图,请高手指教。我的部分代码如下:
//创建X坐标的值,表示月份
int[] Month = new int[5] { 1, 2, 3,4,5 };
//创建Y坐标的值,表示销售额
double[] Count = new double[3] {0.2, 0.2, 0.3 };
//创建图表空间
ChartSpace mychartSpace = new ChartSpace();
//在图表空间内添加一个图表对象
ChChart mychart = mychartSpace.Charts.Add(0);
//设置图表类型,本例使用柱形
//xlColumnStacked100
mychart.Type = ChartChartTypeEnum.chChartTypeColumnStacked100;// .chChartTypeColumnClustered;
//设置图表的一些属性
//是否需要图例
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 = "销量";
//添加三个图表块
mychart.SeriesCollection.Add(0);
mychart.SeriesCollection.Add(0);
mychart.SeriesCollection.Add(0); //设置图表块的属性
//标题
mychart.SeriesCollection[0].Caption = "一月份";
//X坐标的值属性
mychart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, Month[0]);
//y坐标的值属性
//mychart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, Count[0]); ...........
//创建X坐标的值,表示月份
int[] Month = new int[5] { 1, 2, 3,4,5 };
//创建Y坐标的值,表示销售额
double[] Count = new double[3] {0.2, 0.2, 0.3 };
//创建图表空间
ChartSpace mychartSpace = new ChartSpace();
//在图表空间内添加一个图表对象
ChChart mychart = mychartSpace.Charts.Add(0);
//设置图表类型,本例使用柱形
//xlColumnStacked100
mychart.Type = ChartChartTypeEnum.chChartTypeColumnStacked100;// .chChartTypeColumnClustered;
//设置图表的一些属性
//是否需要图例
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 = "销量";
//添加三个图表块
mychart.SeriesCollection.Add(0);
mychart.SeriesCollection.Add(0);
mychart.SeriesCollection.Add(0); //设置图表块的属性
//标题
mychart.SeriesCollection[0].Caption = "一月份";
//X坐标的值属性
mychart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, Month[0]);
//y坐标的值属性
//mychart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, Count[0]); ...........
ChartSpace chart = new ChartSpace();
ChChart chchart = chart.Charts.Add(0);
chchart.Type = ChartChartTypeEnum.chChartTypeColumnClustered;
chchart.HasLegend = true;
chchart.HasTitle = true;
chchart.Title.Caption = "站点访问量统计图";
chchart.Axes[0].HasTitle = true;
chchart.Axes[0].Title.Caption = "时间段";
chchart.Axes[1].HasTitle = true;
chchart.Axes[1].Title.Caption = "访问量";
ChSeries chSeries = chchart.SeriesCollection.Add(0);
chSeries.Caption = "访问量";
chSeries.SetData(ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, x);
chSeries.SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, y);
chart.ExportPicture(path + fileName, "GIF", 640, 480);//图片生成的路径及大小
回复内容太短了!