Hi .net gurus,
I have requirement to generate Bar/column charts in my asp.net application for the data i am retrieving from database.
I have to make use of 'Series' same as in charts we generate excel.
I tried with below code, but i am getting only single bar for the series 'Volume1' below, , any pointers as to what is wrong in here....
I am using the code that i have got from VelocityViews....pasted below
-------------------------------
Response.Buffer =
true;
Response.ContentType =
"image/gif";
string Categories ="Jan,Feb,March,April,May,June,July,August,Septembe r,October,November,December";
string Values = "1,2,3,4,5,6,7,8,9,10,11,12";
string Values1 = "5,6,7,8,9,10,11,12,13,14,15,16";
int ChartHeight = 400;
int ChartWidth = 400;
OWC.
ChChart TheChart;
//create a new chartspace:
OWC.
ChartSpace myChartSpace = new OWC.ChartSpace();
//add a chart to it
TheChart = myChartSpace.Charts.Add(0);
//add a DataSeries to the chart
OWC.
ChSeries DataSeries = TheChart.SeriesCollection.Add(0);
//name it
DataSeries.SetData(OWC.
ChartDimensionsEnum.chDimSeriesNames,(int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral, "OWC DataSet1");
//set the DataSeries plot type
DataSeries.Type = OWC.
ChartChartTypeEnum.chChartTypeColumnStacked;
//populate it
DataSeries.SetData(OWC.
ChartDimensionsEnum.chDimCategories, (int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral, Categories);
DataSeries.SetData(OWC.
ChartDimensionsEnum.chDimValues, (int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral, Values);
OWC.
ChSeries DataSeries2 = TheChart.SeriesCollection.Add(1);
DataSeries2.Type = OWC.
ChartChartTypeEnum.chChartTypeColumnStacked;
//DataSeries2.SetData(OWC.ChartDimensionsEnum.chDimSeriesNames, (int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral, "OWC DataSeries2");
DataSeries2.SetData(OWC.
ChartDimensionsEnum.chDimCategories, (int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral, Categories);
DataSeries2.SetData(OWC.
ChartDimensionsEnum.chDimValues, (int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral, Values1);
//set the chart labels
TheChart.HasTitle =
true;
TheChart.Title.Caption =
"A Simple Chart";
TheChart.Title.Font.Name =
"Arial";
TheChart.Title.Font.Size = 8;
TheChart.Title.Font.Bold =
true;
TheChart.Axes[0].HasTitle =
true;
TheChart.Axes[0].Title.Caption =
"Categories";
TheChart.Axes[0].Title.Font.Name =
"Verdana";
TheChart.Axes[0].Title.Font.Size = 8;
TheChart.Axes[1].HasTitle =
true;
TheChart.Axes[1].Title.Caption =
"Values";
TheChart.Axes[1].Title.Font.Name =
"Verdana";
TheChart.Axes[1].Title.Font.Size = 8;
//Return the new chart in GIF format.
Response.BinaryWrite((
byte[]) myChartSpace.GetPicture("gif", ChartWidth,
ChartHeight));
Response.End();
-------------------------------
Basically my real data would look something like below, each column repesenting an year..
| Jan |
111,111 |
543,638 |
5454,65 |
| Feb |
|
|
782,336 |
| Mar |
|
|
487,132 |
| Apr |
|
|
789,421 |
| May |
484,766 |
441,417 |
444,421 |
| June |
416,926 |
504,586 |
653,321 |
Folks, Am badly waiting for help, do let me know if any other info is requried
Thanks