@opendata-ai/openchart-engine 6.18.0 → 6.19.1
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/dist/index.js
CHANGED
|
@@ -8877,7 +8877,8 @@ function computeLegend(spec, strategy, theme, chartArea, watermark = true) {
|
|
|
8877
8877
|
entryGap: 4
|
|
8878
8878
|
};
|
|
8879
8879
|
}
|
|
8880
|
-
const
|
|
8880
|
+
const reserveBrand = watermark && resolvedPosition === "bottom";
|
|
8881
|
+
const availableWidth = chartArea.width - LEGEND_PADDING * 2 - (reserveBrand ? BRAND_RESERVE_WIDTH : 0);
|
|
8881
8882
|
if (spec.legend?.symbolLimit != null) {
|
|
8882
8883
|
const limit = Math.max(1, spec.legend.symbolLimit);
|
|
8883
8884
|
if (limit < entries.length) {
|
|
@@ -9456,7 +9457,7 @@ function getLinkColors(linkStyle, sourceColor, targetColor, neutralColor) {
|
|
|
9456
9457
|
return { sourceColor, targetColor };
|
|
9457
9458
|
}
|
|
9458
9459
|
}
|
|
9459
|
-
function computeNodeLabel(node, maxDepth, theme, nodeWidth, nodeLabelAlign = "auto") {
|
|
9460
|
+
function computeNodeLabel(node, maxDepth, theme, nodeWidth, nodeLabelAlign = "auto", containerWidth, padding) {
|
|
9460
9461
|
const depth = node.depth ?? 0;
|
|
9461
9462
|
let placeLeft;
|
|
9462
9463
|
if (nodeLabelAlign === "left") {
|
|
@@ -9478,13 +9479,24 @@ function computeNodeLabel(node, maxDepth, theme, nodeWidth, nodeLabelAlign = "au
|
|
|
9478
9479
|
const y0 = node.y0 ?? 0;
|
|
9479
9480
|
const y1 = node.y1 ?? 0;
|
|
9480
9481
|
const midY = (y0 + y1) / 2;
|
|
9482
|
+
const pad2 = padding ?? 0;
|
|
9483
|
+
let maxWidth;
|
|
9484
|
+
if (containerWidth !== void 0) {
|
|
9485
|
+
if (placeLeft) {
|
|
9486
|
+
maxWidth = x0 - LABEL_GAP - pad2;
|
|
9487
|
+
} else {
|
|
9488
|
+
maxWidth = containerWidth - pad2 - (x1 + LABEL_GAP);
|
|
9489
|
+
}
|
|
9490
|
+
if (maxWidth !== void 0 && maxWidth < 0) maxWidth = 0;
|
|
9491
|
+
}
|
|
9481
9492
|
if (placeLeft) {
|
|
9482
9493
|
return {
|
|
9483
9494
|
text: node.label ?? node.id,
|
|
9484
9495
|
x: x0 - LABEL_GAP,
|
|
9485
9496
|
y: midY,
|
|
9486
9497
|
style: { ...style, textAnchor: "end", dominantBaseline: "central" },
|
|
9487
|
-
visible: true
|
|
9498
|
+
visible: true,
|
|
9499
|
+
maxWidth
|
|
9488
9500
|
};
|
|
9489
9501
|
}
|
|
9490
9502
|
return {
|
|
@@ -9492,7 +9504,8 @@ function computeNodeLabel(node, maxDepth, theme, nodeWidth, nodeLabelAlign = "au
|
|
|
9492
9504
|
x: x1 + LABEL_GAP,
|
|
9493
9505
|
y: midY,
|
|
9494
9506
|
style: { ...style, textAnchor: "start", dominantBaseline: "central" },
|
|
9495
|
-
visible: true
|
|
9507
|
+
visible: true,
|
|
9508
|
+
maxWidth
|
|
9496
9509
|
};
|
|
9497
9510
|
}
|
|
9498
9511
|
function compileSankey(spec, options) {
|
|
@@ -9647,7 +9660,15 @@ function compileSankey(spec, options) {
|
|
|
9647
9660
|
height: (node.y1 ?? 0) - (node.y0 ?? 0),
|
|
9648
9661
|
fill,
|
|
9649
9662
|
cornerRadius: NODE_CORNER_RADIUS,
|
|
9650
|
-
label: computeNodeLabel(
|
|
9663
|
+
label: computeNodeLabel(
|
|
9664
|
+
node,
|
|
9665
|
+
maxDepth,
|
|
9666
|
+
theme,
|
|
9667
|
+
sankeySpec.nodeWidth,
|
|
9668
|
+
nodeLabelAlign,
|
|
9669
|
+
options.width,
|
|
9670
|
+
padding
|
|
9671
|
+
),
|
|
9651
9672
|
nodeId: node.id,
|
|
9652
9673
|
value: node.value ?? 0,
|
|
9653
9674
|
depth,
|
|
@@ -11091,7 +11112,7 @@ function compileChart(spec, options) {
|
|
|
11091
11112
|
}
|
|
11092
11113
|
const breakpoint = getBreakpoint(options.width);
|
|
11093
11114
|
const heightClass = getHeightClass(options.height);
|
|
11094
|
-
|
|
11115
|
+
let strategy = getLayoutStrategy(breakpoint, heightClass);
|
|
11095
11116
|
const rawSpec = expandedSpec;
|
|
11096
11117
|
const overrides = rawSpec.overrides;
|
|
11097
11118
|
if (overrides?.[breakpoint]) {
|
|
@@ -11128,6 +11149,7 @@ function compileChart(spec, options) {
|
|
|
11128
11149
|
...chartSpec,
|
|
11129
11150
|
annotations: bp.annotations
|
|
11130
11151
|
};
|
|
11152
|
+
strategy = { ...strategy, annotationPosition: "inline" };
|
|
11131
11153
|
}
|
|
11132
11154
|
}
|
|
11133
11155
|
const rawAnimationSpec = overrides?.[breakpoint]?.animation ?? rawSpec.animation;
|