TeeChart Pro 2011 bar width too thin

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Dynafact
Newbie
Newbie
Posts: 9
Joined: Fri Nov 19, 2010 12:00 am

TeeChart Pro 2011 bar width too thin

Post by Dynafact » Wed Jan 26, 2011 7:19 pm

Hello,

I upgraded from version 8 to TeeChart Pro 2011 when I moved from Delphi 2006 to 2011 (XE). I have a chart with 4 series -- 3 bar charts and one line. Everything was working correctly in version 8 and Delphi 2006, but now I am getting very think bars when graphing week and month time periods.

The graph switches between dtOneDay, dtOneWeek, and dtOneMonth. The bar width is correct with dtOneDay, but when the scale changes to dtOneWeek or dtOneMonth, the bar width is too thin and difficult to see.

The following is my code for day:

with Graph.Axes.Bottom do
begin
LabelsMultiLine:=true;
DateTimeFormat := 'mmm.dd';//
Increment := DateTimeStep[dtOneDay];
Automatic := true;
PageScale := PointsPerPage-1;
SetMinMax(GStartDate, GStartDate + PageScale);
end;

And for week is:

with Graph.Axes.Bottom do
begin
Automatic := false;
Increment := DateTimeStep[dtOneWeek];
DateTimeFormat := 'mmm.dd yy';
PageScale:= PointsPerPage*7;
SetMinMax(GStartDate, GStartDate + PageScale);
end;

I have the three bar series AutoBarSize set to true. If I leave the PageScale for dtOneWeek to the same as the day setting, the bar width is correct, but of course the scale is incorrect.

How do I correct the bar width problem?

Thanks,

Dave

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

Re: TeeChart Pro 2011 bar width too thin

Post by Yeray » Thu Jan 27, 2011 2:39 pm

Hi Dave,

The TBarSeries has been considerably improved in v2010. However, with your application explanation and code snipped, many things could still influence to the final bars width. So it would be very helpful if you could arrange a simple example project we can run as-is to reproduce the problem here.
Thanks in advance.
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

Dynafact
Newbie
Newbie
Posts: 9
Joined: Fri Nov 19, 2010 12:00 am

Re: TeeChart Pro 2011 bar width too thin

Post by Dynafact » Thu Jan 27, 2011 3:50 pm

Hello Yeray,

Here is the complete code to get the thin bars when displaying in Weeks. Click on the radio button to select the scale and then click on the Graph button. Days works fine, but Weeks displays thin bars:

Code: Select all

unit TestBarGraph;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, TeEngine, TeeTools, TeePageNumTool, Series, ExtCtrls, TeeProcs, Chart,
  StdCtrls, DateUtils;

type
  TForm1 = class(TForm)
    pnlTop: TPanel;
    Panel1: TPanel;
    Graph: TChart;
    Series1: TBarSeries;
    Series2: TBarSeries;
    Series3: TLineSeries;
    Series4: TBarSeries;
    ChartTool1: TPageNumTool;
    Button1: TButton;
    ScrollBar1: TScrollBar;
    rdoGraph: TRadioGroup;
    procedure Button1Click(Sender: TObject);
    procedure DisplayBars;
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  GStartDate:TDateTime;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  DDay, DMonth, DYear:word;
  i, PointsPerPage, PageScale:integer;
  EDate:TDateTime;
begin
  ScrollBar1.Max:= 365;
  PageScale:=1;
  PointsPerPage:=12;

  Series1.Clear;
  Series2.Clear;
  Series3.Clear;

  Series1.XValues.DateTime := true;
  Series2.XValues.DateTime := true;
  Series3.XValues.DateTime := true;

  //Set the 4 bar series to have the bar width calculated automatically
  Series1.AutoBarSize:=true;
  Series2.AutoBarSize:=true;
  Series4.AutoBarSize:=true;

  Graph.Axes.Bottom.ExactDateTime:=true;

  if rdoGraph.ItemIndex=0 then
  begin
    with Graph.Axes.Bottom do
    begin
      LabelsMultiLine:=true;
      DateTimeFormat := 'mmm.dd';//ShortDateFormat;
      Increment := DateTimeStep[dtOneDay];
      Automatic := true;
      PageScale := PointsPerPage-1;
      SetMinMax(GStartDate, GStartDate + PageScale);
    end;
    ScrollBar1.SmallChange:=1;
    ScrollBar1.LargeChange:=7;
  end
  else
  begin
    i := DayOfTheWeek(GStartDate);
    if i <> 1 then
    begin
      i := (i-1)*-1;
      GStartDate := IncDay(GStartDate, i);
    end;
    with Graph.Axes.Bottom do
    begin
      Automatic := false;
      Increment := DateTimeStep[dtOneWeek];
      DateTimeFormat := 'mmm.dd yy';
      PageScale:= PointsPerPage*7;
      SetMinMax(GStartDate, GStartDate +  PageScale);
    end;
    ScrollBar1.SmallChange:=7;
    ScrollBar1.LargeChange:=28;
  end;

  DisplayBars;


