protected void columnarBtn_Click(object sender, EventArgs e)
{
int[] month ={ 1, 2, 3 };
//创建Y坐标的值,表示销售额
double[] count ={ 120, 240, 220 };
//创建图表空间
ChartSpace mychartSpace = new ChartSpace();
//在图表空间内添加一个图表对象
ChChart mychart = mychartSpace.Charts.Add(0);
mychartSpace.Border.Color = "White";
//设置图表类型,本例使用柱形
mychart.Type = ChartChartTypeEnum.chChartTypeColumnClustered;
//设置图表的一些属性
//是否需要图例
mychart.HasLegend = true;
//是否需要主题
mychart.HasTitle = true;
//主题内容
mychart.Title.Caption ="柱状图测试";
mychart.Title.Font.Size = 10;
mychart.Title.Font.Bold = false;
mychart.Legend.Position = ChartLegendPositionEnum.chLegendPositionBottom;
mychart.Legend.Interior.Color = "f9f9f9";
mychart.Legend.Font.Size = 9;
mychart.Legend.Border.Color = "White";
//设置x,y坐标
mychart.Axes[1].HasTitle = true;
mychart.Axes[1].Title.Caption = "坐标";
mychart.Axes[1].Title.Font.Size = 9;
for (int i = 0; i < count.Length; i++)
{
mychart.SeriesCollection.Add(i);
mychart.SeriesCollection[i].Caption = count[i].ToString();
mychart.SeriesCollection[i].SetData(ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, month[i]);
mychart.SeriesCollection[i].SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, count[i]);
}
mychartSpace.ExportPicture(Server.MapPath(".") + @"\stat1.gif", "gif", 700, 400);
//加载图片
this.ig.ImageUrl = "stat1.gif" + "?temp=" + new Random().Next(1, 100) + ""; ;
}