Page 1 of 1

Bars half off chart & bar widths

Posted: Wed Aug 26, 2015 11:25 pm
by 16475083
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.

Re: Bars half off chart & bar widths

Posted: Thu Aug 27, 2015 3:08 pm
by yeray
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;