Stacked TAreaSeries does not work well

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Ed
Newbie
Newbie
Posts: 33
Joined: Tue Mar 09, 2004 5:00 am
Location: Oregon, USA
Contact:

Stacked TAreaSeries does not work well

Post by Ed » Thu Oct 27, 2005 7:19 pm

I have a chart with a number of TAreaSeries that are stacked--but try as I might, I can not get the chart to look right.

The key is that not all X points are represented--nor can they be. For example, I am monitoring contributions to an account. Accounts may or may not have contributions on given dates, so I use:

Series.AddXY(Date, YearToDateContributions);

I do the same for payouts of the account:

Series.AddXY(Date, YearToDateDistributions);

Not all accounts have contributions/distributions every year.

Doing this causes the chart to go haywire.

I've got a demo for this but thought I would ask before posting.

Any suggestions for achieving a good looking chart under these conditions?

Thanks
Ed Dressel

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

Post by Pep » Wed Nov 02, 2005 10:53 am

Hi Ed,

the stacking algorithm works only if two conditions are met:

1) all Series have the same number of points

2) all Series share the same XValues.

If this is not the case then area series will not be stacked correctly (internal algorithm cycles through all series and uses Series.YValues[ValueIndex] values for stacking.

A way around this problem is to :

+ cycle through all series and compare XValues

+ store all XValues in separate TChartValueList

+ use this list with series and manually populate missing XValues in each series by using AddNullXY method (or alternatively, AddXY with y =0)

I guess you can use OnBeforeDraw event to check all available XValues in each series and keep track in a boolean array which series is missing what X values. Then you can use AddNullXY (or AddXY with y=0) to add missing points. I know, this it's not very practical to do this, but it works.

Post Reply