@qe-libs/qeviz 0.1.0 → 0.4.0
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.
- package/README.md +124 -1
- package/dist/qeviz.es.js +1381 -78
- package/dist/qeviz.es.js.map +1 -1
- package/dist/qeviz.umd.js +1381 -78
- package/dist/qeviz.umd.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -115,6 +115,7 @@ All three languages share the same chain operations:
|
|
|
115
115
|
| Group means | `qe_group(p, ...)` | `p.group(...)` | `qe_group(p, ...)` |
|
|
116
116
|
| Edge network | `qe_edges(p, group=, unit=, compare=, also=)` | `p.edges(group=, unit=, ...)` | `qe_edges(p; group=, unit=, ...)` |
|
|
117
117
|
| Unit points | `qe_points(p)` | `p.points()` | `qe_points(p)` |
|
|
118
|
+
| Axes | `qe_axes(p, x=, y=)` | `p.axes(x=, y=)` | `qe_axes(p; x=, y=)` |
|
|
118
119
|
| Labels | `qe_labels(p, nodes=, means=, points=)` | `p.labels(...)` | `qe_labels(p; ...)` |
|
|
119
120
|
| Export | `qe_export_html(p, path)` | `p.export_html(path)` | `qe_export_html(p, path)` |
|
|
120
121
|
| Introspect | `qe_groups(p)` / `qe_units(p)` | `p.groups()` / `p.units()` | `qe_groups(p)` / `qe_units(p)` |
|
|
@@ -128,12 +129,31 @@ All three languages share the same chain operations:
|
|
|
128
129
|
| `compare` | Second group to subtract (`group − compare`). Positive differences use the primary colour. |
|
|
129
130
|
| `also` | Second group to overlay alongside `group`. |
|
|
130
131
|
| `show` / `show=false` | Suppress all edges. |
|
|
132
|
+
| `color_scale` | Colour mapping (webENA ramps: saturation 0.25–1, opacity 0.3–1). `"model"` (default) rescales across the whole model, so plots of one model share a colour scale; `"plot"` rescales within the plot (webENA); `"absolute"` uses saturation = opacity = weight. |
|
|
133
|
+
| `edge_width` | Width of a weight-1 edge as a fraction of the plot width (default 0.04). Width is absolute — equal weights draw equally wide — and each node's diameter is the sum of its edges' widths. |
|
|
134
|
+
| `magnify` | Multiply this plot's widths and node sizes (not colour), e.g. for a faint subtraction. When set (even `1`), the plot is labelled "(scaled N.Nx)". |
|
|
131
135
|
|
|
132
136
|
Label modes: `"on"`, `"off"`, `"click"`, `"auto"`.
|
|
133
137
|
|
|
138
|
+
### `qe_axes` / `.axes()` parameters
|
|
139
|
+
|
|
140
|
+
Axes are **opt-in**: a plot draws the x/y axis cross only when `qe_axes()` is in the
|
|
141
|
+
chain (or a `<qe-axes>` element is present). Axis labels are opt-in too: `qe_axes()` alone
|
|
142
|
+
draws the lines with no labels. Each label is controlled independently:
|
|
143
|
+
|
|
144
|
+
| Parameter | Description |
|
|
145
|
+
|---|---|
|
|
146
|
+
| `x` | `FALSE` (default) omits the x-axis label, `TRUE` labels it with its dimension name (e.g. `SVD1`), a string sets custom text. |
|
|
147
|
+
| `y` | Same as `x`, for the y-axis. |
|
|
148
|
+
| `show` / `show=false` | Suppress the axes entirely. |
|
|
149
|
+
|
|
150
|
+
```r
|
|
151
|
+
qe_plot(set) |> qe_edges("FirstGame") |> qe_axes(x = "Task focus", y = TRUE)
|
|
152
|
+
```
|
|
153
|
+
|
|
134
154
|
## TypeScript / web component
|
|
135
155
|
|
|
136
|
-
The `<qe-visual>` and `<qe-graph>` elements can be used directly in any HTML page. Layer configuration uses declarative child elements
|
|
156
|
+
The `<qe-visual>` and `<qe-graph>` elements can be used directly in any HTML page. Mark sizes and colour follow webENA: `<qe-graph edge-width>` sets the width of a weight-1 edge (absolute, as a fraction of the plot width), `<qe-edges color-scale>` picks the colour rescaling (`model` / `plot` / `absolute`), and `<qe-edges magnify>` scales one plot and labels it. Layer configuration uses declarative child elements; each layer draws only when its element is present. Code-node positions always come from the model and set the plot extent, but the nodes are drawn only when `<qe-nodes>` is present. The R / Python / Julia wrappers emit `<qe-nodes>` alongside an edge network by default (`qe_nodes()` / `.nodes()` override that).
|
|
137
157
|
|
|
138
158
|
```html
|
|
139
159
|
<script src="qeviz.umd.js"></script>
|
|
@@ -144,6 +164,7 @@ The `<qe-visual>` and `<qe-graph>` elements can be used directly in any HTML pag
|
|
|
144
164
|
<qe-means confidence label="on"></qe-means>
|
|
145
165
|
<qe-points label="auto"></qe-points>
|
|
146
166
|
<qe-edges group="FirstGame" also="SecondGame"></qe-edges>
|
|
167
|
+
<qe-axes x y></qe-axes>
|
|
147
168
|
</qe-graph>
|
|
148
169
|
</qe-visual>
|
|
149
170
|
|
|
@@ -152,6 +173,21 @@ The `<qe-visual>` and `<qe-graph>` elements can be used directly in any HTML pag
|
|
|
152
173
|
</script>
|
|
153
174
|
```
|
|
154
175
|
|
|
176
|
+
By default, all marks (nodes, mean markers, unit dots) size in graph-coordinate
|
|
177
|
+
units and scale with the data extent and wheel-zoom. Add `fixed-size` to
|
|
178
|
+
`<qe-points>` or `<qe-means>` to keep those markers a constant on-screen pixel
|
|
179
|
+
size instead — useful when embedding coordinated plots at different scales (the
|
|
180
|
+
webENA use case):
|
|
181
|
+
|
|
182
|
+
```html
|
|
183
|
+
<qe-points fixed-size></qe-points>
|
|
184
|
+
<qe-means fixed-size></qe-means>
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
In the language adapters this is `fixed_size = TRUE` on `qe_points()` / `qe_group()`
|
|
188
|
+
(R), `fixed_size=True` on `.points()` / `.group()` (Python), and
|
|
189
|
+
`fixed_size=true` on `qe_points` / `qe_group` (Julia).
|
|
190
|
+
|
|
155
191
|
Child element presence controls layer visibility — add `<qe-points>` to show unit dots, omit it to hide them. A `MutationObserver` watches for child additions, removals, and attribute changes, so interactive controls can manipulate the DOM directly:
|
|
156
192
|
|
|
157
193
|
```js
|
|
@@ -161,6 +197,93 @@ edges.setAttribute("compare", "SecondGame");
|
|
|
161
197
|
edges.removeAttribute("also");
|
|
162
198
|
```
|
|
163
199
|
|
|
200
|
+
### Events
|
|
201
|
+
|
|
202
|
+
`<qe-graph>` dispatches interaction events on the public element with
|
|
203
|
+
`bubbles: true, composed: true`, so a host app can subscribe regardless of shadow
|
|
204
|
+
DOM. Each event's `detail` also carries the `originalEvent`.
|
|
205
|
+
|
|
206
|
+
| Event | `detail` |
|
|
207
|
+
|---|---|
|
|
208
|
+
| `qe-edge-click` / `qe-edge-hover` / `qe-edge-unhover` | `{ source, target, weight, directed, self, group?, unit? }` |
|
|
209
|
+
| `qe-node-click` / `qe-node-hover` / `qe-node-unhover` | `{ id, kind: "node" \| "mean" \| "point", name, x, y, group?, unit? }` |
|
|
210
|
+
| `qe-label-move` | `{ id, transform: { x, y } }` — a label was dragged (offset in graph-space units) |
|
|
211
|
+
|
|
212
|
+
Labels are **draggable** (drag to reposition; the label pins open and stays
|
|
213
|
+
visible), emitting `qe-label-move` on drop so the host can persist the position
|
|
214
|
+
or mirror it across coordinated plots.
|
|
215
|
+
|
|
216
|
+
For a quick built-in tooltip on hover — `source – target (weight)` over edges,
|
|
217
|
+
the mark name over nodes — add the `tooltip` attribute to `<qe-graph>`. It is
|
|
218
|
+
opt-in; most hosts render their own from the hover events instead.
|
|
219
|
+
|
|
220
|
+
```html
|
|
221
|
+
<qe-graph tooltip>…</qe-graph>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
`source`/`target` are code-node names; `x`/`y` are graph-space coordinates. Unhover
|
|
225
|
+
events carry `{ key }` identifying the mark/edge that was left. The host reacts and
|
|
226
|
+
pushes state back declaratively (ModelData + layer attributes) — qeviz adds no
|
|
227
|
+
framework coupling.
|
|
228
|
+
|
|
229
|
+
```js
|
|
230
|
+
graph.addEventListener("qe-edge-click", (e) => {
|
|
231
|
+
const { source, target, weight } = e.detail; // e.g. open a conversation view
|
|
232
|
+
});
|
|
233
|
+
graph.addEventListener("qe-node-click", (e) => {
|
|
234
|
+
if (e.detail.kind === "point") plotUnit(e.detail.id);
|
|
235
|
+
});
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Instance access & read APIs
|
|
239
|
+
|
|
240
|
+
Give coordinated plots an identity and look them up, and read the resolved model
|
|
241
|
+
for host-side hit-testing or export:
|
|
242
|
+
|
|
243
|
+
```js
|
|
244
|
+
import { getGraph, getGraphs } from "@qe-libs/qeviz";
|
|
245
|
+
|
|
246
|
+
getGraph("comparison"); // by id or plot-group attribute
|
|
247
|
+
getGraphs(); // all connected <qe-graph> instances
|
|
248
|
+
|
|
249
|
+
const graph = getGraph("comparison");
|
|
250
|
+
graph.getNodes(); // [{ id, name, x, y }, …]
|
|
251
|
+
graph.getEdges(); // [{ source, target, weight, directed, self }, …]
|
|
252
|
+
graph.getPoints(); // [{ id, group, x, y }, …] (unit points)
|
|
253
|
+
graph.pointsInRect({ x, y, w, h }); // ids of unit points in a graph-space rect
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Transitions & export
|
|
257
|
+
|
|
258
|
+
Opt into animated transitions with the `animate` attribute — on the next
|
|
259
|
+
`setModelData`, marks glide from their old positions to the new ones instead of
|
|
260
|
+
snapping (default 300 ms; `animate="500"` sets the duration):
|
|
261
|
+
|
|
262
|
+
```html
|
|
263
|
+
<qe-graph animate>…</qe-graph>
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Snapshot the current plot for download or embedding:
|
|
267
|
+
|
|
268
|
+
```js
|
|
269
|
+
graph.toSVG(); // standalone SVG string
|
|
270
|
+
await graph.toPNG(2); // PNG data URL (2× resolution)
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Selection / highlight
|
|
274
|
+
|
|
275
|
+
Drive selection styling from the host without touching qeviz's internal DOM. The
|
|
276
|
+
highlight is an overlay that survives model updates:
|
|
277
|
+
|
|
278
|
+
```js
|
|
279
|
+
graph.setHighlight({ edges: [{ source: "Data", target: "Design" }], nodes: ["Data"] });
|
|
280
|
+
graph.clearHighlight();
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
```html
|
|
284
|
+
<qe-graph id="primary" plot-group="comparison" …></qe-graph>
|
|
285
|
+
```
|
|
286
|
+
|
|
164
287
|
### Build
|
|
165
288
|
|
|
166
289
|
```sh
|