stack areas again :-)

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
TestAlways
Advanced
Posts: 228
Joined: Tue Aug 28, 2007 12:00 am
Location: Oregon, USA

stack areas again :-)

Post by TestAlways » Sat May 29, 2010 10:39 pm

8.06, D2007

I have spent all afternoon (3+ hours now-) trying to figure out how to get the attached demo to work. There are three different datasets in the demo, and none of them look right--maybe I am trying to accomplish something that is not possible.

I want the area to be full, with no dead area in the chart. The stacked areas should fill the area of the sum of the values.

Can this be done for all 3 datasets with the same code? If so, what am I missing?

Ed Dressel
Attachments
Stack Area 2 Ways.zip
(4.15 KiB) Downloaded 979 times

bookman
Newbie
Newbie
Posts: 11
Joined: Wed Jul 04, 2007 12:00 am

Re: stack areas again :-)

Post by bookman » Sun May 30, 2010 5:40 pm

Ed,

I'm not exactly sure what you're ultimately looking for, so I plotted your data in Excel (one of your cases), and then tweaked your code so the plots looked similar (at least to me). Is this kinda what you had in mind?
pic1.png
pic1.png (31.05 KiB) Viewed 20327 times
Attachments
UpdateChart.zip
(813 Bytes) Downloaded 973 times

TestAlways
Advanced
Posts: 228
Joined: Tue Aug 28, 2007 12:00 am
Location: Oregon, USA

Re: stack areas again :-)

Post by TestAlways » Tue Jun 01, 2010 2:23 pm

What I am wanting is a little different. When a series goes to zero, I want it to step down right away, not draw a line to zero. Here is a sample chart that steps down:

Image

The green area series works perfectly here.

Let me explain what I am showing--the chart represents income during retirement. The green chart is income is from a cash account that runs out of money in year 16. If I show a step down from there to year 17, it appear it still has money after that. But actually it is running out in year 16, and it should step down (as shown above)

I can do this with charts that do not have many series, but when a large number of series are to be drawn, and/or when a series starts in the middle of the chart, I cannot get the chart to display correctly.

Ed Dressel

bookman
Newbie
Newbie
Posts: 11
Joined: Wed Jul 04, 2007 12:00 am

Re: stack areas again :-)

Post by bookman » Wed Jun 02, 2010 3:16 am

Ed,

Ahh, I understand the problem. I've tried a few things (probably like you) and always end up with a little unfilled triangle somewhere.

My only thoughts, if the Steema folks don't have a solution:

Bar Graph. Data seems tailor made for that...
Custom Drawing. Either custom draw the little triangle, or draw polygons in lieu of the series.

Best of luck.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: stack areas again :-)

Post by Narcís » Wed Jun 02, 2010 6:42 am

Hello Ed and bookman,

First of all notice that to use stacked area series you need to have same number of points and those must have the same X values. This not being the case might lead to such problems. Also, we have implemented a fix for stacked area series with negative values for next maintenance release but this may not apply to the issue discussed here.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

TestAlways
Advanced
Posts: 228
Joined: Tue Aug 28, 2007 12:00 am
Location: Oregon, USA

Re: stack areas again :-)

Post by TestAlways » Wed Jun 02, 2010 2:48 pm

Narcís wrote:First of all notice that to use stacked area series you need to have same number of points and those must have the same X values. This not being the case might lead to such problems.
I was aware of that and int he header of the demo app put the number of points for each series:

Image

I also included the ability to see the data for each stacked area.

I am not sure how to do this--or if it can be done--on a generic basis.

Ed Dressel

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: stack areas again :-)

Post by Narcís » Thu Jun 03, 2010 10:37 am

Hi Ed,

To get a chart similar to the image you posted on 1st June you could try using 3 series and add null values to green or pink series where values shouldn't exist. I recommend you to have a look at the All Features\Welcome!\Chart Styles\Area\Area TreatNulls example in the new features example, available at TeeChart's program group.

If this doesn't help, do you think any of the 3 datasets in your original project contains a data structure as in mentioned chart? Otherwise, could you please attach a simple example project or, at least, some date which should produce such chart structure? We will try to help you getting it.

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

TestAlways
Advanced
Posts: 228
Joined: Tue Aug 28, 2007 12:00 am
Location: Oregon, USA

Re: stack areas again :-)

Post by TestAlways » Thu Jun 03, 2010 2:20 pm

Narcís wrote:I recommend you to have a look at the All Features\Welcome!\Chart Styles\Area\Area TreatNulls example in the new features example, available at TeeChart's program group.
I installed the 8.06 with full source, which doesn't look like it includes the demo. Is there any way to just get the demo without installing over the top of the existing code?

Thank you,

Ed Dressel

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: stack areas again :-)

Post by Yeray » Thu Jun 03, 2010 3:11 pm

Hi Ed,

As you know, the compiled demo has a sources tab, so that's all you need, isn't it?
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

TestAlways
Advanced
Posts: 228
Joined: Tue Aug 28, 2007 12:00 am
Location: Oregon, USA

Re: stack areas again :-)

Post by TestAlways » Thu Jun 03, 2010 4:05 pm

I found a fix--I do self stacking. Here is a screen shot of what I am looking for (the unevenness in the chart on the slope is due to rounding errors--I didn't type in the decimals for the data):

Image

I changed the code so that it stacks itself:

Code: Select all

for I := High(lChartData) downto Low(lChartData) do
begin
  Chart1.FreeAllSeries;
  lChartData := GetChartData;
  for I := High(lChartData) downto Low(lChartData) do
  begin
    lsrs := CreateChartSeries(I, maNone);;
    for J := 0 to High(lChartData[I]) do
    begin
      lIncome := 0;
      for K := 0 to I do
        lIncome := lIncome + lChartData[K, J];
      if (lIncome > 0) then
        lsrs.AddXY(J, lIncome, IntToStr(J))
      else
        lsrs.AddNullXY(J, 0, IntToStr(J));
    end;
  end;
end;
I could not get this result with the maStacked option.

I have attached the project for anyone wanting to review it.

Ed Dressel
Attachments
Stack Area 2 Ways.zip
(4.8 KiB) Downloaded 909 times

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: stack areas again :-)

Post by Narcís » Fri Jun 04, 2010 9:02 am

Hi Ed,

Excellent, thanks for sharing :!:
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply