@d3plus/core 4.5.0 → 4.6.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 +3698 -1074
- package/es/index.js +3 -3
- package/es/index.js.map +1 -1
- package/es/internal.js +6 -1
- package/es/internal.js.map +1 -1
- package/es/src/charts/BarChart/index.js +8 -1
- package/es/src/charts/BarChart/index.js.map +1 -1
- package/es/src/charts/BoxWhisker/index.js +5 -0
- package/es/src/charts/BoxWhisker/index.js.map +1 -1
- package/es/src/charts/Chord/emit.js +55 -3
- package/es/src/charts/Chord/emit.js.map +1 -1
- package/es/src/charts/Chord/index.js +15 -0
- package/es/src/charts/Chord/index.js.map +1 -1
- package/es/src/charts/Geomap/applyLayout.js +17 -10
- package/es/src/charts/Geomap/applyLayout.js.map +1 -1
- package/es/src/charts/Geomap/index.js +5 -1
- package/es/src/charts/Geomap/index.js.map +1 -1
- package/es/src/charts/Histogram/binData.js +225 -0
- package/es/src/charts/Histogram/binData.js.map +1 -0
- package/es/src/charts/Histogram/index.js +271 -0
- package/es/src/charts/Histogram/index.js.map +1 -0
- package/es/src/charts/Network/applyLayout.js +52 -4
- package/es/src/charts/Network/applyLayout.js.map +1 -1
- package/es/src/charts/Network/emit.js +4 -4
- package/es/src/charts/Network/emit.js.map +1 -1
- package/es/src/charts/Network/index.js +6 -1
- package/es/src/charts/Network/index.js.map +1 -1
- package/es/src/charts/Pack/emit.js +37 -2
- package/es/src/charts/Pack/emit.js.map +1 -1
- package/es/src/charts/Pack/index.js +13 -0
- package/es/src/charts/Pack/index.js.map +1 -1
- package/es/src/charts/Pie/applyLayout.js +20 -2
- package/es/src/charts/Pie/applyLayout.js.map +1 -1
- package/es/src/charts/Pie/emit.js +274 -33
- package/es/src/charts/Pie/emit.js.map +1 -1
- package/es/src/charts/Pie/index.js +46 -1
- package/es/src/charts/Pie/index.js.map +1 -1
- package/es/src/charts/Plot/discreteSpan.js +42 -0
- package/es/src/charts/Plot/discreteSpan.js.map +1 -0
- package/es/src/charts/Plot/draw.js +3 -1
- package/es/src/charts/Plot/draw.js.map +1 -1
- package/es/src/charts/Plot/index.js +129 -14
- package/es/src/charts/Plot/index.js.map +1 -1
- package/es/src/charts/Plot/pipeline.js +47 -20
- package/es/src/charts/Plot/pipeline.js.map +1 -1
- package/es/src/charts/Plot/pipelineDomains.js +84 -8
- package/es/src/charts/Plot/pipelineDomains.js.map +1 -1
- package/es/src/charts/Plot/shapeDefaults.js +3 -3
- package/es/src/charts/Plot/shapeDefaults.js.map +1 -1
- package/es/src/charts/Plot/sharedHover.js +431 -0
- package/es/src/charts/Plot/sharedHover.js.map +1 -0
- package/es/src/charts/Plot/sharedHoverScene.js +230 -0
- package/es/src/charts/Plot/sharedHoverScene.js.map +1 -0
- package/es/src/charts/Plot/sharedTooltip.js +163 -0
- package/es/src/charts/Plot/sharedTooltip.js.map +1 -0
- package/es/src/charts/Plot/stackShareLabels.js +137 -0
- package/es/src/charts/Plot/stackShareLabels.js.map +1 -0
- package/es/src/charts/Plot/stackShareTooltip.js +31 -0
- package/es/src/charts/Plot/stackShareTooltip.js.map +1 -0
- package/es/src/charts/Plot/trendLines.js +367 -0
- package/es/src/charts/Plot/trendLines.js.map +1 -0
- package/es/src/charts/Plot/trendScene.js +220 -0
- package/es/src/charts/Plot/trendScene.js.map +1 -0
- package/es/src/charts/Plot/trendTooltip.js +160 -0
- package/es/src/charts/Plot/trendTooltip.js.map +1 -0
- package/es/src/charts/Priestley/emit.js +32 -3
- package/es/src/charts/Priestley/emit.js.map +1 -1
- package/es/src/charts/Radar/index.js +15 -2
- package/es/src/charts/Radar/index.js.map +1 -1
- package/es/src/charts/RadialMatrix/index.js +17 -1
- package/es/src/charts/RadialMatrix/index.js.map +1 -1
- package/es/src/charts/Rings/applyLayout.js +72 -116
- package/es/src/charts/Rings/applyLayout.js.map +1 -1
- package/es/src/charts/Rings/emit.js +2 -3
- package/es/src/charts/Rings/emit.js.map +1 -1
- package/es/src/charts/Rings/index.js +13 -2
- package/es/src/charts/Rings/index.js.map +1 -1
- package/es/src/charts/Rings/ringsSizing.js +189 -0
- package/es/src/charts/Rings/ringsSizing.js.map +1 -0
- package/es/src/charts/StackedArea/index.js +8 -1
- package/es/src/charts/StackedArea/index.js.map +1 -1
- package/es/src/charts/Tree/emit.js +2 -2
- package/es/src/charts/Tree/emit.js.map +1 -1
- package/es/src/charts/Tree/index.js +5 -3
- package/es/src/charts/Tree/index.js.map +1 -1
- package/es/src/charts/Treemap/emit.js +56 -3
- package/es/src/charts/Treemap/emit.js.map +1 -1
- package/es/src/charts/definition/ChartDefinition.js.map +1 -1
- package/es/src/charts/definition/makeChart.js +8 -1
- package/es/src/charts/definition/makeChart.js.map +1 -1
- package/es/src/charts/drawSteps/backControl.js +17 -2
- package/es/src/charts/drawSteps/backControl.js.map +1 -1
- package/es/src/charts/drawSteps/bottomRightControls.js +193 -0
- package/es/src/charts/drawSteps/bottomRightControls.js.map +1 -0
- package/es/src/charts/drawSteps/bottomRightControlsMarkup.js +161 -0
- package/es/src/charts/drawSteps/bottomRightControlsMarkup.js.map +1 -0
- package/es/src/charts/drawSteps/minimap.js +34 -9
- package/es/src/charts/drawSteps/minimap.js.map +1 -1
- package/es/src/charts/drawSteps/zoomControls.js +3 -0
- package/es/src/charts/drawSteps/zoomControls.js.map +1 -1
- package/es/src/charts/events/click.shape.js +24 -1
- package/es/src/charts/events/click.shape.js.map +1 -1
- package/es/src/charts/events/mouseenter.js +3 -0
- package/es/src/charts/events/mouseenter.js.map +1 -1
- package/es/src/charts/events/mouseleave.js +3 -0
- package/es/src/charts/events/mouseleave.js.map +1 -1
- package/es/src/charts/events/mousemove.shape.js +2 -0
- package/es/src/charts/events/mousemove.shape.js.map +1 -1
- package/es/src/charts/features/axes.js +4 -1
- package/es/src/charts/features/axes.js.map +1 -1
- package/es/src/charts/features/emitHelpers.js +24 -0
- package/es/src/charts/features/emitHelpers.js.map +1 -1
- package/es/src/charts/features/features.js +6 -2
- package/es/src/charts/features/features.js.map +1 -1
- package/es/src/charts/features/featuresLegend.js +13 -5
- package/es/src/charts/features/featuresLegend.js.map +1 -1
- package/es/src/charts/features/plotPaint.js +51 -24
- package/es/src/charts/features/plotPaint.js.map +1 -1
- package/es/src/charts/features/shapeEmit.js +20 -2
- package/es/src/charts/features/shapeEmit.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/drillMorph.js +159 -0
- package/es/src/charts/pipeline/drillMorph.js.map +1 -0
- package/es/src/charts/pipeline/runChartDraw.js +35 -1
- package/es/src/charts/pipeline/runChartDraw.js.map +1 -1
- package/es/src/charts/pipeline/runVizPipeline.js +16 -1
- package/es/src/charts/pipeline/runVizPipeline.js.map +1 -1
- package/es/src/charts/pipeline/vizDrawPure.js +20 -0
- package/es/src/charts/pipeline/vizDrawPure.js.map +1 -1
- package/es/src/charts/viz/Viz.js +64 -8
- package/es/src/charts/viz/Viz.js.map +1 -1
- package/es/src/charts/viz/VizBase.js +29 -1
- package/es/src/charts/viz/VizBase.js.map +1 -1
- package/es/src/charts/viz/VizBaseConfig.js +9 -1
- package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
- package/es/src/charts/viz/ordinalColor.js +2 -2
- package/es/src/charts/viz/ordinalColor.js.map +1 -1
- package/es/src/charts/viz/vizDefaults.js +27 -8
- package/es/src/charts/viz/vizDefaults.js.map +1 -1
- package/es/src/charts/viz/vizRender.js +54 -4
- package/es/src/charts/viz/vizRender.js.map +1 -1
- package/es/src/charts/viz/vizTypes.js.map +1 -1
- package/es/src/charts/viz/vizVisibility.js +145 -0
- package/es/src/charts/viz/vizVisibility.js.map +1 -0
- package/es/src/components/Axis/Axis.js +8 -8
- package/es/src/components/Axis/Axis.js.map +1 -1
- package/es/src/components/ColorScale/ColorScale.js +11 -11
- package/es/src/components/ColorScale/ColorScale.js.map +1 -1
- package/es/src/components/ColorScale/colorScaleScale.js +22 -10
- package/es/src/components/ColorScale/colorScaleScale.js.map +1 -1
- package/es/src/components/Legend/Legend.js +8 -5
- package/es/src/components/Legend/Legend.js.map +1 -1
- package/es/src/components/Legend/legendConfig.js +1 -1
- package/es/src/components/Legend/legendConfig.js.map +1 -1
- package/es/src/components/Legend/legendRender.js +29 -22
- package/es/src/components/Legend/legendRender.js.map +1 -1
- package/es/src/components/SizeLegend/SizeLegend.js +411 -0
- package/es/src/components/SizeLegend/SizeLegend.js.map +1 -0
- package/es/src/components/SizeLegend/sizeLegendLayout.js +285 -0
- package/es/src/components/SizeLegend/sizeLegendLayout.js.map +1 -0
- package/es/src/components/Timeline/timelineConfig.js +8 -4
- package/es/src/components/Timeline/timelineConfig.js.map +1 -1
- package/es/src/components/Timeline/timelineRender.js +1 -2
- package/es/src/components/Timeline/timelineRender.js.map +1 -1
- package/es/src/components/Tooltip.js +27 -7
- package/es/src/components/Tooltip.js.map +1 -1
- package/es/src/components/index.js +1 -0
- package/es/src/components/index.js.map +1 -1
- package/es/src/shapes/Box.js +4 -2
- package/es/src/shapes/Box.js.map +1 -1
- package/es/src/shapes/Shape.js +1 -1
- package/es/src/shapes/Shape.js.map +1 -1
- package/es/src/shapes/Whisker.js +3 -2
- package/es/src/shapes/Whisker.js.map +1 -1
- package/es/src/shapes/validateShapeConfig.js +141 -0
- package/es/src/shapes/validateShapeConfig.js.map +1 -0
- package/es/src/utils/BaseClass.js +134 -4
- package/es/src/utils/BaseClass.js.map +1 -1
- package/es/src/utils/D3plusConfig.js.map +1 -1
- package/es/src/utils/configDefault.js +17 -0
- package/es/src/utils/configDefault.js.map +1 -0
- package/es/src/utils/configPrep.js +2 -1
- package/es/src/utils/configPrep.js.map +1 -1
- package/es/src/utils/configWarnings.js +37 -0
- package/es/src/utils/configWarnings.js.map +1 -0
- package/es/src/utils/index.js +1 -0
- package/es/src/utils/index.js.map +1 -1
- package/package.json +11 -10
- package/types/index.d.ts +4 -4
- package/types/internal.d.ts +8 -1
- package/types/src/charts/BarChart/index.d.ts +2 -1
- package/types/src/charts/Geomap/applyLayout.d.ts +9 -1
- package/types/src/charts/Histogram/binData.d.ts +37 -0
- package/types/src/charts/Histogram/index.d.ts +14 -0
- package/types/src/charts/Network/applyLayout.d.ts +8 -0
- package/types/src/charts/Plot/discreteSpan.d.ts +9 -0
- package/types/src/charts/Plot/index.d.ts +39 -0
- package/types/src/charts/Plot/pipeline.d.ts +14 -0
- package/types/src/charts/Plot/sharedHover.d.ts +79 -0
- package/types/src/charts/Plot/sharedHoverScene.d.ts +11 -0
- package/types/src/charts/Plot/sharedTooltip.d.ts +26 -0
- package/types/src/charts/Plot/stackShareLabels.d.ts +21 -0
- package/types/src/charts/Plot/stackShareTooltip.d.ts +9 -0
- package/types/src/charts/Plot/trendLines.d.ts +70 -0
- package/types/src/charts/Plot/trendScene.d.ts +18 -0
- package/types/src/charts/Plot/trendTooltip.d.ts +19 -0
- package/types/src/charts/Rings/applyLayout.d.ts +9 -0
- package/types/src/charts/Rings/ringsSizing.d.ts +49 -0
- package/types/src/charts/StackedArea/index.d.ts +2 -1
- package/types/src/charts/definition/ChartDefinition.d.ts +30 -0
- package/types/src/charts/definition/makeChart.d.ts +2 -1
- package/types/src/charts/drawSteps/bottomRightControls.d.ts +26 -0
- package/types/src/charts/drawSteps/bottomRightControlsMarkup.d.ts +108 -0
- package/types/src/charts/features/emitHelpers.d.ts +8 -0
- package/types/src/charts/features/plotPaint.d.ts +25 -0
- package/types/src/charts/index.d.ts +1 -0
- package/types/src/charts/pipeline/drillMorph.d.ts +29 -0
- package/types/src/charts/pipeline/runVizPipeline.d.ts +8 -0
- package/types/src/charts/viz/Viz.d.ts +18 -1
- package/types/src/charts/viz/VizBase.d.ts +13 -0
- package/types/src/charts/viz/VizBaseConfig.d.ts +5 -1
- package/types/src/charts/viz/vizTypes.d.ts +147 -3
- package/types/src/charts/viz/vizVisibility.d.ts +34 -0
- package/types/src/components/Legend/legendRender.d.ts +8 -2
- package/types/src/components/SizeLegend/SizeLegend.d.ts +107 -0
- package/types/src/components/SizeLegend/sizeLegendLayout.d.ts +101 -0
- package/types/src/components/Tooltip.d.ts +18 -3
- package/types/src/components/index.d.ts +1 -0
- package/types/src/shapes/validateShapeConfig.d.ts +10 -0
- package/types/src/utils/BaseClass.d.ts +15 -1
- package/types/src/utils/D3plusConfig.d.ts +98 -0
- package/types/src/utils/configDefault.d.ts +11 -0
- package/types/src/utils/configWarnings.d.ts +28 -0
- package/types/src/utils/index.d.ts +2 -1
- package/umd/d3plus-core.full.js +7104 -2602
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +2860 -1583
- package/umd/d3plus-core.js +3682 -441
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +1656 -719
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { D3Selection } from "@d3plus/dom";
|
|
2
|
+
import type { GroupNode, SvgRenderer } from "@d3plus/render";
|
|
3
|
+
import { BaseClass } from "../../utils/index.js";
|
|
4
|
+
import type { SizeLegendLayout } from "./sizeLegendLayout.js";
|
|
5
|
+
/** Circle paint for the legend's nested circles. */
|
|
6
|
+
export interface SizeLegendShapeConfig {
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
fill?: string;
|
|
9
|
+
fillOpacity?: number;
|
|
10
|
+
stroke?: string;
|
|
11
|
+
strokeOpacity?: number;
|
|
12
|
+
strokeWidth?: number;
|
|
13
|
+
}
|
|
14
|
+
/** Paint for the leader lines running from each circle to its label. */
|
|
15
|
+
export interface SizeLegendLineConfig {
|
|
16
|
+
stroke?: string;
|
|
17
|
+
strokeDasharray?: number[];
|
|
18
|
+
strokeOpacity?: number;
|
|
19
|
+
strokeWidth?: number;
|
|
20
|
+
}
|
|
21
|
+
/** Font settings for the value labels and the title. */
|
|
22
|
+
export interface SizeLegendTextConfig {
|
|
23
|
+
fontColor?: string;
|
|
24
|
+
fontFamily?: string | string[];
|
|
25
|
+
fontSize?: number;
|
|
26
|
+
fontWeight?: number | string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
A nested-circle legend for a size scale: concentric circles sharing a
|
|
30
|
+
bottom tangent, each labeled with the value its radius encodes.
|
|
31
|
+
|
|
32
|
+
Charts that size marks by a `size` accessor (bubble plots, Geomap points,
|
|
33
|
+
Network, Rings) draw one automatically in their bottom-right corner (see
|
|
34
|
+
`sizeLegend` and `sizeLegendConfig` on the chart). On its own, give it
|
|
35
|
+
any d3 continuous scale that maps values to pixel radii.
|
|
36
|
+
@example
|
|
37
|
+
new SizeLegend()
|
|
38
|
+
.scale(d3.scaleSqrt().domain([0, 1000]).range([2, 30]))
|
|
39
|
+
.title("Population")
|
|
40
|
+
.select("#container")
|
|
41
|
+
.render();
|
|
42
|
+
*/
|
|
43
|
+
export default class SizeLegend extends BaseClass {
|
|
44
|
+
[key: string]: any;
|
|
45
|
+
_layout: SizeLegendLayout;
|
|
46
|
+
/** Drops values whose circles would outgrow this radius; set by a zoomed chart. */
|
|
47
|
+
_maxRadius?: number;
|
|
48
|
+
_select?: D3Selection;
|
|
49
|
+
_sceneRenderer?: SvgRenderer;
|
|
50
|
+
/**
|
|
51
|
+
Invoked when creating a new class instance, and sets any default parameters.
|
|
52
|
+
@private
|
|
53
|
+
*/
|
|
54
|
+
constructor();
|
|
55
|
+
/**
|
|
56
|
+
Font settings for the value labels: `fontColor`, `fontFamily`, `fontSize`. Merged into the current settings.
|
|
57
|
+
*/
|
|
58
|
+
labelConfig(): SizeLegendTextConfig;
|
|
59
|
+
labelConfig(_: SizeLegendTextConfig): this;
|
|
60
|
+
/**
|
|
61
|
+
Paint for the leader lines: `stroke`, `strokeWidth`, `strokeOpacity`, `strokeDasharray`. Merged into the current settings.
|
|
62
|
+
*/
|
|
63
|
+
lineConfig(): SizeLegendLineConfig;
|
|
64
|
+
lineConfig(_: SizeLegendLineConfig): this;
|
|
65
|
+
/**
|
|
66
|
+
Paint for the circles: `fill`, `fillOpacity`, `stroke`, `strokeWidth`, `strokeOpacity`. Merged into the current settings.
|
|
67
|
+
*/
|
|
68
|
+
shapeConfig(): SizeLegendShapeConfig;
|
|
69
|
+
shapeConfig(_: SizeLegendShapeConfig): this;
|
|
70
|
+
/**
|
|
71
|
+
Font settings for the title: `fontColor`, `fontFamily`, `fontSize`, `fontWeight`. Merged into the current settings.
|
|
72
|
+
*/
|
|
73
|
+
titleConfig(): SizeLegendTextConfig;
|
|
74
|
+
titleConfig(_: SizeLegendTextConfig): this;
|
|
75
|
+
/**
|
|
76
|
+
The container element for a standalone render, as a d3 selector or DOM element.
|
|
77
|
+
*/
|
|
78
|
+
select(): D3Selection | undefined;
|
|
79
|
+
select(_: string | HTMLElement | SVGElement): this;
|
|
80
|
+
/**
|
|
81
|
+
Lays the legend out from the current config and returns the result
|
|
82
|
+
(circles, leader lines, labels, overall width/height). Pure: reads no
|
|
83
|
+
DOM, so a chart can measure the legend before it draws.
|
|
84
|
+
*/
|
|
85
|
+
layout(): SizeLegendLayout;
|
|
86
|
+
/**
|
|
87
|
+
The width and height of the last layout, in pixels.
|
|
88
|
+
*/
|
|
89
|
+
outerBounds(): {
|
|
90
|
+
width: number;
|
|
91
|
+
height: number;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
Produces a backend-agnostic scene graph of the last layout, offset by the
|
|
95
|
+
optional transform.
|
|
96
|
+
@param x Horizontal offset of the legend's top-left corner.
|
|
97
|
+
@param y Vertical offset of the legend's top-left corner.
|
|
98
|
+
*/
|
|
99
|
+
toScene(x?: number, y?: number): GroupNode;
|
|
100
|
+
/**
|
|
101
|
+
Renders the legend. Standalone, it paints into the `select` container
|
|
102
|
+
(sized to the legend); inside a chart (`renderMode("compute")`) it only
|
|
103
|
+
lays out, and the chart composes `toScene()`.
|
|
104
|
+
@param callback Optional callback invoked after rendering completes.
|
|
105
|
+
*/
|
|
106
|
+
render(callback?: () => void): this;
|
|
107
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/** A continuous radius scale — the subset of a d3 scale the legend reads. */
|
|
2
|
+
export interface SizeLegendScale {
|
|
3
|
+
(value: number): number;
|
|
4
|
+
domain(): number[];
|
|
5
|
+
invert?(radius: number): number;
|
|
6
|
+
}
|
|
7
|
+
/** A chart's size legend as measured, and the chart area it would share, for the `sizeLegend` visibility check. */
|
|
8
|
+
export interface SizeLegendSize {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
availableWidth: number;
|
|
12
|
+
availableHeight: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
The default `sizeLegend` rule: show the legend (marks are sized by more
|
|
16
|
+
than one value, or there'd be nothing to measure) unless it would take up
|
|
17
|
+
more than a third of the chart's width or height.
|
|
18
|
+
*/
|
|
19
|
+
export declare function sizeLegendFits(_config: unknown, _scale: SizeLegendScale, size: SizeLegendSize): boolean;
|
|
20
|
+
/** Values to show: explicit numbers, a count of auto-picked values, or a picker. */
|
|
21
|
+
export type SizeLegendValues = number[] | number | ((domain: [number, number]) => number[]);
|
|
22
|
+
export interface SizeLegendLayoutInput {
|
|
23
|
+
scale: SizeLegendScale;
|
|
24
|
+
values?: SizeLegendValues;
|
|
25
|
+
tickFormat: (value: number) => string;
|
|
26
|
+
fontFamily: string;
|
|
27
|
+
fontSize: number;
|
|
28
|
+
title?: string;
|
|
29
|
+
titleFontFamily: string;
|
|
30
|
+
titleFontSize: number;
|
|
31
|
+
titleFontWeight: number | string;
|
|
32
|
+
/** Gap between the widest circle's right edge and the leader-line end. */
|
|
33
|
+
lineLength: number;
|
|
34
|
+
/** Gap between the leader-line end and its label. */
|
|
35
|
+
labelPadding: number;
|
|
36
|
+
/** Padding around the whole legend. */
|
|
37
|
+
padding: number;
|
|
38
|
+
/** Drop any value whose circle would be larger than this radius. */
|
|
39
|
+
maxRadius?: number;
|
|
40
|
+
}
|
|
41
|
+
export interface SizeLegendCircle {
|
|
42
|
+
value: number;
|
|
43
|
+
cx: number;
|
|
44
|
+
cy: number;
|
|
45
|
+
r: number;
|
|
46
|
+
}
|
|
47
|
+
export interface SizeLegendLine {
|
|
48
|
+
value: number;
|
|
49
|
+
points: [number, number][];
|
|
50
|
+
}
|
|
51
|
+
export interface SizeLegendLabel {
|
|
52
|
+
value: number;
|
|
53
|
+
text: string;
|
|
54
|
+
/** The label's left edge. */
|
|
55
|
+
x: number;
|
|
56
|
+
/** Vertical center of the label. */
|
|
57
|
+
y: number;
|
|
58
|
+
width: number;
|
|
59
|
+
}
|
|
60
|
+
export interface SizeLegendLayout {
|
|
61
|
+
circles: SizeLegendCircle[];
|
|
62
|
+
lines: SizeLegendLine[];
|
|
63
|
+
labels: SizeLegendLabel[];
|
|
64
|
+
/** The title, centered on `x`, with `y` its baseline. */
|
|
65
|
+
title?: {
|
|
66
|
+
text: string;
|
|
67
|
+
x: number;
|
|
68
|
+
y: number;
|
|
69
|
+
width: number;
|
|
70
|
+
};
|
|
71
|
+
width: number;
|
|
72
|
+
height: number;
|
|
73
|
+
}
|
|
74
|
+
/** A layout with nothing to draw. */
|
|
75
|
+
export declare const emptySizeLegendLayout: () => SizeLegendLayout;
|
|
76
|
+
/**
|
|
77
|
+
The default values for a domain: its min and max (the real extremes, so
|
|
78
|
+
the outer and inner circles match the chart's largest and smallest marks)
|
|
79
|
+
plus, between them, the roundest number near each evenly spaced target —
|
|
80
|
+
among the candidates within 15% of the range of a target, the one with
|
|
81
|
+
the fewest significant digits, then the closest.
|
|
82
|
+
*/
|
|
83
|
+
export declare function defaultSizeLegendValues(domain: [number, number], count?: number): number[];
|
|
84
|
+
/**
|
|
85
|
+
Lays out the legend: circles sharing a bottom edge, a leader line from
|
|
86
|
+
each circle's top to its label in a column on the right (labels are
|
|
87
|
+
pushed apart so they never overlap), and the title centered over the
|
|
88
|
+
circles. Returns an empty layout when the scale's domain is a single
|
|
89
|
+
value (nothing to compare) or every value maps to a zero radius.
|
|
90
|
+
*/
|
|
91
|
+
export declare function computeSizeLegend(input: SizeLegendLayoutInput): SizeLegendLayout;
|
|
92
|
+
/**
|
|
93
|
+
The legend scale for marks drawn under a zoom of `k`: on screen, each
|
|
94
|
+
mark's radius is `k` times its layout radius, so the circles for a value
|
|
95
|
+
grow by `k` too. To keep the legend inside the space reserved for its
|
|
96
|
+
unzoomed circles, the domain's top shrinks to the value whose zoomed
|
|
97
|
+
circle fits in the unzoomed largest one's space (rounded down to a nice
|
|
98
|
+
number) — the legend relabels rather than grows. Scales without
|
|
99
|
+
`invert` keep their domain.
|
|
100
|
+
*/
|
|
101
|
+
export declare function zoomSizeLegendScale(scale: SizeLegendScale, k: number): SizeLegendScale;
|
|
@@ -110,8 +110,23 @@ export default class Tooltip extends BaseClass {
|
|
|
110
110
|
trStyle(): Record<string, unknown>;
|
|
111
111
|
trStyle(_: Record<string, unknown>): this;
|
|
112
112
|
/**
|
|
113
|
-
An object with CSS keys and values to be applied to all <td> elements inside of each <tr>.
|
|
113
|
+
An object with CSS keys and values to be applied to all <td> elements inside of each <tr>. Values may be `(d, i)` functions, where `i` is the cell's column index.
|
|
114
|
+
|
|
115
|
+
@example <caption>default styles</caption>
|
|
116
|
+
{
|
|
117
|
+
"text-align": (d, i) => i ? "right" : "left"
|
|
118
|
+
}
|
|
119
|
+
*/
|
|
120
|
+
tdStyle(): Record<string, unknown>;
|
|
121
|
+
tdStyle(_: Record<string, unknown>): this;
|
|
122
|
+
/**
|
|
123
|
+
An object with CSS keys and values to be applied to all <th> elements inside of the <thead>. Values may be `(d, i)` functions, where `i` is the cell's column index.
|
|
124
|
+
|
|
125
|
+
@example <caption>default styles</caption>
|
|
126
|
+
{
|
|
127
|
+
"text-align": (d, i) => i ? "right" : "left"
|
|
128
|
+
}
|
|
114
129
|
*/
|
|
115
|
-
|
|
116
|
-
|
|
130
|
+
thStyle(): Record<string, unknown>;
|
|
131
|
+
thStyle(_: Record<string, unknown>): this;
|
|
117
132
|
}
|
|
@@ -5,6 +5,7 @@ export { default as AxisRight } from "./Axis/AxisRight.js";
|
|
|
5
5
|
export { default as AxisTop } from "./Axis/AxisTop.js";
|
|
6
6
|
export { default as ColorScale } from "./ColorScale/ColorScale.js";
|
|
7
7
|
export { default as Legend } from "./Legend/Legend.js";
|
|
8
|
+
export { default as SizeLegend } from "./SizeLegend/SizeLegend.js";
|
|
8
9
|
export { default as Message } from "./Message.js";
|
|
9
10
|
export { default as TextBox } from "./TextBox.js";
|
|
10
11
|
export { default as Timeline } from "./Timeline/Timeline.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Warns about `shapeConfig` keys that no shape supports. A top-level key is
|
|
3
|
+
valid if any shape class has it (the config is shared by every shape type);
|
|
4
|
+
a key nested under a shape name (like `{Rect: {…}}`) must exist on that
|
|
5
|
+
shape.
|
|
6
|
+
@param owner The class name of the chart receiving the config.
|
|
7
|
+
@param config The user-supplied `shapeConfig` object.
|
|
8
|
+
@private
|
|
9
|
+
*/
|
|
10
|
+
export default function validateShapeConfig(owner: string, config: Record<string, unknown>): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ColorDefaults } from "@d3plus/color";
|
|
2
|
+
import type { ColorDefaultsConfig, D3plusConfig } from "./D3plusConfig.js";
|
|
2
3
|
/**
|
|
3
4
|
Provides shared configuration, event handling, and locale management inherited by all d3plus classes.
|
|
4
5
|
*/
|
|
@@ -43,6 +44,19 @@ export default class BaseClass {
|
|
|
43
44
|
*/
|
|
44
45
|
locale(): string;
|
|
45
46
|
locale(_: string | object): this;
|
|
47
|
+
/**
|
|
48
|
+
Overrides the default colors used when assigning fills from data and choosing legible text colors: `dark` and `light` (the text colors picked for contrast against a background), `missing` (null/undefined values), `on`/`off` (`true`/`false` values), `sequential` (the anchor hue for magnitude ramps), and `scale` (the categorical palette, given as a d3 ordinal scale or an array of colors). Keys are merged into the current defaults, and a Viz passes its overrides down to the shapes and components it draws.
|
|
49
|
+
|
|
50
|
+
@example
|
|
51
|
+
new Treemap()
|
|
52
|
+
.colorDefaults({
|
|
53
|
+
dark: "#222",
|
|
54
|
+
light: "#fff",
|
|
55
|
+
scale: ["#1b9e77", "#d95f02", "#7570b3"]
|
|
56
|
+
})
|
|
57
|
+
*/
|
|
58
|
+
colorDefaults(): ColorDefaults;
|
|
59
|
+
colorDefaults(_: ColorDefaultsConfig): this;
|
|
46
60
|
/**
|
|
47
61
|
Event listener for the specified event *typenames*. Mirrors the core [d3-selection](https://github.com/d3/d3-selection#selection_on) behavior.
|
|
48
62
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import type { ColorDefaults } from "@d3plus/color";
|
|
1
2
|
import type { DataPoint } from "@d3plus/data";
|
|
2
3
|
import type VizBase from "../charts/viz/VizBase.js";
|
|
3
4
|
import type { AccessorFn } from "./AccessorFn.js";
|
|
5
|
+
import type { SizeLegendLineConfig, SizeLegendShapeConfig, SizeLegendTextConfig } from "../components/SizeLegend/SizeLegend.js";
|
|
6
|
+
import type { SizeLegendScale, SizeLegendSize } from "../components/SizeLegend/sizeLegendLayout.js";
|
|
4
7
|
type Position = "top" | "right" | "bottom" | "left";
|
|
5
8
|
type DataPointAccessor<T> = string | ((d: DataPoint) => T);
|
|
6
9
|
/** A config value that is either a constant or a `(datum, index)` accessor. */
|
|
@@ -183,6 +186,53 @@ export interface LegendConfig {
|
|
|
183
186
|
/** The shape type used for each legend entry. */
|
|
184
187
|
shape?: Accessor<string>;
|
|
185
188
|
}
|
|
189
|
+
export interface SizeLegendConfig {
|
|
190
|
+
/**
|
|
191
|
+
The values to draw circles for: an array of values, how many to pick
|
|
192
|
+
from the size domain (default 3: its min, max, and a round middle), or
|
|
193
|
+
a function receiving the `[min, max]` domain and returning values.
|
|
194
|
+
*/
|
|
195
|
+
values?: number[] | number | ((domain: [number, number]) => number[]);
|
|
196
|
+
/** Formats each value's label. Defaults to the locale's abbreviated number format. */
|
|
197
|
+
tickFormat?: (value: number) => string;
|
|
198
|
+
/** Title above the circles. Defaults to the `size` key when `size` is set to a string. */
|
|
199
|
+
title?: string;
|
|
200
|
+
/** Circle paint: `fill`, `fillOpacity`, `stroke`, `strokeWidth`, `strokeOpacity`. */
|
|
201
|
+
shapeConfig?: SizeLegendShapeConfig;
|
|
202
|
+
/** Leader-line paint: `stroke`, `strokeWidth`, `strokeOpacity`, `strokeDasharray`. */
|
|
203
|
+
lineConfig?: SizeLegendLineConfig;
|
|
204
|
+
/** Value-label font: `fontColor`, `fontFamily`, `fontSize`. */
|
|
205
|
+
labelConfig?: SizeLegendTextConfig;
|
|
206
|
+
/** Title font: `fontColor`, `fontFamily`, `fontSize`, `fontWeight`. */
|
|
207
|
+
titleConfig?: SizeLegendTextConfig;
|
|
208
|
+
padding?: number;
|
|
209
|
+
/** Length of the leader lines past the largest circle, in pixels. */
|
|
210
|
+
lineLength?: number;
|
|
211
|
+
/** Gap between each leader line and its label, in pixels. */
|
|
212
|
+
labelPadding?: number;
|
|
213
|
+
}
|
|
214
|
+
export interface TrendLineConfig {
|
|
215
|
+
/** `"series"` (default) fits one line per series, colored to match it; `"all"` fits one line to every point. Stacked charts always fit the stack totals. */
|
|
216
|
+
group?: "series" | "all";
|
|
217
|
+
/** The polynomial degree when `trendLine` is `"polynomial"`. Defaults to 2. */
|
|
218
|
+
order?: number;
|
|
219
|
+
/** Draws a confidence band around a linear fit. Defaults to `false`. */
|
|
220
|
+
confidence?: boolean;
|
|
221
|
+
/** The confidence band's level, between 0 and 1. Defaults to 0.95. */
|
|
222
|
+
confidenceLevel?: number;
|
|
223
|
+
/** Area shape config for the confidence band. Its fill defaults to the line color. */
|
|
224
|
+
confidenceConfig?: Record<string, unknown>;
|
|
225
|
+
/** Shows the fitted equation, R², and observations when hovering a line. Defaults to `true`. */
|
|
226
|
+
tooltip?: boolean;
|
|
227
|
+
/** Line color. Defaults to the series color (dark gray when `group` is `"all"`). */
|
|
228
|
+
stroke?: string;
|
|
229
|
+
/** Line width in pixels. Defaults to 2. */
|
|
230
|
+
strokeWidth?: number;
|
|
231
|
+
/** Line dash pattern. Defaults to `"6 4"`. */
|
|
232
|
+
strokeDasharray?: string;
|
|
233
|
+
/** Other Line shape config. */
|
|
234
|
+
[key: string]: unknown;
|
|
235
|
+
}
|
|
186
236
|
export interface ColorScaleConfig {
|
|
187
237
|
/**
|
|
188
238
|
For a linear scale, the `[min, max]` values used by the color scale; values
|
|
@@ -198,6 +248,10 @@ export interface ColorScaleConfig {
|
|
|
198
248
|
/** Given a bucket's minimum and maximum values, returns the full label. */
|
|
199
249
|
bucketJoiner?: (min: string, max: string) => string;
|
|
200
250
|
}
|
|
251
|
+
/** `colorDefaults` input: any subset of the color defaults, with `scale` also accepting an array of colors. */
|
|
252
|
+
export type ColorDefaultsConfig = Partial<Omit<ColorDefaults, "scale">> & {
|
|
253
|
+
scale?: ColorDefaults["scale"] | string[];
|
|
254
|
+
};
|
|
201
255
|
export interface D3plusConfig {
|
|
202
256
|
/** Data array or URL string to load data from. */
|
|
203
257
|
data?: DataPoint[] | string;
|
|
@@ -239,6 +293,8 @@ export interface D3plusConfig {
|
|
|
239
293
|
baseline?: number;
|
|
240
294
|
/** Whether to cache the processed data between renders. */
|
|
241
295
|
cache?: boolean;
|
|
296
|
+
/** Overrides for the default colors used for data fills and legible text (see `colorDefaults` in @d3plus/color). */
|
|
297
|
+
colorDefaults?: ColorDefaultsConfig;
|
|
242
298
|
/** Treat a discrete color field as ordered: color it with a single-hue light→dark ramp instead of nominal categorical hues. */
|
|
243
299
|
colorOrdinal?: boolean;
|
|
244
300
|
/** Color scale key or custom color function. */
|
|
@@ -268,6 +324,11 @@ export interface D3plusConfig {
|
|
|
268
324
|
string | ((d: DataPoint, i: number) => number),
|
|
269
325
|
string | ((d: DataPoint, i: number) => number)
|
|
270
326
|
] | false;
|
|
327
|
+
/**
|
|
328
|
+
Paint for the shared tooltip's crosshair guide line (`stroke`,
|
|
329
|
+
`strokeWidth`, `strokeDasharray`, `strokeOpacity`, …).
|
|
330
|
+
*/
|
|
331
|
+
crosshairConfig?: Record<string, unknown>;
|
|
271
332
|
/** Maximum number of data points to render before downsampling. */
|
|
272
333
|
dataCutoff?: number;
|
|
273
334
|
/** Active depth level for nested groupings. */
|
|
@@ -381,6 +442,23 @@ export interface D3plusConfig {
|
|
|
381
442
|
shapeSort?: (a: string, b: string) => number;
|
|
382
443
|
/** Size accessor key. */
|
|
383
444
|
size?: string;
|
|
445
|
+
/**
|
|
446
|
+
Controls size-legend visibility — the nested-circle key drawn in the
|
|
447
|
+
bottom-right corner of charts that size their marks. Shown by default
|
|
448
|
+
whenever marks are sized by more than one value, unless it would take
|
|
449
|
+
up more than a third of the chart's width or height; pass `true` to
|
|
450
|
+
always show it, `false` to hide it, or a `(config, scale, size) =>
|
|
451
|
+
boolean` accessor.
|
|
452
|
+
*/
|
|
453
|
+
sizeLegend?: boolean | ((config: D3plusConfig, scale: SizeLegendScale, size: SizeLegendSize) => boolean);
|
|
454
|
+
/** Configuration for the size-legend component. */
|
|
455
|
+
sizeLegendConfig?: SizeLegendConfig;
|
|
456
|
+
/**
|
|
457
|
+
Which margin the size legend claims in the bottom-right corner:
|
|
458
|
+
`"right"` (default) keeps the chart's full height, `"bottom"` its full
|
|
459
|
+
width.
|
|
460
|
+
*/
|
|
461
|
+
sizeLegendPosition?: "right" | "bottom";
|
|
384
462
|
/** Whether to stack series. */
|
|
385
463
|
stacked?: boolean;
|
|
386
464
|
/**
|
|
@@ -463,6 +541,26 @@ export interface D3plusConfig {
|
|
|
463
541
|
tooltip?: boolean | ((d: DataPoint, i: number) => boolean);
|
|
464
542
|
/** Configuration for the tooltip component. */
|
|
465
543
|
tooltipConfig?: TooltipConfig;
|
|
544
|
+
/**
|
|
545
|
+
Whether hovering a Plot's plot area shows one tooltip listing every
|
|
546
|
+
series' value at the nearest discrete-axis position, with a crosshair
|
|
547
|
+
through it. Applies when a discrete axis is set and at least two series
|
|
548
|
+
share that position.
|
|
549
|
+
*/
|
|
550
|
+
tooltipShared?: boolean;
|
|
551
|
+
/**
|
|
552
|
+
Draws an automatic trend line fit to the plotted data: `true` (or
|
|
553
|
+
`"linear"`) for a least-squares line, or `"exponential"`,
|
|
554
|
+
`"logarithmic"`, `"power"`, or `"polynomial"`. `false` removes it.
|
|
555
|
+
*/
|
|
556
|
+
trendLine?: boolean | "linear" | "exponential" | "logarithmic" | "power" | "polynomial";
|
|
557
|
+
/**
|
|
558
|
+
Options for the trend lines: `group` (`"series"` or `"all"`), the
|
|
559
|
+
polynomial `order`, a `confidence` band with `confidenceLevel` and
|
|
560
|
+
`confidenceConfig`, `tooltip`, and Line styles (`stroke`,
|
|
561
|
+
`strokeWidth`, `strokeDasharray`, …).
|
|
562
|
+
*/
|
|
563
|
+
trendLineConfig?: TrendLineConfig;
|
|
466
564
|
/** Path or object for the topojson data. */
|
|
467
565
|
topojson?: string | object;
|
|
468
566
|
/** CSS color to fill the map shapes. */
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Marks a config function seeded by the library itself, so code that layers
|
|
3
|
+
config can tell it apart from one the user set.
|
|
4
|
+
@private
|
|
5
|
+
*/
|
|
6
|
+
export declare function markDefault<T extends object>(value: T): T;
|
|
7
|
+
/**
|
|
8
|
+
Whether a config value is one registered with `markDefault`.
|
|
9
|
+
@private
|
|
10
|
+
*/
|
|
11
|
+
export declare function isDefault(value: unknown): boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Toggles the console warnings d3plus logs when a class receives a config
|
|
3
|
+
property it does not support (like a misspelled key passed to `.config()`
|
|
4
|
+
or `shapeConfig`). Warnings are on by default and the setting applies to
|
|
5
|
+
every chart on the page. With no argument, returns the current setting.
|
|
6
|
+
|
|
7
|
+
@example
|
|
8
|
+
import {configWarnings} from "@d3plus/core";
|
|
9
|
+
configWarnings(false);
|
|
10
|
+
*/
|
|
11
|
+
export declare function configWarnings(): boolean;
|
|
12
|
+
export declare function configWarnings(_: boolean): void;
|
|
13
|
+
/**
|
|
14
|
+
Marks a config object as shared across several classes, so keys meant for
|
|
15
|
+
other targets (like a `shapeConfig` carrying both `r` and `width`) are
|
|
16
|
+
applied where supported without `BaseClass.config()` warning about the rest.
|
|
17
|
+
@private
|
|
18
|
+
*/
|
|
19
|
+
export declare function markSharedConfig<T extends object>(config: T): T;
|
|
20
|
+
/** @private */
|
|
21
|
+
export declare function isSharedConfig(config: unknown): boolean;
|
|
22
|
+
/**
|
|
23
|
+
Warns that `owner` was given a config key it does not support. Each message
|
|
24
|
+
is logged once, so re-renders (and framework wrappers re-applying the same
|
|
25
|
+
config) don't flood the console.
|
|
26
|
+
@private
|
|
27
|
+
*/
|
|
28
|
+
export declare function warnUnknownConfig(owner: string, key: string): void;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export type { AccessorFn } from "./AccessorFn.js";
|
|
2
2
|
export { default as accessor } from "./accessor.js";
|
|
3
3
|
export { default as BaseClass } from "./BaseClass.js";
|
|
4
|
-
export type { D3plusConfig, AxisConfig, ColorScaleConfig, LegendConfig, TextBoxConfig, TimelineConfig, TooltipConfig, } from "./D3plusConfig.js";
|
|
4
|
+
export type { D3plusConfig, AxisConfig, ColorDefaultsConfig, ColorScaleConfig, LegendConfig, SizeLegendConfig, TextBoxConfig, TimelineConfig, TooltipConfig, TrendLineConfig, } from "./D3plusConfig.js";
|
|
5
5
|
export type { D3Scale } from "./D3Scale.js";
|
|
6
6
|
export { default as configPrep } from "./configPrep.js";
|
|
7
|
+
export { configWarnings } from "./configWarnings.js";
|
|
7
8
|
export { default as constant } from "./constant.js";
|
|
8
9
|
export { default as getProp } from "./getProp.js";
|
|
9
10
|
export { paintComponentScene } from "./paintComponentScene.js";
|