@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
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Options for {@link createDataPoller}. */ /**
|
|
2
|
+
Calls `fetch` every `interval` ms, chaining each wait from the end of the
|
|
3
|
+
previous fetch so requests never overlap. A tick that comes due while
|
|
4
|
+
`paused()` is held until `resume()`. Errors are reported once per streak
|
|
5
|
+
and polling continues.
|
|
6
|
+
@private
|
|
7
|
+
*/ export function createDataPoller(opts) {
|
|
8
|
+
let timer;
|
|
9
|
+
let stopped = false;
|
|
10
|
+
let inFlight = false;
|
|
11
|
+
let missed = false;
|
|
12
|
+
let failing = false;
|
|
13
|
+
const schedule = ()=>{
|
|
14
|
+
timer = setTimeout(tick, opts.interval);
|
|
15
|
+
};
|
|
16
|
+
const run = ()=>{
|
|
17
|
+
missed = false;
|
|
18
|
+
inFlight = true;
|
|
19
|
+
Promise.resolve().then(opts.fetch).then((value)=>{
|
|
20
|
+
if (stopped) return;
|
|
21
|
+
failing = false;
|
|
22
|
+
opts.onData(value);
|
|
23
|
+
}, (err)=>{
|
|
24
|
+
if (stopped) return;
|
|
25
|
+
if (!failing) opts.onError(err);
|
|
26
|
+
failing = true;
|
|
27
|
+
}).catch((err)=>{
|
|
28
|
+
if (!stopped) opts.onError(err);
|
|
29
|
+
}).finally(()=>{
|
|
30
|
+
inFlight = false;
|
|
31
|
+
if (!stopped) schedule();
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
function tick() {
|
|
35
|
+
timer = undefined;
|
|
36
|
+
if (stopped) return;
|
|
37
|
+
if (opts.paused()) missed = true;
|
|
38
|
+
else run();
|
|
39
|
+
}
|
|
40
|
+
schedule();
|
|
41
|
+
return {
|
|
42
|
+
stop () {
|
|
43
|
+
stopped = true;
|
|
44
|
+
clearTimeout(timer);
|
|
45
|
+
timer = undefined;
|
|
46
|
+
},
|
|
47
|
+
resume () {
|
|
48
|
+
if (stopped || !missed || inFlight || opts.paused()) return;
|
|
49
|
+
run();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
*/ /** The row key holding a group row's `groupBy` level. */ export const GROUP_DEPTH_KEY = "__d3plusGroupDepth";
|
|
7
|
+
/** The row key holding a group row's own label, when its chart sets one. */ export const GROUP_LABEL_KEY = "__d3plusGroupLabel";
|
|
8
|
+
/** The source row a datum wraps (a label record, or a laid-out node). */ function unwrap(d) {
|
|
9
|
+
let row = d;
|
|
10
|
+
while(row && row.__d3plus__ && row.data)row = row.data;
|
|
11
|
+
return row;
|
|
12
|
+
}
|
|
13
|
+
/** The `groupBy` level a group row stands for, or undefined for any other row. */ export function groupDepthOf(d) {
|
|
14
|
+
const row = unwrap(d);
|
|
15
|
+
const depth = row ? row[GROUP_DEPTH_KEY] : undefined;
|
|
16
|
+
return typeof depth === "number" ? depth : undefined;
|
|
17
|
+
}
|
|
18
|
+
/** A group row's key at each `groupBy` level, from the first down to its own. */ export function groupPath(groupBy, d, depth) {
|
|
19
|
+
const row = unwrap(d);
|
|
20
|
+
return groupBy.slice(0, depth + 1).map((g)=>g(row, 0));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
Whether `d` belongs to the group at `path`: its key at each of the path's
|
|
24
|
+
levels is the group's, or for a merged row holds it.
|
|
25
|
+
*/ export function inGroup(groupBy, path, d, i) {
|
|
26
|
+
const row = unwrap(d);
|
|
27
|
+
if (!row) return false;
|
|
28
|
+
return path.every((key, j)=>{
|
|
29
|
+
const value = groupBy[j](row, i);
|
|
30
|
+
return value === key || Array.isArray(value) && value.includes(key);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** Whether `rows` hold any row outside the group at `path`, so zooming into it narrows the view. */ export function groupNarrows(groupBy, path, rows) {
|
|
34
|
+
return rows.some((d, i)=>!inGroup(groupBy, path, d, i));
|
|
35
|
+
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/ import { color } from "d3-color";
|
|
11
11
|
import { colorGrayscale } from "@d3plus/color";
|
|
12
12
|
import { activeBucketColors } from "../features/colorScaleBucket.js";
|
|
13
|
+
import { hoveredSwatch } from "../features/colorScaleHover.js";
|
|
13
14
|
import { MARK_TYPES } from "./sceneRows.js";
|
|
14
15
|
/** z value that floats a hovered/highlighted node above its (z-less, i.e. 0) siblings. */ const HOVER_RAISE_Z = 1e6;
|
|
15
16
|
/**
|
|
@@ -73,11 +74,24 @@ import { MARK_TYPES } from "./sceneRows.js";
|
|
|
73
74
|
by its bucket COLOR, not by id/value — so this only touches those nodes and
|
|
74
75
|
leaves the colorScale title/axis/gradient at full opacity. A swatch stays
|
|
75
76
|
bright when its color is "active" (its range contains a datum matching the
|
|
76
|
-
current hover); every other swatch dims.
|
|
77
|
+
current hover); every other swatch dims. A chart without a hover
|
|
78
|
+
predicate of its own (shape hover off) lights the swatch of the value
|
|
79
|
+
its colorScale marks (see `hoveredSwatch`). No-op when nothing is hovered.
|
|
77
80
|
*/ export function applyColorScaleBucketOpacity(nodes, viz) {
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
const swatch = hoveredSwatch(viz);
|
|
82
|
+
let activeColors;
|
|
83
|
+
let dimOpacity;
|
|
84
|
+
if (swatch) {
|
|
85
|
+
activeColors = new Set([
|
|
86
|
+
swatch.color
|
|
87
|
+
]);
|
|
88
|
+
dimOpacity = swatch.dimOpacity;
|
|
89
|
+
} else {
|
|
90
|
+
const settings = dimSettings(viz);
|
|
91
|
+
if (!settings) return nodes;
|
|
92
|
+
activeColors = activeBucketColors(viz, settings.predicate);
|
|
93
|
+
dimOpacity = settings.dimOpacity;
|
|
94
|
+
}
|
|
81
95
|
if (!activeColors) return nodes;
|
|
82
96
|
const walk = (node)=>{
|
|
83
97
|
let next = node;
|
|
@@ -91,7 +105,7 @@ import { MARK_TYPES } from "./sceneRows.js";
|
|
|
91
105
|
...node,
|
|
92
106
|
paint: {
|
|
93
107
|
...node.paint ?? {},
|
|
94
|
-
opacity: base *
|
|
108
|
+
opacity: base * dimOpacity
|
|
95
109
|
}
|
|
96
110
|
};
|
|
97
111
|
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Warns when a config key names a data field that no row of the chart's data
|
|
3
|
+
has (a typo like `y: "vlaue"` otherwise draws an empty chart in silence).
|
|
4
|
+
Only field names the user gave are checked: string config values become
|
|
5
|
+
accessors remembered by `fieldAccessor`, while function accessors,
|
|
6
|
+
constants, and defaults are never checked.
|
|
7
|
+
*/ import { canWarnOnce, warnConfigOnce } from "../../utils/configWarnings.js";
|
|
8
|
+
import { fieldNameOf } from "../../utils/fieldAccessor.js";
|
|
9
|
+
/** Config keys a chart stores outside `viz.schema`. */ const SLOT_KEYS = {
|
|
10
|
+
x: "_x",
|
|
11
|
+
x2: "_x2",
|
|
12
|
+
y: "_y",
|
|
13
|
+
y2: "_y2",
|
|
14
|
+
size: "_size",
|
|
15
|
+
stackOrder: "_stackOrder"
|
|
16
|
+
};
|
|
17
|
+
/** Schema keys that hold field names as plain strings. */ const NAME_KEYS = [
|
|
18
|
+
"dimensions"
|
|
19
|
+
];
|
|
20
|
+
/** The most field names a warning lists. */ export const MAX_LISTED_FIELDS = 10;
|
|
21
|
+
/**
|
|
22
|
+
The data fields a chart's config names, each under the first key that
|
|
23
|
+
holds its accessor (so `thresholdKey`, which some charts point at `sum` or
|
|
24
|
+
`y`, only names a field the user gave it alone).
|
|
25
|
+
@param viz The chart.
|
|
26
|
+
*/ export function fieldUses(viz) {
|
|
27
|
+
const uses = new Map();
|
|
28
|
+
const add = (key, fn)=>{
|
|
29
|
+
const field = fieldNameOf(fn);
|
|
30
|
+
if (field !== undefined && !uses.has(fn)) uses.set(fn, {
|
|
31
|
+
key,
|
|
32
|
+
field
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
for (const [key, slot] of Object.entries(SLOT_KEYS))add(key, viz[slot]);
|
|
36
|
+
for (const band of viz._confidenceBands ?? []){
|
|
37
|
+
add("confidence", band.lower);
|
|
38
|
+
add("confidence", band.upper);
|
|
39
|
+
}
|
|
40
|
+
const keys = Object.keys(viz.schema).filter((k)=>k !== "thresholdKey");
|
|
41
|
+
for (const key of [
|
|
42
|
+
...keys,
|
|
43
|
+
"thresholdKey"
|
|
44
|
+
]){
|
|
45
|
+
const value = viz.schema[key];
|
|
46
|
+
// An array of accessors, like `groupBy`; other arrays (such as `nodes`)
|
|
47
|
+
// hold data, not config.
|
|
48
|
+
if (Array.isArray(value) && typeof value[0] === "function") value.forEach((fn)=>add(key, fn));
|
|
49
|
+
else add(key, value);
|
|
50
|
+
}
|
|
51
|
+
const out = Array.from(uses.values());
|
|
52
|
+
for (const key of NAME_KEYS){
|
|
53
|
+
const value = viz.schema[key];
|
|
54
|
+
const names = Array.isArray(value) ? value : [
|
|
55
|
+
value
|
|
56
|
+
];
|
|
57
|
+
for (const field of names)if (typeof field === "string") out.push({
|
|
58
|
+
key,
|
|
59
|
+
field
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
The rows a chart's field names are read from: its data (the user's rows,
|
|
66
|
+
when the chart derives `_data` from them), plus the `nodes` and `links`
|
|
67
|
+
arrays of a network chart.
|
|
68
|
+
@param viz The chart.
|
|
69
|
+
*/ export function fieldRows(viz) {
|
|
70
|
+
const data = viz._sourceData ?? viz._data;
|
|
71
|
+
return [
|
|
72
|
+
data,
|
|
73
|
+
viz.schema.nodes,
|
|
74
|
+
viz.schema.links
|
|
75
|
+
].filter((rows)=>Array.isArray(rows));
|
|
76
|
+
}
|
|
77
|
+
const isRow = (d)=>d !== null && typeof d === "object";
|
|
78
|
+
/**
|
|
79
|
+
Whether any row in `rowSets` has `field`.
|
|
80
|
+
@param rowSets Arrays of data rows.
|
|
81
|
+
@param field The field name.
|
|
82
|
+
*/ export function rowsHaveField(rowSets, field) {
|
|
83
|
+
return rowSets.some((rows)=>rows.some((d)=>isRow(d) && field in d));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
Every field name in `rowSets`, in the order first seen.
|
|
87
|
+
@param rowSets Arrays of data rows.
|
|
88
|
+
*/ export function rowFields(rowSets) {
|
|
89
|
+
const names = new Set();
|
|
90
|
+
for (const rows of rowSets)for (const d of rows)if (isRow(d)) for(const k in d)names.add(k);
|
|
91
|
+
return Array.from(names);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
The warning for a config key whose field no row has, listing the first
|
|
95
|
+
`MAX_LISTED_FIELDS` fields the rows do have.
|
|
96
|
+
@param chart The chart's name.
|
|
97
|
+
@param use The config key and the field it names.
|
|
98
|
+
@param fields The fields the rows have.
|
|
99
|
+
*/ export function missingFieldMessage(chart, { key, field }, fields) {
|
|
100
|
+
const listed = fields.slice(0, MAX_LISTED_FIELDS);
|
|
101
|
+
if (fields.length > MAX_LISTED_FIELDS) listed.push("…");
|
|
102
|
+
return `${chart} ${key}: no rows have '${field}'; fields are: ${listed.join(", ")}`;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
Warns, once per key and field for each chart, about every config key that
|
|
106
|
+
names a field none of the chart's rows have. Rows missing some fields are
|
|
107
|
+
normal (sparse data), so a field any row has never warns, and a chart with
|
|
108
|
+
no rows warns about nothing.
|
|
109
|
+
@param viz The chart.
|
|
110
|
+
*/ export function warnMissingFields(viz) {
|
|
111
|
+
const id = ({ key, field })=>`missing-field:${key}:${field}`;
|
|
112
|
+
const uses = fieldUses(viz).filter((use)=>canWarnOnce(viz, id(use)));
|
|
113
|
+
if (!uses.length) return;
|
|
114
|
+
const rowSets = fieldRows(viz);
|
|
115
|
+
if (!rowSets.some((rows)=>rows.some(isRow))) return;
|
|
116
|
+
let fields;
|
|
117
|
+
for (const use of uses){
|
|
118
|
+
if (rowsHaveField(rowSets, use.field)) continue;
|
|
119
|
+
fields ??= rowFields(rowSets);
|
|
120
|
+
warnConfigOnce(viz, id(use), missingFieldMessage(viz.constructor.name, use, fields));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Reports an error an event handler threw without interrupting the event:
|
|
3
|
+
`reportError` logs it as an uncaught error (with its stack) and fires the
|
|
4
|
+
window's `error` event, so the remaining handlers still run. Falls back to
|
|
5
|
+
`console.error` where `reportError` doesn't exist.
|
|
6
|
+
*/ export function reportHandlerError(error) {
|
|
7
|
+
const report = globalThis.reportError;
|
|
8
|
+
if (typeof report === "function") report(error);
|
|
9
|
+
else console.error(error);
|
|
10
|
+
}
|
|
@@ -10,6 +10,21 @@
|
|
|
10
10
|
x: raw
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
+
/** The shape class of a mark a chart emits as a bare scene node, without a `shapeType`. */ const nodeShapes = {
|
|
14
|
+
area: "Area",
|
|
15
|
+
circle: "Circle",
|
|
16
|
+
line: "Line",
|
|
17
|
+
path: "Path",
|
|
18
|
+
rect: "Rect"
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
A picked node's shape class: its stamped `shapeType`, else the shape its
|
|
22
|
+
node type draws (a Treemap tile is a `"Rect"`, a Geomap region a
|
|
23
|
+
`"Path"`). Text, images, and groups have none.
|
|
24
|
+
*/ export function nodeShapeType(node) {
|
|
25
|
+
if (typeof node.shapeType === "string") return node.shapeType;
|
|
26
|
+
return nodeShapes[node.type];
|
|
27
|
+
}
|
|
13
28
|
/**
|
|
14
29
|
The shape classes a picked chart node fires `"<event>.<shapeType>"`
|
|
15
30
|
handlers for: the shape that drew it, with the pick's own `(d, i, x)`, then
|
|
@@ -18,8 +33,9 @@
|
|
|
18
33
|
`.Box`, once each.
|
|
19
34
|
*/ export function shapeClassTargets(node, own) {
|
|
20
35
|
const targets = [];
|
|
21
|
-
|
|
22
|
-
|
|
36
|
+
const shapeType = nodeShapeType(node);
|
|
37
|
+
if (shapeType) targets.push({
|
|
38
|
+
shapeType,
|
|
23
39
|
...own
|
|
24
40
|
});
|
|
25
41
|
for (const owner of node.owners ?? []){
|
|
@@ -4,8 +4,10 @@ import { broadcastLink } from "./linkGroup.js";
|
|
|
4
4
|
(Chord, Network, Rings, Sankey): stores the predicate, hands it to the
|
|
5
5
|
legend, schedules a repaint so the scene's interaction-opacity pass
|
|
6
6
|
re-reads it, and broadcasts it to linked charts.
|
|
7
|
+
With no argument, returns the current predicate.
|
|
7
8
|
@param _ The hover predicate, or `false` to clear it.
|
|
8
9
|
*/ export function simpleHover(_) {
|
|
10
|
+
if (!arguments.length) return this._hover;
|
|
9
11
|
this._hover = _;
|
|
10
12
|
if (this.schema.legend && this._legendClass) this._legendClass.hover(_);
|
|
11
13
|
if (this._sceneRenderer) this._scheduleSceneRepaint();
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Where a chart's `className` goes: the element its pixels are drawn on, the
|
|
3
|
+
root `<svg class="d3plus-viz">` or, with the Canvas renderer, its
|
|
4
|
+
`<canvas>`. (With Canvas the root svg stays in place above the canvas for
|
|
5
|
+
the zoom brush, so it takes no classes: a background on it would hide the
|
|
6
|
+
chart.)
|
|
7
|
+
*/ import { RENDERER_CLASSES, rendererSurfaces } from "../../utils/className.js";
|
|
8
|
+
/** A chart's fixed root class. */ export const ROOT_CLASS = "d3plus-viz";
|
|
9
|
+
/**
|
|
10
|
+
The elements a chart's `className` applies to, each with the fixed
|
|
11
|
+
classes it keeps. Before the first render the chart's `select` is still the
|
|
12
|
+
page's own container, which never takes the classes.
|
|
13
|
+
@param root The chart's `select` node.
|
|
14
|
+
@param renderer The chart's scene renderer, once it has rendered.
|
|
15
|
+
@param kind The chart's renderer setting.
|
|
16
|
+
@private
|
|
17
|
+
*/ export function vizClassNameTargets(root, renderer, kind) {
|
|
18
|
+
if (kind === "canvas") return rendererSurfaces(renderer).filter((el)=>el.localName === "canvas").map((el)=>({
|
|
19
|
+
el,
|
|
20
|
+
keep: RENDERER_CLASSES
|
|
21
|
+
}));
|
|
22
|
+
const svg = typeof Element !== "undefined" && root instanceof Element && root.classList.contains(ROOT_CLASS) ? root : undefined;
|
|
23
|
+
return svg ? [
|
|
24
|
+
{
|
|
25
|
+
el: svg,
|
|
26
|
+
keep: [
|
|
27
|
+
ROOT_CLASS
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
] : [];
|
|
31
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { isData, load } from "@d3plus/data";
|
|
2
|
+
import { warnConfig } from "../../utils/configWarnings.js";
|
|
3
|
+
import { createDataPoller } from "./dataPoller.js";
|
|
4
|
+
import { canObserveVisibility, observeVisibility } from "./vizVisibility.js";
|
|
5
|
+
/**
|
|
6
|
+
Whether a `data` value is fetched: a URL, a request object, or an Array
|
|
7
|
+
holding at least one of them.
|
|
8
|
+
@private
|
|
9
|
+
*/ export function isPollable(source) {
|
|
10
|
+
return source instanceof Array ? source.some(isData) : isData(source);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
The paths a poll fetches: `source` as an Array, with each URL and request
|
|
14
|
+
object revalidated with the server (`cache: "no-cache"`) unless the request
|
|
15
|
+
sets its own `cache`.
|
|
16
|
+
@private
|
|
17
|
+
*/ export function pollPaths(source) {
|
|
18
|
+
const paths = source instanceof Array ? source : [
|
|
19
|
+
source
|
|
20
|
+
];
|
|
21
|
+
return paths.map((p)=>{
|
|
22
|
+
if (!isData(p)) return p;
|
|
23
|
+
if (typeof p === "string") return {
|
|
24
|
+
url: p,
|
|
25
|
+
cache: "no-cache"
|
|
26
|
+
};
|
|
27
|
+
const request = p;
|
|
28
|
+
return "cache" in request ? request : {
|
|
29
|
+
...request,
|
|
30
|
+
cache: "no-cache"
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
A short fingerprint of a JSON-serializable value (its JSON length plus a
|
|
36
|
+
32-bit FNV-1a hash), used to skip redrawing when a poll returns the same
|
|
37
|
+
data.
|
|
38
|
+
@private
|
|
39
|
+
*/ export function dataSignature(value) {
|
|
40
|
+
const json = JSON.stringify(value) ?? "";
|
|
41
|
+
let hash = 0x811c9dc5;
|
|
42
|
+
for(let i = 0; i < json.length; i++){
|
|
43
|
+
hash ^= json.charCodeAt(i);
|
|
44
|
+
hash = Math.imul(hash, 0x01000193);
|
|
45
|
+
}
|
|
46
|
+
return `${json.length}:${(hash >>> 0).toString(36)}`;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
Loads `source` the way `data()` does (the same formatter, and a formatter
|
|
50
|
+
may return `{data, ...config}`) without storing it on the chart.
|
|
51
|
+
@private
|
|
52
|
+
*/ function fetchPoll(viz, source, formatter) {
|
|
53
|
+
return new Promise((resolve, reject)=>{
|
|
54
|
+
let config;
|
|
55
|
+
const ctx = {
|
|
56
|
+
_cache: false,
|
|
57
|
+
_lrucache: viz._lrucache,
|
|
58
|
+
_data: [],
|
|
59
|
+
config: (obj)=>{
|
|
60
|
+
config = obj;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const paths = pollPaths(source);
|
|
64
|
+
load.call(ctx, paths, formatter, "data", (err, data)=>{
|
|
65
|
+
if (err) reject(err);
|
|
66
|
+
else resolve({
|
|
67
|
+
data: data ?? [],
|
|
68
|
+
config
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
Records the fingerprint of freshly loaded data, so a poll returning the
|
|
75
|
+
same data skips its redraw.
|
|
76
|
+
@private
|
|
77
|
+
*/ export function recordDataSignature(viz, data) {
|
|
78
|
+
viz._dataSignature = viz.schema.dataPollingInterval ? dataSignature(data) : undefined;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
Stops a chart's data polling and its visibility listeners.
|
|
82
|
+
@private
|
|
83
|
+
*/ export function stopDataPolling(viz) {
|
|
84
|
+
viz._dataPollStop?.();
|
|
85
|
+
viz._dataPollStop = undefined;
|
|
86
|
+
viz._dataPollFor = undefined;
|
|
87
|
+
}
|
|
88
|
+
/** What a running poll was started for; a change restarts it. */ function pollKey(viz) {
|
|
89
|
+
return [
|
|
90
|
+
viz.schema.dataPollingInterval,
|
|
91
|
+
viz._userData,
|
|
92
|
+
viz._userDataFormat,
|
|
93
|
+
viz.schema.detectVisible,
|
|
94
|
+
viz.schema.scrollContainer
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
/** Applies a poll's result and redraws, unless it matches the drawn data. */ function applyPoll(viz, { data, config }) {
|
|
98
|
+
const signature = dataSignature(data);
|
|
99
|
+
if (signature === viz._dataSignature) return;
|
|
100
|
+
viz._dataSignature = signature;
|
|
101
|
+
if (config) viz.config(config);
|
|
102
|
+
viz._data = data;
|
|
103
|
+
// A timeline the user hasn't brushed re-defaults, following a new latest period.
|
|
104
|
+
if (!viz.schema.timeFilter) viz._timelineSelection = false;
|
|
105
|
+
viz.render();
|
|
106
|
+
}
|
|
107
|
+
/** Starts polling `viz._userData` every `interval` ms. */ function startDataPolling(viz, interval) {
|
|
108
|
+
const source = viz._userData;
|
|
109
|
+
const formatter = viz._userDataFormat;
|
|
110
|
+
const doc = viz._select?.node()?.ownerDocument;
|
|
111
|
+
let offscreen = false;
|
|
112
|
+
const poller = createDataPoller({
|
|
113
|
+
interval,
|
|
114
|
+
fetch: ()=>fetchPoll(viz, source, formatter),
|
|
115
|
+
onData: (result)=>applyPoll(viz, result),
|
|
116
|
+
onError: (err)=>{
|
|
117
|
+
console.warn("d3plus: dataPollingInterval could not refresh the data; keeping the last data and retrying.", err);
|
|
118
|
+
},
|
|
119
|
+
paused: ()=>offscreen || doc?.visibilityState === "hidden"
|
|
120
|
+
});
|
|
121
|
+
const onVisibilityChange = ()=>{
|
|
122
|
+
if (doc?.visibilityState !== "hidden") poller.resume();
|
|
123
|
+
};
|
|
124
|
+
doc?.addEventListener("visibilitychange", onVisibilityChange);
|
|
125
|
+
const unobserve = viz.schema.detectVisible && canObserveVisibility() ? observeVisibility(viz._select.node(), viz.schema.scrollContainer, ()=>{
|
|
126
|
+
offscreen = false;
|
|
127
|
+
poller.resume();
|
|
128
|
+
}, 0, ()=>{
|
|
129
|
+
offscreen = true;
|
|
130
|
+
}) : undefined;
|
|
131
|
+
viz._dataPollFor = pollKey(viz);
|
|
132
|
+
viz._dataPollStop = ()=>{
|
|
133
|
+
poller.stop();
|
|
134
|
+
doc?.removeEventListener("visibilitychange", onVisibilityChange);
|
|
135
|
+
unobserve?.();
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
Starts, restarts or stops a drawn chart's data polling to match its
|
|
140
|
+
`dataPollingInterval` and `data`. A no-op while the poll it would start is
|
|
141
|
+
already running, and never polls during server-side rendering.
|
|
142
|
+
@private
|
|
143
|
+
*/ export function syncDataPolling(viz) {
|
|
144
|
+
const interval = viz.schema.dataPollingInterval;
|
|
145
|
+
const wanted = typeof interval === "number" && interval > 0 && isFinite(interval);
|
|
146
|
+
if (wanted && !isPollable(viz._userData)) {
|
|
147
|
+
warnConfig(`${viz.constructor.name}: dataPollingInterval only polls data loaded from a URL.`);
|
|
148
|
+
}
|
|
149
|
+
if (!wanted || viz._ssr || !isPollable(viz._userData)) {
|
|
150
|
+
stopDataPolling(viz);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const key = pollKey(viz);
|
|
154
|
+
const running = viz._dataPollFor;
|
|
155
|
+
if (running && running.every((v, i)=>v === key[i])) return;
|
|
156
|
+
stopDataPolling(viz);
|
|
157
|
+
startDataPolling(viz, interval);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
Applies a `dataPollingInterval` change to a chart that has finished its
|
|
161
|
+
data load; a chart still loading starts polling once it draws.
|
|
162
|
+
@private
|
|
163
|
+
*/ export function onDataPollingIntervalSet(viz) {
|
|
164
|
+
if (!viz._dataPollStop && !viz._sceneRenderer) return;
|
|
165
|
+
if (viz._queue?.some((q)=>q[3] === "data")) return;
|
|
166
|
+
syncDataPolling(viz);
|
|
167
|
+
}
|
|
@@ -131,6 +131,7 @@ function debounce(func, delay) {
|
|
|
131
131
|
*/ function initDataDefaults(viz) {
|
|
132
132
|
viz._data = [];
|
|
133
133
|
viz.schema.dataCutoff = 100;
|
|
134
|
+
viz.schema.dataPollingInterval = false;
|
|
134
135
|
viz.schema.detectResize = true;
|
|
135
136
|
viz.schema.detectResizeDelay = 400;
|
|
136
137
|
viz.schema.detectVisible = true;
|
|
@@ -154,6 +155,8 @@ function debounce(func, delay) {
|
|
|
154
155
|
viz.schema.legend = (config, arr)=>{
|
|
155
156
|
if (viz._legendCategories) return arr.length > 1;
|
|
156
157
|
const maxGrouped = max(arr, (d, i)=>{
|
|
158
|
+
// A threshold bucket is one entry, however many groups it holds.
|
|
159
|
+
if (d._isAggregation) return 1;
|
|
157
160
|
const id = viz.schema.groupBy[viz._legendDepth].bind(viz)(d, i);
|
|
158
161
|
return id instanceof Array ? id.length : 1;
|
|
159
162
|
});
|
|
@@ -522,6 +525,68 @@ export const searchControlStyleHoverDefault = false;
|
|
|
522
525
|
viz.schema.searchControlStyleActive = searchControlStyleActiveDefault;
|
|
523
526
|
viz.schema.searchControlStyleHover = searchControlStyleHoverDefault;
|
|
524
527
|
}
|
|
528
|
+
/**
|
|
529
|
+
Default inline styles for the download button, the same structural values
|
|
530
|
+
as the other top-left controls, as their own objects so setting
|
|
531
|
+
`saveControlClassName` can detect an untouched default by reference.
|
|
532
|
+
@private
|
|
533
|
+
*/ export const saveControlStyleDefault = {
|
|
534
|
+
"align-items": "center",
|
|
535
|
+
"box-sizing": "border-box",
|
|
536
|
+
display: "inline-flex",
|
|
537
|
+
font: `900 15px/1 ${fontFamilyStringify(fontFamily)}`,
|
|
538
|
+
height: "20px",
|
|
539
|
+
"justify-content": "center",
|
|
540
|
+
margin: 0,
|
|
541
|
+
padding: 0,
|
|
542
|
+
width: "20px"
|
|
543
|
+
};
|
|
544
|
+
export const saveControlStyleActiveDefault = {
|
|
545
|
+
"background-color": "AccentColor",
|
|
546
|
+
"border-color": "AccentColor",
|
|
547
|
+
color: "AccentColorText"
|
|
548
|
+
};
|
|
549
|
+
export const saveControlStyleHoverDefault = false;
|
|
550
|
+
/**
|
|
551
|
+
Default inline styles for the download menu and its items: the theme
|
|
552
|
+
(colors, border, spacing, font) on top of the fixed layout in
|
|
553
|
+
`saveControlMarkup.ts`. Setting `saveControlMenuClassName` drops them.
|
|
554
|
+
@private
|
|
555
|
+
*/ export const saveControlMenuStyleDefault = {
|
|
556
|
+
background: "Canvas",
|
|
557
|
+
border: "1px solid rgba(128, 128, 128, 0.5)",
|
|
558
|
+
"border-radius": "3px",
|
|
559
|
+
"box-shadow": "0 2px 6px rgba(0, 0, 0, 0.2)",
|
|
560
|
+
color: "CanvasText",
|
|
561
|
+
"margin-top": "4px",
|
|
562
|
+
padding: "2px 0"
|
|
563
|
+
};
|
|
564
|
+
export const saveControlMenuItemStyleDefault = {
|
|
565
|
+
background: "none",
|
|
566
|
+
border: "none",
|
|
567
|
+
color: "inherit",
|
|
568
|
+
font: `12px/1.2 ${fontFamilyStringify(fontFamily)}`,
|
|
569
|
+
margin: 0,
|
|
570
|
+
padding: "4px 10px"
|
|
571
|
+
};
|
|
572
|
+
export const saveControlMenuItemStyleHoverDefault = {
|
|
573
|
+
background: "rgba(128, 128, 128, 0.2)"
|
|
574
|
+
};
|
|
575
|
+
/**
|
|
576
|
+
Download button defaults.
|
|
577
|
+
@private
|
|
578
|
+
*/ function initSaveControlDefaults(viz) {
|
|
579
|
+
viz.schema.saveControl = true;
|
|
580
|
+
viz.schema.saveControlClassName = undefined;
|
|
581
|
+
viz.schema.saveControlConfig = {};
|
|
582
|
+
viz.schema.saveControlMenuClassName = undefined;
|
|
583
|
+
viz.schema.saveControlMenuItemStyle = saveControlMenuItemStyleDefault;
|
|
584
|
+
viz.schema.saveControlMenuItemStyleHover = saveControlMenuItemStyleHoverDefault;
|
|
585
|
+
viz.schema.saveControlMenuStyle = saveControlMenuStyleDefault;
|
|
586
|
+
viz.schema.saveControlStyle = saveControlStyleDefault;
|
|
587
|
+
viz.schema.saveControlStyleActive = saveControlStyleActiveDefault;
|
|
588
|
+
viz.schema.saveControlStyleHover = saveControlStyleHoverDefault;
|
|
589
|
+
}
|
|
525
590
|
/**
|
|
526
591
|
Seeds a fresh Viz instance's schema defaults and installs the identity-coerce
|
|
527
592
|
fluent accessors. Extracted from the constructor so the seeding logic stays
|
|
@@ -547,4 +612,5 @@ export const searchControlStyleHoverDefault = false;
|
|
|
547
612
|
initMinimapDefaults(viz);
|
|
548
613
|
initBackDefaults(viz);
|
|
549
614
|
initSearchDefaults(viz);
|
|
615
|
+
initSaveControlDefaults(viz);
|
|
550
616
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { fieldAccessor } from "../../utils/fieldAccessor.js";
|
|
2
2
|
import { registerLink } from "./linkGroup.js";
|
|
3
|
-
|
|
3
|
+
import { onDataPollingIntervalSet } from "./vizDataPolling.js";
|
|
4
|
+
/** A falsy value (no color) is stored as given, a key string read from each datum. */ export const optionalAccessor = (value)=>!value || typeof value === "function" ? value : fieldAccessor(value);
|
|
4
5
|
/**
|
|
5
6
|
The config keys every chart has, as generated accessors (`viz.<key>(value)`
|
|
6
7
|
sets, `viz.<key>()` gets): stored as given, wrapped as a constant
|
|
@@ -42,6 +43,9 @@ import { registerLink } from "./linkGroup.js";
|
|
|
42
43
|
coerce: "const"
|
|
43
44
|
},
|
|
44
45
|
dataCutoff: {},
|
|
46
|
+
dataPollingInterval: {
|
|
47
|
+
onSet: (viz)=>onDataPollingIntervalSet(viz)
|
|
48
|
+
},
|
|
45
49
|
depth: {},
|
|
46
50
|
detectResize: {},
|
|
47
51
|
detectResizeDelay: {},
|
|
@@ -105,6 +109,18 @@ import { registerLink } from "./linkGroup.js";
|
|
|
105
109
|
coerce: "const"
|
|
106
110
|
},
|
|
107
111
|
noDataMessage: {},
|
|
112
|
+
saveControl: {},
|
|
113
|
+
saveControlClassName: {},
|
|
114
|
+
saveControlConfig: {
|
|
115
|
+
merge: true
|
|
116
|
+
},
|
|
117
|
+
saveControlMenuClassName: {},
|
|
118
|
+
saveControlMenuItemStyle: {},
|
|
119
|
+
saveControlMenuItemStyleHover: {},
|
|
120
|
+
saveControlMenuStyle: {},
|
|
121
|
+
saveControlStyle: {},
|
|
122
|
+
saveControlStyleActive: {},
|
|
123
|
+
saveControlStyleHover: {},
|
|
108
124
|
scrollContainer: {},
|
|
109
125
|
search: {},
|
|
110
126
|
searchAccessor: {},
|