TCrossFunction -- can I get the returnvalue of the crosspoint?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
senbengtma
Newbie
Newbie
Posts: 15
Joined: Tue Nov 09, 2021 12:00 am

TCrossFunction -- can I get the returnvalue of the crosspoint?

Post by senbengtma » Fri Mar 03, 2023 3:09 pm

series 1 and series2 is crossing .. but how do I get the value of the cross point

mathsbertil
Newbie
Newbie
Posts: 14
Joined: Mon Feb 27, 2023 12:00 am

Re: TCrossFunction -- can I get the returnvalue of the crosspoint?

Post by mathsbertil » Fri Mar 03, 2023 4:52 pm

Do i understand correctly that the first point in the parent series is the first cross point?

Code: Select all

repeat
        if LinesCross(index1,index2,x,y) then
           ParentSeries.AddXY(x,y);

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

Re: TCrossFunction -- can I get the returnvalue of the crosspoint?

Post by Yeray » Mon Mar 06, 2023 10:57 am

Hello,

Yes, the series you assign the TCrossPointsFunction to contains the crossing points.
Ie:
Project1_2023-03-06_12-00-21.png
Project1_2023-03-06_12-00-21.png (27.65 KiB) Viewed 24681 times

Code: Select all

uses Vcl.StdCtrls, VCLTee.TeeGDIPlus, VCLTee.Chart, VCLTee.Series, VCLTee.StatChar;

var Chart1: TChart;
    line1, line2: TLineSeries;
    crossFunction: TCrossPointsFunction;
    crossPoints: TPointSeries;
    Memo1: TMemo;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1:=TChart.Create(Self);
  Chart1.Parent:=Self;
  Chart1.Align:=alClient;
  Chart1.View3D:=False;
  Chart1.Legend.Hide;

  Memo1:=TMemo.Create(Self);
  Memo1.Parent:=Self;
  Memo1.Align:=alRight;

  line1:=TLineSeries(Chart1.AddSeries(TLineSeries));
  line2:=TLineSeries(Chart1.AddSeries(TLineSeries));
  line1.FillSampleValues;
  line2.FillSampleValues;

  crossFunction:=TCrossPointsFunction.Create(Self);
  crossPoints:=TPointSeries(Chart1.AddSeries(TPointSeries));
  crossPoints.Pointer.Size:=2;
  crossPoints.FunctionType:=crossFunction;
  crossPoints.DataSources.Add(line1);
  crossPoints.DataSources.Add(line2);

  Memo1.Lines.Add('Crossing Points:');
  with crossPoints do
    for i:=0 to Count-1 do
      Memo1.Lines.Add('X: '+FormatFloat(ValueFormat, XValues[i])+', Y: '+FormatFloat(ValueFormat, YValues[i]));
end;
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

senbengtma
Newbie
Newbie
Posts: 15
Joined: Tue Nov 09, 2021 12:00 am

Re: TCrossFunction -- can I get the returnvalue of the crosspoint?

Post by senbengtma » Tue Mar 07, 2023 12:06 pm

thanks ..clear! but..

where exactly is the trigger for the final painting of the chart and lines.

I try to debug step by step in Tee9New.. but get lost.

is it here?

------ from Base Form---------------

ncGDIPlus : if not (Chart1.Canvas is TGLCanvas) then // <-- For demos with default OpenGL Canvas, do not change it !
if not (Chart1.Canvas is TGDIPlusCanvas) then // <-- Do not assign a GDI+ canvas if it already is !
Chart1.Canvas:=TGDIPlusCanvas.Create;
{$ENDIF}
else
Chart1.Canvas:=TTeeCanvas3D.Create;

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

Re: TCrossFunction -- can I get the returnvalue of the crosspoint?

Post by Yeray » Tue Mar 07, 2023 2:30 pm

Hello,

I'm not sure what are you trying to achieve.
In the example I posted above, the calculation of the crossing points starts as soon as the second series is added to the crossPoints DataSources.
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

Post Reply