@fundar/data-chart-telling 0.0.8 → 0.0.9
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/plots/utils/segments.js +22 -1
- package/package.json +1 -1
|
@@ -68,6 +68,27 @@ export function validateSegments(segments) {
|
|
|
68
68
|
check(key === DEFAULT_KEY ? '(default)' : `"${key}"`, segs);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
+
function isPlainObject(v) {
|
|
72
|
+
return v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Merges two style objects one level deep: for any key where both base and
|
|
76
|
+
* override hold plain objects (e.g. `stroke`, `dots`), their fields are
|
|
77
|
+
* merged — override wins on conflict. Primitive fields are overridden directly.
|
|
78
|
+
*/
|
|
79
|
+
function mergeStyles(base, override) {
|
|
80
|
+
const result = { ...base };
|
|
81
|
+
for (const [key, val] of Object.entries(override)) {
|
|
82
|
+
const baseVal = result[key];
|
|
83
|
+
if (isPlainObject(val) && isPlainObject(baseVal)) {
|
|
84
|
+
result[key] = { ...baseVal, ...val };
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
result[key] = val;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
71
92
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
93
|
function resolveSeriesSegments(series, segs) {
|
|
73
94
|
if (!segs.length) {
|
|
@@ -143,7 +164,7 @@ function resolveSeriesSegments(series, segs) {
|
|
|
143
164
|
// keys fill in whatever the area segment omits; the area wins on conflict.
|
|
144
165
|
const isAreaSpecific = seg.areas != null && seg.areas.length > 0;
|
|
145
166
|
const resolvedStyle = isAreaSpecific && catchAll?.style
|
|
146
|
-
?
|
|
167
|
+
? mergeStyles(catchAll.style, segStyle)
|
|
147
168
|
: segStyle;
|
|
148
169
|
userVisual.push({ data: run.data, style: resolvedStyle });
|
|
149
170
|
// When the next run is also a user segment (no unmatched data between them),
|