SVG parser reference
Classes
- Selection
Lightweight Selection wrapper that mimics d3-selection's chainable API. Provides basic DOM manipulation methods for working with SVG elements.
Functions
- select(selector) ⇒
Selection Create a Selection from a DOM element or selector string.
- getPointerPosition(event, svgElement) ⇒
Array.<number> Get mouse position relative to an SVG element.
- findBars(svg, axes_class) ⇒
Selection Find bar elements (
patchgroups with clipping) inside a given axes.- findPoints(svg, axes_class, tooltip_groups) ⇒
Selection Find scatter plot points inside a given axes. Handles both
<use>and<path>fallback cases, and assignsdata-groupattributes based on tooltip groups.- findLines(svg, axes_class) ⇒
Selection Find line elements (
line2dpaths) inside a given axes, excluding axis grid lines.- findAreas(svg, axes_class) ⇒
Selection Find filled area elements (
FillBetweenPolyCollectionpaths) inside a given axes.- nearestElementFromMouse(mouseX, mouseY, elements) ⇒
Element|null Compute the nearest element to the mouse cursor from a set of elements. Uses bounding box centers for distance. This function is used when the
hover_nearestargument is true.- setHoverEffect(plot_element, axes_class, tooltip_labels, tooltip_groups, show_tooltip, hover_nearest)
Attach hover interaction and tooltip display to plot elements. Can highlight nearest element (if enabled) or hovered element directly.
Selection
Lightweight Selection wrapper that mimics d3-selection's chainable API. Provides basic DOM manipulation methods for working with SVG elements.
select(selector) ⇒ Selection
Create a Selection from a DOM element or selector string.
Kind: global function
Returns: Selection - New Selection instance
| Param | Type | Description |
|---|---|---|
| selector | string | Element |
CSS selector string or DOM element |
getPointerPosition(event, svgElement) ⇒ Array.<number>
Get mouse position relative to an SVG element.
Kind: global function
Returns: Array.<number> - [x, y] coordinates relative to the SVG
| Param | Type | Description |
|---|---|---|
| event | MouseEvent |
The mouse event |
| svgElement | Element | Selection |
The SVG element or Selection |
findBars(svg, axes_class) ⇒ Selection
Find bar elements (patch groups with clipping) inside a given axes.
Kind: global function
Returns: Selection - Selection of bar elements.
| Param | Type | Description |
|---|---|---|
| svg | Selection |
Selection of the SVG element. |
| axes_class | string |
ID of the axes group (e.g. "axes_1"). |
findPoints(svg, axes_class, tooltip_groups) ⇒ Selection
Find scatter plot points inside a given axes.
Handles both <use> and <path> fallback cases,
and assigns data-group attributes based on tooltip groups.
Kind: global function
Returns: Selection - Selection of point elements.
| Param | Type | Description |
|---|---|---|
| svg | Selection |
Selection of the SVG element. |
| axes_class | string |
ID of the axes group (e.g. "axes_1"). |
| tooltip_groups | Array.<string> |
Group identifiers for tooltips, parallel to points. |
findLines(svg, axes_class) ⇒ Selection
Find line elements (line2d paths) inside a given axes,
excluding axis grid lines.
Kind: global function
Returns: Selection - Selection of line elements.
| Param | Type | Description |
|---|---|---|
| svg | Selection |
Selection of the SVG element. |
| axes_class | string |
ID of the axes group. |
findAreas(svg, axes_class) ⇒ Selection
Find filled area elements (FillBetweenPolyCollection paths) inside a given axes.
Kind: global function
Returns: Selection - Selection of area elements.
| Param | Type | Description |
|---|---|---|
| svg | Selection |
Selection of the SVG element. |
| axes_class | string |
ID of the axes group. |
nearestElementFromMouse(mouseX, mouseY, elements) ⇒ Element | null
Compute the nearest element to the mouse cursor from a set of elements.
Uses bounding box centers for distance.
This function is used when the hover_nearest argument is true.
Kind: global function
Returns: Element | null - The nearest DOM element or null.
| Param | Type | Description |
|---|---|---|
| mouseX | number |
X coordinate of the mouse relative to SVG. |
| mouseY | number |
Y coordinate of the mouse relative to SVG. |
| elements | Selection |
Selection of candidate elements. |
setHoverEffect(plot_element, axes_class, tooltip_labels, tooltip_groups, show_tooltip, hover_nearest)
Attach hover interaction and tooltip display to plot elements. Can highlight nearest element (if enabled) or hovered element directly.
Kind: global function
| Param | Type | Description |
|---|---|---|
| plot_element | Selection |
Selection of plot elements (points, lines, etc.). |
| axes_class | string |
ID of the axes group. |
| tooltip_labels | Array.<string> |
Tooltip labels for each element. |
| tooltip_groups | Array.<string> |
Group identifiers for each element. |
| show_tooltip | "block" | "none" |
Whether to display tooltips. |
| hover_nearest | boolean |
If true, highlight nearest element instead of hovered one. |