Page 1 of 1
Add a bar and group it
Posted: Tue Sep 26, 2006 4:08 pm
by 9787319
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
Posted: Wed Sep 27, 2006 8:26 am
by narcis
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:
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");
}
}
Add a bar and group it
Posted: Wed Sep 27, 2006 1:37 pm
by 9787319
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
Posted: Wed Sep 27, 2006 1:54 pm
by narcis
Hi ssundoro,
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");
}
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:
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;
Add a bar and group it
Posted: Wed Sep 27, 2006 2:23 pm
by 9787319
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
Posted: Wed Sep 27, 2006 2:31 pm
by narcis
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.