Grouping Stacked Bars

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
AMS
Newbie
Newbie
Posts: 24
Joined: Wed Mar 31, 2004 5:00 am
Location: South Africa
Contact:

Grouping Stacked Bars

Post by AMS » Thu Dec 01, 2005 12:34 pm

Hi,

I would like to pose an implementation problem that I have and request possible solutions?

Firstly, if I add 3 bar series defined as mbStacked and then add five items each like this:

Code: Select all

// Add a Green Series
GreenSeries = new THorizBarSeries(MyChart);
GreenSeries->MultiBar = mbStacked;
GreenSeries->ColorEachPoint = true;
MyChat->AddSeries(GreenSeries);

// Add a Yellow Series
YellowSeries = new THorizBarSeries(MyChart);
YellowSeries->MultiBar = mbStacked;
YellowSeries->ColorEachPoint = true;
MyChat->AddSeries(YellowSeries);

// Add a Red Series
RedSeries = new THorizBarSeries(MyChart);
RedSeries->MultiBar = mbStacked;
RedSeries->ColorEachPoint = true;
MyChat->AddSeries(RedSeries);

// 1 - Now we add our first item to each series
GreenSeries->Add(5,"Group1", clGreen);
YellowSeries->Add(10,"Group1", clYellow);
RedSeries->Add(15,"Group1", clRed);

// 2 - Now we add our second item to each series
GreenSeries->Add(10,"Group2", clGreen);
YellowSeries->Add(15,"Group2", clYellow);
RedSeries->Add(20,"Group2", clRed);

// 3 - Now we add our third item to each series
GreenSeries->Add(15,"Group3", clGreen);
YellowSeries->Add(20,"Group3", clYellow);
RedSeries->Add(25,"Group3", clRed);

// 4 - Now we add our third item to each series
ptrToGSeries->Add(20,"Group4", clGreen);
ptrToYSeries->Add(25,"Group4", clYellow);
ptrToRSeries->Add(30,"Group4", clRed);

// 5 - Now we add our third item to each series
ptrToGSeries->Add(25,"Group5", clGreen);
ptrToYSeries->Add(30,"Group5", clYellow);
ptrToRSeries->Add(35,"Group5", clRed);
Now... What this gives is 5 items on the left axis, labelled "Group1", "Group2", "Group3", "Group4" and "Group5"

The problem:
I need to have "Group1" and "Group2" together/grouped, with a new label, say "Set1". I then need "Group3","Group4" and "Group5" together/grouped, with a new label, say "Set2".

Any ideas?
Regards John.

Pep
Site Admin
Site Admin
Posts: 3296
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Dec 01, 2005 3:30 pm

Hi John,

if you only need to group them just with a label then it's easy, you can use the Canvas techniques (or use an Annotation tool) to place a label into the Chart panel (you'll have to increase the left or right margins).

In case you need to have the groups separately grouped as for example group1 and group2 in one Multibar the only way I can think of is calculating the values of the Bar manually and use one Series to add these calculated values setting this Bar series as SelfStacked (using one Series for each group of groups you need).

AMS
Newbie
Newbie
Posts: 24
Joined: Wed Mar 31, 2004 5:00 am
Location: South Africa
Contact:

Post by AMS » Fri Dec 02, 2005 5:58 am

Hi Josep,

Labelling is not what I'm after, I need the bars to be displyed next to each other.

What if I could have series defined as mbSide, this would provide the grouping I need, and then colour the bars in 3 stages, Green, Yellow and Red using canvas techniques or somthing else? (Not gradient colours, I need 3 seperate colours as if I was using mbStacked)

Any suggestions...?

Regards John.

Pep
Site Admin
Site Admin
Posts: 3296
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon Dec 05, 2005 12:52 pm

Hi John,

yes, it could be one way, setting the bars to mbSide, and using Canvas techniques to paint the bars, but this will require a hard code (at the time to paint the Bars). Another way I was thinking is using more than one left axis (and bottom axis) to do the two groups but the actual version of TeeChar Pro ActiveX still not prepared to have several Series stacked and using different axis each one.
Another way could be using more than one Chart (one on top of the other) setting the margints to 0, changing the border, etc...

Post Reply