Stepping as stacked area series to/from zero values
-
- Newbie
- Posts: 20
- Joined: Thu Jan 13, 2022 12:00 am
Stepping as stacked area series to/from zero values
I've spent hours working on this and getting it working, only to find another where it doesn't work.
In the attached demo, a chart is created with area series that should step down to zero when the next value is zero or from zero when the previous value was zero. I can get it working some of the time, but I can't get it working for all four options.
In the demo, there are two methods for creating the char: UpdateChart1 and UpdateChart2, Clicking on the "Illustration #..." radio button produces different results. The combo box on the top right selects which chart method is used. UpdateChart1 shows the chart correctly but doesn't do the stepping. UpdateChart2 has different problems, depending upon which illustration is selected. (The chart is supposed to have a smooth upper line, showing income in retirement).
How can I achieve this?
Much appreciated,
Ed Dressel
In the attached demo, a chart is created with area series that should step down to zero when the next value is zero or from zero when the previous value was zero. I can get it working some of the time, but I can't get it working for all four options.
In the demo, there are two methods for creating the char: UpdateChart1 and UpdateChart2, Clicking on the "Illustration #..." radio button produces different results. The combo box on the top right selects which chart method is used. UpdateChart1 shows the chart correctly but doesn't do the stepping. UpdateChart2 has different problems, depending upon which illustration is selected. (The chart is supposed to have a smooth upper line, showing income in retirement).
How can I achieve this?
Much appreciated,
Ed Dressel
- Attachments
-
- Stepped Area.zip
- (8.99 KiB) Downloaded 1652 times
Re: Stepping as stacked area series to/from zero values
Hello,
Could you please draw what's the result you'd like to obtain? I'm not sure to understand it.
Could you please draw what's the result you'd like to obtain? I'm not sure to understand it.
I see inTest Always #? wrote: ↑Mon Mar 20, 2023 8:34 pmUpdateChart2 has different problems, depending upon which illustration is selected. (The chart is supposed to have a smooth upper line, showing income in retirement).
UpdateChart2
you are adding zeros to draw stairs/steps (instead of slopes) when going from/to a zero. But I'm not sure to see what's wrong with that approach.Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 20
- Joined: Thu Jan 13, 2022 12:00 am
Re: Stepping as stacked area series to/from zero values
Thank you for your response.
Here is a link to an image that I have working (sorry, I could not get the "img" tags to work and display the image in the preview):
http://www.tbinc.com/misc/A.jpg
When the cash flows get more complex, it falls apart--e.g., incomes starting and stopping. It took me a lot of work to get this one working.
I need them to step down, not slide down.
Does that make sense?
Ed Dressel
Here is a link to an image that I have working (sorry, I could not get the "img" tags to work and display the image in the preview):
http://www.tbinc.com/misc/A.jpg
When the cash flows get more complex, it falls apart--e.g., incomes starting and stopping. It took me a lot of work to get this one working.
I need them to step down, not slide down.
Does that make sense?
Ed Dressel
Re: Stepping as stacked area series to/from zero values
Hello,
The link to the image seems broken.
You can use attachments.
The link to the image seems broken.
You can use attachments.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 20
- Joined: Thu Jan 13, 2022 12:00 am
Re: Stepping as stacked area series to/from zero values
Sorry, the link should have been:
Re: Stepping as stacked area series to/from zero values
Hello Ed,
Yeray may have a better understanding of this but he's unavailable for comment for a few days. My interpretation of the Chart, technique UpdateChart1, is that, TeeChartwise, it's fine according to the data input, as you pointed out in your first post.
With respect to your other comment:
I haven't test-coded it but it is codeable I think via a cchart event such as OnBeforeDrawSeries,
ie.
...if value = zero then insert zero value at x of last non-zero value
then an extra point, the same as the next value, will likely be needed for the other series at that location to keep all series in sync.
Recapping, the last high value of each series will also have a zero value at the same x location. ...just a proposal for now.
Regards,
Marc
Yeray may have a better understanding of this but he's unavailable for comment for a few days. My interpretation of the Chart, technique UpdateChart1, is that, TeeChartwise, it's fine according to the data input, as you pointed out in your first post.
With respect to your other comment:
If we were to step the whole series (stairs true), it comes nowhere near to a coherent plot so I guess it's just a step down (looking at the image you've sent-over) at the end that is required, rather than a slope from the last 'highish' value to zero. It occurs to me that a cheat might be required, that a zero value, added at the same x location as the previous 'highish' value could resolve the issue.but doesn't do the stepping
I haven't test-coded it but it is codeable I think via a cchart event such as OnBeforeDrawSeries,
ie.
...if value = zero then insert zero value at x of last non-zero value
then an extra point, the same as the next value, will likely be needed for the other series at that location to keep all series in sync.
Recapping, the last high value of each series will also have a zero value at the same x location. ...just a proposal for now.
Regards,
Marc
Steema Support
Re: Stepping as stacked area series to/from zero values
...another thing we can do is check if perhaps we could add a 'drop-off' close feature for area series, wherein the series drops off to zero at the last value with a non-zero value.
It's a bit tricky because it is a very specific case and unlikely to be generically applicable to other cases where drop-off may not be to zero, or whether to include 'drop-on', ..and to only apply at the the very end of a series, etc. We'll take a look.
It's a bit tricky because it is a very specific case and unlikely to be generically applicable to other cases where drop-off may not be to zero, or whether to include 'drop-on', ..and to only apply at the the very end of a series, etc. We'll take a look.
-
- Newbie
- Posts: 20
- Joined: Thu Jan 13, 2022 12:00 am
Re: Stepping as stacked area series to/from zero values
That would be a great feature! This would make sense for null values--or negative values. But I have spent days trying to figure this out...another thing we can do is check
Much appreciated,
Ed Dressel
Re: Stepping as stacked area series to/from zero values
Hello Ed,
Checking this to see how it can be done. If the rules are:
1. If a value is followed by a zero then no direct join is made to the next point, rather a step downwards is made at the x-location of the last non-zero value.
2. If the predecessor to a value is zero, no direct join is made rather a step up is made at the x-location where the non-zero value occurs.
That would give this chart (a simulation) for the data in the example project:
Does that agree with what you expect to see?
With thanks.
Regards,
Marc
Checking this to see how it can be done. If the rules are:
1. If a value is followed by a zero then no direct join is made to the next point, rather a step downwards is made at the x-location of the last non-zero value.
2. If the predecessor to a value is zero, no direct join is made rather a step up is made at the x-location where the non-zero value occurs.
That would give this chart (a simulation) for the data in the example project:
Does that agree with what you expect to see?
With thanks.
Regards,
Marc
Re: Stepping as stacked area series to/from zero values
We see a obstacle to us adding the step-up/down as a generic feature because for stacked charts, if another series in the stack has values and another doesn't, a stack could show up as hollow
ie. which is, data-wise, true to the values of the blue series, but aesthetically not particularly attractive,
or .... to fill-down the blue.
ie. which is aesthetically easier on the eye, but data-wise gives the impression that, for example, the penultimate blue value is very large, which it isn't.
We are up for thinking this through further and working with any feedback, but at the moment we feel that a generic implementation wouldn't be true to the data in many cases.
Regards,
Marc
ie. which is, data-wise, true to the values of the blue series, but aesthetically not particularly attractive,
or .... to fill-down the blue.
ie. which is aesthetically easier on the eye, but data-wise gives the impression that, for example, the penultimate blue value is very large, which it isn't.
We are up for thinking this through further and working with any feedback, but at the moment we feel that a generic implementation wouldn't be true to the data in many cases.
Regards,
Marc
Steema Support
-
- Newbie
- Posts: 20
- Joined: Thu Jan 13, 2022 12:00 am
Re: Stepping as stacked area series to/from zero values
I think this would depend upon what type of data is being illustrated. For our need (retirement income data) it works well and is what we want to see, but for other data, I can see it being a problem (and probably stacked bars work better).
Re: Stepping as stacked area series to/from zero values
Hello,
I made a simple example trying to replicate the image you posted above.
Here the result: And the code to make it:
I haven't tried that data with the code in your "method 2", but the idea is very similar. Doesn't it work for you?
I made a simple example trying to replicate the image you posted above.
Here the result: And the code to make it:
Code: Select all
uses Series;
procedure TForm1.FormCreate(Sender: TObject);
var i, tmp: Integer;
begin
Chart1.View3D:=False;
Chart1.Hover.Hide;
Chart1.Gradient.Visible:=False;
Chart1.Walls.Back.Hide;
Chart1.Color:=clWhite;
Chart1.Axes.Bottom.Grid.Hide;
Chart1.Legend.Pen.Hide;
Chart1.Legend.Shadow.Hide;
Chart1.Legend.VertSpacing:=15;
Chart1.Title.Hide;
Chart1.Axes.Left.Title.Text:='Monthly Income';
Chart1.Axes.Bottom.Title.Text:='Years in Retirement';
Chart1.Legend.Font.Size:=12;
Chart1.Axes.Left.Title.Font.Size:=15;
Chart1.Axes.Bottom.Title.Font.Size:=15;
Chart1.Axes.Left.LabelsFont.Size:=12;
Chart1.Axes.Bottom.LabelsFont.Size:=12;
Chart1.Axes.Left.Axis.Width:=1;
Chart1.Axes.Left.MinorTicks.Hide;
Chart1.Axes.Bottom.Axis.Width:=1;
Chart1.Axes.Bottom.Ticks.Hide;
Chart1.Axes.Bottom.MinorTicks.Hide;
with TAreaSeries(Chart1.AddSeries(TAreaSeries)) do
begin
Color:=$CA9044;
Title:='Social Security';
Pen.Hide;
AreaLinesPen.Hide;
MultiArea:=maStacked;
tmp:=3800;
for i:=0 to 21 do
begin
if (i=14) then
AddXY(i, tmp);
AddXY(i, tmp);
Inc(tmp, 50);
end;
end;
with TAreaSeries(Chart1.AddSeries(TAreaSeries)) do
begin
Color:=$3ACDA7;
Title:='Retirement Plan';
Pen.Hide;
AreaLinesPen.Hide;
MultiArea:=maStacked;
tmp:=2500;
for i:=0 to 21 do
begin
if (i=14) then
begin
AddXY(i, 2000);
tmp:=0;
end;
AddXY(i, tmp);
end;
end;
with TAreaSeries(Chart1.AddSeries(TAreaSeries)) do
begin
Color:=$9998FF;
Title:='Projected Shortfall';
Transparency:=20;
Pen.Hide;
AreaLinesPen.Hide;
MultiArea:=maStacked;
tmp:=0;
for i:=0 to 21 do
begin
if (i=14) then
begin
AddXY(i, 500);
tmp:=2500;
end;
AddXY(i, tmp);
end;
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 20
- Joined: Thu Jan 13, 2022 12:00 am
Re: Stepping as stacked area series to/from zero values
That will work for this chart, but I need a solution that works for various scenarios when I don't know the data.
Re: Stepping as stacked area series to/from zero values
Hello,
Could you please draw what would you'd like to obtain in those situations where you are failing to obtain it?
You sent us a great project to test with 4 data scenarios. That's fantastic but I'm not sure to understand what's the goal in each of those scenarios.
Could you please draw what would you'd like to obtain in those situations where you are failing to obtain it?
You sent us a great project to test with 4 data scenarios. That's fantastic but I'm not sure to understand what's the goal in each of those scenarios.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 20
- Joined: Thu Jan 13, 2022 12:00 am
Re: Stepping as stacked area series to/from zero values
They should produce stepped area charts. In all the cases in the demo, the top line should be steady/slowly increasing (like the image provided earlier).
Does that make sense?
Does that make sense?