Recent

Author Topic: TAChart: TNearestPointParams - Debug Errors (UPDATE)  (Read 3632 times)

ChrisP

  • New Member
  • *
  • Posts: 14
Re: TAChart: TNearestPointParams - Debug Errors (UPDATE)
« Reply #15 on: May 29, 2024, 07:35:15 am »
Many thanks for your efforts.
The errors are finally gone! :-)

But do you have an idea to add the functionality that the vertical line shows the tooltips at all intersections when crossing the horizontal lines in the diagram? Somehow that hasn't worked yet. The tooltips are still displayed individually when the mouse pointer touches a diagram line. However, this should happen when touching the vertical line and for all displayed diagram lines.

Is there also a way to customize the diagram so that if different diagram lines are displayed and the values are far apart (e.g. line 1 is in the Y-axis range 0 - 500000 ms and line 2 is in the Y-axis range 0-200 ms) that this is dynamically taken into account and the diagram becomes clearer? So that the Y-axis is divided in the scaling? Otherwise the other displayed diagram lines are “lost” in the view.

Perhaps you have another idea?

And one more point: I know it has nothing to do with TAChart.  But when closing the module, the GRID in the MainMenu module should actually update itself and select the previously selected data set. Instead, the GRID is emptied and no data set is displayed or selected. What is the reason for this? It has worked accordingly in the past.
« Last Edit: May 29, 2024, 09:12:12 am by ChrisP »

wp

  • Hero Member
  • *****
  • Posts: 12072
Re: TAChart: TNearestPointParams - Debug Errors (UPDATE)
« Reply #16 on: May 29, 2024, 05:51:32 pm »
But do you have an idea to add the functionality that the vertical line shows the tooltips at all intersections when crossing the horizontal lines in the diagram? Somehow that hasn't worked yet. The tooltips are still displayed individually when the mouse pointer touches a diagram line. However, this should happen when touching the vertical line and for all displayed diagram lines.
If you'd turn on the data point markers of the LineSeriesSelection  (LineSeriesSelection.ShowPoints := true) you'd see that the horizontal pieces of that series consist of many data points having the same y value. Therefore, the behaviour of the DatapointHintTool and DatapointCrosshairTool is correct, they follow the data points and are displayed for every value along the horizontal segments. If you don't want this you have two options:

/1/ When you add a new value to the series check the y value added at the previous step and skip this value if it has the same y value:
Code: Pascal  [Select][+][-]
  1. procedure TFormMessung.DrawChart(SortTimesSelection, SortTimesQuick, SortTimesShell: array of Integer);
  2. var
  3.   i: Integer;
  4. begin
  5.   LineSeriesSelection.BeginUpdate;
  6.   try
  7.     LineSeriesSelection.Clear;
  8.     for i := 0 to High(SortTimesSelection) do
  9.       if i > 0 and (SortTimesSelection[i] <> SortTimesSelection[i-1]) then
  10.         LineSeriesSelection.AddXY(i, SortTimesSelection[i]);
  11.   finally
  12.     LineseriesSelection.EndUpdate;
  13.   end;
  14.   ...

/2/ When positioning the hint text scan the data values in the vicinity of the currently proposed data point index and find the last value at the same y level:
Code: Pascal  [Select][+][-]
  1. procedure TFormMessung.DataPointCrossHairToolCustomDraw(ATool: TDatapointDrawTool; ADrawer: IChartDrawer);
  2. // BTW, there is a small bug in the following code which occasionally crashes the application - I want you to find it yourself...
  3. var
  4.   series: TLineSeries;
  5.   P: TDoublePoint;
  6.   i: Integer;
  7.   y: Double;
  8. begin
  9.   if ATool.Series is TLineSeries then
  10.   begin
  11.     series := TLineSeries(ATool.Series);
  12.     y := series.YValue[ATool.PointIndex];
  13.     i := ATool.PointIndex;
  14.     while (i < series.Count) and (series.YValue[i] = y) do
  15.       inc(i);
  16.     P := DoublePoint(series.XValue[i], series.YValue[i]);
  17.     ToolTipPosition := Chart.GraphToImage(P);
  18.   end;
  19. end;

Is there also a way to customize the diagram so that if different diagram lines are displayed and the values are far apart (e.g. line 1 is in the Y-axis range 0 - 500000 ms and line 2 is in the Y-axis range 0-200 ms) that this is dynamically taken into account and the diagram becomes clearer? So that the Y-axis is divided in the scaling? Otherwise the other displayed diagram lines are “lost” in the view.
You may want to read https://wiki.lazarus.freepascal.org/TAChart_Tutorial:_Dual_y_axis,_Legend which covers exactly the same situation (just ignore the part on UserdefinedChartsource, add the data points to the series as usual).

But when closing the module, the GRID in the MainMenu module should actually update itself and select the previously selected data set. Instead, the GRID is emptied and no data set is displayed or selected. What is the reason for this? It has worked accordingly in the past.
I don't know. It's your code, find it out: Use the debugger and study what is happening and why.

ChrisP

  • New Member
  • *
  • Posts: 14
