@d3plus/core 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +303 -292
- package/es/src/charts/events/click.legend.js +1 -1
- package/es/src/charts/events/click.legend.js.map +1 -1
- package/es/src/charts/events/mousemove.legend.js +1 -1
- package/es/src/charts/events/mousemove.legend.js.map +1 -1
- package/es/src/charts/features/features.js +3 -3
- package/es/src/charts/features/features.js.map +1 -1
- package/es/src/charts/features/featuresLegend.js +1 -1
- package/es/src/charts/features/featuresLegend.js.map +1 -1
- package/es/src/charts/viz/VizBase.js.map +1 -1
- package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
- package/es/src/components/TextBox.js +21 -5
- package/es/src/components/TextBox.js.map +1 -1
- package/es/src/shapes/Circle.js +12 -4
- package/es/src/shapes/Circle.js.map +1 -1
- package/es/src/shapes/buildLabelData.js +59 -4
- package/es/src/shapes/buildLabelData.js.map +1 -1
- package/es/src/utils/D3plusConfig.js.map +1 -1
- package/package.json +10 -10
- package/types/src/charts/viz/VizBase.d.ts +4 -4
- package/types/src/charts/viz/VizBaseConfig.d.ts +4 -3
- package/types/src/utils/D3plusConfig.d.ts +40 -12
- package/umd/d3plus-core.full.js +515 -264
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +785 -699
- package/umd/d3plus-core.js +45 -16
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +35 -12
package/umd/d3plus-core.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
@d3plus/core v4.
|
|
2
|
+
@d3plus/core v4.1.0
|
|
3
3
|
Data visualization made easy. A javascript library that extends the popular D3.js to enable fast and beautiful visualizations.
|
|
4
4
|
Copyright (c) 2026 D3plus - https://d3plus.org
|
|
5
5
|
@license MIT
|
|
@@ -405,7 +405,7 @@
|
|
|
405
405
|
"top",
|
|
406
406
|
"bottom"
|
|
407
407
|
].includes(position);
|
|
408
|
-
const padding = viz.schema.legendPadding() ? viz._padding : {
|
|
408
|
+
const padding = viz.schema.legendPadding(viz) ? viz._padding : {
|
|
409
409
|
top: 0,
|
|
410
410
|
right: 0,
|
|
411
411
|
bottom: 0,
|
|
@@ -575,7 +575,7 @@
|
|
|
575
575
|
panel: null,
|
|
576
576
|
margin: {}
|
|
577
577
|
};
|
|
578
|
-
const usesPadding = viz.schema[opts.paddingMethod]();
|
|
578
|
+
const usesPadding = viz.schema[opts.paddingMethod](viz);
|
|
579
579
|
const padding = usesPadding ? viz._padding : {
|
|
580
580
|
right: 0,
|
|
581
581
|
left: 0
|
|
@@ -771,7 +771,7 @@
|
|
|
771
771
|
let timelinePossible = viz.schema.time && viz.schema.timeline;
|
|
772
772
|
const ticks = timelinePossible ? data.unique(viz._data.map(viz.schema.time)).map((d)=>dom.date(d)) : [];
|
|
773
773
|
timelinePossible = timelinePossible && ticks.length > 1;
|
|
774
|
-
const padding = viz.schema.timelinePadding() ? viz._padding : {
|
|
774
|
+
const padding = viz.schema.timelinePadding(viz) ? viz._padding : {
|
|
775
775
|
right: 0,
|
|
776
776
|
left: 0
|
|
777
777
|
};
|
|
@@ -854,7 +854,7 @@
|
|
|
854
854
|
"bottom"
|
|
855
855
|
].includes(position);
|
|
856
856
|
const showColorScale = viz.schema.colorScale && position;
|
|
857
|
-
const padding = viz.schema.colorScalePadding() ? viz._padding : {
|
|
857
|
+
const padding = viz.schema.colorScalePadding(viz) ? viz._padding : {
|
|
858
858
|
top: 0,
|
|
859
859
|
right: 0,
|
|
860
860
|
bottom: 0,
|
|
@@ -2763,6 +2763,14 @@
|
|
|
2763
2763
|
id: `${id(d, i)}_${l}`,
|
|
2764
2764
|
r,
|
|
2765
2765
|
rotateAnchor,
|
|
2766
|
+
// Wrapping shape rides on the bounds so it stays paired with them:
|
|
2767
|
+
// a shape whose `labelBounds` returns `shape: "circle"` wraps to the
|
|
2768
|
+
// circle, while a chart that supplies its own rectangular bounds
|
|
2769
|
+
// (no `shape`) wraps normally. Stamped under a namespaced key so it
|
|
2770
|
+
// can't collide with a `shape` field a caller's own data might carry.
|
|
2771
|
+
...b.shape ? {
|
|
2772
|
+
__d3plusWrapShape__: b.shape
|
|
2773
|
+
} : {},
|
|
2766
2774
|
text: labels[l],
|
|
2767
2775
|
width: b.width,
|
|
2768
2776
|
x: xPos + b.x,
|
|
@@ -4003,11 +4011,19 @@
|
|
|
4003
4011
|
super("circle");
|
|
4004
4012
|
installFluent(this, circleSchema);
|
|
4005
4013
|
this._name = "Circle";
|
|
4014
|
+
// Bound the label to the full circle (diameter box) and tag it
|
|
4015
|
+
// `shape: "circle"`, so the label TextBox flows text as circle chords —
|
|
4016
|
+
// lines fill the interior, shorter near the top and bottom and full width
|
|
4017
|
+
// through the middle — rather than being capped to a square inscribed in
|
|
4018
|
+
// the circle. The `shape` hint rides on the bounds (not `labelConfig`) so a
|
|
4019
|
+
// chart that repositions the label with its own `labelBounds` (e.g. Tree's
|
|
4020
|
+
// external node labels) gets ordinary rectangular wrapping.
|
|
4006
4021
|
this.schema.labelBounds = (_d, _i, s)=>({
|
|
4007
|
-
width: s.r *
|
|
4008
|
-
height: s.r *
|
|
4009
|
-
x: -s.r
|
|
4010
|
-
y: -s.r
|
|
4022
|
+
width: s.r * 2,
|
|
4023
|
+
height: s.r * 2,
|
|
4024
|
+
x: -s.r,
|
|
4025
|
+
y: -s.r,
|
|
4026
|
+
shape: "circle"
|
|
4011
4027
|
});
|
|
4012
4028
|
this.schema.labelConfig = dom.assign(this.schema.labelConfig, {
|
|
4013
4029
|
textAnchor: "middle",
|
|
@@ -7110,9 +7126,11 @@
|
|
|
7110
7126
|
}
|
|
7111
7127
|
return lineRuns;
|
|
7112
7128
|
}
|
|
7113
|
-
/** Pre-scales the font size to fit the box area before wrapping (resize mode). */ function resizeFontSize(fS, w, h, lH, words, style) {
|
|
7129
|
+
/** Pre-scales the font size to fit the box area before wrapping (resize mode). */ function resizeFontSize(fS, w, h, lH, words, style, shape) {
|
|
7114
7130
|
const sizes = dom.textWidth(words, style);
|
|
7115
|
-
const areaMod = 1.165 + w / h * 0.1,
|
|
7131
|
+
const areaMod = 1.165 + w / h * 0.1, // A circle fills only ~π/4 of its bounding box, so scale the usable area
|
|
7132
|
+
// down to keep the initial font-size guess from overshooting.
|
|
7133
|
+
boxArea = w * h * (shape === "circle" ? Math.PI / 4 : 1), maxWidth = d3Array.max(sizes), textArea = d3Array.sum(sizes, (d)=>d * lH) * areaMod;
|
|
7116
7134
|
if (maxWidth > w || textArea > boxArea) {
|
|
7117
7135
|
const areaRatio = Math.sqrt(boxArea / textArea), widthRatio = w / maxWidth;
|
|
7118
7136
|
const sizeRatio = d3Array.min([
|
|
@@ -7182,8 +7200,8 @@
|
|
|
7182
7200
|
"line-height": lH
|
|
7183
7201
|
};
|
|
7184
7202
|
const padding = dom.parseSides(box.schema.padding(d, i));
|
|
7185
|
-
const h = box.schema.height(d, i) - (padding.top + padding.bottom), w = box.schema.width(d, i) - (padding.left + padding.right);
|
|
7186
|
-
const wrapper = text.textWrap().fontFamily(style["font-family"]).fontSize(fS).fontWeight(style["font-weight"]).lineHeight(lH).maxLines(box.schema.maxLines(d, i)).height(h).overflow(box.schema.overflow(d, i)).width(w).split(box.schema.split);
|
|
7203
|
+
const h = box.schema.height(d, i) - (padding.top + padding.bottom), w = box.schema.width(d, i) - (padding.left + padding.right), shape = box.schema.shape(d, i);
|
|
7204
|
+
const wrapper = text.textWrap().fontFamily(style["font-family"]).fontSize(fS).fontWeight(style["font-weight"]).lineHeight(lH).maxLines(box.schema.maxLines(d, i)).height(h).overflow(box.schema.overflow(d, i)).shape(shape).width(w).split(box.schema.split);
|
|
7187
7205
|
const fMax = box.schema.fontMax(d, i), fMin = box.schema.fontMin(d, i), vA = box.schema.verticalAlign(d, i), words = box.schema.split(t, i);
|
|
7188
7206
|
/**
|
|
7189
7207
|
Figures out the lineData to be used for wrapping.
|
|
@@ -7225,7 +7243,7 @@
|
|
|
7225
7243
|
}
|
|
7226
7244
|
}
|
|
7227
7245
|
if (w > fMin && (h > lH || resize && h > fMin * lHRatio)) {
|
|
7228
|
-
if (resize) fS = resizeFontSize(fS, w, h, lH, words, style);
|
|
7246
|
+
if (resize) fS = resizeFontSize(fS, w, h, lH, words, style, shape);
|
|
7229
7247
|
checkSize();
|
|
7230
7248
|
}
|
|
7231
7249
|
if (!lineData.length) return null;
|
|
@@ -7365,6 +7383,17 @@
|
|
|
7365
7383
|
d.h / 2
|
|
7366
7384
|
]
|
|
7367
7385
|
},
|
|
7386
|
+
// Bounding shape for wrapping: "square" (default) fills the full width on
|
|
7387
|
+
// every line; "circle" treats width/height as the diameter and shortens
|
|
7388
|
+
// lines near the top and bottom to keep text inside the circle. Defaults to
|
|
7389
|
+
// the label record's namespaced `__d3plusWrapShape__` (stamped from a shape's
|
|
7390
|
+
// `labelBounds`) so Circle labels wrap to the circle without callers
|
|
7391
|
+
// configuring anything, while a caller's own `shape` data field is ignored.
|
|
7392
|
+
{
|
|
7393
|
+
key: "shape",
|
|
7394
|
+
coerce: "const",
|
|
7395
|
+
default: (d)=>d.__d3plusWrapShape__ ?? "square"
|
|
7396
|
+
},
|
|
7368
7397
|
{
|
|
7369
7398
|
key: "split",
|
|
7370
7399
|
coerce: "identity",
|
|
@@ -8749,7 +8778,7 @@
|
|
|
8749
8778
|
];
|
|
8750
8779
|
return id;
|
|
8751
8780
|
})).length;
|
|
8752
|
-
const inverted = this.schema.legendFilterInvert.bind(this)();
|
|
8781
|
+
const inverted = this.schema.legendFilterInvert.bind(this)(this);
|
|
8753
8782
|
if (inverted) {
|
|
8754
8783
|
if (event.shiftKey) {
|
|
8755
8784
|
if (hiddenIndex < 0 && !this._solo.length) {
|
|
@@ -8907,7 +8936,7 @@
|
|
|
8907
8936
|
const hasDeeperLevel = this._drawDepth < this.schema.groupBy.length - 1;
|
|
8908
8937
|
// only show the hand cursor when the shape has a click event
|
|
8909
8938
|
this._select.style("cursor", hasUserClick || hasDefaultClick && hasDeeperLevel ? "pointer" : "auto");
|
|
8910
|
-
const invertedBehavior = this.schema.legendFilterInvert.bind(this)();
|
|
8939
|
+
const invertedBehavior = this.schema.legendFilterInvert.bind(this)(this);
|
|
8911
8940
|
const solo = this._solo.includes(id);
|
|
8912
8941
|
const hidden = this._hidden.includes(id);
|
|
8913
8942
|
this._tooltipClass.data([
|