TCrossFunction -- can I get the returnvalue of the crosspoint?
Posted: Fri Mar 03, 2023 3:09 pm
series 1 and series2 is crossing .. but how do I get the value of the cross point
Steema Software - Customer Support Forums
https://974310.kinnakethk.tech/
Code: Select all
repeat
if LinesCross(index1,index2,x,y) then
ParentSeries.AddXY(x,y);
TCrossPointsFunction
to contains the crossing points.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;