Strange bug in THorizBarSeries

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
johnnix
Advanced
Posts: 192
Joined: Tue Jul 10, 2007 12:00 am

Strange bug in THorizBarSeries

Post by johnnix » Fri Aug 21, 2009 7:01 am

Hello,

I am facing a strange problem with THorizBarSeries but I am not able to reproduce this error outside my app, so I will try to explain it here. I am using the latest TChart 8.05 with Turbo Delphi Pro and WinXP.

I have a chart with a THorizBarSeries and by default the left axis is set to Inverted. I need the bars to be continues (touch each other) so I set the Bar Width to 100% and no border visible. I load my data to the plot, zoom in it looks ok, like plot1.gif. Now, I have an option for the user to invert the axis and load the data again, so the chart looks like plot2.gif. After a lot of tests I realized that there is something wrong with the border. If I enable the border to be visible then as you can see in the case where by left axis is not inverted (plot4.gif) the border is drawn over the bar and this is why the gaps appear although it is not clear to me why the gap appears when border is not visible.

Can anyone please share some thoughts and where to look inside the TChart code in order to resolve this?

Kindest regards

http://img341.imageshack.us/img341/8416/plot1.gif
http://img518.imageshack.us/img518/9693/plot2.gif
http://img33.imageshack.us/img33/5995/plot3.gif
http://img341.imageshack.us/img341/1476/plot4.gif

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

Re: Strange bug in THorizBarSeries

Post by Yeray » Fri Aug 21, 2009 12:03 pm

Hi johnnix,

I'm not able to reproduce this here. Could you please see if the attached project reproduces the issue for you? If not, could you please try to modify it until the problem will be reproducible?
Attachments
test.zip
(1.51 KiB) Downloaded 554 times
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

johnnix
Advanced
Posts: 192
Joined: Tue Jul 10, 2007 12:00 am

Re: Strange bug in THorizBarSeries

Post by johnnix » Mon Aug 24, 2009 7:18 am

Hello Yeray,

Unfortunately there is no way to reproduce the error outside my app. Can you please advice me where to look into the code? I first need to resolve why the border is drawn before the bars, so I could need some help where to look into the code.

Regards

johnnix
Advanced
Posts: 192
Joined: Tue Jul 10, 2007 12:00 am

Re: Strange bug in THorizBarSeries

Post by johnnix » Mon Aug 24, 2009 8:55 am

Hello Yeray,

Made some progress and just found where the error is. In Series.pas line 5029 the code is:

Code: Select all

Bottom:=CalcYPos(Pred(ValueIndex))
If I change it to

Code: Select all

Bottom:=CalcYPos(Succ(ValueIndex))
then in my case it works ok but in a clean project like the one you send me the error now appears!!!! What could be wrong so that the statement Pred(ValueIndex) does not work in my chart when axis is Inverted?

Regards

johnnix
Advanced
Posts: 192
Joined: Tue Jul 10, 2007 12:00 am

Re: Strange bug in THorizBarSeries

Post by johnnix » Mon Aug 24, 2009 12:31 pm

Hello Yeray,

Please try the following code in the example you send me:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.View3D := false;
  Chart1.Color := clwhite;
  Chart1.Legend.Visible := false;
  Chart1.Title.Visible := false;

  Series1 := THorizBarSeries.Create(self);
  Chart1.AddSeries(Series1);

  series1.AddXY(6,24);
  series1.AddXY(8,23);
  series1.AddXY(12,22);
  series1.AddXY(10,21);
  series1.AddXY(4,20);
  series1.AddXY(9,19);
  series1.AddXY(12,18);
  series1.AddXY(2,17);
  series1.AddXY(11,16);
  series1.AddXY(5,15);
  series1.AddXY(3,14);


  Series1.BarWidthPercent := 100;
  Series1.Pen.Visible := false;
  Series1.Marks.Visible := false;
  Series1.ColorEachPoint := true;

  Chart1.Axes.Bottom.SetMinMax(0,24);
end;
You will notice the gaps between the bars... I am guessing it has something to do with the Y values I add (from larger to smallest). Please let me know if there is a quick work around for that. Please also notice that the gaps disappear when the 3D is on and also some value is not displayed correctly.

Regards

johnnix
Advanced
Posts: 192
Joined: Tue Jul 10, 2007 12:00 am

Re: Strange bug in THorizBarSeries

Post by johnnix » Tue Aug 25, 2009 12:36 pm

Hello,

Ok, here is an interesting point I just found. After you add my code to import series data you will notice that the gaps appear. Now, edit the chart, change the series from HorizBar to something else e.g. Line and then change it back to HorizSeries. Alter the BarWidth to 100% and here it is, works ok!!!!!

Regards

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

Re: Strange bug in THorizBarSeries

Post by Yeray » Tue Aug 25, 2009 1:56 pm

Hi johnnix,

Excuse the delay.

I've seen that there seems to be a problem in the order of the points because with your code that adds the points with AddXY method so I'll add this to the wish list to be fixed in further releases. In the meanwhile you have two workarounds. You can force Teechart to reorder the YValues:

Code: Select all

Series1.YValues.Sort;
Or you could be carefull and add the values in the inverse way than the one you did:

Code: Select all

  series1.AddXY(3,14);
  series1.AddXY(5,15);
  series1.AddXY(11,16);
  series1.AddXY(2,17);
  series1.AddXY(12,18);
  series1.AddXY(9,19);
  series1.AddXY(4,20);
  series1.AddXY(10,21);
  series1.AddXY(12,22);
  series1.AddXY(8,23);
  series1.AddXY(6,24);
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

johnnix
Advanced
Posts: 192
Joined: Tue Jul 10, 2007 12:00 am

Re: Strange bug in THorizBarSeries

Post by johnnix » Wed Aug 26, 2009 6:17 am

Hello Yeray,

The Sort method do the trick just fine!!! Thank you very much for your support

Regards

Post Reply