Bar Width for Stacked Bars

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
CCRyder
Newbie
Newbie
Posts: 19
Joined: Fri Aug 11, 2006 12:00 am
Location: Germany
Contact:

Bar Width for Stacked Bars

Post by CCRyder » Sun Apr 26, 2009 11:33 am

Hello,
I have a Stacked Bar Chart which displays values for 6 years into the future the problem that I have is when displaying the chart the last Bar is only half as wide as the other bars and I have the Series width set to 100% for all bars. When I add another year to the base data with zero values then the last bar width is ok, but then the bottom axis shows an addtional year with zero values which does not look very professional. Is there any way to force the last bar to be the same width as the other bars?

Thanks!
Regards,
CCRyder

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

Post by Yeray » Mon Apr 27, 2009 8:36 am

Hi CCRyder,

I'm not able to reproduce the problem here with the following code. Could you please modify it in order to reproduce it? Or could you send us a simple example project we can run "as-is" to reproduce the problem here?
You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Code: Select all

uses series;

procedure TForm1.FormCreate(Sender: TObject);
var i, j: Integer;
begin
  for i:=0 to 1 do
  begin
    Chart1.AddSeries(TBarSeries.Create(self));
    for j:=0 to 5 do
      Chart1[i].Add(random*500);
  end;

  (Chart1[0] as TBarSeries).MultiBar := mbStacked;
end;

procedure TForm1.Button1Click(Sender: TObject);
var i: Integer;
begin
  for i:=0 to Chart1.SeriesCount-1 do
    Chart1[i].Add(random*500);
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

CCRyder
Newbie
Newbie
Posts: 19
Joined: Fri Aug 11, 2006 12:00 am
Location: Germany
Contact:

Bar Width for Stacked Bars

Post by CCRyder » Mon Apr 27, 2009 8:52 am

Hello Yeray,
I have uploaded a sample project for you to view. I was trying to correct the width by adding another empty datarow to the table and then adjusting the Bottom Axis offset but this confuses the user when entering data.

Thanks for your help!!

Best regards
Regards,
CCRyder

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

Post by Yeray » Mon Apr 27, 2009 10:35 am

Hi Ryder,

Yes, it seems that having for example two Bar Series, and one of them with BarWidthPercent = 100 and not the other, the last bar of the first series isn't draw as BarWidthPercent = 100. I've added it to the wish list to be fixed in future releases (TV52014110).

Easy to reproduce with this:

Code: Select all

uses series;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  for i:=0 to 1 do
  begin
    Chart1.AddSeries(TBarSeries.Create(self));
    Chart1[i].FillSampleValues(5);
  end;

  (Chart1[0] as TBarSeries).BarWidthPercent := 100;
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

CCRyder
Newbie
Newbie
Posts: 19
Joined: Fri Aug 11, 2006 12:00 am
Location: Germany
Contact:

Bar Width for Stacked Bars

Post by CCRyder » Mon Apr 27, 2009 6:11 pm

Hello Yeray,

Any ideas for a workaround until the next update?

Regards,
Regards,
CCRyder

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

Post by Yeray » Tue Apr 28, 2009 9:06 am

Hi Ryder,

The only workaround I can think right now is to add another series with a null value and adjust the axis:

Code: Select all

uses series;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  for i:=0 to 1 do
  begin
    Chart1.AddSeries(TBarSeries.Create(self));
    Chart1[i].FillSampleValues(5);
  end;

  (Chart1[0] as TBarSeries).BarWidthPercent := 100;
  Chart1[0].AddNull();
  Chart1.Axes.Bottom.AutomaticMaximum:=false;
  Chart1.Axes.Bottom.Maximum:=Chart1[0].Count-1;
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

CCRyder
Newbie
Newbie
Posts: 19
Joined: Fri Aug 11, 2006 12:00 am
Location: Germany
Contact:

Bar Width for Stacked Bars

Post by CCRyder » Tue Apr 28, 2009 9:24 am

Hello Yeray,
Thanks for the info. It looks like this will do the trick until the change has been implemented.
Regards,
CCRyder

Post Reply