Page 1 of 1
Stacked Area--again
Posted: Thu Apr 29, 2010 3:20 pm
by 10546565
I thought I had this figured out but alas, I got put it in my deployment app and it not working right.
I created a demo that shows 3 stacked area series, but I cannot figure out what I am doing wrong.
Here is a screen shot:
I need the empty space to be removed--I've spent hours on this trying to figure out what I am doing wrong.
Demo attached.
Ed Dressel
Re: Stacked Area--again
Posted: Fri Apr 30, 2010 4:15 pm
by narcis
Hi Ed,
I'm afraid the problem here is similar to what was discussed
here. Second series has one point more than others. Adding a TTeeCommander component to your application and going to the Data tab you'll see there's a repeated X value by the end of the series.
Re: Stacked Area--again
Posted: Fri Apr 30, 2010 5:24 pm
by 10546565
Thanks. I was using modified code provided in a previous post (
http://www.teechart.net/support/viewtop ... =3&t=10352).
I modified the original code, and applied the mod to my code. This fixed it. Please let me know if this is correct.
Ed Dressel
Code: Select all
procedure TForm46.UpdateChart;
var
I: Integer;
J: Integer;
lValue: Double;
lSrs: TChartSeries;
Stairs: array of TPoint; //X values will store the series index, and Y values will store the value index of the stairs
begin
Chart1.FreeAllSeries;
SetLength(Stairs,0);
for I := 0 to spnNumSeries.Value-1 do
begin
lSrs := CreateSeries;
for J := 0 to spnNumPoints.Value-1 do
begin
lValue := GetValue(I, J);
if lValue > 0 then
lSrs.AddXY(J, lValue)
else
lSrs.AddNullXY(J, lValue);
if (lValue > 0) and (GetValue(I, J + 1) = 0) then
begin
lSrs.AddNullXY(J, 0);
SetLength(Stairs,Length(Stairs)+1);
Stairs[Length(Stairs)-1] := Point(I,J);
end;
end;
end;
for I := 0 to Length(Stairs)-1 do
begin
//for J := Stairs[I].X+1 to spnNumSeries.Value-1 do // <------ REMOVED
for J := 0 to spnNumSeries.Value-1 do // <------ ADDED
if J <> Stairs[I].X then // <------ ADDED
Chart1[J].AddXY(Stairs[I].Y, Chart1[J].YValue[Stairs[I].Y]);
end;
end;
Re: Stacked Area--again
Posted: Tue May 04, 2010 1:49 pm
by narcis
Hi Ed,
Yes, changing code below in your example works fine for me here.
Code: Select all
for I := Length(Stairs)-1 downto 0 do
for J := 0 to Chart1.SeriesCount-1 do // <------ ADDED
if J <> Stairs[I].X then // <------ ADDED
Chart1[J].AddXY(lSrs.XValue[Stairs[I].Y], lSrs.YValue[Stairs[I].Y]);