Re: TAChart: TNearestPointParams - Debug Errors (UPDATE)
« Reply #17 on: June 03, 2024, 08:33:20 am »
Thank you again!
Quote
/1/ When you add a new value to the series check the y value added at the previous step and skip this value if it has the same y value:

Update2:
I have now got it to run without error. However, the scaling does not work properly. The left Y-axis is scaled in the same way as the right Y-axis. So nothing has changed in the view. In addition, the tooltips still do not work as they should.
« Last Edit: June 09, 2024, 02:44:29 pm by ChrisP »

ChrisP

  • New Member
  • *
  • Posts: 14
Re: TAChart: TNearestPointParams - Debug Errors (UPDATE)
« Reply #18 on: June 06, 2024, 08:27:49 am »
I have made some progress.

Now I only have the following problems:
1. the vertical line (controlled by the mouse cursor) should display a tooltip at all intersection points when it comes into contact with the diagram lines.

2. The course of the diagram lines looks strange. Each diagram should actually show the number of processed (sorted) data over time. Somehow this still looks very “wild”.

Can someone here perhaps help me and take a look at this?

I have attached the corresponding files.
Thanks again for your help!

« Last Edit: June 09, 2024, 02:44:07 pm by ChrisP »

CM630

  • Hero Member
  • *****
  • Posts: 1138
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: TAChart: TNearestPointParams - Debug Errors (UPDATE)
« Reply #19 on: June 06, 2024, 09:45:19 am »
Code: Pascal  [Select][+][-]
  1. formmessung.pas(92,20) Error: Identifier not found "IDataExch"
Google says nothing about that.
Maybe if you have attached the LPI, LPR, etc. files it would compile.
Лазар 3,4 32 bit (sometimes 64 bit); FPC3,2,2

cdbc

  • Hero Member
  • *****
  • Posts: 1250
    • http://www.cdbc.dk
Re: TAChart: TNearestPointParams - Debug Errors (UPDATE)
« Reply #20 on: June 06, 2024, 10:28:46 am »
Hi
@CM630: It's just an elaborate callback interface he uses to communicate between forms...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

wp

  • Hero Member
  • *****
  • Posts: 12072
Re: TAChart: TNearestPointParams - Debug Errors (UPDATE)
« Reply #21 on: June 06, 2024, 04:06:35 pm »
Sorry I can't help you. Please post a full compilable project (incl lpi, lpr), which you have tested to show the issue. Finally, I somehow was able to create a project which I could compile after removal of the IDataExch things. But now the chart does not show any data, and everything is disabled. Probably due the missing IDataExch...

ChrisP

  • New Member
  • *
  • Posts: 14
Re: TAChart: TNearestPointParams - Debug Errors (UPDATE)
« Reply #22 on: June 07, 2024, 07:41:46 am »
Sorry. You are right, of course.
I have packed the program executable (incl. lpi, lpr).
Unfortunately, the size limit of the forum only allows an upload of 500 KB. Therefore again via an external link:

It would be nice if you could help me with these problems again:
1. the vertical line (controlled by the mouse pointer) should display a tooltip at all intersection points when it comes into contact with the diagram lines.

2. the course of the diagram lines looks strange. Each chart should actually show the number of processed (sorted) data over time. Somehow this still looks very “wild”. It should therefore show an ascending line over time for all three sortings. Or am I wrong?

The problems relate only to formmessung.pas and formmessung.lfm, more precisely the chart integrated there.

Many thanks again!
« Last Edit: June 09, 2024, 02:43:56 pm by ChrisP »

wp

  • Hero Member
  • *****
  • Posts: 12072
Re: TAChart: TNearestPointParams - Debug Errors (UPDATE)
« Reply #23 on: June 07, 2024, 10:20:44 pm »
I'm sorry I am not willing to help you. It is a huge progam, which I don't even know how to use. And why did you include the exe in the download? and lots unit folders, all of ccr, although they are not needed at all.

ChrisP

  • New Member
  • *
  • Posts: 14
Re: TAChart: TNearestPointParams - Debug Errors (UPDATE)
« Reply #24 on: June 08, 2024, 07:50:22 am »
@wp No problem. You've already helped me a lot.
I'll try to work it out myself somehow. I'm making progress step by step.

About the download file: I just wanted everything to be together and executable.


CM630

  • Hero Member
  • *****
  • Posts: 1138
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: TAChart: TNearestPointParams - Debug Errors (UPDATE)
« Reply #25 on: June 08, 2024, 11:54:00 pm »
My advice - create a standalone project, containg only the part of code that is related to your question.
For example - one TAChart, some small code to draw whatever to you want, etc.
Then upload all source files (pas, frm, lpi, lpr...). (lps files are not needed, the subfolders generated by the compiler are useless).
Some screenshots might be usefull.
So when s.o. downloads your snippet he/she could get straight to the issue - click the LPI, the project is open.
Also, ultra compression of 7zip might create several times smaller files than pure Zip.
« Last Edit: June 08, 2024, 11:55:49 pm by CM630 »
Лазар 3,4 32 bit (sometimes 64 bit); FPC3,2,2

 

TinyPortal © 2005-2018