strange bar width combining series with different # of data
Posted: 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 :
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 ).
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>