-
|
Is it possible to make any plottable draggable? It would be nice to drag and drop arrows, text, pictures, and lines other than horizontal, vertical and spans by passing or setting isDraggable to true. Can a user define a plottable to inherit from IDraggable, so that maybe the center point of the plottable can be dragged to another position or something along those lines? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Hi @anose001, Most plottables do not interact with the mouse for performance reasons1. However, users can create custom plottables (that implement To take an existing plot type and add mouse interactivity you could do something like this (but populate the not-implemented sections). You can use draggable axis line plottables as a reference (AxisLine.cs) public class DraggableArrow : ScottPlot.Plottable.ArrowCoordinated, ScottPlot.Plottable.IDraggable
{
public DraggableArrow(double xBase, double yBase, double xTip, double yTip) : base(xBase, yBase, xTip, yTip) { }
public bool DragEnabled { get; set; } = true;
public event EventHandler? Dragged;
public ScottPlot.Cursor DragCursor { get; }
public bool IsUnderMouse(double coordinateX, double coordinateY, double snapX, double snapY) => throw new NotImplementedException();
public void DragTo(double coordinateX, double coordinateY, bool fixedSize) => throw new NotImplementedException();
}Then instantiate it and add it to your plot like this: ScottPlot.Plot plt = new(400, 300);
DraggableArrow myArrow = new(5, 5, 3, 3);
plt.Add(myArrow);Footnotes
|
Beta Was this translation helpful? Give feedback.
Hi @anose001,
Most plottables do not interact with the mouse for performance reasons1. However, users can create custom plottables (that implement
IPlottableand, if they also implementIDraggable, they can interact with the mouse.To take an existing plot type and add mouse interactivity you could do something like this (but populate the not-implemented sections). You can use draggable axis line plottables as a reference (AxisLine.cs)