Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

Author Topic: Strange behavior of TChart  (Read 577 times)

was.ok

• Newbie
• Posts: 3
Strange behavior of TChart
« on: June 01, 2020, 10:44:11 pm »
Hi!

I was trying to create a Chart with multiple panes (something like this one https://wiki.freepascal.org/TAChart_Tutorial:_Multiple_Panes_in_one_Chart) and discovered some strange behavior of TChart:

- when axis X is aligned at the bottom and Y-axis (3 items) on the left - all works fine (img_1.png);
- when axis X is aligned on the left and Y-axis at the bottom - the first line on the Chart is not drawing at the point [x = 1, y = 1] (img_2.png, img_3.png).

Is this a bug or just my mistake?

The code is simple:

procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
begin
for i := 1 to 1000 do
begin
end;
end;

FPC: 3.0.4
Lazarus: 2.0.8

wp

• Hero Member
• Posts: 7544
Re: Strange behavior of TChart
« Reply #1 on: June 01, 2020, 11:56:16 pm »

It seems to be a bug. I found this:
• Open file TACustomSeries.pas in folder components/tachart of your Lazarus installation (make a backup copy of this file before changing anything)
• Find the implementation of procedure TBasicPointSeries.FindExtentInterval
• In the center of this procedure there is an "if IsRotated then"
• In the next line ("axisExtent := DoubleInterval(GraphToAxisY(a.Y), GraphToAxisY(b.Y))" replace the GraphToAxisY by GraphToAxisX, i.e. the entire "if" block must be
Code: Pascal  [Select][+][-]
1.       if IsRotated then
2.         axisExtent := DoubleInterval(GraphToAxisX(a.Y), GraphToAxisX(b.Y))   // Replace GraphToAxisY by GraphToAxisX
3.       else
4.         axisExtent := DoubleInterval(GraphToAxisX(a.X), GraphToAxisX(b.X));
• Recompile the TAChart package: Go to "Package" > "Open package file .lpk" > Select and load "tachartlazaruspkg.lpk" (in components/tachart). In the package editor, click "Compile".
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

was.ok

• Newbie
• Posts: 3
Re: Strange behavior of TChart
« Reply #2 on: June 02, 2020, 07:48:25 am »
Sorry about that. How to delete the first one? (https://forum.lazarus.freepascal.org/index.php/topic,50047.0.html)
(It says "You cannot delete your own topics in this board.")

Quote

It seems to be a bug. I found this:
• Open file TACustomSeries.pas in folder components/tachart of your Lazarus installation (make a backup copy of this file before changing anything)
• Find the implementation of procedure TBasicPointSeries.FindExtentInterval
• In the center of this procedure there is an "if IsRotated then"
• In the next line ("axisExtent := DoubleInterval(GraphToAxisY(a.Y), GraphToAxisY(b.Y))" replace the GraphToAxisY by GraphToAxisX, i.e. the entire "if" block must be
Code: Pascal  [Select][+][-]
1.       if IsRotated then
2.         axisExtent := DoubleInterval(GraphToAxisX(a.Y), GraphToAxisX(b.Y))   // Replace GraphToAxisY by GraphToAxisX
3.       else
4.         axisExtent := DoubleInterval(GraphToAxisX(a.X), GraphToAxisX(b.X));
• Recompile the TAChart package: Go to "Package" > "Open package file .lpk" > Select and load "tachartlazaruspkg.lpk" (in components/tachart). In the package editor, click "Compile".

It works!!!

Thank you, wp!

wp

• Hero Member
• Posts: 7544
Re: Strange behavior of TChart
« Reply #3 on: June 02, 2020, 09:25:27 am »
Sorry about that. How to delete the first one?
Maybe click on the "Report to moderator" button at the bottom of the first post. There will be a single-line edit box in which you can drop a note why you want it to be deleted.
« Last Edit: June 03, 2020, 11:18:44 am by wp »
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

was.ok

• Newbie
• Posts: 3
Re: Strange behavior of TChart
« Reply #4 on: June 02, 2020, 09:43:58 am »
May click on the "Report to moderator" button at the bottom of the first post. There will be a single-line edit box in which you can drop a note why you want it to be deleted.

Thanks!

Done.

wp

• Hero Member
• Posts: 7544
Re: Strange behavior of TChart
« Reply #5 on: June 03, 2020, 11:19:47 am »
The bug fix has been applied the Lazarus trunk and will be backported to Lazarus fixes.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...