@d3plus/core 4.9.0 → 4.10.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/es/internal.js +3 -1
- package/es/src/charts/BoxWhisker/index.js +73 -4
- package/es/src/charts/BoxWhisker/outliers.js +68 -0
- package/es/src/charts/BoxWhisker/summary.js +83 -0
- package/es/src/charts/BoxWhisker/tooltip.js +122 -0
- package/es/src/charts/Bullet/index.js +2 -1
- package/es/src/charts/BumpChart/index.js +5 -0
- package/es/src/charts/Calendar/index.js +2 -1
- package/es/src/charts/Candlestick/aggregate.js +11 -1
- package/es/src/charts/Candlestick/index.js +5 -5
- package/es/src/charts/Chord/index.js +3 -2
- package/es/src/charts/Funnel/index.js +2 -1
- package/es/src/charts/Gauge/index.js +2 -1
- package/es/src/charts/Geomap/index.js +9 -3
- package/es/src/charts/Histogram/index.js +5 -1
- package/es/src/charts/Matrix/index.js +3 -2
- package/es/src/charts/Network/index.js +9 -4
- package/es/src/charts/Pack/index.js +2 -1
- package/es/src/charts/Pie/index.js +2 -1
- package/es/src/charts/Plot/axisHover.js +180 -0
- package/es/src/charts/Plot/axisHoverAnchors.js +174 -0
- package/es/src/charts/Plot/axisHoverScene.js +202 -0
- package/es/src/charts/Plot/barHitArea.js +81 -0
- package/es/src/charts/Plot/barLabelFit.js +123 -0
- package/es/src/charts/Plot/barWidth.js +2 -2
- package/es/src/charts/Plot/confidenceConfig.js +2 -2
- package/es/src/charts/Plot/draw.js +6 -2
- package/es/src/charts/Plot/index.js +25 -6
- package/es/src/charts/Plot/labelPlacement.js +9 -1
- package/es/src/charts/Plot/openDomainEnds.js +2 -5
- package/es/src/charts/Plot/pipeline.js +5 -3
- package/es/src/charts/Plot/pipelineAxisLayout.js +38 -8
- package/es/src/charts/Plot/pipelineDomains.js +7 -3
- package/es/src/charts/Plot/pipelineLineLabels.js +1 -1
- package/es/src/charts/Plot/plotInit.js +15 -0
- package/es/src/charts/Plot/plotZoom.js +15 -6
- package/es/src/charts/Plot/shapeDefaults.js +4 -4
- package/es/src/charts/Plot/sharedHoverScene.js +50 -31
- package/es/src/charts/Plot/sharedTooltip.js +19 -7
- package/es/src/charts/Plot/stackHelpers.js +13 -1
- package/es/src/charts/Plot/stackShareTooltip.js +9 -4
- package/es/src/charts/Plot/stackThreshold.js +154 -0
- package/es/src/charts/PolarArea/index.js +3 -2
- package/es/src/charts/Priestley/index.js +3 -2
- package/es/src/charts/Pyramid/index.js +4 -2
- package/es/src/charts/Radar/index.js +3 -2
- package/es/src/charts/RadialBar/index.js +2 -1
- package/es/src/charts/RadialMatrix/index.js +3 -2
- package/es/src/charts/Rings/index.js +5 -3
- package/es/src/charts/Sankey/index.js +3 -2
- package/es/src/charts/Treemap/applyLayout.js +14 -1
- package/es/src/charts/Treemap/emit.js +8 -2
- package/es/src/charts/Treemap/emitGroupHeaders.js +104 -0
- package/es/src/charts/Treemap/groupHeaders.js +95 -0
- package/es/src/charts/Treemap/index.js +15 -2
- package/es/src/charts/Treemap/thresholdFunction.js +11 -9
- package/es/src/charts/Waffle/index.js +4 -2
- package/es/src/charts/Waffle/tooltip.js +6 -2
- package/es/src/charts/Waterfall/index.js +4 -2
- package/es/src/charts/definition/makeChart.js +12 -5
- package/es/src/charts/drawSteps/saveChart.js +176 -0
- package/es/src/charts/drawSteps/saveControl.js +148 -0
- package/es/src/charts/drawSteps/saveControlMarkup.js +104 -0
- package/es/src/charts/drawSteps/tableViewMarkup.js +1 -1
- package/es/src/charts/drawSteps/topLeftControls.js +3 -1
- package/es/src/charts/drawSteps/topLeftControlsMarkup.js +1 -1
- package/es/src/charts/events/click.shape.js +30 -1
- package/es/src/charts/events/mouseenter.js +9 -0
- package/es/src/charts/events/mousemove.legend.js +3 -0
- package/es/src/charts/events/mousemove.shape.js +7 -2
- package/es/src/charts/facet/facetConfig.js +2 -2
- package/es/src/charts/facet/facetData.js +2 -2
- package/es/src/charts/features/axes.js +7 -6
- package/es/src/charts/features/axesFinal.js +23 -3
- package/es/src/charts/features/axesMeasure.js +54 -2
- package/es/src/charts/features/colorScaleBucket.js +17 -0
- package/es/src/charts/features/colorScaleHover.js +69 -0
- package/es/src/charts/features/features.js +13 -1
- package/es/src/charts/features/featuresColorScale.js +44 -4
- package/es/src/charts/features/featuresLegend.js +6 -8
- package/es/src/charts/features/plotPaint.js +4 -4
- package/es/src/charts/features/shapeEmit.js +23 -2
- package/es/src/charts/features/shareKey.js +15 -0
- package/es/src/charts/features/thresholdMembers.js +71 -0
- package/es/src/charts/helpers/densityChart.js +3 -1
- package/es/src/charts/helpers/valueTitle.js +6 -3
- package/es/src/charts/partition/chartFields.js +4 -3
- package/es/src/charts/partition/hierarchy.js +2 -0
- package/es/src/charts/pipeline/preDrawData.js +31 -10
- package/es/src/charts/pipeline/vizDraw.js +40 -29
- package/es/src/charts/pipeline/vizPreDraw.js +24 -15
- package/es/src/charts/viz/Viz.js +43 -8
- package/es/src/charts/viz/VizBase.js +32 -12
- package/es/src/charts/viz/dataPoller.js +52 -0
- package/es/src/charts/viz/groupRow.js +35 -0
- package/es/src/charts/viz/interactionOpacity.js +19 -5
- package/es/src/charts/viz/missingFields.js +122 -0
- package/es/src/charts/viz/reportHandlerError.js +10 -0
- package/es/src/charts/viz/shapeClassTargets.js +18 -2
- package/es/src/charts/viz/simpleHover.js +2 -0
- package/es/src/charts/viz/vizClassName.js +31 -0
- package/es/src/charts/viz/vizDataPolling.js +167 -0
- package/es/src/charts/viz/vizDefaults.js +66 -0
- package/es/src/charts/viz/vizFields.js +18 -2
- package/es/src/charts/viz/vizRender.js +8 -2
- package/es/src/components/Axis/Axis.js +28 -0
- package/es/src/components/Axis/axisDefaults.js +3 -1
- package/es/src/components/Axis/axisLabelAngle.js +175 -0
- package/es/src/components/Axis/axisLabelThinning.js +13 -4
- package/es/src/components/Axis/axisLayout.js +86 -19
- package/es/src/components/Axis/axisLayoutLabels.js +66 -13
- package/es/src/components/Axis/axisLayoutScale.js +3 -0
- package/es/src/components/Axis/axisRender.js +38 -9
- package/es/src/components/Axis/axisRounding.js +15 -4
- package/es/src/components/Axis/axisSlantWrap.js +39 -0
- package/es/src/components/Axis/powTicks.js +73 -0
- package/es/src/components/ColorScale/ColorScale.js +28 -28
- package/es/src/components/ColorScale/bucketBounds.js +35 -0
- package/es/src/components/ColorScale/colorScaleHoverMark.js +327 -0
- package/es/src/components/ColorScale/colorScaleRender.js +25 -1
- package/es/src/components/ColorScale/colorScaleScale.js +15 -9
- package/es/src/components/ColorScale/colorScaleType.js +26 -0
- package/es/src/components/TextBox.js +2 -0
- package/es/src/components/Timeline/Timeline.js +43 -52
- package/es/src/components/Timeline/brushSpan.js +78 -0
- package/es/src/components/Timeline/timelineConfig.js +7 -0
- package/es/src/components/Timeline/timelineRender.js +44 -6
- package/es/src/components/Tooltip.js +13 -8
- package/es/src/shapes/Box.js +66 -79
- package/es/src/shapes/boxOutlierShape.js +19 -0
- package/es/src/shapes/boxStats.js +35 -0
- package/es/src/shapes/boxStyle.js +78 -0
- package/es/src/shapes/boxSummary.js +174 -0
- package/es/src/shapes/shapeStandalone.js +2 -0
- package/es/src/utils/BaseClass.js +19 -0
- package/es/src/utils/className.js +78 -0
- package/es/src/utils/configWarnings.js +25 -0
- package/es/src/utils/fieldAccessor.js +31 -0
- package/es/src/utils/paintComponentScene.js +2 -0
- package/package.json +10 -9
- package/types/index.d.ts +3 -1
- package/types/internal.d.ts +3 -1
- package/types/src/charts/BoxWhisker/index.d.ts +3 -1
- package/types/src/charts/BoxWhisker/outliers.d.ts +25 -0
- package/types/src/charts/BoxWhisker/summary.d.ts +39 -0
- package/types/src/charts/BoxWhisker/tooltip.d.ts +36 -0
- package/types/src/charts/Candlestick/aggregate.d.ts +6 -0
- package/types/src/charts/Plot/axisHover.d.ts +68 -0
- package/types/src/charts/Plot/axisHoverAnchors.d.ts +88 -0
- package/types/src/charts/Plot/axisHoverScene.d.ts +88 -0
- package/types/src/charts/Plot/barHitArea.d.ts +59 -0
- package/types/src/charts/Plot/barLabelFit.d.ts +81 -0
- package/types/src/charts/Plot/index.d.ts +13 -0
- package/types/src/charts/Plot/labelPlacement.d.ts +5 -0
- package/types/src/charts/Plot/plotInit.d.ts +9 -2
- package/types/src/charts/Plot/plotZoom.d.ts +2 -0
- package/types/src/charts/Plot/sharedHoverScene.d.ts +3 -3
- package/types/src/charts/Plot/sharedTooltip.d.ts +11 -4
- package/types/src/charts/Plot/stackHelpers.d.ts +5 -0
- package/types/src/charts/Plot/stackThreshold.d.ts +75 -0
- package/types/src/charts/Treemap/emit.d.ts +2 -1
- package/types/src/charts/Treemap/emitGroupHeaders.d.ts +16 -0
- package/types/src/charts/Treemap/groupHeaders.d.ts +91 -0
- package/types/src/charts/Treemap/index.d.ts +2 -0
- package/types/src/charts/Treemap/thresholdFunction.d.ts +5 -2
- package/types/src/charts/definition/ChartDefinition.d.ts +14 -2
- package/types/src/charts/definition/makeChart.d.ts +4 -3
- package/types/src/charts/drawSteps/saveChart.d.ts +47 -0
- package/types/src/charts/drawSteps/saveControl.d.ts +9 -0
- package/types/src/charts/drawSteps/saveControlMarkup.d.ts +44 -0
- package/types/src/charts/drawSteps/tableViewMarkup.d.ts +1 -0
- package/types/src/charts/drawSteps/topLeftControls.d.ts +1 -1
- package/types/src/charts/drawSteps/topLeftControlsMarkup.d.ts +1 -1
- package/types/src/charts/facet/facetData.d.ts +1 -1
- package/types/src/charts/features/axesMeasure.d.ts +9 -1
- package/types/src/charts/features/colorScaleBucket.d.ts +9 -0
- package/types/src/charts/features/colorScaleHover.d.ts +32 -0
- package/types/src/charts/features/features.d.ts +8 -0
- package/types/src/charts/features/plotPaint.d.ts +2 -0
- package/types/src/charts/features/shapeEmit.d.ts +2 -0
- package/types/src/charts/features/shareKey.d.ts +9 -0
- package/types/src/charts/features/thresholdMembers.d.ts +38 -0
- package/types/src/charts/helpers/valueTitle.d.ts +4 -2
- package/types/src/charts/pipeline/stages.d.ts +2 -0
- package/types/src/charts/pipeline/vizDraw.d.ts +8 -3
- package/types/src/charts/pipeline/vizPreDraw.d.ts +3 -2
- package/types/src/charts/viz/Viz.d.ts +28 -4
- package/types/src/charts/viz/VizBase.d.ts +12 -3
- package/types/src/charts/viz/dataPoller.d.ts +28 -0
- package/types/src/charts/viz/groupRow.d.ts +24 -0
- package/types/src/charts/viz/interactionOpacity.d.ts +3 -1
- package/types/src/charts/viz/missingFields.d.ts +57 -0
- package/types/src/charts/viz/reportHandlerError.d.ts +7 -0
- package/types/src/charts/viz/shapeClassTargets.d.ts +6 -0
- package/types/src/charts/viz/simpleHover.d.ts +2 -1
- package/types/src/charts/viz/vizClassName.d.ts +23 -0
- package/types/src/charts/viz/vizDataPolling.d.ts +48 -0
- package/types/src/charts/viz/vizDefaults.d.ts +49 -0
- package/types/src/charts/viz/vizFields.d.ts +15 -0
- package/types/src/charts/viz/vizTypes.d.ts +33 -1
- package/types/src/components/Axis/Axis.d.ts +36 -8
- package/types/src/components/Axis/axisLabelAngle.d.ts +110 -0
- package/types/src/components/Axis/axisLabelThinning.d.ts +3 -7
- package/types/src/components/Axis/axisLayout.d.ts +5 -0
- package/types/src/components/Axis/axisLayoutLabels.d.ts +13 -0
- package/types/src/components/Axis/axisRounding.d.ts +6 -3
- package/types/src/components/Axis/axisSlantWrap.d.ts +22 -0
- package/types/src/components/Axis/powTicks.d.ts +29 -0
- package/types/src/components/ColorScale/ColorScale.d.ts +13 -0
- package/types/src/components/ColorScale/bucketBounds.d.ts +14 -0
- package/types/src/components/ColorScale/colorScaleHoverMark.d.ts +86 -0
- package/types/src/components/ColorScale/colorScaleScale.d.ts +3 -0
- package/types/src/components/ColorScale/colorScaleType.d.ts +17 -0
- package/types/src/components/Timeline/brushSpan.d.ts +41 -0
- package/types/src/components/Timeline/timelineConfig.d.ts +6 -0
- package/types/src/components/Timeline/timelineRender.d.ts +8 -0
- package/types/src/components/Tooltip.d.ts +8 -0
- package/types/src/shapes/Box.d.ts +1 -8
- package/types/src/shapes/boxOutlierShape.d.ts +9 -0
- package/types/src/shapes/boxStats.d.ts +19 -0
- package/types/src/shapes/boxStyle.d.ts +25 -0
- package/types/src/shapes/boxSummary.d.ts +66 -0
- package/types/src/shapes/emitLabels.d.ts +1 -1
- package/types/src/shapes/shapeConfig.d.ts +42 -4
- package/types/src/utils/BaseClass.d.ts +23 -0
- package/types/src/utils/D3Scale.d.ts +3 -0
- package/types/src/utils/D3plusConfig.d.ts +261 -5
- package/types/src/utils/className.d.ts +64 -0
- package/types/src/utils/configWarnings.d.ts +21 -2
- package/types/src/utils/fieldAccessor.d.ts +24 -0
- package/types/src/utils/index.d.ts +1 -1
- package/types/src/utils/paintComponentScene.d.ts +3 -1
- package/umd/d3plus-core.full.js +6405 -1068
- package/umd/d3plus-core.full.min.js +2 -2
- package/umd/d3plus-core.js +5328 -1002
- package/umd/d3plus-core.min.js +2 -2
|
@@ -15,11 +15,14 @@ export interface ThresholdInputs {
|
|
|
15
15
|
threshold: (branchData: DataPoint[]) => number;
|
|
16
16
|
/** Per-datum value accessor compared against `threshold * totalSum`. */
|
|
17
17
|
thresholdKey: (d: DataPoint) => number;
|
|
18
|
+
/** Names each bucketed item in the bucket's member list (default: its id). */
|
|
19
|
+
label?: (d: DataPoint, i: number) => string;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
Walks `data` to `drawDepth` and merges entries whose `thresholdKey`
|
|
21
23
|
value falls below `threshold(branchData) * totalSum` into a single
|
|
22
|
-
aggregated row at that depth
|
|
23
|
-
|
|
24
|
+
aggregated row at that depth, listing them (largest first) under
|
|
25
|
+
`MEMBERS_KEY`. A lone entry under the threshold stays as itself: a
|
|
26
|
+
bucket needs two. Returns the kept set; original `data` is not mutated.
|
|
24
27
|
*/
|
|
25
28
|
export declare function thresholdFunction(data: DataPoint[], inputs: ThresholdInputs): DataPoint[];
|
|
@@ -53,6 +53,12 @@ interface ChartDefinitionBase {
|
|
|
53
53
|
chart has no room to offer.
|
|
54
54
|
*/
|
|
55
55
|
insetRegion?: (viz: VizInstance) => InsetRegion | null;
|
|
56
|
+
/**
|
|
57
|
+
Optional shape a colorScale row draws as, when it isn't the row's
|
|
58
|
+
`shape`: the `shapeConfig` key the colorScale's bucket swatches take
|
|
59
|
+
their stroke and opacity from (a Geomap row drawn as a topojson Path).
|
|
60
|
+
*/
|
|
61
|
+
colorScaleShape?: (viz: VizInstance, d: DataPoint, i: number) => string;
|
|
56
62
|
/**
|
|
57
63
|
Optional small-multiples hooks (see `facet/facetConfig.ts`): the panel
|
|
58
64
|
aspect the chart reads best at, and for charts with scales, how panels
|
|
@@ -60,8 +66,14 @@ interface ChartDefinitionBase {
|
|
|
60
66
|
panel drawn the way the whole chart is.
|
|
61
67
|
*/
|
|
62
68
|
facet?: FacetHooks;
|
|
63
|
-
/**
|
|
64
|
-
|
|
69
|
+
/**
|
|
70
|
+
Optional pure threshold algorithm (replaces the base chart's
|
|
71
|
+
`_thresholdFunction`): returns the drawn rows `data` with small items
|
|
72
|
+
bucketed. `all` holds every row they were drawn from, legend-hidden
|
|
73
|
+
ones included. The legend's rows run through it too, so the legend
|
|
74
|
+
shows the bucket rather than the items it holds.
|
|
75
|
+
*/
|
|
76
|
+
thresholdFunction?: (viz: VizInstance, data: unknown[], all?: unknown[]) => unknown[];
|
|
65
77
|
/**
|
|
66
78
|
Optional chart-specific `_chartTransform` builder. Receives the viz
|
|
67
79
|
after the layout stage runs; returns the transform applied to the
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
The class is identical for every chart: its constructor runs
|
|
6
6
|
`applyDefinition(this, def)`, its `_draw` runs the shared Viz pipeline
|
|
7
7
|
then the chart's own layout stage via `runChartDraw`, and its
|
|
8
|
-
`_thresholdFunction` / `_sizeLegendScale` / `_insetRegion`
|
|
9
|
-
`
|
|
10
|
-
|
|
8
|
+
`_thresholdFunction` / `_thresholdLegend` / `_sizeLegendScale` / `_insetRegion` /
|
|
9
|
+
`_colorScaleShape` delegate to `def.thresholdFunction` /
|
|
10
|
+
`def.sizeLegendScale` / `def.insetRegion` / `def.colorScaleShape` if
|
|
11
|
+
present (else to the base chart's), `_facetHooks` layers `def.facet` over the base chart's, and
|
|
11
12
|
`toScene` passes the base chart's scene through `def.decorateScene`.
|
|
12
13
|
|
|
13
14
|
A chart's `index.ts` becomes literally `export default makeChart(def)`.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { SaveFormat } from "../../utils/D3plusConfig.js";
|
|
2
|
+
import type Viz from "../viz/Viz.js";
|
|
3
|
+
/** Every format the download button can save, in its default menu order. */
|
|
4
|
+
export declare const SAVE_FORMATS: SaveFormat[];
|
|
5
|
+
/** The valid, de-duplicated formats in `value`, or every format when `value` isn't an array. */
|
|
6
|
+
export declare function saveFormats(value: unknown): SaveFormat[];
|
|
7
|
+
/**
|
|
8
|
+
A filename (without extension) from a title: markup and characters that
|
|
9
|
+
file systems reject are dropped, whitespace collapsed, and the result
|
|
10
|
+
capped at 100 characters. `"download"` when nothing is left.
|
|
11
|
+
*/
|
|
12
|
+
export declare function saveFilename(title: unknown): string;
|
|
13
|
+
export interface ResolvedSaveConfig {
|
|
14
|
+
filename: string;
|
|
15
|
+
formats: SaveFormat[];
|
|
16
|
+
background: string | false;
|
|
17
|
+
callback?: (error?: Error) => void;
|
|
18
|
+
renderOptions: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/** `saveControlConfig` with its defaults applied. */
|
|
21
|
+
export declare function resolveSaveConfig(viz: Viz): ResolvedSaveConfig;
|
|
22
|
+
/** The chart's drawing surface: its `<canvas>` on the Canvas backend, else its `<svg>`. */
|
|
23
|
+
export declare function saveTarget(viz: Viz): HTMLElement | SVGElement | null;
|
|
24
|
+
/**
|
|
25
|
+
A detached copy of the chart's `<svg>` to save as a file, with a rect
|
|
26
|
+
filling `background` behind everything (none when `false`). The SVG
|
|
27
|
+
backend copies its live `<svg>`; the Canvas backend parses the scene
|
|
28
|
+
re-rendered as SVG markup.
|
|
29
|
+
*/
|
|
30
|
+
export declare function svgForSave(viz: Viz, background: string | false): SVGSVGElement | null;
|
|
31
|
+
/** The pixel density a PNG or JPG is drawn at: `pixelRatio`, else the screen's. */
|
|
32
|
+
export declare function savePixelRatio(renderOptions: Record<string, unknown>): number;
|
|
33
|
+
/**
|
|
34
|
+
Whether a canvas has fewer backing pixels per CSS pixel than
|
|
35
|
+
`pixelRatio`, so drawing an image from it would come out blurry.
|
|
36
|
+
*/
|
|
37
|
+
export declare function canvasTooCoarse(canvas: {
|
|
38
|
+
width: number;
|
|
39
|
+
getBoundingClientRect(): {
|
|
40
|
+
width: number;
|
|
41
|
+
};
|
|
42
|
+
}, pixelRatio: number): boolean;
|
|
43
|
+
/**
|
|
44
|
+
Saves the chart as a `format` file, named and styled by
|
|
45
|
+
`saveControlConfig`. Errors go to its `callback`, or to the console.
|
|
46
|
+
*/
|
|
47
|
+
export declare function saveChart(viz: Viz, format: SaveFormat): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type Viz from "../viz/Viz.js";
|
|
2
|
+
import type { Contribution } from "./topLeftControlsMarkup.js";
|
|
3
|
+
/** Whether the menu inside `root` is open. */
|
|
4
|
+
export declare function isSaveMenuOpen(root: HTMLElement): boolean;
|
|
5
|
+
/** Closes the menu inside `root`, returning focus to its button when `refocus`. */
|
|
6
|
+
export declare function closeSaveMenu(viz: Viz, root: HTMLElement, refocus?: boolean): void;
|
|
7
|
+
/** Opens the menu inside `root` and focuses its first (or last) item. */
|
|
8
|
+
export declare function openSaveMenu(viz: Viz, root: HTMLElement, focus?: "first" | "last"): void;
|
|
9
|
+
export declare function saveContribution(viz: Viz): Contribution | null;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Markup and styling for the download button (`saveControl.ts`): a toggle
|
|
3
|
+
button and the menu of file formats it opens.
|
|
4
|
+
|
|
5
|
+
The menu's open state lives only in the DOM (its `display` and the
|
|
6
|
+
button's `aria-expanded`), never in the generated html, so opening it
|
|
7
|
+
neither changes the panel's measured size nor makes the next repaint
|
|
8
|
+
rewrite the open menu.
|
|
9
|
+
|
|
10
|
+
@module
|
|
11
|
+
*/
|
|
12
|
+
import type { SaveFormat } from "../../utils/D3plusConfig.js";
|
|
13
|
+
import type Viz from "../viz/Viz.js";
|
|
14
|
+
import { type ControlButtonStyles, type StyleObject } from "./controlButtonStyle.js";
|
|
15
|
+
/** The English label of each format's menu item, translated through `translate`. */
|
|
16
|
+
export declare const SAVE_FORMAT_LABELS: Record<SaveFormat, string>;
|
|
17
|
+
/** Whether a chart shows the download button. */
|
|
18
|
+
export declare function showsSaveControl(viz: Viz): boolean;
|
|
19
|
+
/** The resolved base / active / hover styles of the download button. */
|
|
20
|
+
export declare function saveButtonStyles(viz: Viz): ControlButtonStyles;
|
|
21
|
+
/** Paints the download button's inline style for its state (base, hover, menu open). */
|
|
22
|
+
export declare function paintSaveButton(viz: Viz, btn: HTMLElement, hovered?: boolean): void;
|
|
23
|
+
/** The menu's fixed layout while closed; `SAVE_MENU_OPEN_STYLE` shows it. */
|
|
24
|
+
export declare const SAVE_MENU_STYLE: StyleObject;
|
|
25
|
+
export declare const SAVE_MENU_OPEN_STYLE: StyleObject;
|
|
26
|
+
/** The menu's and its items' resolved theme styles. */
|
|
27
|
+
export interface SaveMenuStyles {
|
|
28
|
+
menu: StyleObject;
|
|
29
|
+
item: StyleObject;
|
|
30
|
+
itemHover: StyleObject;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
Resolves `saveControlMenuStyle`, `saveControlMenuItemStyle`, and
|
|
34
|
+
`saveControlMenuItemStyleHover`, with `saveControlMenuClassName`
|
|
35
|
+
dropping whichever are still the defaults.
|
|
36
|
+
*/
|
|
37
|
+
export declare function saveMenuStyles(viz: Viz): SaveMenuStyles;
|
|
38
|
+
/** Paints a menu item's inline style, with the hover style while it has focus. */
|
|
39
|
+
export declare function paintSaveMenuItem(viz: Viz, item: HTMLElement, focused: boolean): void;
|
|
40
|
+
/**
|
|
41
|
+
The button's markup, plus its menu when more than one format is offered.
|
|
42
|
+
With one format, the button saves it directly and names it in its label.
|
|
43
|
+
*/
|
|
44
|
+
export declare function saveControlHtml(viz: Viz): string;
|
|
@@ -43,6 +43,7 @@ export declare function setTableViewDataSource(viz: Viz, value: TableViewDataSou
|
|
|
43
43
|
export declare function paintTableViewButton(viz: Viz, btn: HTMLElement, hovered?: boolean): void;
|
|
44
44
|
/** The cheap, non-DOM signature capturing the button's resolved style — see `Contribution.styleSignature`. */
|
|
45
45
|
export declare function tableViewButtonStyleSignature(viz: Viz): string;
|
|
46
|
+
export declare const DOWNLOAD_ICON = "<svg 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\"><path d=\"M12 3v12\"/><polyline points=\"7 11 12 16 17 11\"/><path d=\"M4 18v1a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-1\"/></svg>";
|
|
46
47
|
/** The toggle button's markup — a real `<button>` so host-page button styling applies once `tableViewControlClassName` disables the inline defaults. */
|
|
47
48
|
export declare function tableViewButtonHtml(viz: Viz): string;
|
|
48
49
|
/**
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
zoom-controls panel's "N buttons, one flex-row `htmlOverlay` panel"
|
|
5
5
|
composition (`zoomControls.ts`/`zoomControlsMarkup.ts`), except fed by
|
|
6
6
|
independent contributor functions (`backContribution`,
|
|
7
|
-
`tableViewContribution`, `searchContribution`) rather than one feature's
|
|
7
|
+
`tableViewContribution`, `saveContribution`, `searchContribution`) rather than one feature's
|
|
8
8
|
own fixed button set. A downstream branch adding a new top-left control
|
|
9
9
|
appends its own contributor function to `TOP_LEFT_CONTRIBUTORS` — a
|
|
10
10
|
one-line diff, not a dynamic registry.
|
|
@@ -53,7 +53,7 @@ export declare function buildTopLeftPanel(viz: Viz, contributions: Contribution[
|
|
|
53
53
|
The shared top-left panel's rendered size (padding included) as it will
|
|
54
54
|
render in the chart's page, so top-positioned content can leave room for
|
|
55
55
|
it — the same measure-a-hidden-probe technique `zoomControlsBox` uses,
|
|
56
|
-
generalized to whichever mix of controls (back / table-view / search)
|
|
56
|
+
generalized to whichever mix of controls (back / table-view / save / search)
|
|
57
57
|
is currently contributing, and to each contribution's OWN resolved
|
|
58
58
|
button styling (not just its markup). Returns null when nothing is
|
|
59
59
|
contributing.
|
|
@@ -37,7 +37,7 @@ export declare function facetGroups(viz: VizInstance, sort: FacetSort): FacetGro
|
|
|
37
37
|
/**
|
|
38
38
|
One panel's drawable rows: `rows` run through the same time filter,
|
|
39
39
|
rollup, legend hide/solo, and threshold the chart applies to its whole
|
|
40
|
-
dataset. `timeFilter` is computed once from the whole dataset, so every
|
|
40
|
+
dataset (a threshold that weighs rows weighs the whole chart's). `timeFilter` is computed once from the whole dataset, so every
|
|
41
41
|
panel shows the same period.
|
|
42
42
|
*/
|
|
43
43
|
export declare function facetFilteredData(viz: VizInstance, rows: DataPoint[], timeFilter: ReturnType<typeof computeTimeFilter>): DataPoint[];
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
`viz._padding.*`. Runs BEFORE the base `Viz` draw finalizes margins.
|
|
6
6
|
*/
|
|
7
7
|
import type Axis from "../../components/Axis/Axis.js";
|
|
8
|
+
import { type BarLabelCheck } from "../Plot/barLabelFit.js";
|
|
8
9
|
import type { VizInstance as Viz } from "../viz/vizTypes.js";
|
|
9
10
|
import type { AxisBounds } from "./axesFinal.js";
|
|
10
11
|
import type { XLabelMode } from "./plotEndLabels.js";
|
|
@@ -56,6 +57,8 @@ export interface AxisMeasureInputs {
|
|
|
56
57
|
xData: unknown[];
|
|
57
58
|
/** `x.padding()` when the x scale is banded, else 0 — feeds the x config. */
|
|
58
59
|
xScalePadding: number;
|
|
60
|
+
/** Category labels the bars carry in place of the category axis's ticks. */
|
|
61
|
+
barLabelCheck?: BarLabelCheck;
|
|
59
62
|
}
|
|
60
63
|
/** The four-side margin claim + offsets the joint solve produces. */
|
|
61
64
|
export interface AxisMeasureResult {
|
|
@@ -75,6 +78,11 @@ export interface AxisMeasureResult {
|
|
|
75
78
|
topOffset: number;
|
|
76
79
|
xHeight: number;
|
|
77
80
|
xLabelMode: XLabelMode;
|
|
81
|
+
/** The category axis keeps its ticks, which the bars had no room to label. */
|
|
82
|
+
barLabelsOnAxis: boolean;
|
|
83
|
+
/** The x and y ticks the axes were measured with (see `barLabelsOnAxis`). */
|
|
84
|
+
xTicks: unknown[] | null;
|
|
85
|
+
yTicks: unknown[] | null;
|
|
78
86
|
}
|
|
79
87
|
/**
|
|
80
88
|
MEASURE half of the joint axis solve. Configures + measures the four
|
|
@@ -85,4 +93,4 @@ export interface AxisMeasureResult {
|
|
|
85
93
|
`measureLineLabels` is invoked once, after the first x-axis measure and
|
|
86
94
|
before the re-measure, so its `xRangeMax` can re-bound the x range.
|
|
87
95
|
*/
|
|
88
|
-
export declare function measureAxes(viz: Viz,
|
|
96
|
+
export declare function measureAxes(viz: Viz, measureInputs: AxisMeasureInputs, measureLineLabels: () => LineLabelMeasurement): AxisMeasureResult;
|
|
@@ -41,3 +41,12 @@ export declare function colorScaleBucketPredicate(viz: VizInstance, bucketColor:
|
|
|
41
41
|
colorScale.
|
|
42
42
|
*/
|
|
43
43
|
export declare function activeBucketColors(viz: VizInstance, predicate: (d: DataPoint, i: number) => boolean): Set<unknown> | null;
|
|
44
|
+
/**
|
|
45
|
+
The first of the colorScale's rows in each bucket, keyed by bucket color,
|
|
46
|
+
with its index: the row a bucket's swatch takes the chart's shape styles
|
|
47
|
+
from. Null without a colorScale to read.
|
|
48
|
+
*/
|
|
49
|
+
export declare function colorScaleBucketRows(viz: VizInstance): Map<unknown, {
|
|
50
|
+
row: DataPoint;
|
|
51
|
+
i: number;
|
|
52
|
+
}> | null;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { SceneEvent, SceneNode } from "@d3plus/render";
|
|
2
|
+
import type { VizInstance } from "../viz/vizTypes.js";
|
|
3
|
+
/**
|
|
4
|
+
The colorScale value of a hovered scene node: its datum unwrapped to the
|
|
5
|
+
source row (as the shapes' fill unwraps it), read through the chart's
|
|
6
|
+
`colorScale`. Null for chrome (legend, axes, the colorScale itself), a
|
|
7
|
+
node without a row, or a row without a finite value.
|
|
8
|
+
@param viz The chart.
|
|
9
|
+
@param node The hovered scene node.
|
|
10
|
+
*/
|
|
11
|
+
export declare function colorScaleHoverValue(viz: VizInstance, node: SceneNode | undefined): number | null;
|
|
12
|
+
/**
|
|
13
|
+
Updates the colorScale's hover mark for a pointer event, repainting only
|
|
14
|
+
when the marked value changes. Moves are ignored while a transition is
|
|
15
|
+
in flight; leaving the chart always clears the mark.
|
|
16
|
+
@param viz The chart.
|
|
17
|
+
@param event The pointer event.
|
|
18
|
+
*/
|
|
19
|
+
export declare function handleColorScaleHover(viz: VizInstance, event: SceneEvent): void;
|
|
20
|
+
/**
|
|
21
|
+
The swatch to keep lit for the colorScale's hovered value when the chart
|
|
22
|
+
has no hover predicate of its own (shape hover is off, as on Geomap,
|
|
23
|
+
Calendar, or past `dataCutoff`): the value's bucket color, and the
|
|
24
|
+
opacity the other swatches dim to (`hoverOpacity`, or 0.5 when that is
|
|
25
|
+
1). Null when the chart's own hover drives the highlight, nothing is
|
|
26
|
+
marked, `hoverMark` is off, or the scale isn't drawn as swatches.
|
|
27
|
+
@param viz The chart.
|
|
28
|
+
*/
|
|
29
|
+
export declare function hoveredSwatch(viz: VizInstance): {
|
|
30
|
+
color: unknown;
|
|
31
|
+
dimOpacity: number;
|
|
32
|
+
} | null;
|
|
@@ -126,6 +126,14 @@ export declare function zoomControlsInset(viz: VizInstance, top: number, right:
|
|
|
126
126
|
or content starts below the panel's height.
|
|
127
127
|
*/
|
|
128
128
|
export declare function topLeftControlsInset(viz: VizInstance, top: number, left: number): number;
|
|
129
|
+
/**
|
|
130
|
+
How far a left or right legend/colorScale starting `top` px down the
|
|
131
|
+
chart, its outer edge `edge` px in from the chart's edge on that side,
|
|
132
|
+
must drop to start below the corner control panel on its side: the
|
|
133
|
+
top-left panel for `"left"`, the zoom controls for `"right"`. Zero when
|
|
134
|
+
that panel isn't showing, is narrower than `edge`, or ends above `top`.
|
|
135
|
+
*/
|
|
136
|
+
export declare function sideControlsDrop(viz: VizInstance, position: string | false, top: number, edge: number): number;
|
|
129
137
|
/**
|
|
130
138
|
The combined left+right corner-panel insets for content starting `top`
|
|
131
139
|
px down the chart, plus the single symmetric amount CENTERED content
|
|
@@ -154,6 +154,8 @@ export interface PlotPaintContext {
|
|
|
154
154
|
verticalMargin: number;
|
|
155
155
|
opp: "x" | "y" | undefined;
|
|
156
156
|
barLabels: string[];
|
|
157
|
+
/** The category axis names the bars, which drop their labels (see `Plot/barLabelFit.ts`). */
|
|
158
|
+
barLabelsOnAxis?: boolean;
|
|
157
159
|
showLineLabels: boolean;
|
|
158
160
|
stackGroup: unknown;
|
|
159
161
|
/** How the x axis is labeled (see `plotEndLabels.ts`); "axis" when omitted. */
|
|
@@ -58,6 +58,8 @@ export interface ShapeEmitContext {
|
|
|
58
58
|
insetBottom?: number;
|
|
59
59
|
/** The x2 axis's height: `yRange` minus this is content space. */
|
|
60
60
|
x2Height?: number;
|
|
61
|
+
/** The category axis names the bars, which drop their labels (see `Plot/barLabelFit.ts`). */
|
|
62
|
+
barLabelsOnAxis?: boolean;
|
|
61
63
|
/** Where the unzoomed x/y plot ranges land in a zoom repaint (see `Plot/plotZoom.ts`). */
|
|
62
64
|
zoomRanges?: Partial<Record<"x" | "y", number[]>>;
|
|
63
65
|
}
|
|
@@ -20,5 +20,14 @@ export declare function shareOf(row: Record<string, unknown> | undefined): unkno
|
|
|
20
20
|
the row carries none.
|
|
21
21
|
*/
|
|
22
22
|
export declare function summedShare(row: Record<string, unknown> | undefined): number;
|
|
23
|
+
/** The data row under a shape or legend wrapper (`{__d3plus__, data}`). */
|
|
24
|
+
export declare function unwrapRow<T>(d: T): T;
|
|
25
|
+
/**
|
|
26
|
+
`d`'s share of every row's total: the size of its `value` over the summed
|
|
27
|
+
size of every row's. NaN when that total is 0. A legend entry, which
|
|
28
|
+
merges a series over every position, reads its share of the whole chart
|
|
29
|
+
this way.
|
|
30
|
+
*/
|
|
31
|
+
export declare function shareOfRows(d: Record<string, unknown>, rows: Record<string, unknown>[], value: (d: Record<string, unknown>) => unknown): number;
|
|
23
32
|
/** Whether `key` is one d3plus writes onto data rows for its own use. */
|
|
24
33
|
export declare function isInternalKey(key: string): boolean;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { DataPoint } from "@d3plus/data";
|
|
2
|
+
import type { VizInstance } from "../viz/vizTypes.js";
|
|
3
|
+
/** The row key a threshold bucket lists its members under. */
|
|
4
|
+
export declare const MEMBERS_KEY = "__d3plusMembers";
|
|
5
|
+
/** How many members a tooltip lists before summing up the rest as "+N more". */
|
|
6
|
+
export declare const MEMBER_LIMIT = 10;
|
|
7
|
+
/** One item in a threshold bucket: its label and its value. */
|
|
8
|
+
export interface ThresholdMember {
|
|
9
|
+
label: string;
|
|
10
|
+
value: number;
|
|
11
|
+
}
|
|
12
|
+
type Accessor<T> = (d: DataPoint, i: number) => T;
|
|
13
|
+
/**
|
|
14
|
+
The members `rows` make up: one per `key`, labelled by its first row and
|
|
15
|
+
valued by the sum of its rows' `value`, largest first.
|
|
16
|
+
*/
|
|
17
|
+
export declare function thresholdMemberList(rows: DataPoint[], key: Accessor<unknown>, label: Accessor<unknown>, value: Accessor<unknown>): ThresholdMember[];
|
|
18
|
+
/** The members a bucket row (or a wrapper around one) lists, or none. */
|
|
19
|
+
export declare function thresholdMembers(d: unknown): ThresholdMember[];
|
|
20
|
+
/** A member's name, indented under the bucket it belongs to. */
|
|
21
|
+
export declare const memberName: (label: string) => string;
|
|
22
|
+
/**
|
|
23
|
+
Tooltip rows for a bucket's members: `[name, value]` for up to `limit`
|
|
24
|
+
of them, largest first, then a "+N more" row with the rest's summed
|
|
25
|
+
value. Empty for a row that isn't a bucket.
|
|
26
|
+
*/
|
|
27
|
+
export declare function thresholdMemberRows(viz: VizInstance, d: unknown, limit?: number): string[][];
|
|
28
|
+
/** A tooltip whose `tbody` can be read and replaced. */
|
|
29
|
+
interface TbodyHost {
|
|
30
|
+
tbody(): unknown;
|
|
31
|
+
tbody(_: unknown): unknown;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
Appends a bucket's member rows to `tooltip`'s `tbody`, after the rows it
|
|
35
|
+
already has. Does nothing for a row that isn't a bucket.
|
|
36
|
+
*/
|
|
37
|
+
export declare function appendThresholdMembers<T extends TbodyHost>(tooltip: T, viz: VizInstance, d: unknown): T;
|
|
38
|
+
export {};
|
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
until the user sets a title of their own.
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
|
-
`accessor(key)` that remembers its key (see `valueKeyOf`)
|
|
7
|
+
`accessor(key)` that remembers its key (see `valueKeyOf`), for a default
|
|
8
|
+
`value`; a user's string `value` becomes a `fieldAccessor`.
|
|
8
9
|
@param key The data key to read.
|
|
9
10
|
*/
|
|
10
11
|
export declare function keyedAccessor(key: string): (d: import("@d3plus/data").DataPoint) => import("@d3plus/data").DataPoint[keyof import("@d3plus/data").DataPoint];
|
|
11
12
|
/**
|
|
12
|
-
The data key behind an accessor built by `keyedAccessor
|
|
13
|
+
The data key behind an accessor built by `keyedAccessor` or
|
|
14
|
+
`fieldAccessor`, if any.
|
|
13
15
|
@param fn The accessor.
|
|
14
16
|
*/
|
|
15
17
|
export declare function valueKeyOf(fn: unknown): string | undefined;
|
|
@@ -19,6 +19,7 @@ import type { DataPoint } from "@d3plus/data";
|
|
|
19
19
|
import type { Axis, TextBox } from "../../components/index.js";
|
|
20
20
|
import type Shape from "../../shapes/Shape.js";
|
|
21
21
|
import type { D3Scale } from "../../utils/index.js";
|
|
22
|
+
import type { BarLabelCheck } from "../Plot/barLabelFit.js";
|
|
22
23
|
import type { VizInstance } from "../viz/vizTypes.js";
|
|
23
24
|
/** The four configured d3 scales plus their resolved scale-type strings. */
|
|
24
25
|
export interface PlotScales {
|
|
@@ -137,6 +138,7 @@ export interface VizContext {
|
|
|
137
138
|
plotShowY?: boolean;
|
|
138
139
|
plotYC?: Record<string, unknown>;
|
|
139
140
|
plotBarLabels?: string[];
|
|
141
|
+
plotBarLabelCheck?: BarLabelCheck;
|
|
140
142
|
plotXTicks?: unknown[] | null;
|
|
141
143
|
plotX2Ticks?: unknown[] | null;
|
|
142
144
|
plotYTicks?: unknown[] | null;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
`vizDraw(viz)` — the chart-shell layout every draw runs: it lays out the
|
|
3
|
-
margin-claiming chrome
|
|
4
|
-
|
|
5
|
-
claims to `viz._margin`, and collects their panels on
|
|
3
|
+
margin-claiming chrome in two passes, adds their claims to
|
|
4
|
+
`viz._margin`, and collects their panels on
|
|
6
5
|
`viz._featurePanels`. Each FeatureModule.layout() still writes through to
|
|
7
6
|
`viz` (component mounts, intra-feature state); `vizUpdate` is the
|
|
8
7
|
cross-feature publishing channel.
|
|
9
8
|
|
|
9
|
+
The first pass lays out everything positioned top or bottom (title /
|
|
10
|
+
subtitle / total, timeline, the bottom-right corner panel, a top/bottom
|
|
11
|
+
legend or colorScale). The second lays out a left/right legend or
|
|
12
|
+
colorScale in the vertical band left between those claims, each starting
|
|
13
|
+
below the corner control panel on its side (see `sideControlsDrop`).
|
|
14
|
+
|
|
10
15
|
The post-layout consumers (axes, chartGeometry, plotPaint, ensureZoomDom,
|
|
11
16
|
attribution) read the final margin off `viz._margin`. Plot and other Viz
|
|
12
17
|
subclasses override `_draw` and reach this through `super._draw()`.
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
onto the viz:
|
|
4
4
|
1. `_drawDepth` and the `_id` / `_ids` / `_drawLabel` closures;
|
|
5
5
|
2. `_filteredData` (time filter, `filter`, rollup, hide/solo, then the
|
|
6
|
-
chart's `_thresholdFunction`) and `_legendData
|
|
6
|
+
chart's `_thresholdFunction`) and `_legendData` (through `_thresholdLegend`);
|
|
7
7
|
3. the hover/duration override past `dataCutoff`;
|
|
8
|
-
and mounts the no-data message when nothing is left to draw.
|
|
8
|
+
and mounts the no-data message when nothing is left to draw. It first
|
|
9
|
+
warns about config keys naming a field no row has (`missingFields.ts`).
|
|
9
10
|
|
|
10
11
|
`Viz._preDraw()` calls it, so subclass overrides run it through
|
|
11
12
|
`super._preDraw()`.
|
|
@@ -48,12 +48,27 @@ export default class Viz extends VizBase {
|
|
|
48
48
|
@private
|
|
49
49
|
*/
|
|
50
50
|
_insetRegion(): InsetRegion | null;
|
|
51
|
+
/**
|
|
52
|
+
The shape a colorScale row draws as (see
|
|
53
|
+
`ChartDefinition.colorScaleShape`): the row's `shape`, unless the chart
|
|
54
|
+
draws it as something else.
|
|
55
|
+
@private
|
|
56
|
+
*/
|
|
57
|
+
_colorScaleShape(d: DataPoint, i: number): string;
|
|
51
58
|
/**
|
|
52
59
|
* Applies the threshold algorithm according to the type of chart used.
|
|
53
60
|
* @param {Array} data The data to process.
|
|
61
|
+
* @param {Array} all Every row `data` was drawn from, legend-hidden ones included.
|
|
54
62
|
* @private
|
|
55
63
|
*/
|
|
56
|
-
_thresholdFunction(data: DataPoint[], _tree?: unknown): DataPoint[];
|
|
64
|
+
_thresholdFunction(data: DataPoint[], _tree?: unknown, _all?: DataPoint[]): DataPoint[];
|
|
65
|
+
/**
|
|
66
|
+
* The legend rows with the chart's threshold bucket folded in, so the
|
|
67
|
+
* legend shows the bucket rather than the items it holds.
|
|
68
|
+
* @param {Array} legendData Every legend row, legend-hidden ones included.
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
_thresholdLegend(legendData: DataPoint[]): DataPoint[];
|
|
57
72
|
/**
|
|
58
73
|
* Detects width and height and sets SVG properties
|
|
59
74
|
* @private
|
|
@@ -68,8 +83,9 @@ export default class Viz extends VizBase {
|
|
|
68
83
|
Serializes the most recently rendered output to an SVG string. Returns
|
|
69
84
|
`""` if the chart has not been rendered yet. Both backends support this:
|
|
70
85
|
the SVG backend returns its live `<svg>`, the canvas backend re-renders the
|
|
71
|
-
retained scene through a throwaway SVG backend.
|
|
72
|
-
server-side rendering (see
|
|
86
|
+
retained scene through a throwaway SVG backend. Its root element carries
|
|
87
|
+
the chart's `className`. Primarily used for server-side rendering (see
|
|
88
|
+
`@d3plus/ssr`).
|
|
73
89
|
*/
|
|
74
90
|
toSVGString(): string;
|
|
75
91
|
/**
|
|
@@ -117,6 +133,14 @@ export default class Viz extends VizBase {
|
|
|
117
133
|
@private
|
|
118
134
|
*/
|
|
119
135
|
_sharedHover(_event: SceneEvent): void;
|
|
136
|
+
/**
|
|
137
|
+
The element the chart draws on: its root svg, or its canvas.
|
|
138
|
+
@private
|
|
139
|
+
*/
|
|
140
|
+
_classNameTargets(): {
|
|
141
|
+
el: Element;
|
|
142
|
+
keep?: string[];
|
|
143
|
+
}[];
|
|
120
144
|
/**
|
|
121
145
|
The chart's small-multiple hooks (see `ChartDefinition.facet`). The base
|
|
122
146
|
chart has none: each panel draws the way the whole chart does.
|
|
@@ -160,7 +184,7 @@ export default class Viz extends VizBase {
|
|
|
160
184
|
*/
|
|
161
185
|
_scheduleSceneRepaint(): void;
|
|
162
186
|
/**
|
|
163
|
-
Tears down the visualization: disconnects the ResizeObserver, stops listening for web font loads, and removes DOM event listeners. Call this when unmounting to avoid memory leaks.
|
|
187
|
+
Tears down the visualization: disconnects the ResizeObserver, stops listening for web font loads and polling for data, and removes DOM event listeners. Call this when unmounting to avoid memory leaks.
|
|
164
188
|
*/
|
|
165
189
|
destroy(): this;
|
|
166
190
|
}
|
|
@@ -27,12 +27,14 @@ declare class VizBase extends BaseClass {
|
|
|
27
27
|
/**
|
|
28
28
|
The primary data array used to draw the visualization. The value passed should be an *Array* of objects or a *String* representing a filepath or URL to be loaded. The following filetypes are supported: `csv`, `tsv`, `txt`, and `json`.
|
|
29
29
|
|
|
30
|
-
If your data URL needs specific headers to be set, an Object with "url" and "headers"
|
|
30
|
+
If your data URL needs specific headers to be set, an Object with a "url" and "headers" (or any other `fetch` request option) may also be passed. An Object with any other key is a data row, not a request.
|
|
31
31
|
|
|
32
32
|
Additionally, a custom formatting function can be passed as a second argument to this method. This custom function will be passed the data that has been loaded, as long as there are no errors. This function should return the final array of obejcts to be used as the primary data array. For example, some JSON APIs return the headers split from the data values to save bandwidth. These would need be joined using a custom formatter.
|
|
33
33
|
|
|
34
34
|
If you would like to specify certain configuration options based on the yet-to-be-loaded data, you can also return a full `config` object from the data formatter (including the new `data` array as a key in the object).
|
|
35
35
|
|
|
36
|
+
To re-fetch a URL on an interval and redraw when its data changes, set `dataPollingInterval`; each poll runs the same formatter.
|
|
37
|
+
|
|
36
38
|
Defaults to an empty array (`[]`).
|
|
37
39
|
@param f The data array or a URL string to load data from.
|
|
38
40
|
*/
|
|
@@ -67,6 +69,7 @@ declare class VizBase extends BaseClass {
|
|
|
67
69
|
/**
|
|
68
70
|
The hover callback function for highlighting shapes on mouseover.
|
|
69
71
|
*/
|
|
72
|
+
hover(): ((d: DataPoint, i: number) => boolean) | false | undefined;
|
|
70
73
|
hover(_?: ((d: DataPoint, i: number) => boolean) | false): this;
|
|
71
74
|
/**
|
|
72
75
|
Persistently emphasizes the data points matching the given predicate: the
|
|
@@ -86,11 +89,17 @@ declare class VizBase extends BaseClass {
|
|
|
86
89
|
shapeConfig(): D3plusConfig;
|
|
87
90
|
shapeConfig(_: D3plusConfig): this;
|
|
88
91
|
/**
|
|
89
|
-
The threshold value for bucketing small data points together
|
|
92
|
+
The threshold value for bucketing small data points together, as a
|
|
93
|
+
share of the total. On a stacked Plot, the series whose summed value
|
|
94
|
+
across every position is under that share of the whole chart's total
|
|
95
|
+
merge into one series, stacked on top. A bucket needs at least two
|
|
96
|
+
items, and its tooltips list them. Off (`0`) by default on Plot
|
|
97
|
+
charts.
|
|
90
98
|
*/
|
|
91
99
|
threshold(_?: number | ((data: DataPoint[]) => number)): this | number | ((data: DataPoint[]) => number);
|
|
92
100
|
/**
|
|
93
|
-
Accessor for the value used in the threshold algorithm.
|
|
101
|
+
Accessor for the value used in the threshold algorithm. A stacked Plot
|
|
102
|
+
defaults to its stacked value.
|
|
94
103
|
@param key The data key used to group values for thresholding.
|
|
95
104
|
*/
|
|
96
105
|
thresholdKey(key?: string | ((d: DataPoint, i: number) => DataPoint[keyof DataPoint])): this | string | ((d: DataPoint, i: number) => DataPoint[keyof DataPoint]);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Options for {@link createDataPoller}. */
|
|
2
|
+
export interface DataPollerOptions<T> {
|
|
3
|
+
/** Milliseconds between the end of one fetch and the start of the next. */
|
|
4
|
+
interval: number;
|
|
5
|
+
/** Fetches a fresh value. */
|
|
6
|
+
fetch: () => Promise<T>;
|
|
7
|
+
/** Receives each value fetched while the poller is running. */
|
|
8
|
+
onData: (value: T) => void;
|
|
9
|
+
/** Receives the first error of each run of consecutive failures. */
|
|
10
|
+
onError: (error: unknown) => void;
|
|
11
|
+
/** Whether ticks should wait (a hidden tab or an off-screen chart). */
|
|
12
|
+
paused: () => boolean;
|
|
13
|
+
}
|
|
14
|
+
/** A running poller, from {@link createDataPoller}. */
|
|
15
|
+
export interface DataPoller {
|
|
16
|
+
/** Stops the poller; a fetch still in flight is discarded. */
|
|
17
|
+
stop(): void;
|
|
18
|
+
/** Fetches at once if a tick came due while paused, then resumes the cadence. */
|
|
19
|
+
resume(): void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
Calls `fetch` every `interval` ms, chaining each wait from the end of the
|
|
23
|
+
previous fetch so requests never overlap. A tick that comes due while
|
|
24
|
+
`paused()` is held until `resume()`. Errors are reported once per streak
|
|
25
|
+
and polling continues.
|
|
26
|
+
@private
|
|
27
|
+
*/
|
|
28
|
+
export declare function createDataPoller<T>(opts: DataPollerOptions<T>): DataPoller;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Group rows: a row a chart draws for a whole group at a shallower `groupBy`
|
|
3
|
+
level than its marks (a Treemap's group header), merged from every row in
|
|
4
|
+
that group and stamped with its level under `GROUP_DEPTH_KEY`. Labels,
|
|
5
|
+
hover, and clicks read that level in place of the chart's drawn depth.
|
|
6
|
+
*/
|
|
7
|
+
import type { DataPoint } from "@d3plus/data";
|
|
8
|
+
/** The row key holding a group row's `groupBy` level. */
|
|
9
|
+
export declare const GROUP_DEPTH_KEY = "__d3plusGroupDepth";
|
|
10
|
+
/** The row key holding a group row's own label, when its chart sets one. */
|
|
11
|
+
export declare const GROUP_LABEL_KEY = "__d3plusGroupLabel";
|
|
12
|
+
type GroupKey = (d: DataPoint, i: number) => unknown;
|
|
13
|
+
/** The `groupBy` level a group row stands for, or undefined for any other row. */
|
|
14
|
+
export declare function groupDepthOf(d: DataPoint | undefined | null): number | undefined;
|
|
15
|
+
/** A group row's key at each `groupBy` level, from the first down to its own. */
|
|
16
|
+
export declare function groupPath(groupBy: GroupKey[], d: DataPoint, depth: number): unknown[];
|
|
17
|
+
/**
|
|
18
|
+
Whether `d` belongs to the group at `path`: its key at each of the path's
|
|
19
|
+
levels is the group's, or for a merged row holds it.
|
|
20
|
+
*/
|
|
21
|
+
export declare function inGroup(groupBy: GroupKey[], path: unknown[], d: DataPoint, i: number): boolean;
|
|
22
|
+
/** Whether `rows` hold any row outside the group at `path`, so zooming into it narrows the view. */
|
|
23
|
+
export declare function groupNarrows(groupBy: GroupKey[], path: unknown[], rows: DataPoint[]): boolean;
|
|
24
|
+
export {};
|
|
@@ -17,7 +17,9 @@ import type { VizInstance } from "./vizTypes.js";
|
|
|
17
17
|
by its bucket COLOR, not by id/value — so this only touches those nodes and
|
|
18
18
|
leaves the colorScale title/axis/gradient at full opacity. A swatch stays
|
|
19
19
|
bright when its color is "active" (its range contains a datum matching the
|
|
20
|
-
current hover); every other swatch dims.
|
|
20
|
+
current hover); every other swatch dims. A chart without a hover
|
|
21
|
+
predicate of its own (shape hover off) lights the swatch of the value
|
|
22
|
+
its colorScale marks (see `hoveredSwatch`). No-op when nothing is hovered.
|
|
21
23
|
*/
|
|
22
24
|
export declare function applyColorScaleBucketOpacity(nodes: SceneNode[], viz: VizInstance): SceneNode[];
|
|
23
25
|
export declare function applyInteractionOpacity(nodes: SceneNode[], viz: VizInstance): SceneNode[];
|