@d3plus/core 4.3.0 → 4.5.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 +1820 -714
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/internal.js +7 -1
- package/es/internal.js.map +1 -1
- package/es/src/charts/AreaPlot/index.js +1 -2
- package/es/src/charts/AreaPlot/index.js.map +1 -1
- package/es/src/charts/BarChart/index.js +1 -2
- package/es/src/charts/BarChart/index.js.map +1 -1
- package/es/src/charts/BoxWhisker/index.js +1 -2
- package/es/src/charts/BoxWhisker/index.js.map +1 -1
- package/es/src/charts/BumpChart/index.js +1 -2
- package/es/src/charts/BumpChart/index.js.map +1 -1
- package/es/src/charts/Chord/applyLayout.js +205 -0
- package/es/src/charts/Chord/applyLayout.js.map +1 -0
- package/es/src/charts/Chord/emit.js +168 -0
- package/es/src/charts/Chord/emit.js.map +1 -0
- package/es/src/charts/Chord/index.js +234 -0
- package/es/src/charts/Chord/index.js.map +1 -0
- package/es/src/charts/Geomap/basemapTheme.js +78 -0
- package/es/src/charts/Geomap/basemapTheme.js.map +1 -0
- package/es/src/charts/Geomap/emit.js +18 -9
- package/es/src/charts/Geomap/emit.js.map +1 -1
- package/es/src/charts/Geomap/index.js +69 -104
- package/es/src/charts/Geomap/index.js.map +1 -1
- package/es/src/charts/LinePlot/index.js +1 -2
- package/es/src/charts/LinePlot/index.js.map +1 -1
- package/es/src/charts/Matrix/emit.js +6 -0
- package/es/src/charts/Matrix/emit.js.map +1 -1
- package/es/src/charts/Matrix/index.js +1 -2
- package/es/src/charts/Matrix/index.js.map +1 -1
- package/es/src/charts/Network/emit.js +58 -24
- package/es/src/charts/Network/emit.js.map +1 -1
- package/es/src/charts/Network/index.js +34 -54
- package/es/src/charts/Network/index.js.map +1 -1
- package/es/src/charts/Pack/emit.js +3 -0
- package/es/src/charts/Pack/emit.js.map +1 -1
- package/es/src/charts/Pack/index.js +1 -2
- package/es/src/charts/Pack/index.js.map +1 -1
- package/es/src/charts/Pie/emit.js +6 -2
- package/es/src/charts/Pie/emit.js.map +1 -1
- package/es/src/charts/Pie/index.js +1 -2
- package/es/src/charts/Pie/index.js.map +1 -1
- package/es/src/charts/Plot/index.js +26 -6
- package/es/src/charts/Plot/index.js.map +1 -1
- package/es/src/charts/Plot/pipeline.js +1 -2
- package/es/src/charts/Plot/pipeline.js.map +1 -1
- package/es/src/charts/Plot/plotZoom.js +278 -0
- package/es/src/charts/Plot/plotZoom.js.map +1 -0
- package/es/src/charts/Priestley/emit.js +4 -0
- package/es/src/charts/Priestley/emit.js.map +1 -1
- package/es/src/charts/Priestley/index.js +1 -2
- package/es/src/charts/Priestley/index.js.map +1 -1
- package/es/src/charts/Radar/emit.js +4 -1
- package/es/src/charts/Radar/emit.js.map +1 -1
- package/es/src/charts/Radar/index.js +1 -2
- package/es/src/charts/Radar/index.js.map +1 -1
- package/es/src/charts/RadialMatrix/emit.js +6 -0
- package/es/src/charts/RadialMatrix/emit.js.map +1 -1
- package/es/src/charts/RadialMatrix/index.js +1 -2
- package/es/src/charts/RadialMatrix/index.js.map +1 -1
- package/es/src/charts/Rings/emit.js +74 -8
- package/es/src/charts/Rings/emit.js.map +1 -1
- package/es/src/charts/Rings/index.js +11 -3
- package/es/src/charts/Rings/index.js.map +1 -1
- package/es/src/charts/Sankey/emit.js +55 -11
- package/es/src/charts/Sankey/emit.js.map +1 -1
- package/es/src/charts/Sankey/index.js +8 -2
- package/es/src/charts/Sankey/index.js.map +1 -1
- package/es/src/charts/StackedArea/index.js +1 -2
- package/es/src/charts/StackedArea/index.js.map +1 -1
- package/es/src/charts/Tree/emit.js +8 -2
- package/es/src/charts/Tree/emit.js.map +1 -1
- package/es/src/charts/Tree/index.js +1 -2
- package/es/src/charts/Tree/index.js.map +1 -1
- package/es/src/charts/Treemap/index.js +1 -2
- package/es/src/charts/Treemap/index.js.map +1 -1
- package/es/src/charts/definition/ChartDefinition.js.map +1 -1
- package/es/src/charts/drawSteps/backControl.js +70 -0
- package/es/src/charts/drawSteps/backControl.js.map +1 -0
- package/es/src/charts/drawSteps/controlButtonStyle.js +108 -0
- package/es/src/charts/drawSteps/controlButtonStyle.js.map +1 -0
- package/es/src/charts/drawSteps/minimap.js +370 -0
- package/es/src/charts/drawSteps/minimap.js.map +1 -0
- package/es/src/charts/drawSteps/minimapMarkup.js +147 -0
- package/es/src/charts/drawSteps/minimapMarkup.js.map +1 -0
- package/es/src/charts/drawSteps/searchControls.js +358 -0
- package/es/src/charts/drawSteps/searchControls.js.map +1 -0
- package/es/src/charts/drawSteps/searchControlsMarkup.js +430 -0
- package/es/src/charts/drawSteps/searchControlsMarkup.js.map +1 -0
- package/es/src/charts/drawSteps/tableView.js +173 -0
- package/es/src/charts/drawSteps/tableView.js.map +1 -0
- package/es/src/charts/drawSteps/tableViewControl.js +39 -0
- package/es/src/charts/drawSteps/tableViewControl.js.map +1 -0
- package/es/src/charts/drawSteps/tableViewMarkup.js +647 -0
- package/es/src/charts/drawSteps/tableViewMarkup.js.map +1 -0
- package/es/src/charts/drawSteps/topLeftControls.js +73 -0
- package/es/src/charts/drawSteps/topLeftControls.js.map +1 -0
- package/es/src/charts/drawSteps/topLeftControlsMarkup.js +227 -0
- package/es/src/charts/drawSteps/topLeftControlsMarkup.js.map +1 -0
- package/es/src/charts/drawSteps/zoomControls.js +314 -175
- package/es/src/charts/drawSteps/zoomControls.js.map +1 -1
- package/es/src/charts/drawSteps/zoomControlsMarkup.js +280 -0
- package/es/src/charts/drawSteps/zoomControlsMarkup.js.map +1 -0
- package/es/src/charts/features/attributionFeature.js +137 -0
- package/es/src/charts/features/attributionFeature.js.map +1 -0
- package/es/src/charts/features/axes.js +20 -8
- package/es/src/charts/features/axes.js.map +1 -1
- package/es/src/charts/features/chartGeometry.js +16 -2
- package/es/src/charts/features/chartGeometry.js.map +1 -1
- package/es/src/charts/features/edgeArrows.js +155 -0
- package/es/src/charts/features/edgeArrows.js.map +1 -0
- package/es/src/charts/features/emitHelpers.js +8 -0
- package/es/src/charts/features/emitHelpers.js.map +1 -1
- package/es/src/charts/features/ensureZoomDom.js +63 -12
- package/es/src/charts/features/ensureZoomDom.js.map +1 -1
- package/es/src/charts/features/features.js +83 -110
- package/es/src/charts/features/features.js.map +1 -1
- package/es/src/charts/features/featuresLegend.js +45 -17
- package/es/src/charts/features/featuresLegend.js.map +1 -1
- package/es/src/charts/features/plotPaint.js +32 -7
- package/es/src/charts/features/plotPaint.js.map +1 -1
- package/es/src/charts/features/zoomExtent.js +185 -0
- package/es/src/charts/features/zoomExtent.js.map +1 -0
- package/es/src/charts/helpers/tileAttributions.js +26 -0
- package/es/src/charts/helpers/tileAttributions.js.map +1 -1
- package/es/src/charts/index.js +1 -0
- package/es/src/charts/index.js.map +1 -1
- package/es/src/charts/pipeline/runVizPipeline.js +33 -14
- package/es/src/charts/pipeline/runVizPipeline.js.map +1 -1
- package/es/src/charts/pipeline/vizDrawPure.js +32 -6
- package/es/src/charts/pipeline/vizDrawPure.js.map +1 -1
- package/es/src/charts/viz/Viz.js +39 -51
- package/es/src/charts/viz/Viz.js.map +1 -1
- package/es/src/charts/viz/VizBase.js +157 -4
- package/es/src/charts/viz/VizBase.js.map +1 -1
- package/es/src/charts/viz/VizBaseConfig.js +32 -2
- package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
- package/es/src/charts/viz/vizDefaults.js +243 -50
- package/es/src/charts/viz/vizDefaults.js.map +1 -1
- package/es/src/charts/viz/vizTypes.js.map +1 -1
- package/es/src/components/Axis/Axis.js +10 -1
- package/es/src/components/Axis/Axis.js.map +1 -1
- package/es/src/components/Axis/axisLayoutLabels.js +2 -1
- package/es/src/components/Axis/axisLayoutLabels.js.map +1 -1
- package/es/src/components/Axis/axisRender.js +5 -1
- package/es/src/components/Axis/axisRender.js.map +1 -1
- package/es/src/components/Legend/legendConfig.js +86 -20
- package/es/src/components/Legend/legendConfig.js.map +1 -1
- package/es/src/utils/D3plusConfig.js.map +1 -1
- package/package.json +11 -10
- package/types/index.d.ts +1 -1
- package/types/internal.d.ts +8 -1
- package/types/src/charts/Chord/applyLayout.d.ts +43 -0
- package/types/src/charts/Chord/emit.d.ts +10 -0
- package/types/src/charts/Chord/index.d.ts +19 -0
- package/types/src/charts/Geomap/basemapTheme.d.ts +35 -0
- package/types/src/charts/Plot/index.d.ts +12 -3
- package/types/src/charts/Plot/plotZoom.d.ts +65 -0
- package/types/src/charts/definition/ChartDefinition.d.ts +3 -1
- package/types/src/charts/drawSteps/backControl.d.ts +29 -0
- package/types/src/charts/drawSteps/controlButtonStyle.d.ts +45 -0
- package/types/src/charts/drawSteps/minimap.d.ts +19 -0
- package/types/src/charts/drawSteps/minimapMarkup.d.ts +45 -0
- package/types/src/charts/drawSteps/searchControls.d.ts +3 -0
- package/types/src/charts/drawSteps/searchControlsMarkup.d.ts +111 -0
- package/types/src/charts/drawSteps/tableView.d.ts +23 -0
- package/types/src/charts/drawSteps/tableViewControl.d.ts +21 -0
- package/types/src/charts/drawSteps/tableViewMarkup.d.ts +119 -0
- package/types/src/charts/drawSteps/topLeftControls.d.ts +32 -0
- package/types/src/charts/drawSteps/topLeftControlsMarkup.d.ts +72 -0
- package/types/src/charts/drawSteps/zoomControls.d.ts +48 -8
- package/types/src/charts/drawSteps/zoomControlsMarkup.d.ts +138 -0
- package/types/src/charts/features/attributionFeature.d.ts +21 -0
- package/types/src/charts/features/axes.d.ts +1 -1
- package/types/src/charts/features/chartGeometry.d.ts +9 -3
- package/types/src/charts/features/edgeArrows.d.ts +92 -0
- package/types/src/charts/features/emitHelpers.d.ts +11 -0
- package/types/src/charts/features/ensureZoomDom.d.ts +6 -2
- package/types/src/charts/features/features.d.ts +32 -17
- package/types/src/charts/features/featuresLegend.d.ts +15 -0
- package/types/src/charts/features/plotPaint.d.ts +15 -2
- package/types/src/charts/features/zoomExtent.d.ts +25 -0
- package/types/src/charts/index.d.ts +1 -0
- package/types/src/charts/pipeline/runVizPipeline.d.ts +6 -3
- package/types/src/charts/viz/VizBase.d.ts +86 -4
- package/types/src/charts/viz/VizBaseConfig.d.ts +20 -2
- package/types/src/charts/viz/vizDefaults.d.ts +155 -0
- package/types/src/charts/viz/vizTypes.d.ts +57 -1
- package/types/src/components/Axis/Axis.d.ts +2 -0
- package/types/src/utils/D3plusConfig.d.ts +102 -8
- package/umd/d3plus-core.full.js +39613 -35374
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +5747 -4361
- package/umd/d3plus-core.js +13132 -9289
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +3658 -2302
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Markup, styling, and measurement for the zoom-control button panel —
|
|
3
|
+
shared by the zoom feature (which renders and wires the panel) and the
|
|
4
|
+
top-positioned layout features (title, subtitle, total, legend), which
|
|
5
|
+
measure the panel so their content can leave room for it.
|
|
6
|
+
|
|
7
|
+
@module
|
|
8
|
+
*/
|
|
9
|
+
import type Viz from "../viz/Viz.js";
|
|
10
|
+
import { kebab } from "./controlButtonStyle.js";
|
|
11
|
+
export { kebab };
|
|
12
|
+
/**
|
|
13
|
+
Brush mode is per-chart, not global: it lives on `viz._brushing` and is
|
|
14
|
+
read/written via these helpers.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isBrushing(viz: Viz): boolean;
|
|
17
|
+
export declare function setBrushing(viz: Viz, value: boolean): void;
|
|
18
|
+
/** Paints a zoom-control button's inline style for its current state (base/hover/active) — see `paintControlButton`. */
|
|
19
|
+
export declare function paintZoomButton(viz: Viz, btn: HTMLElement, hovered?: boolean): void;
|
|
20
|
+
/**
|
|
21
|
+
Shared attributes for the four icon `<svg>`s below: one `viewBox`, one
|
|
22
|
+
`stroke-width`, `currentColor` for the stroke (so the icon still follows
|
|
23
|
+
`color` from `zoomControlStyle`/a host page's CSS, same as the glyph
|
|
24
|
+
characters this replaced). Sizing and `vertical-align: middle` live in
|
|
25
|
+
the `style` attribute rather than as `width`/`height` SVG attributes —
|
|
26
|
+
plenty of CSS resets (Bulma's base stylesheet, for one) include a plain
|
|
27
|
+
`svg { width: auto; height: auto }` rule, and *any* CSS declaration beats
|
|
28
|
+
a presentation attribute. An SVG with only a `viewBox` and no definite
|
|
29
|
+
CSS size can collapse to 0×0 inside a flex layout, which is exactly what
|
|
30
|
+
happened here — an inline `style` has enough specificity that no host
|
|
31
|
+
page's element-selector reset can strip it back out. `vertical-align:
|
|
32
|
+
middle` matters because an inline `svg` defaults to `vertical-align:
|
|
33
|
+
baseline` like text, which sits it a couple pixels off-center inside a
|
|
34
|
+
host page's own button styling (Bootstrap/Tailwind/Bulma center *text*
|
|
35
|
+
via their own line-height/padding, not a replaced element's baseline).
|
|
36
|
+
`zoomControlClassName` intentionally drops our own `align-items`/
|
|
37
|
+
`justify-content` centering so it doesn't fight a framework's layout —
|
|
38
|
+
`vertical-align: middle` is what keeps the icon itself centered
|
|
39
|
+
regardless of whose CSS is doing the centering. `flex-shrink: 0` guards
|
|
40
|
+
against a different failure mode: if a host framework's own button
|
|
41
|
+
(Bulma's `.button`, for one) is itself `display: flex` with padding wide
|
|
42
|
+
enough to leave less than 12px of content room, the icon — a flex item
|
|
43
|
+
of that button — would otherwise shrink to fit, quietly distorting it
|
|
44
|
+
into a non-square sliver instead of keeping its aspect ratio.
|
|
45
|
+
|
|
46
|
+
Text-glyph icons (`+`, `−`, a Unicode home/square symbol, …) come from
|
|
47
|
+
different font fallback chains, and browsers apply synthetic bold to
|
|
48
|
+
each inconsistently — no single font reliably bolds all of them to the
|
|
49
|
+
same visual stroke thickness across OSes. Vector paths sidestep that
|
|
50
|
+
entirely: every icon renders at the exact same stroke weight regardless
|
|
51
|
+
of the visitor's font/OS/browser (and all four share the same 4–20
|
|
52
|
+
bounding box within the 24x24 viewBox, so they also match in apparent
|
|
53
|
+
size) — this is how icon sets like Feather/Lucide/Material Symbols do it.
|
|
54
|
+
*/
|
|
55
|
+
export declare const ICON_ATTRS = "viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"width:12px;height:12px;vertical-align:middle;flex-shrink:0\"";
|
|
56
|
+
/**
|
|
57
|
+
A custom zoom-control icon: either raw markup (a string — inserted as the
|
|
58
|
+
button's content in place of the built-in `<svg>`, no wrapper) or a mount
|
|
59
|
+
function, the escape hatch for a live component (a React/Vue/Svelte tree,
|
|
60
|
+
a canvas sprite, anything imperative). The function receives the actual
|
|
61
|
+
`<span>` reserved for the icon — sized to match the built-ins, 12x12px —
|
|
62
|
+
once per fresh button element (see `mountCustomIcons` below), and may
|
|
63
|
+
return a cleanup function, called right before that element is discarded
|
|
64
|
+
(the panel's html regenerates wholesale on a brush toggle, a `.locale(...)`
|
|
65
|
+
change, or a `zoomControlClassName` change — see `zoomControlsHtml`'s own
|
|
66
|
+
doc — so a mounted icon is torn down and remounted on those, not just once
|
|
67
|
+
per chart). Omit the return value for icons with nothing to clean up.
|
|
68
|
+
|
|
69
|
+
@example
|
|
70
|
+
// Raw markup — a single emoji.
|
|
71
|
+
viz.zoomControlIcons({zoomIn: "➕"})
|
|
72
|
+
|
|
73
|
+
// A React tree, mounted imperatively into the reserved slot.
|
|
74
|
+
viz.zoomControlIcons({
|
|
75
|
+
zoomIn: el => {
|
|
76
|
+
const root = createRoot(el);
|
|
77
|
+
root.render(<PlusIcon />);
|
|
78
|
+
return () => root.unmount();
|
|
79
|
+
},
|
|
80
|
+
})
|
|
81
|
+
*/
|
|
82
|
+
export type ZoomControlIconRenderer = (el: HTMLElement) => void | (() => void);
|
|
83
|
+
export type ZoomControlIconValue = string | ZoomControlIconRenderer;
|
|
84
|
+
export type ZoomControlIconKey = "zoomIn" | "zoomOut" | "zoomReset" | "zoomBrush";
|
|
85
|
+
export type ZoomControlIcons = Partial<Record<ZoomControlIconKey, ZoomControlIconValue>>;
|
|
86
|
+
/**
|
|
87
|
+
The panel's own layout: a right-aligned flex row. Spacing lives here, not
|
|
88
|
+
on the buttons — per-button `margin` doesn't collapse between flex
|
|
89
|
+
siblings, so two adjacent 4px margins would add up to an 8px gap. A
|
|
90
|
+
container `gap` gives exactly one 4px gap between each pair, and
|
|
91
|
+
`padding` (with `box-sizing: border-box`) one 4px inset from the chart's
|
|
92
|
+
top/right edge. This isn't part of the auto-disable `zoomControlClassName`
|
|
93
|
+
triggers, so a host page never has to re-add its own spacing utility.
|
|
94
|
+
*/
|
|
95
|
+
export declare const ZOOM_PANEL_STYLE: Record<string, string>;
|
|
96
|
+
/**
|
|
97
|
+
The four buttons' markup. Real <button>s (not <div>s) so a host page's own
|
|
98
|
+
button styling (Tailwind, Bootstrap, a design system's global `button`
|
|
99
|
+
reset) applies through the cascade once a `zoomControlClassName`
|
|
100
|
+
auto-disables the inline defaults. `zoomControlClassName` layers a
|
|
101
|
+
consumer's own class onto each button without losing the fixed classes
|
|
102
|
+
event delegation depends on. The brush toggle carries `aria-pressed` (and
|
|
103
|
+
the `.active` class frameworks like Bootstrap style) while brush mode is on.
|
|
104
|
+
*/
|
|
105
|
+
export declare function zoomControlsHtml(viz: Viz): string;
|
|
106
|
+
/**
|
|
107
|
+
Mounts each configured custom icon function into its button's reserved
|
|
108
|
+
slot — called once per fresh button element (from the same `onUpdate`
|
|
109
|
+
guard in `zoomControls.ts` that binds hover/style exactly once), so a
|
|
110
|
+
remount only happens when the whole panel's html actually regenerates
|
|
111
|
+
(see `ZoomControlIconRenderer`'s doc for when that is). Runs any PREVIOUS
|
|
112
|
+
mount's cleanup for that icon key first — the prior button element (if
|
|
113
|
+
any) is about to be discarded regardless of whether its content was
|
|
114
|
+
custom-mounted, so this is the one place that teardown can happen.
|
|
115
|
+
*/
|
|
116
|
+
export declare function mountCustomIcons(viz: Viz, btn: HTMLElement): void;
|
|
117
|
+
/** The HTML element a chart's overlays (the zoom controls) mount in. */
|
|
118
|
+
export declare function overlayHost(viz: Viz): HTMLElement | null;
|
|
119
|
+
/**
|
|
120
|
+
Reflects the brush mode onto the brush toggle button (its `.active`
|
|
121
|
+
class, `aria-pressed`, and active style) when the mode changes without
|
|
122
|
+
a click on the button itself — e.g. leaving brush mode after a selection.
|
|
123
|
+
*/
|
|
124
|
+
export declare function syncBrushButton(viz: Viz): void;
|
|
125
|
+
/** Whether a chart shows the zoom-control panel. */
|
|
126
|
+
export declare function showsZoomControls(viz: Viz): boolean;
|
|
127
|
+
/**
|
|
128
|
+
The zoom-control panel's size (padding included) as it will render in the
|
|
129
|
+
chart's page, so top-positioned content can leave room for it. Measured
|
|
130
|
+
by mounting a hidden copy beside the chart — the buttons' size depends on
|
|
131
|
+
the host page's CSS (a `zoomControlClassName`, a global `button` reset) —
|
|
132
|
+
and cached until the markup or styling changes. Returns null when the
|
|
133
|
+
chart shows no controls.
|
|
134
|
+
*/
|
|
135
|
+
export declare function zoomControlsBox(viz: Viz): {
|
|
136
|
+
width: number;
|
|
137
|
+
height: number;
|
|
138
|
+
} | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
The tile/data credit, an HTML overlay in the chart area's bottom-right
|
|
3
|
+
corner. It sits outside the SVG plane, so rather than encode it into the
|
|
4
|
+
scene graph this feature creates it imperatively from inside `layout()`
|
|
5
|
+
(funneled through `runLayout` like the other features); it claims zero
|
|
6
|
+
margin and emits no panel.
|
|
7
|
+
|
|
8
|
+
A credit that would take up more than half the chart's width collapses to
|
|
9
|
+
an ⓘ badge that expands on hover, focus, or click — the compact
|
|
10
|
+
attribution modern web maps use — so a long required credit (Esri's
|
|
11
|
+
basemap credit, for one) doesn't lay a banner across a small map.
|
|
12
|
+
|
|
13
|
+
The badge is an inline SVG by default; `attributionIcon` overrides it with
|
|
14
|
+
raw HTML or a mount function (a live component escape hatch — see its doc
|
|
15
|
+
and `zoomControlsMarkup.ts`'s matching `zoomControlIcons`, which this
|
|
16
|
+
mirrors).
|
|
17
|
+
|
|
18
|
+
@module
|
|
19
|
+
*/
|
|
20
|
+
import type { FeatureModule } from "./features.js";
|
|
21
|
+
export declare const attributionFeature: FeatureModule;
|
|
@@ -130,5 +130,5 @@ export declare function measureAxes(viz: Viz, inputs: AxisMeasureInputs, measure
|
|
|
130
130
|
bumps the line labels, and queues axis scenes for the emit phase.
|
|
131
131
|
Returns everything `plotEmit` needs to consume.
|
|
132
132
|
*/
|
|
133
|
-
export declare function renderAxes(viz: Viz, pCtx: PlotPaintContext): PlotMeasureResult;
|
|
133
|
+
export declare function renderAxes(viz: Viz, pCtx: PlotPaintContext, frozen?: PlotMeasureResult): PlotMeasureResult;
|
|
134
134
|
export {};
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
@module
|
|
18
18
|
*/
|
|
19
|
-
import type { Transform } from "@d3plus/render";
|
|
19
|
+
import type { ClipShape, Transform } from "@d3plus/render";
|
|
20
20
|
import type { VizInstance as Viz } from "../viz/vizTypes.js";
|
|
21
21
|
/**
|
|
22
22
|
Margin-adjusted chart-area dimensions. Replaces the pattern:
|
|
@@ -48,11 +48,17 @@ export declare function marginOriginTransform(viz: Viz): Transform;
|
|
|
48
48
|
y: this._margin.top + height / 2,
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
Used by Pie, Donut, RadialMatrix, Radar — every chart whose
|
|
52
|
-
lays out around a center point (polar / circular geometry).
|
|
51
|
+
Used by Pie, Donut, RadialMatrix, Radar, Chord — every chart whose
|
|
52
|
+
data lays out around a center point (polar / circular geometry).
|
|
53
53
|
|
|
54
54
|
Width and height are the margin-adjusted chart-area dimensions —
|
|
55
55
|
callers usually have them on hand from `chartBounds(viz)` or from
|
|
56
56
|
fields a stage stashed (e.g. `_pieWidth` / `_radialMatrixWidth`).
|
|
57
57
|
*/
|
|
58
58
|
export declare function centerChartTransform(viz: Viz, width: number, height: number): Transform;
|
|
59
|
+
/**
|
|
60
|
+
The chart area (the svg minus its margins) as a scene-space rect clip —
|
|
61
|
+
where zoomable content is clipped so pan/zoom can't spill it over the
|
|
62
|
+
legend, title, or timeline.
|
|
63
|
+
*/
|
|
64
|
+
export declare function chartAreaRect(viz: Viz): ClipShape;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Shared arrowhead geometry for edge charts (Network, Rings, Sankey).
|
|
3
|
+
|
|
4
|
+
Arrowheads are drawn as filled-triangle `path` scene nodes rather than SVG
|
|
5
|
+
`marker-end`, because d3plus renders to both SVG and Canvas and Canvas has no
|
|
6
|
+
marker support. Each chart computes the tip point + tangent angle from its own
|
|
7
|
+
edge geometry (edges terminate differently per chart) and calls `arrowNode`.
|
|
8
|
+
The triangle lives in the same content coordinate space as its edge, so it
|
|
9
|
+
pans/zooms and hover-dims in lockstep with the edge.
|
|
10
|
+
|
|
11
|
+
Chord doesn't use this module — its ribbons carry arrowheads via d3-chord's
|
|
12
|
+
`ribbonArrow`.
|
|
13
|
+
|
|
14
|
+
@module
|
|
15
|
+
*/
|
|
16
|
+
import type { DataPoint } from "@d3plus/data";
|
|
17
|
+
import type { SceneNode } from "@d3plus/render";
|
|
18
|
+
/** Which end(s) of an edge carry an arrowhead. `true` is equivalent to `"target"`. */
|
|
19
|
+
export type ArrowEndValue = boolean | "target" | "source" | "both";
|
|
20
|
+
/** The `arrows` config: a fixed value or a per-edge accessor. */
|
|
21
|
+
export type ArrowValue = ArrowEndValue | ((d: DataPoint, i: number) => ArrowEndValue);
|
|
22
|
+
/** Resolved per-edge arrow ends. */
|
|
23
|
+
export interface ArrowEnds {
|
|
24
|
+
source: boolean;
|
|
25
|
+
target: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** Normalize an `arrows` config value for one edge into `{source, target}` flags. */
|
|
28
|
+
export declare function arrowEnds(arrows: ArrowValue, d: DataPoint, i: number): ArrowEnds;
|
|
29
|
+
/**
|
|
30
|
+
SVG path `d` for a filled isosceles triangle whose tip is at `(x, y)`, pointing
|
|
31
|
+
along `angle` (radians), with `size` the tip-to-base length.
|
|
32
|
+
*/
|
|
33
|
+
export declare function arrowPathD(x: number, y: number, angle: number, size: number): string;
|
|
34
|
+
/**
|
|
35
|
+
Tip point + direction for a straight-edge arrowhead sitting at the boundary of
|
|
36
|
+
an endpoint node (radius `r`), pointing from `(fromX, fromY)` toward
|
|
37
|
+
`(toX, toY)`. `gap` insets the tip slightly off the node edge. Used by Network
|
|
38
|
+
(center-to-center links) and Rings' straight center-links.
|
|
39
|
+
*/
|
|
40
|
+
export declare function straightArrowTip(fromX: number, fromY: number, toX: number, toY: number, r: number, gap?: number): {
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
angle: number;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
Resolve the arrowhead size from the `arrowSize` config (a number or per-edge
|
|
47
|
+
accessor), falling back to a size derived from the edge's stroke width.
|
|
48
|
+
*/
|
|
49
|
+
export declare function arrowSizeFor(arrowSize: unknown, d: DataPoint, i: number, strokeWidth: number): number;
|
|
50
|
+
/**
|
|
51
|
+
Emit arrowhead nodes for a straight, center-to-center edge between two nodes
|
|
52
|
+
(radii `source.r`/`target.r`), insetting each tip to the node boundary.
|
|
53
|
+
Returns `[]` when `arrows` selects neither end. Used by Network and Rings'
|
|
54
|
+
straight center-links.
|
|
55
|
+
*/
|
|
56
|
+
export declare function straightEdgeArrows(opts: {
|
|
57
|
+
arrows: ArrowValue;
|
|
58
|
+
arrowSize: unknown;
|
|
59
|
+
strokeWidth?: number;
|
|
60
|
+
datum: DataPoint;
|
|
61
|
+
i: number;
|
|
62
|
+
keyPrefix: string;
|
|
63
|
+
fill?: string;
|
|
64
|
+
source: {
|
|
65
|
+
x: number;
|
|
66
|
+
y: number;
|
|
67
|
+
r?: number;
|
|
68
|
+
};
|
|
69
|
+
target: {
|
|
70
|
+
x: number;
|
|
71
|
+
y: number;
|
|
72
|
+
r?: number;
|
|
73
|
+
};
|
|
74
|
+
}): SceneNode[];
|
|
75
|
+
/** Inputs for a single arrowhead scene node. */
|
|
76
|
+
export interface ArrowNodeOpts {
|
|
77
|
+
key: string | number;
|
|
78
|
+
datum: DataPoint;
|
|
79
|
+
x: number;
|
|
80
|
+
y: number;
|
|
81
|
+
/** Direction the arrow points, in radians. */
|
|
82
|
+
angle: number;
|
|
83
|
+
size: number;
|
|
84
|
+
fill?: string;
|
|
85
|
+
opacity?: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
Build one arrowhead scene node. `interactive: false` so the edge path owns
|
|
89
|
+
hit-testing, and the same `datum` as its edge so the hover-dim pass keeps the
|
|
90
|
+
arrow paired with its edge.
|
|
91
|
+
*/
|
|
92
|
+
export declare function arrowNode(opts: ArrowNodeOpts): SceneNode;
|
|
@@ -73,6 +73,17 @@ export declare function paintFromShapeConfig(sc: Record<string, unknown>, d: Dat
|
|
|
73
73
|
opacity?: number;
|
|
74
74
|
vectorEffect?: "none" | "non-scaling-stroke";
|
|
75
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
Resolve a layout node's `drawLabel` text, unwrapping the `{data, i}`
|
|
78
|
+
wrapper the emit-side layout nodes carry (Network/Rings/Sankey/Tree
|
|
79
|
+
convention — same unwrap `paintFromShapeConfig` callers already do).
|
|
80
|
+
*/
|
|
81
|
+
export declare function drawNodeLabel(viz: {
|
|
82
|
+
_drawLabel: (d: DataPoint, i: number) => string;
|
|
83
|
+
}, d: DataPoint & {
|
|
84
|
+
data?: DataPoint;
|
|
85
|
+
i?: number;
|
|
86
|
+
}, i: number): string;
|
|
76
87
|
/**
|
|
77
88
|
Apply a shape-config object to a chart-specific shape key, returning the
|
|
78
89
|
configPrep-massaged object suitable for `.config(...)`. Equivalent to
|
|
@@ -22,9 +22,13 @@
|
|
|
22
22
|
it's the documented home for the imperative half of v4 zoom.
|
|
23
23
|
*/
|
|
24
24
|
import type { VizInstance as Viz } from "../viz/vizTypes.js";
|
|
25
|
-
export type ZoomDomKind = "network" | "geomap";
|
|
25
|
+
export type ZoomDomKind = "network" | "geomap" | "generic";
|
|
26
26
|
interface SetupOpts {
|
|
27
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
"network" or "geomap" — picks the css class + behavior tweaks. "generic"
|
|
29
|
+
is the bare surface (zoom group + brush host) every other chart gets
|
|
30
|
+
when `zoom` is enabled.
|
|
31
|
+
*/
|
|
28
32
|
kind: ZoomDomKind;
|
|
29
33
|
/** Chart-area width (margin-adjusted). */
|
|
30
34
|
width: number;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SceneNode } from "@d3plus/render";
|
|
2
2
|
import type { VizContext } from "../pipeline/stages.js";
|
|
3
|
+
import type { VizInstance } from "../viz/vizTypes.js";
|
|
3
4
|
/** A margin claim, in pixels along each side. Unclaimed sides default to 0. */
|
|
4
5
|
export interface MarginClaim {
|
|
5
6
|
top?: number;
|
|
@@ -102,6 +103,36 @@ export declare function sanitizePosition(raw: unknown): PanelPosition;
|
|
|
102
103
|
the math first, then improve.
|
|
103
104
|
*/
|
|
104
105
|
export declare function runLayout(ctx: VizContext, features: FeatureModule[], baseMargin?: Required<MarginClaim>): LayoutResult;
|
|
106
|
+
/**
|
|
107
|
+
How far content starting `top` px down the chart, whose right edge sits
|
|
108
|
+
`right` px in from the chart's right edge, must pull in its right edge to
|
|
109
|
+
clear the zoom-control panel pinned to the chart's top-right corner. Zero
|
|
110
|
+
when the chart shows no controls or the content starts below them.
|
|
111
|
+
*/
|
|
112
|
+
export declare function zoomControlsInset(viz: VizInstance, top: number, right: number): number;
|
|
113
|
+
/**
|
|
114
|
+
The left-side mirror of `zoomControlsInset`: how far content starting
|
|
115
|
+
`top` px down the chart, whose left edge sits `left` px in from the
|
|
116
|
+
chart's left edge, must pull in to clear the shared top-left controls
|
|
117
|
+
panel (back / table-view / search). Zero when nothing is showing there
|
|
118
|
+
or content starts below the panel's height.
|
|
119
|
+
*/
|
|
120
|
+
export declare function topLeftControlsInset(viz: VizInstance, top: number, left: number): number;
|
|
121
|
+
/**
|
|
122
|
+
The combined left+right corner-panel insets for content starting `top`
|
|
123
|
+
px down the chart, plus the single symmetric amount CENTERED content
|
|
124
|
+
should inset both sides by to stay centered on the full chart width even
|
|
125
|
+
when only one corner has something to avoid (the larger of the two —
|
|
126
|
+
see `textBlockLayout`'s doc comment for why). Shared by `textBlockLayout`
|
|
127
|
+
(title/subtitle/total) and the legend's own top-position layout
|
|
128
|
+
(`featuresLegend.ts`), which independently needed this exact same
|
|
129
|
+
"combine the two corners' insets" math before this existed.
|
|
130
|
+
*/
|
|
131
|
+
export declare function cornerInsets(viz: VizInstance, top: number, left: number, right: number): {
|
|
132
|
+
left: number;
|
|
133
|
+
right: number;
|
|
134
|
+
symmetric: number;
|
|
135
|
+
};
|
|
105
136
|
/**
|
|
106
137
|
Title as a FeatureModule. Uses `_titleClass._textData()` for height
|
|
107
138
|
(pure compute, no DOM) and returns the margin claim explicitly.
|
|
@@ -109,12 +140,6 @@ export declare function runLayout(ctx: VizContext, features: FeatureModule[], ba
|
|
|
109
140
|
export declare const titleFeature: FeatureModule;
|
|
110
141
|
/** Converts `drawSubtitle.ts` to a FeatureModule. Mirrors titleFeature. */
|
|
111
142
|
export declare const subtitleFeature: FeatureModule;
|
|
112
|
-
/**
|
|
113
|
-
Converts `drawBack.ts` to a FeatureModule. Visible only when there are
|
|
114
|
-
drill-down history entries; emits a "← Back" TextNode at the chart's
|
|
115
|
-
top-left and claims its line height + padding × 2 from `margin.top`.
|
|
116
|
-
*/
|
|
117
|
-
export declare const backFeature: FeatureModule;
|
|
118
143
|
export { legendFeature } from "./featuresLegend.js";
|
|
119
144
|
/**
|
|
120
145
|
Converts `drawTimeline.ts` to a FeatureModule.
|
|
@@ -133,17 +158,7 @@ export declare const timelineFeature: FeatureModule;
|
|
|
133
158
|
claims margin along its position side.
|
|
134
159
|
*/
|
|
135
160
|
export declare const colorScaleFeature: FeatureModule;
|
|
136
|
-
|
|
137
|
-
Converts `drawAttribution.ts` to a FeatureModule.
|
|
138
|
-
|
|
139
|
-
Attribution is an HTML `<div>` overlay positioned absolutely outside the SVG
|
|
140
|
-
plane — it doesn't fit naturally as a SceneNode in the chart scene graph.
|
|
141
|
-
Rather than encode an HTML overlay into the scene graph, this feature runs
|
|
142
|
-
the DOM-creating side effect imperatively from inside `layout()`, so
|
|
143
|
-
invocation is funneled through `runLayout` for consistency with the
|
|
144
|
-
other features. It claims zero margin and emits no panel.
|
|
145
|
-
*/
|
|
146
|
-
export declare const attributionFeature: FeatureModule;
|
|
161
|
+
export { attributionFeature } from "./attributionFeature.js";
|
|
147
162
|
/**
|
|
148
163
|
Converts `drawTotal.ts` to a FeatureModule. Slightly different from title/
|
|
149
164
|
subtitle: the text comes from `sum()` over the filtered data when `_total`
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
+
import type { DataPoint } from "@d3plus/data";
|
|
1
2
|
import type { FeatureModule } from "./features.js";
|
|
3
|
+
import type { VizInstance } from "../viz/vizTypes.js";
|
|
4
|
+
interface LegendData {
|
|
5
|
+
legendData: DataPoint[];
|
|
6
|
+
legendKey: (d: DataPoint, i: number) => string;
|
|
7
|
+
getAttr: (d: DataPoint, i: number, attr: string) => string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
Rolls filtered legend data up by paint attributes, sorts it, and computes
|
|
11
|
+
`viz._legendDepth` (the lowest groupBy level whose values are unique).
|
|
12
|
+
Returns the `legendData` array plus the `fill`/`getAttr` accessors the
|
|
13
|
+
render step reuses.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildLegendData(viz: VizInstance): LegendData;
|
|
2
16
|
/**
|
|
3
17
|
Converts `drawLegend.ts` to a FeatureModule.
|
|
4
18
|
|
|
@@ -10,3 +24,4 @@ import type { FeatureModule } from "./features.js";
|
|
|
10
24
|
scene composition for Legend happens via Viz.toScene's `components` array.
|
|
11
25
|
*/
|
|
12
26
|
export declare const legendFeature: FeatureModule;
|
|
27
|
+
export {};
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
destructure block below for the full schema.
|
|
12
12
|
*/
|
|
13
13
|
import type { DataPoint } from "@d3plus/data";
|
|
14
|
-
import type { SceneNode } from "@d3plus/render";
|
|
14
|
+
import type { ClipShape, SceneNode } from "@d3plus/render";
|
|
15
15
|
import type Axis from "../../components/Axis/Axis.js";
|
|
16
16
|
import type { VizInstance as Viz } from "../viz/vizTypes.js";
|
|
17
17
|
/** An axis position function: maps a domain value to a pixel coordinate. */
|
|
@@ -155,6 +155,8 @@ export interface PlotPaintContext {
|
|
|
155
155
|
barLabels: string[];
|
|
156
156
|
showLineLabels: boolean;
|
|
157
157
|
stackGroup: unknown;
|
|
158
|
+
/** Per-axis config a zoom repaint layers over each production axis (see `Plot/plotZoom.ts`). */
|
|
159
|
+
zoomAxes?: Partial<Record<"x" | "x2" | "y" | "y2", Record<string, unknown>>>;
|
|
158
160
|
}
|
|
159
161
|
/**
|
|
160
162
|
Result of the MEASURE phase of plotPaint. Captures everything the EMIT
|
|
@@ -215,7 +217,9 @@ export interface PlotMeasureResult {
|
|
|
215
217
|
Returns the flat `SceneNode[]` array that the caller (`Plot._paint`)
|
|
216
218
|
merges into `_chartScene`.
|
|
217
219
|
*/
|
|
218
|
-
export declare function plotEmit(viz: Viz, pCtx: PlotPaintContext, mCtx: PlotMeasureResult): SceneNode[];
|
|
220
|
+
export declare function plotEmit(viz: Viz, pCtx: PlotPaintContext, mCtx: PlotMeasureResult, clip?: ClipShape): SceneNode[];
|
|
221
|
+
/** Key of the group `plotEmit` wraps a zoomable plot's non-axis content in. */
|
|
222
|
+
export declare const PLOT_ZOOM_CONTENT_KEY = "plot-zoom-content";
|
|
219
223
|
/**
|
|
220
224
|
Plot paint phase as a free function — orchestrates the axis render +
|
|
221
225
|
EMIT.
|
|
@@ -231,3 +235,12 @@ export declare function plotEmit(viz: Viz, pCtx: PlotPaintContext, mCtx: PlotMea
|
|
|
231
235
|
@param pCtx Cross-phase locals produced by `Plot._draw`.
|
|
232
236
|
*/
|
|
233
237
|
export declare function plotPaint(viz: Viz, pCtx: PlotPaintContext): SceneNode[];
|
|
238
|
+
/**
|
|
239
|
+
`plotPaint` that also returns the solved axis layout, and accepts a
|
|
240
|
+
`frozen` layout to repaint against (plus a clip for the plot content) —
|
|
241
|
+
how a zoom repaints the plot with rescaled domains.
|
|
242
|
+
*/
|
|
243
|
+
export declare function plotPaintMeasured(viz: Viz, pCtx: PlotPaintContext, frozen?: PlotMeasureResult, clip?: ClipShape): {
|
|
244
|
+
nodes: SceneNode[];
|
|
245
|
+
layout: PlotMeasureResult;
|
|
246
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Automatic maximum zoom scale (#85): how far a chart can zoom depends on
|
|
3
|
+
what it draws. A network of a few large nodes needs little zoom, while a
|
|
4
|
+
detailed map should be able to zoom all the way into its smallest path.
|
|
5
|
+
|
|
6
|
+
@module
|
|
7
|
+
*/
|
|
8
|
+
import type { SceneNode } from "@d3plus/render";
|
|
9
|
+
/**
|
|
10
|
+
The zoom scale at which the chart's smallest data shape fills the chart
|
|
11
|
+
area (less `padding` on each side, matching `zoomToBounds`), floored at 1.
|
|
12
|
+
|
|
13
|
+
Data shapes are the top-level datum-bearing nodes of `_chartScene` (a
|
|
14
|
+
Line/Area series is measured per segment — see `nodeSizes`). Chart
|
|
15
|
+
decorations (axes, gridlines, radar spokes, …) are nested in groups, text
|
|
16
|
+
labels scale with the shapes they annotate, and `::hit` nodes duplicate
|
|
17
|
+
the geometry of the shape they belong to, so none of those are measured.
|
|
18
|
+
|
|
19
|
+
@param nodes The chart's `_chartScene`.
|
|
20
|
+
@param width Chart-area width.
|
|
21
|
+
@param height Chart-area height.
|
|
22
|
+
@param padding Pixel padding kept around a shape zoomed to fill the area.
|
|
23
|
+
@param baseScale Any scale the chart's own transform already applies.
|
|
24
|
+
*/
|
|
25
|
+
export declare function autoZoomMax(nodes: SceneNode[], width: number, height: number, padding: number, baseScale?: number): number;
|
|
@@ -2,6 +2,7 @@ export { default as AreaPlot } from "./AreaPlot/index.js";
|
|
|
2
2
|
export { default as BarChart } from "./BarChart/index.js";
|
|
3
3
|
export { default as BoxWhisker } from "./BoxWhisker/index.js";
|
|
4
4
|
export { default as BumpChart } from "./BumpChart/index.js";
|
|
5
|
+
export { default as Chord } from "./Chord/index.js";
|
|
5
6
|
export { default as Donut } from "./Donut/index.js";
|
|
6
7
|
export { default as Geomap } from "./Geomap/index.js";
|
|
7
8
|
export { default as LinePlot } from "./LinePlot/index.js";
|
|
@@ -15,14 +15,17 @@
|
|
|
15
15
|
1. `viz._preDraw()` — data filtering + legend-data + drawDepth
|
|
16
16
|
2. `viz._draw()` — chart-specific layout + scene absorption
|
|
17
17
|
3. `zoomControls(viz)` — zoom HTML overlay (architectural carve-out)
|
|
18
|
-
4. `
|
|
19
|
-
5. `
|
|
18
|
+
4. `minimapFeature.layout(viz)` — zoomed-chart viewport indicator
|
|
19
|
+
5. `topLeftControlsFeature.layout(viz)` — back/table-view/search panel
|
|
20
|
+
6. `attributionFeature.layout(viz)` — bottom-right attribution panel
|
|
21
|
+
7. `tableViewFeature.layout(viz)` — chart-sized data-table overlay
|
|
22
|
+
8. `viz._drawSceneToTarget()` — paint scene via SvgRenderer/CanvasRenderer
|
|
20
23
|
|
|
21
24
|
Future work:
|
|
22
25
|
- Extract a `ResolvedSpec` so step 1 takes (config) not (this).
|
|
23
26
|
- Decouple step 2 so it takes (ctx) not (this); stages already follow
|
|
24
27
|
this pattern but `_draw` itself doesn't.
|
|
25
|
-
- Replace step
|
|
28
|
+
- Replace step 8's `this._sceneRenderer` slot with a returned handle
|
|
26
29
|
so callers can pick/destroy/diff without instance lookup.
|
|
27
30
|
|
|
28
31
|
@param viz A Viz instance (or any subclass: Plot, Treemap, Pack, …).
|