Page 1 of 1

stack areas again :-)

Posted: Sat May 29, 2010 10:39 pm
by 10546565
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

Re: stack areas again :-)

Posted: Sun May 30, 2010 5:40 pm
by 10545995
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 20632 times

Re: stack areas again :-)

Posted: Tue Jun 01, 2010 2:23 pm
by 10546565
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

Re: stack areas again :-)

Posted: Wed Jun 02, 2010 3:16 am
by 10545995
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.

Re: stack areas again :-)

Posted: Wed Jun 02, 2010 6:42 am
by narcis
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.

Re: stack areas again :-)

Posted: Wed Jun 02, 2010 2:48 pm
by 10546565
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

Re: stack areas again :-)

Posted: Thu Jun 03, 2010 10:37 am
by narcis
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.

Re: stack areas again :-)

Posted: Thu Jun 03, 2010 2:20 pm
by 10546565
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

Re: stack areas again :-)

Posted: Thu Jun 03, 2010 3:11 pm
by yeray
Hi Ed,

As you know, the compiled demo has a sources tab, so that's all you need, isn't it?

Re: stack areas again :-)

Posted: Thu Jun 03, 2010 4:05 pm
by 10546565
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

Re: stack areas again :-)

Posted: Fri Jun 04, 2010 9:02 am
by narcis
Hi Ed,

Excellent, thanks for sharing :!: