Problem with bar series (THorizBarSeries)

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Alexandre
Newbie
Newbie
Posts: 1
Joined: Tue Jun 27, 2017 12:00 am

Problem with bar series (THorizBarSeries)

Post by Alexandre » Thu Oct 05, 2017 5:34 pm

Hello,

For bar series, the functions "AddXY" and "AddNullXY" do not insert, internally, the points in same order that column series. There is a sample attached.

I think that this is a BUG. Can anyone help me?

Thank you.

Alexandre da Silva.
Attachments
Unit1.rar
(2.11 KiB) Downloaded 565 times

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

Re: Problem with bar series (THorizBarSeries)

Post by Yeray » Fri Oct 06, 2017 1:26 pm

Hello,

Sorting the values in your series helps on the majority of cases. However, note you should also have the same number of values in both series when using stacked.
Here a method you can call after adding your values that solves that problems:

Code: Select all

procedure TForm1.FillAndSort;

    procedure Sync(ASeries1, ASeries2: TChartSeries);
    var i, j: Integer;
        exists: Boolean;
    begin
      for i:=0 to ASeries1.Count-1 do
      begin
        exists:=False;
        for j:=0 to ASeries2.Count-1 do
        begin
          if ASeries1.NotMandatoryValueList[i] = ASeries2.NotMandatoryValueList[j] then
          begin
            exists:=True;
            break;
          end;
        end;

        if not exists then
          if ASeries1 is THorizBarSeries then
             ASeries2.AddNullXY(0, ASeries1.YValue[i])
          else
             ASeries2.AddNullXY(ASeries1.XValue[i], 0);
      end;
    end;

begin
  Sync(Chart1[0], Chart1[1]);
  Sync(Chart1[1], Chart1[0]);

  Sync(Chart2[0], Chart2[1]);
  Sync(Chart2[1], Chart2[0]);

  Chart1[0].XValues.Sort;
  Chart1[1].XValues.Sort;
  Chart2[0].YValues.Sort;
  Chart2[1].YValues.Sort;
end;
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

Post Reply