end;
procedure TForm1.DisplayBars;
var
  i:integer;
  x:double;
begin

  for i:=0 to 11 do
  begin
    if rdoGraph.ItemIndex=0 then
    begin
      x := IncDay(GStartDate, i);
    end
    else
    begin
      x := IncDay(GStartDate, (i* 7));
    end;
    series1.AddXY(x, 15-i, '', clTeeColor);
    series2.AddXY(x, 5+1, '', clTeeColor);
    series3.AddXY(x, 7+i, '', clTeeColor);
    series4.AddXY(x, 12-i, '', clTeeColor);

  end;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  GStartDate := Now;
end;

end.
Thanks!
Dave

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

Re: TeeChart Pro 2011 bar width too thin

Post by Yeray » Fri Jan 28, 2011 11:50 am

Hi Dave,

I've simplified your code to see what's happening clearly. There were some incoherences too: Series4 wasn't cleared nor set as DateTime like the others, and Series3 didn't have AutoBarSize set to true.
AutoBarSize_Test.zip
(3.78 KiB) Downloaded 348 times
As you can see in the application attached, the key is the AutoBarSize property.
So could you please check if not setting AutoBarSize to true is acceptable in your application?
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

Dynafact
Newbie
Newbie
Posts: 9
Joined: Fri Nov 19, 2010 12:00 am

Re: TeeChart Pro 2011 bar width too thin

Post by Dynafact » Wed Feb 02, 2011 3:54 pm

Hello Yeray,

I took a few days off and went skiing – too nice to work – so I am late getting back to you.

In the example I posted, I am using the AutoBarSize:=true. Also, one of the series is a ribbon, not a bar graph.

Your test does work, but in your example you are not changing the page scale with SetMinMax. In my example I am using the Graph.Axes.Bottom and changing the PageScale with the SetMinMax. This is where the problem appears to be. If you work with my example you will get the error.

Dave

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

Re: TeeChart Pro 2011 bar width too thin

Post by Yeray » Thu Feb 03, 2011 3:45 pm

Hi Dave,

As said before, there are some objects in your code I don't know what they do in your application. For example, there is a scroll bar I can't see interacting with the chart. And Series4 wasn't cleared nor set to datetime.
Here it is the application I'm using with the minimum changes. I've removed the button and called your code at rdoGraphClick to simplify the test project. Note that without AutoBarSize, the bars look well.
BarWidth.zip
(2.43 KiB) Downloaded 351 times
If that's not what you want, please, try to arrange a simple but complete project we can run as-is to reproduce the problem here.
Thanks in advance.
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

Dynafact
Newbie
Newbie
Posts: 9
Joined: Fri Nov 19, 2010 12:00 am

Re: TeeChart Pro 2011 bar width too thin

Post by Dynafact » Mon Feb 07, 2011 4:04 pm

Hello,

After some more experimenting, I believe that the problem has to do with loading of the data using AddXY. In your example, change the loop where you load the series bars to be 364 days as in:

Code: Select all

  for i:=0 to 364 do
  begin
    if rdoGraph.ItemIndex=0 then
    begin
      x := IncDay(GStartDate, i);
    end
    else
    begin
      x := IncDay(GStartDate, (i* 31));
    end;
    series1.AddXY(x, 15, '', clTeeColor);
    series2.AddXY(x, 5, '', clTeeColor);
    series3.AddXY(x, 7, '', clTeeColor);
    series4.AddXY(x, 12, '', clTeeColor);
  end;
What I am finding so frustrating is that this code worked perfectly with your 2008 release. What is different?

Thanks,

Dave

Dynafact
Newbie
Newbie
Posts: 9
Joined: Fri Nov 19, 2010 12:00 am

Re: TeeChart Pro 2011 bar width too thin

Post by Dynafact » Mon Feb 07, 2011 7:44 pm

Also, as per your question the scroll bar is attached to the graph so that the user can scroll through the dates. It is not attached in the example for simplicity purposes.

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

Re: TeeChart Pro 2011 bar width too thin

Post by Yeray » Tue Feb 08, 2011 5:02 pm

Hi Dave,

In that case you could recalculate manually the width of the bars. Adding the following at the end it looks well:

Code: Select all

  Graph.Draw;
  tmp:=(Graph.Axes.Bottom.IEndPos-Graph.Axes.Bottom.IStartPos) div (Graph.SeriesCount*PointsPerPage);
  series1.CustomBarWidth:=tmp;
  series2.CustomBarWidth:=tmp;
  series4.CustomBarWidth:=tmp;
Does it work as you expected?
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

Dynafact
Newbie
Newbie
Posts: 9
Joined: Fri Nov 19, 2010 12:00 am

Re: TeeChart Pro 2011 bar width too thin

Post by Dynafact » Tue Feb 08, 2011 6:58 pm

That's it!

Thanks,

Dave

Post Reply