plotjs 0.0.6__tar.gz → 0.0.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- plotjs-0.0.8/.github/workflows/tests-browser.yaml +42 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/.github/workflows/tests-python.yaml +4 -2
- plotjs-0.0.6/AGENTS.md → plotjs-0.0.8/AGENT.md +18 -16
- {plotjs-0.0.6 → plotjs-0.0.8}/LICENSE +1 -1
- {plotjs-0.0.6/plotjs.egg-info → plotjs-0.0.8}/PKG-INFO +1 -1
- plotjs-0.0.8/docs/developers/svg-parser-reference.md +164 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/iframes/CSS-2.html +258 -65
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/iframes/CSS.html +258 -65
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/iframes/area-natural-disasters.html +258 -65
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/iframes/bug.html +258 -65
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/iframes/javascript.html +258 -65
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/iframes/javascript2.html +258 -65
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/iframes/quickstart.html +258 -65
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/iframes/quickstart10.html +258 -65
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/iframes/quickstart11.html +258 -65
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/iframes/quickstart2.html +258 -65
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/iframes/quickstart3.html +258 -65
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/iframes/quickstart4.html +258 -65
- plotjs-0.0.8/docs/iframes/quickstart5.html +1744 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/iframes/quickstart6.html +258 -65
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/iframes/quickstart7.html +258 -65
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/iframes/quickstart8.html +258 -65
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/iframes/quickstart9.html +258 -65
- plotjs-0.0.8/docs/iframes/random-walk-1.html +39589 -0
- plotjs-0.0.8/docs/reference/plotjs.md +1 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/justfile +9 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/mkdocs.yaml +19 -1
- {plotjs-0.0.6 → plotjs-0.0.8}/package.json +0 -1
- plotjs-0.0.8/plotjs/__init__.py +4 -0
- plotjs-0.0.6/plotjs/main.py → plotjs-0.0.8/plotjs/plotjs.py +84 -3
- {plotjs-0.0.6 → plotjs-0.0.8}/plotjs/static/plotparser.js +155 -24
- plotjs-0.0.8/plotjs/static/template.html +167 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/plotjs/utils.py +12 -1
- {plotjs-0.0.6 → plotjs-0.0.8/plotjs.egg-info}/PKG-INFO +1 -1
- {plotjs-0.0.6 → plotjs-0.0.8}/plotjs.egg-info/SOURCES.txt +10 -2
- {plotjs-0.0.6 → plotjs-0.0.8}/pyproject.toml +2 -1
- plotjs-0.0.8/pytest.ini +7 -0
- plotjs-0.0.8/tests/test-browser/conftest.py +58 -0
- plotjs-0.0.8/tests/test-browser/test_interactions.py +429 -0
- plotjs-0.0.8/tests/test-browser/test_rendering.py +163 -0
- plotjs-0.0.8/tests/test-javascript/EdgeCases.test.js +394 -0
- plotjs-0.0.8/tests/test-javascript/ParserSelectors.test.js +430 -0
- plotjs-0.0.8/tests/test-javascript/ParserSetHover.test.js +576 -0
- plotjs-0.0.8/tests/test-javascript/Selection.test.js +219 -0
- plotjs-0.0.8/tests/test-python/__init__.py +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/tests/test-python/test_main.py +1 -1
- plotjs-0.0.8/tests/test-python/test_plotjs.py +358 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/uv.lock +94 -1
- plotjs-0.0.6/docs/developers/svg-parser-reference.md +0 -123
- plotjs-0.0.6/docs/iframes/quickstart5.html +0 -1595
- plotjs-0.0.6/docs/iframes/random-walk-1.html +0 -39128
- plotjs-0.0.6/docs/reference/plotjs.md +0 -1
- plotjs-0.0.6/plotjs/__init__.py +0 -6
- plotjs-0.0.6/plotjs/static/template.html +0 -103
- plotjs-0.0.6/tests/test-javascript/ParserSelectors.test.js +0 -51
- plotjs-0.0.6/tests/test-javascript/ParserSetHover.test.js +0 -42
- plotjs-0.0.6/tests/test-python/test_plotjs.py +0 -145
- {plotjs-0.0.6 → plotjs-0.0.8}/.coverage +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/.gitattributes +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/.github/workflows/doc.yaml +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/.github/workflows/lint.yaml +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/.github/workflows/pypi.yaml +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/.github/workflows/tests-js.yaml +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/.github/workflows/type.yaml +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/.gitignore +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/.pre-commit-config.yaml +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/README.md +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/bun.lock +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/coverage-badge.svg +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/developers/contributing.md +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/developers/overview.md +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/developers/parsing-matplotlib-svg.md +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/gallery/index.md +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/gallery/index.qmd +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/guides/advanced/advanced.py +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/guides/advanced/index.md +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/guides/css/CSS.py +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/guides/css/index.md +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/guides/embed-graphs/index.md +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/guides/javascript/index.md +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/guides/javascript/javascript.py +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/guides/troubleshooting/index.md +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/img/how-it-works-1.png +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/img/how-it-works-2.png +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/img/overview.png +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/index.md +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/index.qmd +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/index_files/figure-commonmark/cell-3-output-1.png +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/reference/css.md +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/reference/datasets.md +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/reference/javascript.md +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/static/style.css +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/docs/stylesheets/style.css +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/overrides/partials/footer.html +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/plotjs/css.py +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/plotjs/data/__init__.py +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/plotjs/data/datasets.py +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/plotjs/data/iris.csv +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/plotjs/data/mtcars.csv +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/plotjs/data/titanic.csv +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/plotjs/javascript.py +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/plotjs/static/default.css +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/plotjs.egg-info/dependency_links.txt +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/plotjs.egg-info/requires.txt +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/plotjs.egg-info/top_level.txt +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/setup.cfg +0 -0
- {plotjs-0.0.6/tests/test-python → plotjs-0.0.8/tests/test-browser}/__init__.py +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/tests/test-python/static/script.js +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/tests/test-python/static/script2.js +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/tests/test-python/static/style-invalid.css +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/tests/test-python/static/style.css +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/tests/test-python/test_css.py +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/tests/test-python/test_data.py +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/tests/test-python/test_js.py +0 -0
- {plotjs-0.0.6 → plotjs-0.0.8}/tests/test-python/test_other_utils.py +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
name: Tests Browser
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [main]
|
|
6
|
+
push:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
browser-tests:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.10", "3.13"]
|
|
15
|
+
env:
|
|
16
|
+
UV_PYTHON: ${{ matrix.python-version }}
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Install uv
|
|
22
|
+
uses: astral-sh/setup-uv@v5
|
|
23
|
+
with:
|
|
24
|
+
enable-cache: true
|
|
25
|
+
|
|
26
|
+
- name: Install the project
|
|
27
|
+
run: uv sync --all-groups
|
|
28
|
+
|
|
29
|
+
- name: Install Playwright browsers
|
|
30
|
+
run: uv run playwright install --with-deps chromium
|
|
31
|
+
|
|
32
|
+
- name: Run browser tests
|
|
33
|
+
run: uv run pytest tests/test-browser/ -v
|
|
34
|
+
|
|
35
|
+
- name: Upload test artifacts on failure
|
|
36
|
+
if: failure()
|
|
37
|
+
uses: actions/upload-artifact@v4
|
|
38
|
+
with:
|
|
39
|
+
name: browser-test-artifacts-${{ matrix.python-version }}
|
|
40
|
+
path: |
|
|
41
|
+
/tmp/pytest-of-*/
|
|
42
|
+
retention-days: 7
|
|
@@ -9,20 +9,26 @@ PlotJS is a Python package that transforms static matplotlib charts into interac
|
|
|
9
9
|
## Quick Architecture
|
|
10
10
|
|
|
11
11
|
```
|
|
12
|
-
Matplotlib Figure → SVG Export (Python) → HTML Template (Jinja2) → Interactive Browser
|
|
12
|
+
Matplotlib Figure → SVG Export (Python) → HTML Template (Jinja2) → Interactive Browser
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
### Workflow:
|
|
16
|
-
|
|
17
15
|
1. **Python (PlotJS class):** Captures matplotlib figure as SVG string, collects tooltip/styling metadata
|
|
18
16
|
2. **Jinja2 Template:** Injects SVG + CSS + JavaScript parser + configuration into HTML
|
|
19
17
|
3. **Browser (PlotSVGParser):** Parses SVG structure to identify plot elements, attaches hover interactivity
|
|
20
18
|
|
|
19
|
+
## How to run command
|
|
20
|
+
|
|
21
|
+
Always use `uv` and/or `just` for running commands:
|
|
22
|
+
|
|
23
|
+
- `uv run pytest tests/test-python`
|
|
24
|
+
- `uv run pytest tests/test-python`
|
|
25
|
+
- `uv run python -c "import matplotlib"`
|
|
26
|
+
|
|
21
27
|
## Key Components
|
|
22
28
|
|
|
23
29
|
### Python Module (`/plotjs/`)
|
|
24
30
|
|
|
25
|
-
**`
|
|
31
|
+
**`plotjs.py`** - Core `PlotJS` class with method chaining
|
|
26
32
|
|
|
27
33
|
- `__init__(fig, **savefig_kws)` - Converts matplotlib figure to SVG
|
|
28
34
|
- `add_tooltip(labels, groups, hover_nearest, ax)` - Configure hover tooltips
|
|
@@ -53,7 +59,7 @@ Matplotlib Figure → SVG Export (Python) → HTML Template (Jinja2) → Interac
|
|
|
53
59
|
**`template.html`** - Jinja2 template structure
|
|
54
60
|
|
|
55
61
|
- Injects: `{{ svg }}`, `{{ default_css }}`, `{{ additional_css }}`, `{{ js_parser }}`, `{{ plot_data_json }}`
|
|
56
|
-
- Creates tooltip container and
|
|
62
|
+
- Creates tooltip container and event handling
|
|
57
63
|
|
|
58
64
|
**`plotparser.js`** - `PlotSVGParser` JavaScript class
|
|
59
65
|
|
|
@@ -125,17 +131,17 @@ Optional `seed` parameter ensures deterministic UUID generation for consistent o
|
|
|
125
131
|
```
|
|
126
132
|
plotjs/
|
|
127
133
|
├── __init__.py # Package exports
|
|
128
|
-
├──
|
|
129
|
-
├── css.py # CSS utilities
|
|
130
|
-
├── javascript.py # JavaScript utilities
|
|
131
|
-
├── utils.py # Internal helpers
|
|
134
|
+
├── plotjs.py # Core PlotJS class
|
|
135
|
+
├── css.py # CSS utilities
|
|
136
|
+
├── javascript.py # JavaScript utilities
|
|
137
|
+
├── utils.py # Internal helpers
|
|
132
138
|
├── data/
|
|
133
139
|
│ ├── datasets.py # Sample datasets with Narwhals
|
|
134
140
|
│ └── *.csv # Data files
|
|
135
141
|
└── static/
|
|
136
|
-
├── template.html # Jinja2 HTML template
|
|
137
|
-
├── plotparser.js # SVG parser class
|
|
138
|
-
└── default.css # Default styles
|
|
142
|
+
├── template.html # Jinja2 HTML template
|
|
143
|
+
├── plotparser.js # SVG parser class
|
|
144
|
+
└── default.css # Default styles
|
|
139
145
|
|
|
140
146
|
tests/
|
|
141
147
|
├── test-python/ # Python unit tests
|
|
@@ -156,10 +162,6 @@ docs/ # Comprehensive documentation
|
|
|
156
162
|
- jinja2 >= 3.0.0 (HTML templating)
|
|
157
163
|
- narwhals >= 2.0.0 (dataframe abstraction)
|
|
158
164
|
|
|
159
|
-
**JavaScript (via CDN):**
|
|
160
|
-
|
|
161
|
-
- d3 v7.9.0 (DOM manipulation via d3-selection)
|
|
162
|
-
|
|
163
165
|
**Python Version:** Requires 3.10+
|
|
164
166
|
|
|
165
167
|
## Critical Patterns & Limitations
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
## Classes
|
|
2
|
+
|
|
3
|
+
<dl>
|
|
4
|
+
<dt><a href="#Selection">Selection</a></dt>
|
|
5
|
+
<dd><p>Lightweight Selection wrapper that mimics d3-selection's chainable API.
|
|
6
|
+
Provides basic DOM manipulation methods for working with SVG elements.</p>
|
|
7
|
+
</dd>
|
|
8
|
+
</dl>
|
|
9
|
+
|
|
10
|
+
## Functions
|
|
11
|
+
|
|
12
|
+
<dl>
|
|
13
|
+
<dt><a href="#select">select(selector)</a> ⇒ <code><a href="#Selection">Selection</a></code></dt>
|
|
14
|
+
<dd><p>Create a Selection from a DOM element or selector string.</p>
|
|
15
|
+
</dd>
|
|
16
|
+
<dt><a href="#getPointerPosition">getPointerPosition(event, svgElement)</a> ⇒ <code>Array.<number></code></dt>
|
|
17
|
+
<dd><p>Get mouse position relative to an SVG element.</p>
|
|
18
|
+
</dd>
|
|
19
|
+
<dt><a href="#findBars">findBars(svg, axes_class)</a> ⇒ <code><a href="#Selection">Selection</a></code></dt>
|
|
20
|
+
<dd><p>Find bar elements (<code>patch</code> groups with clipping) inside a given axes.</p>
|
|
21
|
+
</dd>
|
|
22
|
+
<dt><a href="#findPoints">findPoints(svg, axes_class, tooltip_groups)</a> ⇒ <code><a href="#Selection">Selection</a></code></dt>
|
|
23
|
+
<dd><p>Find scatter plot points inside a given axes.
|
|
24
|
+
Handles both <code><use></code> and <code><path></code> fallback cases,
|
|
25
|
+
and assigns <code>data-group</code> attributes based on tooltip groups.</p>
|
|
26
|
+
</dd>
|
|
27
|
+
<dt><a href="#findLines">findLines(svg, axes_class)</a> ⇒ <code><a href="#Selection">Selection</a></code></dt>
|
|
28
|
+
<dd><p>Find line elements (<code>line2d</code> paths) inside a given axes,
|
|
29
|
+
excluding axis grid lines.</p>
|
|
30
|
+
</dd>
|
|
31
|
+
<dt><a href="#findAreas">findAreas(svg, axes_class)</a> ⇒ <code><a href="#Selection">Selection</a></code></dt>
|
|
32
|
+
<dd><p>Find filled area elements (<code>FillBetweenPolyCollection</code> paths) inside a given axes.</p>
|
|
33
|
+
</dd>
|
|
34
|
+
<dt><a href="#nearestElementFromMouse">nearestElementFromMouse(mouseX, mouseY, elements)</a> ⇒ <code>Element</code> | <code>null</code></dt>
|
|
35
|
+
<dd><p>Compute the nearest element to the mouse cursor from a set of elements.
|
|
36
|
+
Uses bounding box centers for distance.
|
|
37
|
+
This function is used when the <code>hover_nearest</code> argument is true.</p>
|
|
38
|
+
</dd>
|
|
39
|
+
<dt><a href="#setHoverEffect">setHoverEffect(plot_element, axes_class, tooltip_labels, tooltip_groups, show_tooltip, hover_nearest)</a></dt>
|
|
40
|
+
<dd><p>Attach hover interaction and tooltip display to plot elements.
|
|
41
|
+
Can highlight nearest element (if enabled) or hovered element directly.</p>
|
|
42
|
+
</dd>
|
|
43
|
+
</dl>
|
|
44
|
+
|
|
45
|
+
<a name="Selection"></a>
|
|
46
|
+
|
|
47
|
+
## Selection
|
|
48
|
+
Lightweight Selection wrapper that mimics d3-selection's chainable API.
|
|
49
|
+
Provides basic DOM manipulation methods for working with SVG elements.
|
|
50
|
+
|
|
51
|
+
**Kind**: global class
|
|
52
|
+
<a name="select"></a>
|
|
53
|
+
|
|
54
|
+
## select(selector) ⇒ [<code>Selection</code>](#Selection)
|
|
55
|
+
Create a Selection from a DOM element or selector string.
|
|
56
|
+
|
|
57
|
+
**Kind**: global function
|
|
58
|
+
**Returns**: [<code>Selection</code>](#Selection) - New Selection instance
|
|
59
|
+
|
|
60
|
+
| Param | Type | Description |
|
|
61
|
+
| --- | --- | --- |
|
|
62
|
+
| selector | <code>string</code> \| <code>Element</code> | CSS selector string or DOM element |
|
|
63
|
+
|
|
64
|
+
<a name="getPointerPosition"></a>
|
|
65
|
+
|
|
66
|
+
## getPointerPosition(event, svgElement) ⇒ <code>Array.<number></code>
|
|
67
|
+
Get mouse position relative to an SVG element.
|
|
68
|
+
|
|
69
|
+
**Kind**: global function
|
|
70
|
+
**Returns**: <code>Array.<number></code> - [x, y] coordinates relative to the SVG
|
|
71
|
+
|
|
72
|
+
| Param | Type | Description |
|
|
73
|
+
| --- | --- | --- |
|
|
74
|
+
| event | <code>MouseEvent</code> | The mouse event |
|
|
75
|
+
| svgElement | <code>Element</code> \| [<code>Selection</code>](#Selection) | The SVG element or Selection |
|
|
76
|
+
|
|
77
|
+
<a name="findBars"></a>
|
|
78
|
+
|
|
79
|
+
## findBars(svg, axes_class) ⇒ [<code>Selection</code>](#Selection)
|
|
80
|
+
Find bar elements (`patch` groups with clipping) inside a given axes.
|
|
81
|
+
|
|
82
|
+
**Kind**: global function
|
|
83
|
+
**Returns**: [<code>Selection</code>](#Selection) - Selection of bar elements.
|
|
84
|
+
|
|
85
|
+
| Param | Type | Description |
|
|
86
|
+
| --- | --- | --- |
|
|
87
|
+
| svg | [<code>Selection</code>](#Selection) | Selection of the SVG element. |
|
|
88
|
+
| axes_class | <code>string</code> | ID of the axes group (e.g. "axes_1"). |
|
|
89
|
+
|
|
90
|
+
<a name="findPoints"></a>
|
|
91
|
+
|
|
92
|
+
## findPoints(svg, axes_class, tooltip_groups) ⇒ [<code>Selection</code>](#Selection)
|
|
93
|
+
Find scatter plot points inside a given axes.
|
|
94
|
+
Handles both `<use>` and `<path>` fallback cases,
|
|
95
|
+
and assigns `data-group` attributes based on tooltip groups.
|
|
96
|
+
|
|
97
|
+
**Kind**: global function
|
|
98
|
+
**Returns**: [<code>Selection</code>](#Selection) - Selection of point elements.
|
|
99
|
+
|
|
100
|
+
| Param | Type | Description |
|
|
101
|
+
| --- | --- | --- |
|
|
102
|
+
| svg | [<code>Selection</code>](#Selection) | Selection of the SVG element. |
|
|
103
|
+
| axes_class | <code>string</code> | ID of the axes group (e.g. "axes_1"). |
|
|
104
|
+
| tooltip_groups | <code>Array.<string></code> | Group identifiers for tooltips, parallel to points. |
|
|
105
|
+
|
|
106
|
+
<a name="findLines"></a>
|
|
107
|
+
|
|
108
|
+
## findLines(svg, axes_class) ⇒ [<code>Selection</code>](#Selection)
|
|
109
|
+
Find line elements (`line2d` paths) inside a given axes,
|
|
110
|
+
excluding axis grid lines.
|
|
111
|
+
|
|
112
|
+
**Kind**: global function
|
|
113
|
+
**Returns**: [<code>Selection</code>](#Selection) - Selection of line elements.
|
|
114
|
+
|
|
115
|
+
| Param | Type | Description |
|
|
116
|
+
| --- | --- | --- |
|
|
117
|
+
| svg | [<code>Selection</code>](#Selection) | Selection of the SVG element. |
|
|
118
|
+
| axes_class | <code>string</code> | ID of the axes group. |
|
|
119
|
+
|
|
120
|
+
<a name="findAreas"></a>
|
|
121
|
+
|
|
122
|
+
## findAreas(svg, axes_class) ⇒ [<code>Selection</code>](#Selection)
|
|
123
|
+
Find filled area elements (`FillBetweenPolyCollection` paths) inside a given axes.
|
|
124
|
+
|
|
125
|
+
**Kind**: global function
|
|
126
|
+
**Returns**: [<code>Selection</code>](#Selection) - Selection of area elements.
|
|
127
|
+
|
|
128
|
+
| Param | Type | Description |
|
|
129
|
+
| --- | --- | --- |
|
|
130
|
+
| svg | [<code>Selection</code>](#Selection) | Selection of the SVG element. |
|
|
131
|
+
| axes_class | <code>string</code> | ID of the axes group. |
|
|
132
|
+
|
|
133
|
+
<a name="nearestElementFromMouse"></a>
|
|
134
|
+
|
|
135
|
+
## nearestElementFromMouse(mouseX, mouseY, elements) ⇒ <code>Element</code> \| <code>null</code>
|
|
136
|
+
Compute the nearest element to the mouse cursor from a set of elements.
|
|
137
|
+
Uses bounding box centers for distance.
|
|
138
|
+
This function is used when the `hover_nearest` argument is true.
|
|
139
|
+
|
|
140
|
+
**Kind**: global function
|
|
141
|
+
**Returns**: <code>Element</code> \| <code>null</code> - The nearest DOM element or `null`.
|
|
142
|
+
|
|
143
|
+
| Param | Type | Description |
|
|
144
|
+
| --- | --- | --- |
|
|
145
|
+
| mouseX | <code>number</code> | X coordinate of the mouse relative to SVG. |
|
|
146
|
+
| mouseY | <code>number</code> | Y coordinate of the mouse relative to SVG. |
|
|
147
|
+
| elements | [<code>Selection</code>](#Selection) | Selection of candidate elements. |
|
|
148
|
+
|
|
149
|
+
<a name="setHoverEffect"></a>
|
|
150
|
+
|
|
151
|
+
## setHoverEffect(plot_element, axes_class, tooltip_labels, tooltip_groups, show_tooltip, hover_nearest)
|
|
152
|
+
Attach hover interaction and tooltip display to plot elements.
|
|
153
|
+
Can highlight nearest element (if enabled) or hovered element directly.
|
|
154
|
+
|
|
155
|
+
**Kind**: global function
|
|
156
|
+
|
|
157
|
+
| Param | Type | Description |
|
|
158
|
+
| --- | --- | --- |
|
|
159
|
+
| plot_element | [<code>Selection</code>](#Selection) | Selection of plot elements (points, lines, etc.). |
|
|
160
|
+
| axes_class | <code>string</code> | ID of the axes group. |
|
|
161
|
+
| tooltip_labels | <code>Array.<string></code> | Tooltip labels for each element. |
|
|
162
|
+
| tooltip_groups | <code>Array.<string></code> | Group identifiers for each element. |
|
|
163
|
+
| show_tooltip | <code>"block"</code> \| <code>"none"</code> | Whether to display tooltips. |
|
|
164
|
+
| hover_nearest | <code>boolean</code> | If true, highlight nearest element instead of hovered one. |
|