ドラッグの簡単な例。
![enter image description here](https://i.stack.imgur.com/JL2qy.png)
私は、自由にラインシリーズをマウスの右ボタンを使用してFalseにAllowPanningチャートを設定して、ポイントスタイルはサイズ= 4の円で、単純なリストトラバーサルで触れたポイントを求めて(ないことを確認Stdがカーソルに最も近い点を取得するメソッドを持っているかどうか)。
は、おそらくあなたは、あなたが私の編集した質問で助けることができる
DragIdx: integer = -1;
procedure TForm1.Button18Click(Sender: TObject);
var
i: Integer;
begin
for i := 0 to 19 do
Series1.AddXY(i, Sin(i/2));
end;
procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
i, xx, yy: Integer;
begin
if Button = mbRight then begin
DragIdx := -1;
for i := 0 to Series1.Count - 1 do begin
xx := Series1.CalcXPos(i);
yy := Series1.CalcYPos(i);
if Sqr(xx - x) + Sqr(yy - y) <= 5 * 5 then begin
DragIdx := i;
Break;
end;
end;
Memo1.Lines.Add(Format('grab %d', [DragIdx]));
end;
end;
procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
xx, yy: Double;
begin
if (ssRight in Shift) and (DragIdx >=0) then begin
Series1.GetCursorValues(xx, yy);
Memo1.Lines.Add(Format('change %d to %f %f', [DragIdx, xx, yy]));
Series1.XValues[DragIdx] := xx;
Series1.YValues[DragIdx] := yy;
Chart1.Repaint;
end;
end;
出典
2017-11-03 03:15:00
MBo
@KenWhite(例えば、隣人値などによって水平シフトを制限する)いくつかの制限が必要でしょうか? – wBB
他の投稿を調べた後、質問を再開しました。あなたは正しい。そのバージョンはかなり異なっています。チュートリアルを見て、https://www.steema.com/downloads/vclからダウンロードできるガイドをお探しですか? –
はい、C#のようなDelphiのコンポーネントの属性は見つかりません。 – wBB