Bar3D BarWidthPercent issue with multiple series and bars

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
SteveP
Advanced
Posts: 132
Joined: Sun Sep 07, 2003 4:00 am

Bar3D BarWidthPercent issue with multiple series and bars

Post by SteveP » Mon May 16, 2005 9:28 pm

I am attempting to have several Bar3D series (in 2D view) each with many bars. The X values with each series will all be the same integer value but be different (by a value of 1) from the other series. I would like the series to align next to each other without side margins. The behavior of BarWidthPercent varies depending on whether there is more than one bar per series. BarWidthPercent = 100 does not work correctly.

{ needed to clear series as sometimes points from design-time editor are kept }
series1.Clear;
series2.Clear;
series3.Clear;

series1.SideMargins := false;
series2.SideMargins := false;
series3.SideMargins := false;

series1.AddBar(1, 10, 12);
series2.AddBar(2, 11, 13);
series3.AddBar(3, 9, 15);

series1.BarWidthPercent := 33;
series2.BarWidthPercent := 33;
series3.BarWidthPercent := 33;

{ with only one bar per series,
BarWidthPercent of 100 does not show anything;
BarWidthPercent needs to be (100/number of series) ? }

exit;

series1.AddBar(1, 14, 17);
series1.AddBar(1, 21, 22);
series2.AddBar(2, 15, 21);
series2.AddBar(2, 23, 25);
series3.AddBar(3, 16, 19);
series3.AddBar(3, 22, 25);

{ with more than one bar per series,
if BarWidthPercent is 100 only the last bar
is correct, the others only show their left edge
BarWidthPercent of 99 shows all bars but with gap }

series1.BarWidthPercent := 100;
series2.BarWidthPercent := 100;
series3.BarWidthPercent := 100;

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue May 17, 2005 8:27 am

Hi Steve,

I've been able to reproduce what you report, however when having 1 bar for each series and BarWidth=100 worked fine.

I've included this to our bug list to be fixed for future releases. There's no workaround I can think of.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

SteveP
Advanced
Posts: 132
Joined: Sun Sep 07, 2003 4:00 am

Post by SteveP » Tue May 17, 2005 4:08 pm

In an attempt to get around this, I'm trying to set the Bar3D series CustomBarWidth property to chart1.ChartWidth (when there is just one Bar3D series). For a chart1.ChartWidth of less than around 200 pixels, the bar3d series does occupy the full width of the chart. But at larger chart widths, nothing is shown. It is necessary to subtract 1 from chart1.ChartWidth.

Perhaps this is because chart1.ChartWidth which is (chart1.ChartRect.Right - chart1.ChartRect.Left ) represents the outer bounding region one pixel outside of the actual drawing region. Drawing a line vertically along ChartRect.Reft and ChartRect.Right shows that Left lies on top of the left axis line and Right lies on the first pixel outside of the inner region. Thus their difference must have 1 subtracted to obtain the number of pixels of the actual plotted region. If ChartRect.Reft = 3 and ChartRect.Right = 9, then there are not (9-3) pixels between them but only 5 according to what I observe.

chart1.Canvas.Line(chart1.ChartRect.Left, 0, chart1.ChartRect.Left, 90);
chart1.Canvas.Line(chart1.ChartRect.right, 0, chart1.ChartRect.right, 90);

If chart1.LeftAxis.Axis.Visible is set false, then the chart1.ChartRect.Left moves left two pixels and chart1.ChartWidth increases by 2 pixels. But after setting CustomBarWidth to the now larger chart1.ChartWidth, the Bar3D left edge does not fill in where the left axis had been. There is a vertical line showing the chart back wall color where the Bar3D pixels are not being shown.

This is all with SideMargins := false;

Post Reply