Stacked Area--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

Stacked Area--again

Post by TestAlways » Thu Apr 29, 2010 3:20 pm

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:

Image

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
Attachments
Stack Area 2.zip
(7.24 KiB) Downloaded 465 times

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

Re: Stacked Area--again

Post by Narcís » Fri Apr 30, 2010 4:15 pm

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.
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: Stacked Area--again

Post by TestAlways » Fri Apr 30, 2010 5:24 pm

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;

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

Re: Stacked Area--again

Post by Narcís » Tue May 04, 2010 1:49 pm

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]);
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