Hi,
is there a way to group bars side by side?
I like to make chart that showed:
Jan, Feb, Mar, etc and
each label ex:"Jan" contains mutliple bars of Types.
I need to add each bar to be grouped ex "Jan" .
as for right now here is the codes:
Bar bar1 = new Bar(WebChart1.Chart);
bar1.Add(Convert.ToDouble(dt.Rows[0].ItemArray[5].ToString()), dt.Rows[0].ItemArray[1].ToString());
bar1.Add(Convert.ToDouble(dt.Rows[1].ItemArray[5].ToString()), dt.Rows[1].ItemArray[1].ToString());
Thanks in advance,
ssundoro
Add a bar and group it
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi ssundoro,
Having several bar series in a chart, its default behaviour is stacking the bars according to their x values so that you could use something like this:
Having several bar series in a chart, its default behaviour is stacking the bars according to their x values so that you could use something like this:
Code: Select all
private void Form1_Load(object sender, EventArgs e)
{
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
Steema.TeeChart.Styles.Bar bar2 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
Steema.TeeChart.Styles.Bar bar3 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
Random yVals = new Random();
for (int i = 0; i < tChart1.Series.Count; i++)
{
tChart1[i].Add(yVals.Next(), "Jan");
tChart1[i].Add(yVals.Next(), "Feb");
tChart1[i].Add(yVals.Next(), "May");
tChart1[i].Add(yVals.Next(), "Jun");
tChart1[i].Add(yVals.Next(), "Jul");
tChart1[i].Add(yVals.Next(), "Aug");
tChart1[i].Add(yVals.Next(), "Sep");
tChart1[i].Add(yVals.Next(), "Oct");
tChart1[i].Add(yVals.Next(), "Nov");
tChart1[i].Add(yVals.Next(), "Dec");
}
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Add a bar and group it
Hi Narcis,
In this issue, I am able to show the bar for "Jan","Feb", etc.
The problem I am having is to add multiple bar in group "Jan" so each bar will be group side by side.
So, my question is, do you think it is able to add multiple bar in group "Jan"? If yes, how can I make it happen?
Thanks,
ssundoro
In this issue, I am able to show the bar for "Jan","Feb", etc.
The problem I am having is to add multiple bar in group "Jan" so each bar will be group side by side.
So, my question is, do you think it is able to add multiple bar in group "Jan"? If yes, how can I make it happen?
Thanks,
ssundoro
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi ssundoro,
I would have explained better if I had used X and Y values for populating the series as shown here:
BTW: I also forgot some months . Who knows what I was thinking about at that moment .
Anyway, you can add any value to any month just adding a new series with a new bar having the month value as X value and the Y value you want, as for example:
I would have explained better if I had used X and Y values for populating the series as shown here:
Code: Select all
for (int i = 0; i < tChart1.Series.Count; i++)
{
tChart1[i].Add(1, yVals.Next(), "Jan");
tChart1[i].Add(2, yVals.Next(), "Feb");
tChart1[i].Add(3, yVals.Next(), "Mar");
tChart1[i].Add(4, yVals.Next(), "Apr");
tChart1[i].Add(5, yVals.Next(), "May");
tChart1[i].Add(6, yVals.Next(), "Jun");
tChart1[i].Add(7, yVals.Next(), "Jul");
tChart1[i].Add(8, yVals.Next(), "Aug");
tChart1[i].Add(9, yVals.Next(), "Sep");
tChart1[i].Add(10, yVals.Next(), "Oct");
tChart1[i].Add(11, yVals.Next(), "Nov");
tChart1[i].Add(12, yVals.Next(), "Dec");
}
Anyway, you can add any value to any month just adding a new series with a new bar having the month value as X value and the Y value you want, as for example:
Code: Select all
Steema.TeeChart.Styles.Bar bar4 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar4.Add(1, 0, "Jan", Color.Transparent);
bar4.Add(2, 0, "Feb", Color.Transparent);
bar4.Add(3, yVals.Next(), "Mar");
bar4.Add(4, yVals.Next(), "Apr");
bar4.Add(5, 0, "May", Color.Transparent);
bar4.Add(6, yVals.Next(), "Jun");
bar4.Add(7, yVals.Next(), "Jul");
bar4.Add(8, 0, "Aug", Color.Transparent);
bar4.Add(9, yVals.Next(), "Sep");
bar4.Add(10, 0, "Oct", Color.Transparent);
bar4.Add(11, yVals.Next(), "Nov");
bar4.Add(12, yVals.Next(), "Dec");
for (int i = 0; i < tChart1.Series.Count; i++)
tChart1[i].Marks.Visible = false;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Add a bar and group it
Hi Narcis,
Sorry to bother you again but I think your answer is not the one I am looking for. I wish I could draw it but I don't think I am able to.
I tend to add multiple bars in group "Jan" side by side without any gap.
So it would be like multiple bar in "Jan" then another multiple bar in "Feb", etc.
The code you give me is only adding a value to each group bar.
Thanks,
ssundoro
Sorry to bother you again but I think your answer is not the one I am looking for. I wish I could draw it but I don't think I am able to.
I tend to add multiple bars in group "Jan" side by side without any gap.
So it would be like multiple bar in "Jan" then another multiple bar in "Feb", etc.
The code you give me is only adding a value to each group bar.
Thanks,
ssundoro
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi ssundoro,
To add multiple values add as many series like as the number of values you want to add as I did in my last code snippet.
To add multiple values add as many series like as the number of values you want to add as I did in my last code snippet.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |