Hi
I use the chart with the tpolarseries object.
One serie is set to initialialize the tchart and make it visible.
I'd like to use mouse to click on the chart (not necessary on a serie ), trap the screen x,y coordinates and transform them to an angle and radius. I may be able to create a new serie with one point on the clicked position of the chart.
Is teechart abled to do this ?
may i have a sample ?
Creating series useing Mouse
Hi.
PS : I'll also add this to TCircledSeries as public method so that all circles series can use this method in the future.
You'll have to manually calculate current screen position radius and angle. This can be done by transforming values from screen coordinates to real axis balues. I think the example is good for circled and also for non circled (x radius <> y radius) case:I'd like to use mouse to click on the chart (not necessary on a serie ), trap the screen x,y coordinates and transform them to an angle and radius.
Code: Select all
function PointToRadius(ASeries : TCustomPolarSeries; X,Y: Integer): double;
var dx,dy: double;
begin
With ASeries.GetVertAxis, ASeries do
begin
if (Maximum-Minimum) <> 0.0 then
begin
dx := x-CircleXCenter;
dx := dx*(Maximum-Minimum)/XRadius;
dy := y-CircleYCenter;
dy := dy*(Maximum-Minimum)/YRadius;
Result := Sqrt(dx*dx+dy*dy)+Minimum;
end
else Result := 0.0;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.FillSampleValues(10);
end;
procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var a,r: double;
begin
a := 180.0*Series1.PointToAngle(X,Y)/3.1416;
r := PointToRadius(Series1,X,Y);
Chart1.Title.Text.Clear;
Chart1.Title.Text.Add('radius='+FormatFloat('0.00',r)
+' angle='+FormatFloat('0.00',a));
end;
Marjan Slatinek,
http://www.steema.com
http://www.steema.com