strange bar width combining series with different # of data

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
h.hasenack
Newbie
Newbie
Posts: 32
Joined: Tue Jul 21, 2009 12:00 am
Location: Nijmegen, Netherlands

strange bar width combining series with different # of data

Post by h.hasenack » Mon Jul 27, 2009 8:58 am

When combining barseries and line series with different # of datapoints, the bar width becomes strange (check attached screenshots and test app). Here's a patch for that 8) :

Code: Select all

Procedure TCustomBarSeries.DoBeforeDrawChart;
<snip>

  for t:=0 to SeriesCount-1 do
{$ifdef HH_PATCH_TC_BARWIDTH}
// THis fixes a problem when using eg mixed stacked bars and a line series. If
// the line series has more datapoints than the barseries, the bars will become
// too wide, because only other barseries are originally checkd for datacount.
// This now also checks other series with YMandatory=True
  if Series[t].Active then
  begin
    if SameClass(Series[t]) then
    begin
      Stop:=Stop or (Series[t]=Self);
      tmp:=Series[t].Count;
      if (IMaxBarPoints=TeeAllValues) or (tmp>IMaxBarPoints) then
         IMaxBarPoints:=tmp;
      Case FMultiBar of
        mbNone: INumBars:=1;
        mbSide,
        mbSideAll: begin
                     Inc(INumBars);
                     if not Stop then Inc(IOrderPos);
                   end;
        mbStacked,
        mbStacked100: if NewGroup(TCustomBarSeries(Series[t]).FStackGroup) then
                      begin
                        Inc(INumBars);
                        if not Stop then Inc(IOrderPos);
                      end;
      end;
      if not Stop then Inc(IPreviousCount,tmp);
    end
    else
    begin
      if Series[t].YMandatory then
      begin
        tmp:=Series[t].Count;
        if (IMaxBarPoints=TeeAllValues) or (tmp>IMaxBarPoints) then
           IMaxBarPoints:=tmp;
      end;

    end;
  end;
{$else}
  if Series[t].Active and SameClass(Series[t]) then
  begin
    Stop:=Stop or (Series[t]=Self);
    tmp:=Series[t].Count;

    if (IMaxBarPoints=TeeAllValues) or (tmp>IMaxBarPoints) then
    begin
      IMaxBarPoints:=tmp;

      if FSideMargins and (tmp>0) then // 7.06
         Inc(IMaxBarPoints);
    end;

    Case FMultiBar of
      mbNone: INumBars:=1;
      mbSide,
      mbSideAll: begin
                   Inc(INumBars);
                   if not Stop then Inc(IOrderPos);
                 end;
      mbStacked,
      mbStacked100: if NewGroup(TCustomBarSeries(Series[t]).FStackGroup) then
                    begin
                      Inc(INumBars);
                      if not Stop then Inc(IOrderPos);
                    end;
      mbSelfStack: INumBars:=1;
    end;

    if not Stop then
       Inc(IPreviousCount,tmp);
  end;
  {$endif}
<snip>
PS Also the bar with becomes strange when setting eg bottomaxis min to 100, max to 1000 and adding a few irrregular datapoints like AddXY(X,Y) (110,100) (120,100) (800,100), but I have no fix for this yet as this is no problem for me at the moment :twisted: ).
Attachments
TestTChart.zip
Demo app & screenshots of bar width failure
(36.71 KiB) Downloaded 201 times

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

Re: strange bar width combining series with different # of data

Post by Yeray » Mon Jul 27, 2009 2:19 pm

Hi Hans,

I've reproduced and added your fix to the sources so that it will be available in the next maintenance release.

Thank you.
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