Bars half off chart & bar widths

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
MVBobj
Newbie
Newbie
Posts: 34
Joined: Fri Jul 17, 2015 12:00 am
Contact:

Bars half off chart & bar widths

Post by MVBobj » Wed Aug 26, 2015 11:25 pm

Hi,

I have 2 questions:

When I look at a chart in the Delphi development environment, the chart works as it should but when I create even a very simple project - it doesn't. The first and last bars appearing on the chart are both half off the chart - why is this? Am I doing something wrong here?

Also the bar widths - in the development environment, the sample bars expand and contract as they should when I adjust the Series | Format | % Bar Offset - but when I run the program, the behavior is very different.

I enclose a sample project illustrating these questions.

Thank you.
Attachments
TeeChartBarTest.zip
(3.55 KiB) Downloaded 504 times

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

Re: Bars half off chart & bar widths

Post by Yeray » Thu Aug 27, 2015 3:08 pm

Hello,
MVBobj wrote:When I look at a chart in the Delphi development environment, the chart works as it should but when I create even a very simple project - it doesn't. The first and last bars appearing on the chart are both half off the chart - why is this? Am I doing something wrong here?
When you call SetMinMax you are forcing the axis minimum and maximum, but this doesn't take in consideration if the series being drawn need extra space to fit.
Try forcing a chart repaint and assigning a MinimumOffset and a MaximumOffset relative to the series' BarWidth:

Code: Select all

  DBChart1.BottomAxis.SetMinMax(0, StrToInt(Edit1.Text));

  DBChart1.Draw;
  DBChart1.BottomAxis.MinimumOffset:=Series1.BarWidth div 2;
  DBChart1.BottomAxis.MaximumOffset:=Series1.BarWidth div 2;
MVBobj wrote:Also the bar widths - in the development environment, the sample bars expand and contract as they should when I adjust the Series | Format | % Bar Offset - but when I run the program, the behavior is very different.
Try setting AutoBarSize to true:

Code: Select all

  Series1.AutoBarSize:=true;
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