Skip to content

ChartInteractionController

ClassChartGuruChartGuru
public class ChartInteractionController

Backend-neutral interaction controller shared by every chart host component (ChartGuru.ChartComponent, ChartGuru.ChartGraphic, ChartGuruElement). Consumes chart-space pointer positions (pixels, bottom-left origin) and forwards them to a ChartGuru.ChartProxy, driving the same selection, hover, drag-scroll and wheel-zoom behaviour that previously lived inline in ChartGuru.ChartGraphic.

Hosts translate their native pointer types (uGUI PointerEventData, UI Toolkit PointerDownEvent, etc.) into Vector2 chartPos + phase and call the methods below. The controller stays UI-framework agnostic so the same logic is reused across the three backends.

public bool EnableSelection { get; set; }

Allow the controller to toggle selection on pointer tap.

Returns

System.Boolean — No return description is available.

public bool EnableHoverHighlight { get; set; }

Allow the controller to update ChartGuru.Chart.HoveredIndex during pointer move.

Returns

System.Boolean — No return description is available.

public bool EnableDragSelection { get; set; }

Allow drag gestures inside the plot area to run a rubber-band selection.

Returns

System.Boolean — No return description is available.

public bool EnableViewportDrag { get; set; }

Allow drag gestures to scroll the viewport.

Returns

System.Boolean — No return description is available.

public bool EnableViewportZoom { get; set; }

Allow the scroll wheel to zoom the viewport.

Returns

System.Boolean — No return description is available.

public float ViewportZoomSensitivity { get; set; }

Multiplier applied to scroll delta when computing zoom factor.

Returns

System.Single — No return description is available.

public event Action<int, DataPoint> DataPointClicked

Raised when the user clicks on a mark and selection is enabled.

Returns

System.Action{System.Int32,ChartGuru.DataPoint} — No return description is available.

public event Action<int, DataPoint> DataPointHovered

Raised when the user hovers a mark and hover-highlight is enabled.

Returns

System.Action{System.Int32,ChartGuru.DataPoint} — No return description is available.

public event Action<int> HoverChanged

Raised whenever the hovered-index changes. -1 when no hover.

Returns

System.Action{System.Int32} — No return description is available.

public event Action RenderRequested

Raised by the controller when the chart needs to be re-rendered. Hosts should invalidate their surface.

Returns

System.Action — No return description is available.

public void Bind(Chart chart, ChartProxy proxy)

Associates the controller with a chart + proxy pair. Passing null detaches.

Parameters

Name Type Description
chart ChartGuru.Chart
proxy ChartGuru.ChartProxy
public void Tap(Vector2 chartPos)

Handle a click / tap at the given chart-space position. Toggles selection at the mark containing the pointer when ChartGuru.ChartInteractionController.EnableSelection is true.

Parameters

Name Type Description
chartPos UnityEngine.Vector2
public void HoverMove(Vector2 chartPos)

Handle hover-move at the given chart-space position. Updates ChartGuru.Chart.HoveredIndex and raises ChartGuru.ChartInteractionController.HoverChanged / ChartGuru.ChartInteractionController.DataPointHovered when the hovered mark changes.

Parameters

Name Type Description
chartPos UnityEngine.Vector2
public void HoverExit()

Clears the hover state, e.g. when the pointer leaves the chart surface.

public void DragBegin(Vector2 chartPos)

Start a drag gesture. Records chartPos as the anchor for subsequent updates.

Parameters

Name Type Description
chartPos UnityEngine.Vector2
public void DragUpdate(Vector2 chartPos)

Update an in-flight drag. Routes to viewport scrolling (when ChartGuru.ChartInteractionController.EnableViewportDrag is enabled and the chart is scrollable) or drag-selection (when ChartGuru.ChartInteractionController.EnableDragSelection is enabled).

Parameters

Name Type Description
chartPos UnityEngine.Vector2
public void DragEnd(Vector2 chartPos)

End a drag gesture.

Parameters

Name Type Description
chartPos UnityEngine.Vector2
public void Wheel(Vector2 chartPos, float scrollDelta)

Handle a scroll-wheel / pinch gesture. Zooms around the cursor by a factor derived from scrollDelta and ChartGuru.ChartInteractionController.ViewportZoomSensitivity.

Parameters

Name Type Description
chartPos UnityEngine.Vector2
scrollDelta System.Single