Bar chart with gaps and overlaps

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
ChrisR
Newbie
Newbie
Posts: 4
Joined: Fri Jan 12, 2007 12:00 am
Location: Auckland, NZ
Contact:

Bar chart with gaps and overlaps

Post by ChrisR » Mon Jan 15, 2007 11:58 pm

I am programatically building a chart with a number of Tbarseries each of which is set to mbStacked.
The points are being added with addXY(x,y,'label').
3d is turned off.

However while the rectangles have the correct colour, x-axis value and height (from the y-value). The base of many of the rectangles seems to be incorrectly calculated. This means that my bars have gaps and overlaps.

Any suggestions?

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Tue Jan 16, 2007 7:16 am

Hi, Chris.

The stacking algorithm will work correctly *only* if all series have the same number of points and point x values coincide. If this is not the case, you'll have to use AddNullXY method to add "missing points". I'd use the following approach:

1) Make a list of all available (pool) of x values.
2) For individual series, cycle through (1) and use AddXY if point (x,y) exists and AddNullXY if specific point (x,y) does not exist for this series.
Marjan Slatinek,
http://www.steema.com

ChrisR
Newbie
Newbie
Posts: 4
Joined: Fri Jan 12, 2007 12:00 am
Location: Auckland, NZ
Contact:

Post by ChrisR » Tue Jan 16, 2007 7:31 am

Thanks Marjan,

worked like a charm :)

Post Reply