Page 1 of 1

Problem with bar series (THorizBarSeries)

Posted: Thu Oct 05, 2017 5:34 pm
by 16481249
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.

Re: Problem with bar series (THorizBarSeries)

Posted: Fri Oct 06, 2017 1:26 pm
by yeray
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;