graphein 0.7.1 → 0.8.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/dist/index.d.ts +12 -10
- package/dist/index.js +8 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2482,8 +2482,9 @@ declare function fontString(size: number, family: string, weight?: number | stri
|
|
|
2482
2482
|
*
|
|
2483
2483
|
* A dashboard owns a shared dataset and a shared selection store, lays its views
|
|
2484
2484
|
* out on a responsive grid, and *auto-wires* cross-interaction: slicers filter
|
|
2485
|
-
* the charts, and clicking a chart cross-
|
|
2486
|
-
*
|
|
2485
|
+
* the charts, and clicking a chart cross-filters the other views while the
|
|
2486
|
+
* source dims its own unpicked marks (Power BI–style).
|
|
2487
|
+
* Everything is plain JSON — no callbacks — so a dashboard
|
|
2487
2488
|
* round-trips through `JSON.stringify` just like a chart.
|
|
2488
2489
|
*/
|
|
2489
2490
|
|
|
@@ -2607,8 +2608,9 @@ interface DashboardSpec {
|
|
|
2607
2608
|
views: DashboardView[];
|
|
2608
2609
|
/**
|
|
2609
2610
|
* Cross-interaction policy:
|
|
2610
|
-
* - 'auto' (default):
|
|
2611
|
-
*
|
|
2611
|
+
* - 'auto' (default): every source cross-filters the page — slicers and chart
|
|
2612
|
+
* clicks both subset rows in the other views; the clicked chart dims its own
|
|
2613
|
+
* unpicked marks instead of hiding them.
|
|
2612
2614
|
* - 'none': views are laid out but not linked.
|
|
2613
2615
|
* - an array of {@link InteractionLink}: explicit wiring (replaces auto).
|
|
2614
2616
|
*/
|
|
@@ -3682,12 +3684,12 @@ declare function render(target: HTMLElement | string, spec: ChartSpec, options?:
|
|
|
3682
3684
|
* store) so it unit-tests in node and the runtime stays a thin shell.
|
|
3683
3685
|
*
|
|
3684
3686
|
* Rules (interactions: 'auto'):
|
|
3685
|
-
* - A **slicer** publishes a value on its field/param; every
|
|
3686
|
-
*
|
|
3687
|
-
* - A **chart** click publishes a point selection on its key field(s)
|
|
3688
|
-
*
|
|
3689
|
-
*
|
|
3690
|
-
*
|
|
3687
|
+
* - A **slicer** publishes a value on its field/param; every other non-slicer
|
|
3688
|
+
* view gets a `filter` clause for it (page-level cross-filter).
|
|
3689
|
+
* - A **chart** click publishes a point selection on its key field(s). The
|
|
3690
|
+
* source emphasizes itself (`highlight` on its own param, so it dims the
|
|
3691
|
+
* unpicked marks rather than hiding them), and **every other view** gets a
|
|
3692
|
+
* `filter` clause for that param (Power BI–style cross-filter of the page).
|
|
3691
3693
|
*/
|
|
3692
3694
|
|
|
3693
3695
|
declare function isSlicerType(type: ChartSpec['type']): boolean;
|
package/dist/index.js
CHANGED
|
@@ -8259,7 +8259,8 @@ function drawPie(surface, spec, tokens, size, context) {
|
|
|
8259
8259
|
color: tokens.color.text,
|
|
8260
8260
|
size: tokens.font.size.small,
|
|
8261
8261
|
transform: o.align === "right" ? "translate(-100%,-50%)" : "translateY(-50%)",
|
|
8262
|
-
opacity: alpha === 1 ? void 0 : alpha
|
|
8262
|
+
opacity: alpha === 1 ? void 0 : alpha,
|
|
8263
|
+
pill: { background: tokens.color.surface, border: tokens.color.border, padX: 6 }
|
|
8263
8264
|
});
|
|
8264
8265
|
}
|
|
8265
8266
|
for (const l of labelPlan.inside) {
|
|
@@ -8269,11 +8270,12 @@ function drawPie(surface, spec, tokens, size, context) {
|
|
|
8269
8270
|
left: l.x,
|
|
8270
8271
|
top: l.y,
|
|
8271
8272
|
text: l.text,
|
|
8272
|
-
color:
|
|
8273
|
+
color: tokens.color.text,
|
|
8273
8274
|
size: tokens.font.size.small,
|
|
8274
8275
|
weight: tokens.font.weight.bold,
|
|
8275
8276
|
transform: "translate(-50%,-50%)",
|
|
8276
|
-
opacity: alpha === 1 ? void 0 : alpha
|
|
8277
|
+
opacity: alpha === 1 ? void 0 : alpha,
|
|
8278
|
+
pill: { background: tokens.color.surface, border: tokens.color.border, padX: 6 }
|
|
8277
8279
|
});
|
|
8278
8280
|
}
|
|
8279
8281
|
}
|
|
@@ -16399,11 +16401,6 @@ function addFilterParam(spec, paramName) {
|
|
|
16399
16401
|
filter.push({ param: paramName });
|
|
16400
16402
|
return { ...spec, filter };
|
|
16401
16403
|
}
|
|
16402
|
-
function usesAll(spec, fields) {
|
|
16403
|
-
if (fields.length === 0) return false;
|
|
16404
|
-
const have = specFields(spec);
|
|
16405
|
-
return fields.every((f) => have.has(f));
|
|
16406
|
-
}
|
|
16407
16404
|
function autoParamName(view) {
|
|
16408
16405
|
const existing = view.spec.params?.[0]?.name;
|
|
16409
16406
|
return existing ?? `__sel__${view.id}`;
|
|
@@ -16439,16 +16436,12 @@ function wireViews(views, interactions) {
|
|
|
16439
16436
|
name: src.param,
|
|
16440
16437
|
select: { type: "point", on: "click", fields: src.fields }
|
|
16441
16438
|
});
|
|
16439
|
+
out[src.view].spec = addHighlight(out[src.view].spec, src.param);
|
|
16442
16440
|
}
|
|
16443
16441
|
out.forEach((v, j) => {
|
|
16444
16442
|
if (isSlicerType(v.spec.type)) return;
|
|
16445
|
-
if (
|
|
16446
|
-
|
|
16447
|
-
out[j].spec = addFilterParam(out[j].spec, src.param);
|
|
16448
|
-
} else {
|
|
16449
|
-
if (!usesAll(v.spec, src.fields)) return;
|
|
16450
|
-
out[j].spec = addHighlight(out[j].spec, src.param);
|
|
16451
|
-
}
|
|
16443
|
+
if (j === src.view) return;
|
|
16444
|
+
out[j].spec = addFilterParam(out[j].spec, src.param);
|
|
16452
16445
|
});
|
|
16453
16446
|
}
|
|
16454
16447
|
return out;
|