@d3plus/core 4.11.0 → 4.12.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 +15 -5
- package/es/src/charts/Alluvial/emit.js +2 -2
- package/es/src/charts/Alluvial/index.js +7 -1
- package/es/src/charts/Alluvial/titles.js +24 -4
- package/es/src/charts/ArcDiagram/emit.js +27 -13
- package/es/src/charts/ArcDiagram/events.js +6 -2
- package/es/src/charts/ArcDiagram/index.js +2 -0
- package/es/src/charts/BarChart/index.js +3 -10
- package/es/src/charts/Calendar/index.js +2 -0
- package/es/src/charts/Candlestick/index.js +4 -10
- package/es/src/charts/Gantt/applyLayout.js +2 -4
- package/es/src/charts/Geomap/flowEmit.js +11 -6
- package/es/src/charts/Hexbin/index.js +2 -0
- package/es/src/charts/Icicle/index.js +3 -1
- package/es/src/charts/Matrix/applyLayout.js +20 -9
- package/es/src/charts/Matrix/index.js +19 -1
- package/es/src/charts/Network/applyLayout.js +36 -5
- package/es/src/charts/Network/bundle.js +5 -4
- package/es/src/charts/Network/emit.js +39 -40
- package/es/src/charts/Network/graph.js +34 -5
- package/es/src/charts/Network/graphFluent.js +5 -3
- package/es/src/charts/Network/index.js +6 -1
- package/es/src/charts/Pack/applyLayout.js +16 -5
- package/es/src/charts/Pack/emit.js +15 -8
- package/es/src/charts/Pack/groupRows.js +61 -0
- package/es/src/charts/Pack/index.js +3 -0
- package/es/src/charts/Pack/neutralPaint.js +20 -0
- package/es/src/charts/Pack/nodeNames.js +35 -0
- package/es/src/charts/ParallelCoordinates/axes.js +22 -22
- package/es/src/charts/ParallelCoordinates/chrome.js +18 -0
- package/es/src/charts/ParallelCoordinates/index.js +3 -1
- package/es/src/charts/ParallelCoordinates/titles.js +17 -9
- package/es/src/charts/Pie/emit.js +9 -1
- package/es/src/charts/Pie/index.js +10 -0
- package/es/src/charts/Plot/areaEnter.js +68 -0
- package/es/src/charts/Plot/draw.js +26 -12
- package/es/src/charts/Plot/index.js +4 -10
- package/es/src/charts/Plot/lineMarkerKeys.js +19 -0
- package/es/src/charts/Plot/plotInit.js +6 -0
- package/es/src/charts/Plot/shapeLabelLegend.js +67 -0
- package/es/src/charts/Plot/sharedHover.js +2 -1
- package/es/src/charts/Plot/sharedTooltip.js +13 -3
- package/es/src/charts/PolarArea/index.js +2 -1
- package/es/src/charts/Priestley/applyLayout.js +11 -7
- package/es/src/charts/Priestley/index.js +0 -2
- package/es/src/charts/Priestley/timeAxis.js +11 -8
- package/es/src/charts/Pyramid/gutter.js +52 -16
- package/es/src/charts/Pyramid/index.js +55 -7
- package/es/src/charts/Pyramid/scene.js +4 -4
- package/es/src/charts/Radar/applyLayout.js +31 -33
- package/es/src/charts/Radar/axisDecorations.js +29 -17
- package/es/src/charts/Radar/curvedLabels.js +43 -2
- package/es/src/charts/Radar/emit.js +30 -15
- package/es/src/charts/Radar/index.js +41 -2
- package/es/src/charts/Radar/points.js +85 -0
- package/es/src/charts/RadialBar/emit.js +6 -1
- package/es/src/charts/RadialBar/index.js +10 -0
- package/es/src/charts/RadialMatrix/applyLayout.js +115 -31
- package/es/src/charts/RadialMatrix/index.js +15 -2
- package/es/src/charts/Rings/applyLayout.js +11 -150
- package/es/src/charts/Rings/emit.js +80 -40
- package/es/src/charts/Rings/index.js +27 -4
- package/es/src/charts/Rings/ringsCurves.js +156 -0
- package/es/src/charts/Rings/ringsParallel.js +20 -3
- package/es/src/charts/Rings/ringsPlacement.js +152 -0
- package/es/src/charts/Rings/ringsSizing.js +61 -38
- package/es/src/charts/Sankey/applyLayout.js +18 -4
- package/es/src/charts/Sankey/index.js +7 -1
- package/es/src/charts/Sunburst/emit.js +9 -1
- package/es/src/charts/Sunburst/index.js +13 -1
- package/es/src/charts/Tree/applyLayout.js +44 -14
- package/es/src/charts/Tree/emit.js +5 -5
- package/es/src/charts/Tree/index.js +10 -12
- package/es/src/charts/Tree/keys.js +33 -0
- package/es/src/charts/Tree/nodeLabel.js +15 -0
- package/es/src/charts/Treemap/emitGroupHeaders.js +3 -5
- package/es/src/charts/definition/makeChart.js +6 -2
- package/es/src/charts/drawSteps/minimap.js +4 -20
- package/es/src/charts/drawSteps/zoomActions.js +36 -0
- package/es/src/charts/drawSteps/zoomControls.js +31 -18
- package/es/src/charts/drawSteps/zoomControlsMarkup.js +23 -4
- package/es/src/charts/drawSteps/zoomDrag.js +188 -0
- package/es/src/charts/drawSteps/zoomFit.js +69 -0
- package/es/src/charts/events/click.legend.js +4 -2
- package/es/src/charts/events/click.shape.js +5 -3
- package/es/src/charts/events/mouseenter.js +6 -16
- package/es/src/charts/events/mouseleave.js +9 -2
- package/es/src/charts/events/mousemove.legend.js +28 -32
- package/es/src/charts/events/mousemove.shape.js +44 -44
- package/es/src/charts/features/axes.js +15 -4
- package/es/src/charts/features/axesFinal.js +7 -2
- package/es/src/charts/features/axesMeasure.js +26 -8
- package/es/src/charts/features/axisTooltip.js +138 -0
- package/es/src/charts/features/centerLabel.js +177 -0
- package/es/src/charts/features/colorScaleBivariate.js +83 -0
- package/es/src/charts/features/colorScaleBucket.js +18 -0
- package/es/src/charts/features/colorScaleHover.js +30 -5
- package/es/src/charts/features/colorScaleLimit.js +73 -0
- package/es/src/charts/features/colorScaleTooltip.js +77 -0
- package/es/src/charts/features/colorScaleTop.js +61 -0
- package/es/src/charts/features/curvedArrows.js +33 -0
- package/es/src/charts/features/depthKey.js +26 -0
- package/es/src/charts/features/edgeArrows.js +61 -2
- package/es/src/charts/features/featuresColorScale.js +57 -16
- package/es/src/charts/features/hoverTicks.js +41 -0
- package/es/src/charts/features/idleQueue.js +72 -0
- package/es/src/charts/features/linkInteraction.js +59 -7
- package/es/src/charts/features/networkMeasures.js +241 -0
- package/es/src/charts/features/nodeStats.js +309 -0
- package/es/src/charts/features/plotEndLabels.js +28 -7
- package/es/src/charts/features/plotPaint.js +9 -2
- package/es/src/charts/features/shapeEmit.js +7 -1
- package/es/src/charts/features/textHalo.js +3 -2
- package/es/src/charts/partition/chartFields.js +12 -3
- package/es/src/charts/partition/interaction.js +10 -5
- package/es/src/charts/pipeline/insetPlacement.js +8 -3
- package/es/src/charts/polar/chrome.js +81 -9
- package/es/src/charts/polar/config.js +4 -0
- package/es/src/charts/polar/wedgeLayout.js +2 -1
- package/es/src/charts/viz/Viz.js +24 -15
- package/es/src/charts/viz/VizBase.js +39 -4
- package/es/src/charts/viz/backgroundInk.js +10 -0
- package/es/src/charts/viz/emphasis.js +14 -0
- package/es/src/charts/viz/fillStroke.js +10 -0
- package/es/src/charts/viz/interactionOpacity.js +115 -32
- package/es/src/charts/viz/reportDrawError.js +15 -0
- package/es/src/charts/viz/setCursor.js +29 -0
- package/es/src/charts/viz/tooltipEnabled.js +38 -0
- package/es/src/charts/viz/userClick.js +34 -0
- package/es/src/charts/viz/vizDataPolling.js +0 -1
- package/es/src/charts/viz/vizDefaults.js +13 -34
- package/es/src/charts/viz/vizFields.js +6 -1
- package/es/src/charts/viz/vizRender.js +35 -5
- package/es/src/charts/viz/vizVisibility.js +12 -2
- package/es/src/components/Axis/Axis.js +29 -2
- package/es/src/components/Axis/axisBreak.js +29 -7
- package/es/src/components/Axis/axisDefaults.js +11 -0
- package/es/src/components/Axis/axisLabelKinds.js +36 -0
- package/es/src/components/Axis/axisLabelLineHeight.js +19 -0
- package/es/src/components/Axis/axisLabelRoom.js +37 -0
- package/es/src/components/Axis/axisLabelSize.js +171 -0
- package/es/src/components/Axis/axisLabelThinning.js +98 -4
- package/es/src/components/Axis/axisLayout.js +71 -46
- package/es/src/components/Axis/axisLayoutLabels.js +82 -140
- package/es/src/components/Axis/axisLayoutScale.js +9 -10
- package/es/src/components/Axis/axisLimit.js +27 -0
- package/es/src/components/Axis/axisMaxSize.js +39 -0
- package/es/src/components/Axis/axisRender.js +20 -8
- package/es/src/components/Axis/axisRounding.js +16 -1
- package/es/src/components/Axis/axisScene.js +11 -2
- package/es/src/components/Axis/axisTitle.js +53 -0
- package/es/src/components/Axis/axisTooltipTargets.js +128 -0
- package/es/src/components/ColorScale/ColorScale.js +62 -18
- package/es/src/components/ColorScale/bivariateRender.js +353 -0
- package/es/src/components/ColorScale/bivariateScale.js +150 -0
- package/es/src/components/ColorScale/colorScaleRender.js +32 -2
- package/es/src/components/ColorScale/colorScaleSwatchTooltips.js +77 -0
- package/es/src/components/Legend/Legend.js +10 -2
- package/es/src/components/Legend/legendCut.js +108 -0
- package/es/src/components/Legend/legendRender.js +38 -13
- package/es/src/components/TextBox.js +5 -2
- package/es/src/components/Timeline/timelineRender.js +2 -1
- package/es/src/components/textBoxScene.js +3 -0
- package/es/src/components/textEllipsis.js +7 -0
- package/es/src/components/tooltipDom.js +8 -5
- package/es/src/fluent.js +48 -0
- package/es/src/utils/BaseClass.js +7 -2
- package/es/src/utils/configValue.js +9 -0
- package/package.json +10 -10
- package/types/index.d.ts +1 -1
- package/types/internal.d.ts +22 -5
- package/types/src/charts/Alluvial/titles.d.ts +16 -3
- package/types/src/charts/ArcDiagram/emit.d.ts +3 -2
- package/types/src/charts/ArcDiagram/events.d.ts +2 -1
- package/types/src/charts/Geomap/flowEmit.d.ts +3 -2
- package/types/src/charts/Matrix/applyLayout.d.ts +4 -2
- package/types/src/charts/Network/applyLayout.d.ts +11 -0
- package/types/src/charts/Network/bundle.d.ts +3 -1
- package/types/src/charts/Network/graph.d.ts +12 -4
- package/types/src/charts/Pack/applyLayout.d.ts +2 -0
- package/types/src/charts/Pack/groupRows.d.ts +46 -0
- package/types/src/charts/Pack/index.d.ts +3 -0
- package/types/src/charts/Pack/neutralPaint.d.ts +14 -0
- package/types/src/charts/Pack/nodeNames.d.ts +23 -0
- package/types/src/charts/ParallelCoordinates/chrome.d.ts +12 -0
- package/types/src/charts/ParallelCoordinates/index.d.ts +1 -0
- package/types/src/charts/ParallelCoordinates/titles.d.ts +7 -2
- package/types/src/charts/Plot/areaEnter.d.ts +34 -0
- package/types/src/charts/Plot/index.d.ts +4 -10
- package/types/src/charts/Plot/lineMarkerKeys.d.ts +11 -0
- package/types/src/charts/Plot/shapeLabelLegend.d.ts +19 -0
- package/types/src/charts/Plot/sharedTooltip.d.ts +7 -1
- package/types/src/charts/Priestley/timeAxis.d.ts +7 -4
- package/types/src/charts/Pyramid/gutter.d.ts +28 -6
- package/types/src/charts/Pyramid/scene.d.ts +1 -1
- package/types/src/charts/Radar/applyLayout.d.ts +2 -3
- package/types/src/charts/Radar/axisDecorations.d.ts +5 -2
- package/types/src/charts/Radar/curvedLabels.d.ts +35 -0
- package/types/src/charts/Radar/emit.d.ts +5 -2
- package/types/src/charts/Radar/index.d.ts +7 -2
- package/types/src/charts/Radar/points.d.ts +50 -0
- package/types/src/charts/RadialMatrix/applyLayout.d.ts +6 -4
- package/types/src/charts/Rings/emit.d.ts +24 -2
- package/types/src/charts/Rings/index.d.ts +4 -2
- package/types/src/charts/Rings/ringsCurves.d.ts +50 -0
- package/types/src/charts/Rings/ringsGraph.d.ts +29 -5
- package/types/src/charts/Rings/ringsParallel.d.ts +4 -2
- package/types/src/charts/Rings/ringsPlacement.d.ts +47 -0
- package/types/src/charts/Rings/ringsSizing.d.ts +36 -9
- package/types/src/charts/Tree/applyLayout.d.ts +20 -0
- package/types/src/charts/Tree/keys.d.ts +25 -0
- package/types/src/charts/Tree/nodeLabel.d.ts +11 -0
- package/types/src/charts/definition/ChartDefinition.d.ts +13 -0
- package/types/src/charts/definition/makeChart.d.ts +2 -2
- package/types/src/charts/drawSteps/zoomActions.d.ts +30 -0
- package/types/src/charts/drawSteps/zoomControls.d.ts +15 -0
- package/types/src/charts/drawSteps/zoomControlsMarkup.d.ts +16 -1
- package/types/src/charts/drawSteps/zoomDrag.d.ts +71 -0
- package/types/src/charts/drawSteps/zoomFit.d.ts +30 -0
- package/types/src/charts/features/axisTooltip.d.ts +49 -0
- package/types/src/charts/features/centerLabel.d.ts +75 -0
- package/types/src/charts/features/colorScaleBivariate.d.ts +50 -0
- package/types/src/charts/features/colorScaleBucket.d.ts +10 -0
- package/types/src/charts/features/colorScaleHover.d.ts +13 -3
- package/types/src/charts/features/colorScaleLimit.d.ts +60 -0
- package/types/src/charts/features/colorScaleTooltip.d.ts +43 -0
- package/types/src/charts/features/colorScaleTop.d.ts +30 -0
- package/types/src/charts/features/curvedArrows.d.ts +14 -0
- package/types/src/charts/features/depthKey.d.ts +19 -0
- package/types/src/charts/features/edgeArrows.d.ts +29 -2
- package/types/src/charts/features/hoverTicks.d.ts +30 -0
- package/types/src/charts/features/idleQueue.d.ts +46 -0
- package/types/src/charts/features/linkInteraction.d.ts +13 -4
- package/types/src/charts/features/networkMeasures.d.ts +53 -0
- package/types/src/charts/features/nodeStats.d.ts +93 -0
- package/types/src/charts/features/plotEndLabels.d.ts +14 -1
- package/types/src/charts/features/textHalo.d.ts +4 -3
- package/types/src/charts/partition/chartFields.d.ts +6 -1
- package/types/src/charts/pipeline/insetPlacement.d.ts +6 -0
- package/types/src/charts/polar/chrome.d.ts +19 -6
- package/types/src/charts/viz/Viz.d.ts +10 -3
- package/types/src/charts/viz/VizBase.d.ts +31 -2
- package/types/src/charts/viz/backgroundInk.d.ts +8 -0
- package/types/src/charts/viz/emphasis.d.ts +17 -0
- package/types/src/charts/viz/fillStroke.d.ts +7 -0
- package/types/src/charts/viz/reportDrawError.d.ts +12 -0
- package/types/src/charts/viz/setCursor.d.ts +26 -0
- package/types/src/charts/viz/tooltipEnabled.d.ts +31 -0
- package/types/src/charts/viz/userClick.d.ts +35 -0
- package/types/src/charts/viz/vizFields.d.ts +5 -0
- package/types/src/charts/viz/vizTypes.d.ts +16 -0
- package/types/src/charts/viz/vizVisibility.d.ts +7 -0
- package/types/src/components/Axis/Axis.d.ts +33 -3
- package/types/src/components/Axis/axisBreak.d.ts +19 -3
- package/types/src/components/Axis/axisDefaults.d.ts +12 -0
- package/types/src/components/Axis/axisLabelKinds.d.ts +22 -0
- package/types/src/components/Axis/axisLabelLineHeight.d.ts +27 -0
- package/types/src/components/Axis/axisLabelRoom.d.ts +17 -0
- package/types/src/components/Axis/axisLabelSize.d.ts +82 -0
- package/types/src/components/Axis/axisLabelThinning.d.ts +38 -2
- package/types/src/components/Axis/axisLayout.d.ts +9 -2
- package/types/src/components/Axis/axisLayoutLabels.d.ts +28 -33
- package/types/src/components/Axis/axisLayoutScale.d.ts +3 -1
- package/types/src/components/Axis/axisLimit.d.ts +18 -0
- package/types/src/components/Axis/axisMaxSize.d.ts +48 -0
- package/types/src/components/Axis/axisRounding.d.ts +8 -0
- package/types/src/components/Axis/axisTitle.d.ts +30 -0
- package/types/src/components/Axis/axisTooltipTargets.d.ts +82 -0
- package/types/src/components/ColorScale/ColorScale.d.ts +21 -11
- package/types/src/components/ColorScale/bivariateRender.d.ts +53 -0
- package/types/src/components/ColorScale/bivariateScale.d.ts +92 -0
- package/types/src/components/ColorScale/colorScaleSwatchTooltips.d.ts +48 -0
- package/types/src/components/Legend/Legend.d.ts +5 -0
- package/types/src/components/Legend/legendCut.d.ts +31 -0
- package/types/src/components/Legend/legendRender.d.ts +6 -1
- package/types/src/components/TextBox.d.ts +4 -0
- package/types/src/components/textEllipsis.d.ts +6 -0
- package/types/src/fluent.d.ts +18 -0
- package/types/src/shapes/emitLabels.d.ts +1 -1
- package/types/src/utils/D3plusConfig.d.ts +485 -609
- package/types/src/utils/configValue.d.ts +8 -0
- package/types/src/utils/index.d.ts +1 -1
- package/types/umd-entry.d.ts +4 -0
- package/umd/d3plus-core.full.js +22930 -17936
- package/umd/d3plus-core.full.min.js +2 -2
- package/umd/d3plus-core.js +21240 -16404
- package/umd/d3plus-core.min.js +2 -2
|
@@ -4,6 +4,7 @@ import { elem, rtl as detectRTL } from "@d3plus/dom";
|
|
|
4
4
|
import { TextBox } from "../index.js";
|
|
5
5
|
import { accessor, BaseClass, constant, paintComponentScene } from "../../utils/index.js";
|
|
6
6
|
import { installFluent, mergeConfigBag, resolvesReset } from "../../fluent.js";
|
|
7
|
+
import { labelLineHeight } from "../Axis/axisLabelLineHeight.js";
|
|
7
8
|
import { buildLegendShapeConfig } from "./legendConfig.js";
|
|
8
9
|
import { clearLegend, computeLegendBounds, computeLegendLineData, measureLegendTitle, renderLegendShapes, renderLegendTitle, wrapLegendRows } from "./legendRender.js";
|
|
9
10
|
import { inkText } from "../../utils/themeInk.js";
|
|
@@ -85,6 +86,10 @@ import { inkText } from "../../utils/themeInk.js";
|
|
|
85
86
|
_titleHeight;
|
|
86
87
|
_titleWidth;
|
|
87
88
|
_wrapLines;
|
|
89
|
+
/**
|
|
90
|
+
Whether labels that don't fit whole are cut short with "..." rather
|
|
91
|
+
than left out, as a ColorScale's swatches are (see `legendCut.ts`).
|
|
92
|
+
*/ _cutLabels = false;
|
|
88
93
|
_wrapRows;
|
|
89
94
|
// Standalone scene renderer (used when rendered on its own, not inside a
|
|
90
95
|
// Viz). Reused across re-renders by paintComponentScene().
|
|
@@ -121,8 +126,9 @@ import { inkText } from "../../utils/themeInk.js";
|
|
|
121
126
|
@private
|
|
122
127
|
*/ _fetchConfig(key, d, i) {
|
|
123
128
|
const labelConfig = this.schema.shapeConfig.labelConfig;
|
|
129
|
+
// Labels are measured at the line height their TextBoxes paint with.
|
|
130
|
+
if (key === "lineHeight") return labelLineHeight(this.schema.shapeConfig, d, i, this._fetchConfig("fontSize", d, i));
|
|
124
131
|
const val = this.schema.shapeConfig[key] !== undefined ? this.schema.shapeConfig[key] : labelConfig?.[key];
|
|
125
|
-
if (!val && key === "lineHeight") return this._fetchConfig("fontSize", d, i) * 1.4;
|
|
126
132
|
return typeof val === "function" ? val(d, i) : val;
|
|
127
133
|
}
|
|
128
134
|
/**
|
|
@@ -210,7 +216,9 @@ import { inkText } from "../../utils/themeInk.js";
|
|
|
210
216
|
this._lineData = computeLegendLineData(this, availableHeight);
|
|
211
217
|
let spaceNeeded = this._rowWidth(this._lineData);
|
|
212
218
|
const availableWidth = this.schema.width - this.schema.padding * 2;
|
|
213
|
-
|
|
219
|
+
// A single row fits when it is no wider and no taller than the room left.
|
|
220
|
+
const rowFits = spaceNeeded <= availableWidth && (!this._lineData.length || this._rowHeight(this._lineData) + this.schema.padding <= availableHeight);
|
|
221
|
+
if (this.schema.direction === "column" || !rowFits) spaceNeeded = wrapLegendRows(this, availableWidth, availableHeight);
|
|
214
222
|
if (spaceNeeded === false) clearLegend(this);
|
|
215
223
|
else {
|
|
216
224
|
computeLegendBounds(this, spaceNeeded);
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Lays out labels that don't fit a Legend whole in the room it has left,
|
|
3
|
+
for its TextBoxes to wrap within and cut short with "...": a Legend that
|
|
4
|
+
a ColorScale draws its swatches with (`_cutLabels`) cuts its labels short
|
|
5
|
+
rather than leaving them out.
|
|
6
|
+
*/ import { max } from "d3-array";
|
|
7
|
+
import { textWrap } from "@d3plus/text";
|
|
8
|
+
import { TEXTBOX_LINE_HEIGHT, textBoxEllipsis } from "../TextBox.js";
|
|
9
|
+
/** The narrowest room a cut label keeps beside its swatch, for a letter or two and "...". */ const MIN_WIDTH = 24;
|
|
10
|
+
/**
|
|
11
|
+
The room each label of `legend` has with its swatches in `rows` rows of
|
|
12
|
+
as many each as fit (`rows` 1 to the count of swatches), or in one
|
|
13
|
+
column.
|
|
14
|
+
*/ export function labelRoom(legend, availableWidth, availableHeight, rows = 1) {
|
|
15
|
+
const lines = legend._lineData;
|
|
16
|
+
const pad = legend.schema.padding;
|
|
17
|
+
const shape = max(lines, (d)=>d.shapeWidth) ?? 0;
|
|
18
|
+
const n = lines.length;
|
|
19
|
+
// As `buildRows` packs them: each swatch, its label and the padding
|
|
20
|
+
// between take less than the available width, and the rows, each its
|
|
21
|
+
// tallest label or swatch and the padding below, no more than its height.
|
|
22
|
+
if (legend.schema.direction === "column") return {
|
|
23
|
+
width: availableWidth - shape - pad * 2 - 1,
|
|
24
|
+
height: Math.floor((availableHeight - pad) / n - pad)
|
|
25
|
+
};
|
|
26
|
+
const perRow = Math.ceil(n / rows);
|
|
27
|
+
return {
|
|
28
|
+
width: Math.floor((availableWidth - 1) / perRow) - shape - pad * 2,
|
|
29
|
+
height: Math.floor((availableHeight - pad) / rows - pad)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** Lays the label `d` out in `room`, or null when the room can't hold a line of it. */ function fitLabel(d, room) {
|
|
33
|
+
const step = d.lh + 1;
|
|
34
|
+
const most = Math.floor(room.height / step);
|
|
35
|
+
if (room.width < MIN_WIDTH || most < 1) return null;
|
|
36
|
+
const wrap = textWrap().fontFamily(d.f).fontSize(d.s).lineHeight(d.lh).width(room.width).height(most * step)(d.sentence);
|
|
37
|
+
const cut = wrap.truncated;
|
|
38
|
+
// A label cut down to nothing doesn't fit.
|
|
39
|
+
if (cut && !wrap.lines.length) return null;
|
|
40
|
+
return {
|
|
41
|
+
cut,
|
|
42
|
+
shown: cut ? wrap.lines.join("").length : `${d.sentence}`.length,
|
|
43
|
+
width: cut ? room.width : Math.min(room.width, Math.ceil(max(wrap.widths) ?? 0) + 10),
|
|
44
|
+
height: (cut ? most : wrap.lines.length) * step
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
The lines the TextBox of the label `d` paints in the room it was given:
|
|
49
|
+
wrapped with the line height and ellipsis of the legend's labels (a
|
|
50
|
+
TextBox's own by default), as `renderLegendShapes` draws it.
|
|
51
|
+
*/ export function paintedLines(legend, d) {
|
|
52
|
+
const label = legend.schema.shapeConfig.labelConfig ?? {};
|
|
53
|
+
const value = (v, fallback)=>v === undefined ? fallback : typeof v === "function" ? v(d.data, d.i) : v;
|
|
54
|
+
const size = d.s;
|
|
55
|
+
const ellipsis = typeof label.ellipsis === "function" ? label.ellipsis : textBoxEllipsis;
|
|
56
|
+
const wrap = textWrap().fontFamily(d.f).fontSize(size).lineHeight(value(label.lineHeight, size * TEXTBOX_LINE_HEIGHT)).width(d.width).height(Math.max(d.height, d.shapeHeight)).ellipsis(ellipsis)(d.sentence);
|
|
57
|
+
const lines = wrap.lines.filter((line)=>line !== "");
|
|
58
|
+
return lines.length ? lines : [
|
|
59
|
+
ellipsis("", 0)
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
Gives each label of `legend` the room it has in the layout of its
|
|
64
|
+
swatches that shows the most of its labels, its whole text when that
|
|
65
|
+
fits there and else as many lines as fit, marking it `cut`, with the
|
|
66
|
+
lines it paints there. In a row, the swatches try each count of rows
|
|
67
|
+
within the height, keeping the layout that cuts the fewest labels short,
|
|
68
|
+
then shows the most of their text, then is the shortest. In a column,
|
|
69
|
+
they keep to one column, which reads in order from top to bottom.
|
|
70
|
+
Returns false, changing nothing, when no layout can hold a line of a
|
|
71
|
+
few letters.
|
|
72
|
+
*/ export function cutLegendLabels(legend, availableWidth, availableHeight) {
|
|
73
|
+
const lines = legend._lineData;
|
|
74
|
+
const labeled = lines.filter((d)=>d.sentence);
|
|
75
|
+
if (!labeled.length) return false;
|
|
76
|
+
const counts = legend.schema.direction === "column" ? [
|
|
77
|
+
1
|
|
78
|
+
] : Array.from({
|
|
79
|
+
length: lines.length
|
|
80
|
+
}, (_, i)=>i + 1);
|
|
81
|
+
const shape = max(lines, (d)=>d.shapeHeight) ?? 0;
|
|
82
|
+
const pad = legend.schema.padding;
|
|
83
|
+
let best;
|
|
84
|
+
for (const rows of counts){
|
|
85
|
+
const room = labelRoom(legend, availableWidth, availableHeight, rows);
|
|
86
|
+
const fits = labeled.map((d)=>fitLabel(d, room));
|
|
87
|
+
if (fits.some((fit)=>!fit)) continue;
|
|
88
|
+
const all = fits;
|
|
89
|
+
const cut = all.filter((fit)=>fit.cut).length;
|
|
90
|
+
const shown = all.reduce((total, fit)=>total + fit.shown, 0);
|
|
91
|
+
const height = rows * (Math.max(shape, ...all.map((fit)=>fit.height)) + pad) + pad;
|
|
92
|
+
if (!best || cut < best.cut || cut === best.cut && (shown > best.shown || shown === best.shown && height < best.height)) best = {
|
|
93
|
+
fits: all,
|
|
94
|
+
cut,
|
|
95
|
+
shown,
|
|
96
|
+
height
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
if (!best) return false;
|
|
100
|
+
labeled.forEach((d, i)=>{
|
|
101
|
+
const fit = best.fits[i];
|
|
102
|
+
d.cut = fit.cut;
|
|
103
|
+
d.width = fit.width;
|
|
104
|
+
d.height = fit.height;
|
|
105
|
+
d.lines = paintedLines(legend, d);
|
|
106
|
+
});
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
@@ -3,16 +3,26 @@ import { textWidth } from "@d3plus/dom";
|
|
|
3
3
|
import { textWrap } from "@d3plus/text";
|
|
4
4
|
import * as shapes from "../../shapes/index.js";
|
|
5
5
|
import { configPrep } from "../../utils/index.js";
|
|
6
|
+
import { labelLineHeight } from "../Axis/axisLabelLineHeight.js";
|
|
7
|
+
import { cutLegendLabels } from "./legendCut.js";
|
|
6
8
|
const padding = 5;
|
|
7
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
Wraps + measures the title, setting `_titleHeight` / `_titleWidth`: it
|
|
11
|
+
wraps within the width the title is drawn in, the legend's less its
|
|
12
|
+
padding on both sides, and is left out (both zero) when it doesn't fit
|
|
13
|
+
there whole.
|
|
14
|
+
*/ export function measureLegendTitle(legend) {
|
|
8
15
|
legend._titleHeight = 0;
|
|
9
16
|
legend._titleWidth = 0;
|
|
10
17
|
if (legend.schema.title) {
|
|
11
18
|
const f = legend.schema.titleConfig.fontFamily || legend._titleClass.fontFamily()(), s = legend.schema.titleConfig.fontSize || legend._titleClass.fontSize()();
|
|
12
|
-
|
|
13
|
-
lH =
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
// Measured at the line height its TextBox paints with.
|
|
20
|
+
const lH = labelLineHeight(legend.schema.titleConfig, {
|
|
21
|
+
text: legend.schema.title
|
|
22
|
+
}, 0, s);
|
|
23
|
+
const res = textWrap().fontFamily(f).fontSize(s).lineHeight(lH).width(legend.schema.width - legend.schema.padding * 2).height(legend.schema.height)(legend.schema.title);
|
|
24
|
+
if (res.truncated || !res.lines.length) return;
|
|
25
|
+
legend._titleHeight = res.lines.length * (lH + 1) + legend.schema.padding;
|
|
16
26
|
legend._titleWidth = max(res.widths);
|
|
17
27
|
}
|
|
18
28
|
}
|
|
@@ -61,10 +71,16 @@ const padding = 5;
|
|
|
61
71
|
return res;
|
|
62
72
|
});
|
|
63
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
An item's width as `_rowWidth` reports it when it ends a row: its swatch
|
|
76
|
+
and label, without the padding that only separates it from a next item.
|
|
77
|
+
*/ function itemWidth(d) {
|
|
78
|
+
return d.width + d.shapeWidth;
|
|
79
|
+
}
|
|
64
80
|
/** Attempts to wrap labels onto an additional line, recursing into rows. */ function tryWrapLines(legend, state, availableWidth, availableHeight) {
|
|
65
81
|
state.lines++;
|
|
66
82
|
if (state.lines > state.maxLines) return;
|
|
67
|
-
const wrappable = state.lines === 1 ? legend._lineData.slice() : legend._lineData.filter((d)=>
|
|
83
|
+
const wrappable = state.lines === 1 ? legend._lineData.slice() : legend._lineData.filter((d)=>itemWidth(d) > availableWidth && d.words.length >= state.lines).sort((a, b)=>b.sentence.length - a.sentence.length);
|
|
68
84
|
if (wrappable.length && availableHeight > wrappable[0].height * state.lines) {
|
|
69
85
|
let truncated = false;
|
|
70
86
|
for(let x = 0; x < wrappable.length; x++){
|
|
@@ -73,10 +89,13 @@ const padding = 5;
|
|
|
73
89
|
const h = og.height * state.lines, w = og.width * (1.5 * (1 / state.lines));
|
|
74
90
|
const res = textWrap().fontFamily(label.f).fontSize(label.s).lineHeight(label.lh).width(w).height(h)(label.sentence);
|
|
75
91
|
if (!res.truncated) {
|
|
92
|
+
// Measured as `computeLegendLineData` measures a label: the lines
|
|
93
|
+
// its TextBox paints, and the widest with the padding either side.
|
|
94
|
+
label.lines = res.lines;
|
|
76
95
|
label.width = Math.ceil(max(res.lines.map((t)=>textWidth(t, {
|
|
77
96
|
"font-family": label.f,
|
|
78
97
|
"font-size": label.s
|
|
79
|
-
})))) +
|
|
98
|
+
})))) + padding * 2;
|
|
80
99
|
label.height = res.lines.length * (label.lh + 1);
|
|
81
100
|
} else {
|
|
82
101
|
truncated = true;
|
|
@@ -93,7 +112,8 @@ const padding = 5;
|
|
|
93
112
|
state.newRows = [];
|
|
94
113
|
let row = 1, rowWidth = 0;
|
|
95
114
|
for(let i = 0; i < legend._lineData.length; i++){
|
|
96
|
-
const d = legend._lineData[i],
|
|
115
|
+
const d = legend._lineData[i], // The padding after an item counts only when another follows it.
|
|
116
|
+
w = itemWidth(d) + legend.schema.padding * (d.width ? 2 : 1);
|
|
97
117
|
if (sum(state.newRows.map((row)=>max(row, (d)=>max([
|
|
98
118
|
d.height,
|
|
99
119
|
d.shapeHeight
|
|
@@ -101,11 +121,11 @@ const padding = 5;
|
|
|
101
121
|
state.newRows = [];
|
|
102
122
|
break;
|
|
103
123
|
}
|
|
104
|
-
if (
|
|
124
|
+
if (itemWidth(d) > availableWidth) {
|
|
105
125
|
state.newRows = [];
|
|
106
126
|
legend._wrapLines();
|
|
107
127
|
break;
|
|
108
|
-
} else if (rowWidth +
|
|
128
|
+
} else if (rowWidth + itemWidth(d) <= availableWidth) {
|
|
109
129
|
rowWidth += w;
|
|
110
130
|
} else if (legend.schema.direction !== "column") {
|
|
111
131
|
rowWidth = w;
|
|
@@ -131,15 +151,19 @@ const padding = 5;
|
|
|
131
151
|
};
|
|
132
152
|
legend._wrapLines = ()=>tryWrapLines(legend, state, availableWidth, availableHeight);
|
|
133
153
|
legend._wrapRows = ()=>buildRows(legend, state, availableWidth, availableHeight);
|
|
154
|
+
const overflows = ()=>!state.newRows.length || sum(state.newRows, legend._rowHeight.bind(legend)) + legend.schema.padding > availableHeight;
|
|
134
155
|
legend._wrapRows();
|
|
135
|
-
|
|
156
|
+
// Labels that don't fit whole are cut short (a ColorScale's Legend), or
|
|
157
|
+
// else left out.
|
|
158
|
+
if (overflows() && !(legend._cutLabels && cutLegendLabels(legend, availableWidth, availableHeight) && (legend._wrapRows(), !overflows()))) {
|
|
136
159
|
for(let i = 0; i < legend._lineData.length; i++){
|
|
137
160
|
legend._lineData[i].width = 0;
|
|
138
161
|
legend._lineData[i].height = 0;
|
|
162
|
+
legend._lineData[i].cut = false;
|
|
139
163
|
}
|
|
140
164
|
legend._wrapRows();
|
|
141
165
|
}
|
|
142
|
-
if (
|
|
166
|
+
if (overflows()) return false;
|
|
143
167
|
state.newRows.forEach((row, i)=>{
|
|
144
168
|
row.forEach((d)=>{
|
|
145
169
|
if (i) {
|
|
@@ -181,7 +205,8 @@ const padding = 5;
|
|
|
181
205
|
legend._outerBounds.y = yOffset;
|
|
182
206
|
}
|
|
183
207
|
/** Renders the title TextBox into the legend's title group. */ export function renderLegendTitle(legend) {
|
|
184
|
-
legend._titleClass.renderMode("compute")
|
|
208
|
+
legend._titleClass.renderMode("compute")// A title left out for want of room measures no height.
|
|
209
|
+
.data(legend._titleHeight ? [
|
|
185
210
|
{
|
|
186
211
|
text: legend.schema.title
|
|
187
212
|
}
|
|
@@ -7,12 +7,15 @@ import { applyClassName } from "../utils/className.js";
|
|
|
7
7
|
import { installFluent } from "../fluent.js";
|
|
8
8
|
import { computeTextBoxDatum } from "./textBoxLayout.js";
|
|
9
9
|
import { textBoxNodes } from "./textBoxScene.js";
|
|
10
|
+
import { textEllipsis } from "./textEllipsis.js";
|
|
10
11
|
const defaultHtmlLookup = {
|
|
11
12
|
i: "font-style: italic;",
|
|
12
13
|
em: "font-style: italic;",
|
|
13
14
|
b: "font-weight: bold;",
|
|
14
15
|
strong: "font-weight: bold;"
|
|
15
16
|
};
|
|
17
|
+
/** The ellipsis a TextBox ends a cut line with by default: none for a line with nothing kept. */ export const textBoxEllipsis = (text, line)=>line ? textEllipsis(text) : "";
|
|
18
|
+
/** A TextBox's default line height, as a multiple of its font size. */ export const TEXTBOX_LINE_HEIGHT = 1.2;
|
|
16
19
|
/** TextBox's fluent accessor schema. Config storage lives on `this.schema.<key>`. */ const textBoxSchema = [
|
|
17
20
|
{
|
|
18
21
|
key: "ariaHidden",
|
|
@@ -32,7 +35,7 @@ const defaultHtmlLookup = {
|
|
|
32
35
|
{
|
|
33
36
|
key: "ellipsis",
|
|
34
37
|
coerce: "const",
|
|
35
|
-
default:
|
|
38
|
+
default: textBoxEllipsis
|
|
36
39
|
},
|
|
37
40
|
{
|
|
38
41
|
key: "fontColor",
|
|
@@ -220,7 +223,7 @@ const defaultHtmlLookup = {
|
|
|
220
223
|
*/ constructor(){
|
|
221
224
|
super();
|
|
222
225
|
installFluent(this, textBoxSchema);
|
|
223
|
-
this.schema.lineHeight = (d, i)=>this.schema.fontSize(d, i) *
|
|
226
|
+
this.schema.lineHeight = (d, i)=>this.schema.fontSize(d, i) * TEXTBOX_LINE_HEIGHT;
|
|
224
227
|
this.schema.html = defaultHtmlLookup;
|
|
225
228
|
}
|
|
226
229
|
/**
|
|
@@ -9,6 +9,7 @@ import { SvgRenderer } from "@d3plus/render";
|
|
|
9
9
|
import { textWrap } from "@d3plus/text";
|
|
10
10
|
import { configPrep } from "../../utils/index.js";
|
|
11
11
|
import { applyClassName } from "../../utils/className.js";
|
|
12
|
+
import { labelLineHeight } from "../Axis/axisLabelLineHeight.js";
|
|
12
13
|
import { parseTimeValues } from "../Axis/timeValues.js";
|
|
13
14
|
import { nearestIndex, spanIndices, timelineBrushSpan } from "./brushSpan.js";
|
|
14
15
|
import { byValue } from "./timelineConfig.js";
|
|
@@ -90,7 +91,7 @@ import { byValue } from "./timelineConfig.js";
|
|
|
90
91
|
ticks.forEach((d, i)=>{
|
|
91
92
|
const { fontFamily, fontSize } = tl.schema.shapeConfig.labelConfig;
|
|
92
93
|
const f = typeof fontFamily === "function" ? fontFamily(d, i) : fontFamily, s = typeof fontSize === "function" ? fontSize(d, i) : fontSize;
|
|
93
|
-
const wrap = textWrap().fontFamily(f).fontSize(s).lineHeight(tl.schema.shapeConfig
|
|
94
|
+
const wrap = textWrap().fontFamily(f).fontSize(s).lineHeight(labelLineHeight(tl.schema.shapeConfig, d, i, s));
|
|
94
95
|
const res = wrap(tickFormat(d));
|
|
95
96
|
let width = res.lines.length ? Math.ceil(max(res.lines.map((line)=>textWidth(line, {
|
|
96
97
|
"font-family": f,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Ends cut text with "...", first dropping its trailing periods, commas, and
|
|
3
|
+
spaces, so a decimal or an abbreviation inside the text survives.
|
|
4
|
+
@param text The text kept before the ellipsis.
|
|
5
|
+
*/ export function textEllipsis(text) {
|
|
6
|
+
return `${text.replace(/[.,\s]+$/, "")}...`;
|
|
7
|
+
}
|
|
@@ -131,11 +131,14 @@ import { elem, stylize } from "@d3plus/dom";
|
|
|
131
131
|
@private
|
|
132
132
|
*/ export function divElement(that, enter, update, cat) {
|
|
133
133
|
enter.append("div").attr("class", `d3plus-tooltip-${cat}`).attr("id", (d, i)=>elementId(that, d, i, cat));
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
})
|
|
134
|
+
const value = (d, i)=>that.schema[cat](d, i);
|
|
135
|
+
// A part set to `false` (or nothing) is hidden and left empty, rather
|
|
136
|
+
// than holding the text "false".
|
|
137
|
+
const shown = (val)=>val !== false && val !== undefined && val !== null;
|
|
138
|
+
const div = update.select(`.d3plus-tooltip-${cat}`).html((d, i)=>{
|
|
139
|
+
const val = value(d, i);
|
|
140
|
+
return shown(val) ? val : "";
|
|
141
|
+
}).style("display", (d, i)=>shown(value(d, i)) ? "block" : "none");
|
|
139
142
|
stylize(div, that.schema[`${cat}Style`]);
|
|
140
143
|
}
|
|
141
144
|
/**
|
package/es/src/fluent.js
CHANGED
|
@@ -114,6 +114,16 @@ resolvesReset(Shape.prototype, "labelConfig");
|
|
|
114
114
|
const base = isPlainObject(bag) ? bag : {};
|
|
115
115
|
return mergeConfig(base, isPlainObject(patch) ? patch : {}, defaults);
|
|
116
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
The `config()` argument that restores each of `keys` that `host` has a
|
|
119
|
+
setter for to its default, as `RESET` does: a component that a chart
|
|
120
|
+
configures again on every render starts from its defaults, so config the
|
|
121
|
+
chart gave it before and no longer gives it is dropped.
|
|
122
|
+
*/ export function resetKeys(host, keys) {
|
|
123
|
+
const out = {};
|
|
124
|
+
for (const key of keys)if (typeof host[key] === "function") out[key] = RESET;
|
|
125
|
+
return out;
|
|
126
|
+
}
|
|
117
127
|
/**
|
|
118
128
|
Tags hand-written setters that resolve `RESET` themselves (typically via
|
|
119
129
|
`mergeConfigBag`), so `BaseClass.config()` passes their argument through
|
|
@@ -132,6 +142,43 @@ resolvesReset(Shape.prototype, "labelConfig");
|
|
|
132
142
|
if (value === RESET) return cloneConfig(host._defaultConfig?.()[key]);
|
|
133
143
|
return mergeConfigBag(host, key, value);
|
|
134
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
The entries of each config-bag field that its setter (the user's config,
|
|
147
|
+
through `viz.<key>(…)` or `config()`) has set, per host: defaults and
|
|
148
|
+
factories seed a field without going through its setter, so they never
|
|
149
|
+
count.
|
|
150
|
+
*/ const setEntries = new WeakMap();
|
|
151
|
+
/**
|
|
152
|
+
Notes the entries a config-bag setter call sets: each key of a plain
|
|
153
|
+
object `patch`, except one set to `RESET` or `undefined`, which clears
|
|
154
|
+
it; a whole-field `RESET` clears them all.
|
|
155
|
+
*/ function noteSetEntries(host, key, patch) {
|
|
156
|
+
let fields = setEntries.get(host);
|
|
157
|
+
if (!fields) setEntries.set(host, fields = new Map());
|
|
158
|
+
if (patch === RESET) {
|
|
159
|
+
fields.delete(key);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (!isPlainObject(patch)) return;
|
|
163
|
+
let entries = fields.get(key);
|
|
164
|
+
if (!entries) fields.set(key, entries = new Set());
|
|
165
|
+
for (const [k, v] of Object.entries(patch)){
|
|
166
|
+
if (v === RESET || v === undefined) entries.delete(k);
|
|
167
|
+
else entries.add(k);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
Whether the user has set `entry` of the config-bag field `key` (such as
|
|
172
|
+
`tooltipConfig`'s `tbody`) through its setter, as opposed to the value a
|
|
173
|
+
chart seeds by default. Cleared by setting the entry to `RESET` or
|
|
174
|
+
`undefined`, or the whole field to `RESET`.
|
|
175
|
+
@param host The chart or component.
|
|
176
|
+
@param key The config-bag field.
|
|
177
|
+
@param entry The entry within it.
|
|
178
|
+
@private
|
|
179
|
+
*/ export function isSetEntry(host, key, entry) {
|
|
180
|
+
return Boolean(setEntries.get(host)?.get(key)?.has(entry));
|
|
181
|
+
}
|
|
135
182
|
const FLUENT_ACCESSOR = Symbol("d3plus.fluentAccessor");
|
|
136
183
|
/** The schemas already installed on each prototype. */ const installedSchemas = new WeakMap();
|
|
137
184
|
/**
|
|
@@ -224,6 +271,7 @@ target, schema, defaults = {}) {
|
|
|
224
271
|
proto[key] = function(...args) {
|
|
225
272
|
if (!args.length) return this.schema[key];
|
|
226
273
|
const value = coerceValue(field, args[0]);
|
|
274
|
+
if (field.merge) noteSetEntries(this, key, value);
|
|
227
275
|
const next = field.merge ? mergeFieldValue(this, key, value) : value;
|
|
228
276
|
this.schema[key] = next;
|
|
229
277
|
// `onSet` is declared only by Viz chart defs; at runtime `this` is that
|
|
@@ -39,7 +39,11 @@ import { displayName } from "./displayName.js";
|
|
|
39
39
|
"renderMode",
|
|
40
40
|
"toCanvas",
|
|
41
41
|
"toSVGString",
|
|
42
|
-
"toScene"
|
|
42
|
+
"toScene",
|
|
43
|
+
"zoomBrush",
|
|
44
|
+
"zoomIn",
|
|
45
|
+
"zoomOut",
|
|
46
|
+
"zoomReset"
|
|
43
47
|
]);
|
|
44
48
|
/**
|
|
45
49
|
finds all prototype methods of a class and it's parent classes
|
|
@@ -56,7 +60,8 @@ import { displayName } from "./displayName.js";
|
|
|
56
60
|
// axis-layout pass; `destroy` tears down the scene renderer (which defeats
|
|
57
61
|
// keyed reconcile and forces a full remount on the next draw);
|
|
58
62
|
// `toSVGString` serializes the drawn chart (through a throwaway SVG
|
|
59
|
-
// backend on Canvas),
|
|
63
|
+
// backend on Canvas), `layout` recomputes a SizeLegend's layout, and
|
|
64
|
+
// the zoom methods zoom a rendered chart.
|
|
60
65
|
!REFLECT_SKIP.has(e));
|
|
61
66
|
}
|
|
62
67
|
/**
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
The value of a config property that takes either a constant or a function
|
|
3
|
+
(such as a label's `fontSize` or a shape's `lineHeight`): calls a function
|
|
4
|
+
`value` with `args`, and returns any other `value` as it is.
|
|
5
|
+
@param value A constant, or a function returning the value.
|
|
6
|
+
@param args The arguments a function `value` is called with.
|
|
7
|
+
*/ export default function configValue(value, ...args) {
|
|
8
|
+
return typeof value === "function" ? value(...args) : value;
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d3plus/core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.12.0",
|
|
4
4
|
"description": "Data visualization made easy. A javascript library that extends the popular D3.js to enable fast and beautiful visualizations.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -37,15 +37,15 @@
|
|
|
37
37
|
"visualization"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@d3plus/color": "4.
|
|
41
|
-
"@d3plus/data": "4.
|
|
42
|
-
"@d3plus/dom": "4.
|
|
43
|
-
"@d3plus/export": "4.
|
|
44
|
-
"@d3plus/format": "4.
|
|
45
|
-
"@d3plus/locales": "4.
|
|
46
|
-
"@d3plus/math": "4.
|
|
47
|
-
"@d3plus/render": "4.
|
|
48
|
-
"@d3plus/text": "4.
|
|
40
|
+
"@d3plus/color": "4.12.0",
|
|
41
|
+
"@d3plus/data": "4.12.0",
|
|
42
|
+
"@d3plus/dom": "4.12.0",
|
|
43
|
+
"@d3plus/export": "4.12.0",
|
|
44
|
+
"@d3plus/format": "4.12.0",
|
|
45
|
+
"@d3plus/locales": "4.12.0",
|
|
46
|
+
"@d3plus/math": "4.12.0",
|
|
47
|
+
"@d3plus/render": "4.12.0",
|
|
48
|
+
"@d3plus/text": "4.12.0",
|
|
49
49
|
"@floating-ui/dom": "^1.6.0",
|
|
50
50
|
"d3-array": "^3.2.4",
|
|
51
51
|
"d3-brush": "^3.0.0",
|
package/types/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { Alluvial, ArcDiagram, AreaPlot, BarChart, Beeswarm, BoxWhisker, BubbleC
|
|
|
2
2
|
export { Axis, AxisBottom, AxisLeft, AxisRight, AxisTop, ColorScale, Legend, Message, SizeLegend, TextBox, Timeline, Tooltip, } from "./src/components/index.js";
|
|
3
3
|
export { Area, Bar, Box, Circle, Image, Line, Path, Rect, Shape, Whisker, } from "./src/shapes/index.js";
|
|
4
4
|
export { accessor, BaseClass, configPrep, configWarnings, constant, RESET, } from "./src/utils/index.js";
|
|
5
|
-
export type { D3plusConfig, AxisConfig, ColorDefaultsConfig, ColorScaleConfig, ConfidenceBandSetting, ConfidenceBound, KeyboardNavConfig, LegendConfig, PointLabelConfig, SaveControlConfig, SaveFormat, SizeLegendConfig, TextBoxConfig, TimelineConfig, TooltipConfig, TrendLineConfig, } from "./src/utils/index.js";
|
|
5
|
+
export type { D3plusConfig, AxisConfig, AxisTooltipConfig, ColorDefaultsConfig, ColorScaleConfig, ColorScaleField, ConfidenceBandSetting, ConfidenceBound, KeyboardNavConfig, LegendConfig, PointLabelConfig, SaveControlConfig, SaveFormat, SizeLegendConfig, TextBoxConfig, TimelineConfig, TooltipConfig, TooltipLevels, TrendLineConfig, } from "./src/utils/index.js";
|
|
6
6
|
export type { LinkConfig, LinkOption } from "./src/charts/viz/linkGroup.js";
|
|
7
7
|
export type { Annotation, AnnotationRef, AnnotationTextStyle, AnnotationValue, CalloutAnnotation, ReferenceBandConfig, ReferenceLineConfig, ReferenceStyle, } from "./src/charts/features/annotationTypes.js";
|
|
8
8
|
export type { RangeBreakRule, RangeBreakTime, } from "./src/components/Axis/rangeBreaks.js";
|
package/types/internal.d.ts
CHANGED
|
@@ -16,8 +16,8 @@ export { applyFunnelLayout } from "./src/charts/Funnel/applyLayout.js";
|
|
|
16
16
|
export { applyGaugeLayout } from "./src/charts/Gauge/applyLayout.js";
|
|
17
17
|
export { applyGeomapLayout } from "./src/charts/Geomap/applyLayout.js";
|
|
18
18
|
export { applyMatrixLayout } from "./src/charts/Matrix/applyLayout.js";
|
|
19
|
-
export { applyNetworkLayout } from "./src/charts/Network/applyLayout.js";
|
|
20
|
-
export { graphLinkEnd, graphNodeId, resolveGraphLinks, resolveGraphNodes, zoomToNodeBounds, } from "./src/charts/Network/graph.js";
|
|
19
|
+
export { applyNetworkLayout, placeLoneNodes, } from "./src/charts/Network/applyLayout.js";
|
|
20
|
+
export { graphLinkEnd, graphNodeId, graphNodeRows, resolveGraphLinks, resolveGraphNodes, zoomToNodeBounds, } from "./src/charts/Network/graph.js";
|
|
21
21
|
export type { GraphLink, GraphNode } from "./src/charts/Network/graph.js";
|
|
22
22
|
export { installGraphFluent } from "./src/charts/Network/graphFluent.js";
|
|
23
23
|
export type { GraphFluent } from "./src/charts/Network/graphFluent.js";
|
|
@@ -33,6 +33,12 @@ export { bindSvgBackgroundClick, clearLinkFocus, focusLink, installFocusBackgrou
|
|
|
33
33
|
export type { FocusBox } from "./src/charts/features/linkFocus.js";
|
|
34
34
|
export { isLinkDatum, LINK_HIT_WIDTH, linkArrows, linkAriaLabel, linkCellText, linkEndLabel, linkHighlight, linkHitPath, linkMeta, linkNodeOf, linkTooltipConfig, linkTooltipRows, linkTooltipTitle, makeLinkDatum, nodeConnectionRows, nodeConnections, nodeHighlight, nodeTooltipLinkLimit, publishLinkGraph, rtlLocale, setLinkValue, } from "./src/charts/features/linkInteraction.js";
|
|
35
35
|
export type { LinkDatum, LinkEnd, LinkGraph, LinkMeta, } from "./src/charts/features/linkInteraction.js";
|
|
36
|
+
export { measuresTask, networkMeasures, } from "./src/charts/features/networkMeasures.js";
|
|
37
|
+
export type { MeasureArc, MeasuresTask, NetworkMeasures, } from "./src/charts/features/networkMeasures.js";
|
|
38
|
+
export { cancelIdleWork, IDLE_BUDGET, IdleQueue, idleQueue, requestIdle, } from "./src/charts/features/idleQueue.js";
|
|
39
|
+
export type { IdleJob } from "./src/charts/features/idleQueue.js";
|
|
40
|
+
export { NODE_STATS, nodeStatRows, nodeStatsFields, nodeStatsGraph, nodeStatsInIdle, scheduleNodeStats, STAT_PENDING, nodeTooltipStatList, } from "./src/charts/features/nodeStats.js";
|
|
41
|
+
export type { NodeStat, NodeStatsGraph, StatLink, } from "./src/charts/features/nodeStats.js";
|
|
36
42
|
export { applyRingsLayout } from "./src/charts/Rings/applyLayout.js";
|
|
37
43
|
export { applySankeyLayout } from "./src/charts/Sankey/applyLayout.js";
|
|
38
44
|
export { applyPackLayout } from "./src/charts/Pack/applyLayout.js";
|
|
@@ -101,6 +107,10 @@ export type { Box as CalloutBox, Point as CalloutPoint, } from "./src/charts/fea
|
|
|
101
107
|
export { calloutNodes, calloutPicker, calloutRowNodes, } from "./src/charts/features/calloutScene.js";
|
|
102
108
|
export { expandReferenceBands, expandReferenceLines, REFERENCE_BAND, REFERENCE_LINE, referenceAxis, referenceBandLabelAt, referenceBandLabelSpots, referenceBandNodes, referenceBandRect, referenceLineLabelAt, referenceLineLabelSpots, referenceLineNodes, referenceLinePoints, } from "./src/charts/features/referenceAnnotations.js";
|
|
103
109
|
export { textHalo } from "./src/charts/features/textHalo.js";
|
|
110
|
+
export { bindAccessors, handleAxisTooltip, isAxisTooltipDatum, resolveAxisTooltip, } from "./src/charts/features/axisTooltip.js";
|
|
111
|
+
export type { AxisTooltipContent } from "./src/charts/features/axisTooltip.js";
|
|
112
|
+
export { axisTooltipTarget, inertAxis, labelCut, stampTickTooltips, stampTitleTooltip, tickRank, } from "./src/components/Axis/axisTooltipTargets.js";
|
|
113
|
+
export type { AxisTooltipTarget, RankedAxis, } from "./src/components/Axis/axisTooltipTargets.js";
|
|
104
114
|
export { clearGraphFocus, withinArea, } from "./src/charts/features/ensureZoomDom.js";
|
|
105
115
|
export { labelSpotBox, pickLabelSpot, placeReferenceLabels, registerLabelSpots, slideSteps, } from "./src/charts/features/referenceLabelPlacement.js";
|
|
106
116
|
export type { LabelSpot } from "./src/charts/features/referenceLabelPlacement.js";
|
|
@@ -182,6 +192,7 @@ export { linePoints, parallelPath, } from "./src/charts/ParallelCoordinates/path
|
|
|
182
192
|
export type { LineAxis, ParallelCurve, ParallelOrient, } from "./src/charts/ParallelCoordinates/paths.js";
|
|
183
193
|
export { axisDomain, dimensionAxisConfig, dimensionTitleStyle, layoutAxes, } from "./src/charts/ParallelCoordinates/axes.js";
|
|
184
194
|
export type { AxesLayout, PlacedAxis, } from "./src/charts/ParallelCoordinates/axes.js";
|
|
195
|
+
export { chromeNode } from "./src/charts/ParallelCoordinates/chrome.js";
|
|
185
196
|
export { brushTarget, parallelDimensionKeys, parallelOrient, } from "./src/charts/ParallelCoordinates/applyLayout.js";
|
|
186
197
|
export { clearStrip, stripLength, stripSelection, syncBrushDom, } from "./src/charts/ParallelCoordinates/brushDom.js";
|
|
187
198
|
export type { BrushTarget } from "./src/charts/ParallelCoordinates/brushDom.js";
|
|
@@ -202,7 +213,7 @@ export { alluvialColumns, alluvialRibbon, incomingBarycenters, layoutAlluvial, s
|
|
|
202
213
|
export type { AlluvialLayoutOptions, AlluvialNodeSort, } from "./src/charts/Alluvial/layout.js";
|
|
203
214
|
export { alluvialDimensions, alluvialGroupBy, alluvialMeta, setAlluvialMeta, sourceRows, } from "./src/charts/Alluvial/meta.js";
|
|
204
215
|
export type { AlluvialMeta } from "./src/charts/Alluvial/meta.js";
|
|
205
|
-
export { TITLE_GAP as ALLUVIAL_TITLE_GAP, alluvialTitleBoxes, alluvialTitleNodes, alluvialTitleStyle, sizeAlluvialTitles, } from "./src/charts/Alluvial/titles.js";
|
|
216
|
+
export { TITLE_GAP as ALLUVIAL_TITLE_GAP, alluvialTitleBoxes, alluvialTitleNodes, alluvialTitleStyle, alluvialTitleTooltip, sizeAlluvialTitles, } from "./src/charts/Alluvial/titles.js";
|
|
206
217
|
export type { AlluvialTitle } from "./src/charts/Alluvial/titles.js";
|
|
207
218
|
export { candleChange, candleDirection, candlePath, candleWidth, finiteValue, ohlcBarPath, ohlcExtent, periodSpacing, pixelCenter, readOhlc, } from "./src/charts/Candlestick/ohlc.js";
|
|
208
219
|
export type { CandleDirection, CandlestickVariant, Ohlc, OhlcAccessor, OhlcAccessors, } from "./src/charts/Candlestick/ohlc.js";
|
|
@@ -322,7 +333,7 @@ export { gapIndex, hidesAllTime, isHiddenTime, isRangeBreakRule, normalizeRangeB
|
|
|
322
333
|
export type { RangeBreakRule, RangeBreakTime, TimeGap, } from "./src/components/Axis/rangeBreaks.js";
|
|
323
334
|
export { applyAxisRangeBreaks, visibleTimeValues, } from "./src/components/Axis/axisRangeBreaks.js";
|
|
324
335
|
export { dropHiddenRows, plotRangeBreaks, plotTimeScale, rangeBreaksTimeAxis, timelineRangeBreaks, } from "./src/charts/Plot/plotRangeBreaks.js";
|
|
325
|
-
export { applyAxisBreaks, axisBarNodes, baselineBreakStyle, breakGap, breakStyle, breakStyleOf, breakTickValues, brokenBarScene, resolveBaselineBreak, } from "./src/components/Axis/axisBreak.js";
|
|
336
|
+
export { applyAxisBreaks, axisBarNodes, baselineBreakStyle, breakGap, breakStyle, breakStyleOf, breakTickValues, brokenBarScene, fitBreakSpace, resolveBaselineBreak, } from "./src/components/Axis/axisBreak.js";
|
|
326
337
|
export type { AxisBaselineBreak, AxisBreak, BreakStyle, } from "./src/components/Axis/axisBreak.js";
|
|
327
338
|
export { bandPolygon, breakLineNodes, breakLinePaint, maskBreaks, maskPath, unwrapBreakMasks, } from "./src/charts/Plot/plotBreaks.js";
|
|
328
339
|
export { baselineBreakAxisConfig, clampBarConfig, outsideBaselineBreak, plotAxisConfig, userDomainBreaksBaseline, valueAxis, valueAxisExtent, } from "./src/charts/Plot/baselineBreak.js";
|
|
@@ -369,6 +380,8 @@ export type { NearestHoverState } from "./src/charts/viz/nearestHover.js";
|
|
|
369
380
|
export { nearestHoverSurface } from "./src/charts/viz/nearestHoverSurface.js";
|
|
370
381
|
export { clientAnchor, pointTooltipAnchor, surfaceOrigin, } from "./src/charts/viz/pointTooltipAnchor.js";
|
|
371
382
|
export type { ClientOrigin } from "./src/charts/viz/pointTooltipAnchor.js";
|
|
383
|
+
export { tooltipEnabled, tooltipLevels, } from "./src/charts/viz/tooltipEnabled.js";
|
|
384
|
+
export type { TooltipHost } from "./src/charts/viz/tooltipEnabled.js";
|
|
372
385
|
export { pointVoronoi, polygonDistance } from "./src/charts/viz/pointVoronoi.js";
|
|
373
386
|
export { boxCoverage, boxesOverlap, boxHitsCircle, placeCircleLabels, ringCentroid, sideBox, sideOrder, } from "./src/charts/features/circleLabelPlacement.js";
|
|
374
387
|
export type { CircleLabelBox, CircleLabelPlacement, CircleLabelRequest, LabelCircle, LabelPosition, LabelSide, PlaceCircleLabelsOptions, } from "./src/charts/features/circleLabelPlacement.js";
|
|
@@ -500,7 +513,11 @@ export { uniqueLinkKeys } from "./src/charts/features/linkKeys.js";
|
|
|
500
513
|
export { sankeyLinkIds } from "./src/charts/Sankey/emit.js";
|
|
501
514
|
export { ringsLinkKeys } from "./src/charts/Rings/emit.js";
|
|
502
515
|
export { bowedEdge, edgesBetween, fanParallelEdges, firstPerNeighbor, parallelOffsets, slideOnRim, } from "./src/charts/Rings/ringsParallel.js";
|
|
503
|
-
export {
|
|
516
|
+
export { buildRingsEdges, claimRings, placeRings, ringWeights, } from "./src/charts/Rings/ringsPlacement.js";
|
|
517
|
+
export { applyRingArc, arcCubics, curveRingsEdge, gapMiddle, ringArcRadius, ringArcCubics, ringRadius, } from "./src/charts/Rings/ringsCurves.js";
|
|
518
|
+
export type { RingsTree } from "./src/charts/Rings/ringsPlacement.js";
|
|
519
|
+
export { ringNodeRadii, ringsGeometry, ringsHops, ringsNodeRadii, } from "./src/charts/Rings/ringsSizing.js";
|
|
520
|
+
export { cubicsArrowEdge, cubicsPathD, polylineArrowEdge, } from "./src/charts/features/curvedArrows.js";
|
|
504
521
|
export { polylineReach } from "./src/charts/features/polyline.js";
|
|
505
522
|
export { EDGE_BUNDLE_DEFAULTS, angleCompatibility, bundleEdges, compatibilityGraph, edgeBundleCache, edgeBundleKey, edgeBundleOptions, edgeCompatibility, maxLengthRatio, positionCompatibility, scaleCompatibility, subdividePolyline, visibilityCompatibility, } from "./src/charts/features/edgeBundling.js";
|
|
506
523
|
export type { CompatibilityGraph, EdgeBundleCache, EdgeBundleOptions, Segment, } from "./src/charts/features/edgeBundling.js";
|
|
@@ -22,12 +22,25 @@ export interface AlluvialTitle extends DimensionTitle {
|
|
|
22
22
|
@param width The chart width.
|
|
23
23
|
*/
|
|
24
24
|
export declare function alluvialTitleBoxes(texts: string[], x: number[], nodeWidth: number, width: number): AlluvialTitle[];
|
|
25
|
-
/** The column
|
|
25
|
+
/** The column titles' `titleTooltip`, from `dimensionTitleConfig`. */
|
|
26
|
+
export declare function alluvialTitleTooltip(viz: VizInstance): unknown;
|
|
27
|
+
/**
|
|
28
|
+
The column title style: `dimensionTitleConfig` over the chart's background
|
|
29
|
+
ink, without its `titleTooltip` (see `alluvialTitleTooltip`).
|
|
30
|
+
*/
|
|
26
31
|
export declare function alluvialTitleStyle(viz: VizInstance, titles: AlluvialTitle[]): Record<string, unknown>;
|
|
27
32
|
/**
|
|
28
33
|
Sizes the title boxes to the tallest wrapped title and returns that
|
|
29
34
|
height (0 with no titles).
|
|
30
35
|
*/
|
|
31
36
|
export declare function sizeAlluvialTitles(titles: AlluvialTitle[], style: Record<string, unknown>, locale?: string): number;
|
|
32
|
-
/**
|
|
33
|
-
|
|
37
|
+
/**
|
|
38
|
+
The title text nodes, as chrome with no datum: a title takes the pointer
|
|
39
|
+
only when it has a tooltip to show, the option's or, drawn cut short, its
|
|
40
|
+
whole text.
|
|
41
|
+
@param titles The sized title boxes.
|
|
42
|
+
@param style The title style.
|
|
43
|
+
@param locale The chart's locale.
|
|
44
|
+
@param tooltip `dimensionTitleConfig`'s `titleTooltip`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function alluvialTitleNodes(titles: AlluvialTitle[], style: Record<string, unknown>, locale?: string, tooltip?: unknown): SceneNode[];
|