# How do I get bar chart with multiple bars graphed? ( by using owc 1.1)?RSS

## 4 replies

Last post Apr 09, 2011 06:45 PM by andresdev

• keepfatinmin...

Member

2 Points

54 Posts

### How do I get bar chart with multiple bars graphed? ( by using owc 1.1)?

I have a DataSet  named dataSet

These Values if for x-axis
dataSet.Tables[0].Rows

dataSet.Tables[0].Rows[0][0] = A
dataSet.Tables[0].Rows[1][0] = B
dataSet.Tables[0].Rows[2][0] = C
dataSet.Tables[0].Rows[3][0] = D
dataSet.Tables[0].Rows[4][0] = E
dataSet.Tables[0].Rows[5][0] = F

Theese 10 values is  for y-axis
int[] MonthTotal = new int[10] { 0, 10, 20, 30,40,50,60 };

and each columns of row used for shows mutiple bar
EX:

These values is for A of x-axis
dataSet.Tables[0].Rows[0][1] = 30
dataSet.Tables[0].Rows[0][2] = 20
dataSet.Tables[0].Rows[0][3] = 30

these values if for B of x-axix

These values is for A of x-axis
dataSet.Tables[0].Rows[1][1] = 40
dataSet.Tables[0].Rows[1][2] = 10
dataSet.Tables[0].Rows[1][3] = 20

60 |
50 |
40 |     |
30 || |  |
20 ||||  | |
10 ||||__|||__________________
0   A    B   C   D ....

Here is the code I wrote

I have problems

one is axes..
// x-axis 's caption  ( How do I set x-axis and y-asix 's caption to Horizontal ? I got the result is x and Y  how do I set can get the format as "xxxx" and "yyyy"
mychart.Axes[0].HasTitle = true;                                                                      x     Y
mychart.Axes[0].Title.Caption = "XXXX";                                                               x     Y
x     Y

//y-axis 's caption
mychart.Axes[1].HasTitle = true;
mychart.Axes[1].Title.Caption = "YYYY";

and another is ... I can't get mutiple bar as I metioned ... I need the result like that

60 |
50 |
40 |     |
30 || |  |
20 ||||  | |
10 ||||__|||__________________
0   A    B   C   D ....

//x

string[] Unit = new string[dataSet.Tables[0].Rows.Count];
for (int x = 0; x < dataSet.Tables[0].Rows.Count; x++)
{
Unit[x] = dataSet.Tables[0].Rows[x][0].ToString();
}
//y
int[] MonthTotal = new int[10] { 0, 10, 20, 30, 40, 50, 60 };

//ChartSpace
ChartSpace ChartSpace = new ChartSpace();

//Setting type of Chart
mychart.Type = ChartChartTypeEnum.chChartTypeColumnClustered;

//
mychart.HasLegend = true;
mychart.HasTitle = true;
mychart.Title.Caption = "Mutiple Bar Chart";

// x-axis 's caption  ( How do I set x-axis and y-asix 's caption to Horizontal ? I got the result is x and Y  how do I set can get the format as "xxxx" and "yyyy"
mychart.Axes[0].HasTitle = true;                                                                      x     Y
mychart.Axes[0].Title.Caption = "XXXX";                                                               x     Y
x     Y

//y-axis 's caption
mychart.Axes[1].HasTitle = true;
mychart.Axes[1].Title.Caption = "YYYY";

//
mychart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, Unit[0]);
mychart.SeriesCollection[1].SetData(ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, Unit[1]);
mychart.SeriesCollection[2].SetData(ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, Unit[2]);
mychart.SeriesCollection[3].SetData(ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, Unit[3]);
mychart.SeriesCollection[4].SetData(ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, Unit[4]);
mychart.SeriesCollection[5].SetData(ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, Unit[5]);

//y
mychart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, MonthTotal[0]);
mychart.SeriesCollection[1].SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, MonthTotal[1]);
mychart.SeriesCollection[2].SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, MonthTotal[2]);
mychart.SeriesCollection[3].SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, MonthTotal[3]);
mychart.SeriesCollection[4].SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, MonthTotal[4]);
mychart.SeriesCollection[5].SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, MonthTotal[5]);

//careat image
ChartSpace.ExportPicture(Server.MapPath(".") + @"bar.jpg", "jpg", 500, 450);
Image Chart = new Image();
Chart.ImageUrl = Server.MapPath(".") + @"bar.jpg";

• keepfatinmin...

Member

2 Points

54 Posts

### Re: How do I get bar chart with multiple bars graphed? ( by using owc 1.1)?

sorry let me describe my question clearily again

How do I set x-axis and y-asix 's caption to Horizontal ?

My caption shows like   Y     But I want  YYYY ... how to set it?

Y

Y

Y

and the follow chart is what I try to describe the chart I want

60 |
50 |
40 |      |
30 || |    |
20 ||||    ||
10 ||||__|||__________________
0   A    B   C   D ....

I want multiple bars for each x-axis  like the A of x-axis have 3 bars one is in 30' 20 ' 30 and C of x-axis have 3 bars as well  in 40 10 0

how to setting multiple bars?

thank you

• keepfatinmin...

Member

2 Points

54 Posts

### Re: How do I get bar chart with multiple bars graphed? ( by using owc 1.1)?

I need this kind of bar chart

my code can only created this kind of bar chart

can you please give me a hint how to do it? please... thank you

• nevron

Member

30 Points

31 Posts

### Re: How do I get bar chart with multiple bars graphed? ( by using owc 1.1)?

Hi keepfatinmind,

I don't know if this will help, but if you are looking for advanced charting control, you may take a look at Nevron Chart for .NET. It has support for what you need - stacked column/bar chart and other chart types and features. Here is a screen of stacked-cluster bar/column chart.

Online examples are available here.

Best regards,

Anton

.NET ASP.NET C# asP.NET 2.0 component .net

• andresdev

None

0 Points

4 Posts