@automattic/charts 1.3.1 → 1.4.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/CHANGELOG.md +15 -0
- package/dist/index.cjs +158 -209
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +0 -9
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +11 -10
- package/dist/index.d.ts +11 -10
- package/dist/index.js +125 -176
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/charts/area-chart/area-chart.tsx +124 -54
- package/src/charts/area-chart/test/area-chart.test.tsx +203 -0
- package/src/hooks/index.ts +0 -1
- package/src/hooks/test/use-chart-margin.test.tsx +21 -0
- package/src/hooks/use-chart-margin.tsx +4 -0
- package/src/providers/chart-context/global-charts-provider.tsx +1 -18
- package/src/style.css +10 -0
- package/src/types.ts +10 -0
- package/tsup.config.ts +3 -2
- package/AGENTS.md +0 -78
- package/src/hooks/test/use-tooltip-portal-relocator.test.ts +0 -216
- package/src/hooks/use-tooltip-portal-relocator.module.scss +0 -7
- package/src/hooks/use-tooltip-portal-relocator.ts +0 -188
package/dist/index.cjs
CHANGED
|
@@ -495,103 +495,6 @@ var useSingleChartContext = useChartInstanceContext;
|
|
|
495
495
|
var _d3color = require('@visx/vendor/d3-color');
|
|
496
496
|
|
|
497
497
|
|
|
498
|
-
// src/hooks/use-tooltip-portal-relocator.ts
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
// src/hooks/use-tooltip-portal-relocator.module.scss
|
|
502
|
-
var use_tooltip_portal_relocator_module_default = {
|
|
503
|
-
"relocatedPortal": "a8ccharts-jCw5dQ"
|
|
504
|
-
};
|
|
505
|
-
|
|
506
|
-
// src/hooks/use-tooltip-portal-relocator.ts
|
|
507
|
-
function isVisxPortalNode(node2) {
|
|
508
|
-
return node2 instanceof HTMLDivElement && node2.parentElement === document.body && !node2.id && !node2.className && node2.querySelector(".visx-tooltip") !== null;
|
|
509
|
-
}
|
|
510
|
-
var patchRefCount = 0;
|
|
511
|
-
var origRemoveChild = null;
|
|
512
|
-
var patchedRemoveChild = null;
|
|
513
|
-
var relocatedNodes = /* @__PURE__ */ new WeakSet();
|
|
514
|
-
function installRemoveChildPatch() {
|
|
515
|
-
if (patchRefCount++ > 0) {
|
|
516
|
-
return;
|
|
517
|
-
}
|
|
518
|
-
origRemoveChild = document.body.removeChild;
|
|
519
|
-
patchedRemoveChild = function(child) {
|
|
520
|
-
if (relocatedNodes.has(child) && child.parentNode !== this) {
|
|
521
|
-
relocatedNodes.delete(child);
|
|
522
|
-
_optionalChain([child, 'access', _2 => _2.parentNode, 'optionalAccess', _3 => _3.removeChild, 'call', _4 => _4(child)]);
|
|
523
|
-
return child;
|
|
524
|
-
}
|
|
525
|
-
return origRemoveChild.call(this, child);
|
|
526
|
-
};
|
|
527
|
-
document.body.removeChild = patchedRemoveChild;
|
|
528
|
-
}
|
|
529
|
-
function uninstallRemoveChildPatch() {
|
|
530
|
-
if (--patchRefCount > 0) {
|
|
531
|
-
return;
|
|
532
|
-
}
|
|
533
|
-
if (document.body.removeChild === patchedRemoveChild) {
|
|
534
|
-
document.body.removeChild = origRemoveChild;
|
|
535
|
-
}
|
|
536
|
-
origRemoveChild = null;
|
|
537
|
-
patchedRemoveChild = null;
|
|
538
|
-
}
|
|
539
|
-
function useTooltipPortalRelocator(containerRef) {
|
|
540
|
-
_react.useEffect.call(void 0, () => {
|
|
541
|
-
const container = _optionalChain([containerRef, 'optionalAccess', _5 => _5.current]);
|
|
542
|
-
if (!container) {
|
|
543
|
-
return;
|
|
544
|
-
}
|
|
545
|
-
const instanceNodes = /* @__PURE__ */ new Set();
|
|
546
|
-
const relocateNode = (node2) => {
|
|
547
|
-
if (!isVisxPortalNode(node2)) {
|
|
548
|
-
return;
|
|
549
|
-
}
|
|
550
|
-
node2.style.opacity = "0";
|
|
551
|
-
node2.classList.add(use_tooltip_portal_relocator_module_default.relocatedPortal);
|
|
552
|
-
const { activeElement } = node2.ownerDocument;
|
|
553
|
-
const focusedElement = activeElement instanceof HTMLElement && node2.contains(activeElement) ? activeElement : null;
|
|
554
|
-
container.insertBefore(node2, container.firstChild);
|
|
555
|
-
relocatedNodes.add(node2);
|
|
556
|
-
instanceNodes.add(node2);
|
|
557
|
-
if (focusedElement) {
|
|
558
|
-
focusedElement.focus();
|
|
559
|
-
}
|
|
560
|
-
requestAnimationFrame(() => {
|
|
561
|
-
requestAnimationFrame(() => {
|
|
562
|
-
node2.style.opacity = "";
|
|
563
|
-
});
|
|
564
|
-
});
|
|
565
|
-
};
|
|
566
|
-
installRemoveChildPatch();
|
|
567
|
-
for (const child of Array.from(document.body.children)) {
|
|
568
|
-
relocateNode(child);
|
|
569
|
-
}
|
|
570
|
-
const observer = new MutationObserver((mutations) => {
|
|
571
|
-
for (const mutation of mutations) {
|
|
572
|
-
for (const node2 of mutation.addedNodes) {
|
|
573
|
-
relocateNode(node2);
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
});
|
|
577
|
-
observer.observe(document.body, { childList: true });
|
|
578
|
-
return () => {
|
|
579
|
-
observer.disconnect();
|
|
580
|
-
for (const node2 of instanceNodes) {
|
|
581
|
-
if (node2 instanceof HTMLElement) {
|
|
582
|
-
node2.classList.remove(use_tooltip_portal_relocator_module_default.relocatedPortal);
|
|
583
|
-
}
|
|
584
|
-
if (node2.parentNode === container) {
|
|
585
|
-
document.body.appendChild(node2);
|
|
586
|
-
}
|
|
587
|
-
relocatedNodes.delete(node2);
|
|
588
|
-
}
|
|
589
|
-
instanceNodes.clear();
|
|
590
|
-
uninstallRemoveChildPatch();
|
|
591
|
-
};
|
|
592
|
-
}, [containerRef]);
|
|
593
|
-
}
|
|
594
|
-
|
|
595
498
|
// src/utils/create-composition.ts
|
|
596
499
|
function attachSubComponents(Chart2, subComponents) {
|
|
597
500
|
return Object.assign(Chart2, subComponents);
|
|
@@ -722,14 +625,14 @@ var getLongestTickWidth = (ticks, formatTick, labelStyle) => {
|
|
|
722
625
|
|
|
723
626
|
// src/utils/get-styles.ts
|
|
724
627
|
function getSeriesLineStyles(seriesData, index, providerTheme) {
|
|
725
|
-
const themeSemanticLineStyle = _optionalChain([providerTheme, 'optionalAccess',
|
|
726
|
-
const themeSeriesLineStyle = _optionalChain([providerTheme, 'optionalAccess',
|
|
727
|
-
return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([seriesData, 'access',
|
|
628
|
+
const themeSemanticLineStyle = _optionalChain([providerTheme, 'optionalAccess', _2 => _2.lineChart, 'optionalAccess', _3 => _3.lineStyles, 'optionalAccess', _4 => _4[_optionalChain([seriesData, 'access', _5 => _5.options, 'optionalAccess', _6 => _6.type])]]);
|
|
629
|
+
const themeSeriesLineStyle = _optionalChain([providerTheme, 'optionalAccess', _7 => _7.seriesLineStyles, 'optionalAccess', _8 => _8[index % providerTheme.seriesLineStyles.length]]);
|
|
630
|
+
return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([seriesData, 'access', _9 => _9.options, 'optionalAccess', _10 => _10.seriesLineStyle]), () => ( themeSemanticLineStyle)), () => ( themeSeriesLineStyle)), () => ( {}));
|
|
728
631
|
}
|
|
729
632
|
function getItemShapeStyles(series, index, theme, legendShape) {
|
|
730
|
-
const seriesShapeStyles = _nullishCoalesce(_optionalChain([series, 'access',
|
|
633
|
+
const seriesShapeStyles = _nullishCoalesce(_optionalChain([series, 'access', _11 => _11.options, 'optionalAccess', _12 => _12.legendShapeStyle]), () => ( {}));
|
|
731
634
|
const lineStyles = legendShape === "line" ? getSeriesLineStyles(series, index, theme) : {};
|
|
732
|
-
const themeShapeStyles = _optionalChain([theme, 'access',
|
|
635
|
+
const themeShapeStyles = _optionalChain([theme, 'access', _13 => _13.legend, 'optionalAccess', _14 => _14.shapeStyles, 'optionalAccess', _15 => _15[index]]);
|
|
733
636
|
const itemShapeStyles = {
|
|
734
637
|
...seriesShapeStyles,
|
|
735
638
|
...lineStyles
|
|
@@ -1096,13 +999,11 @@ var _jsxruntime = require('react/jsx-runtime');
|
|
|
1096
999
|
var GlobalChartsContext = /* @__PURE__ */ _react.createContext.call(void 0, null);
|
|
1097
1000
|
var GlobalChartsProvider = ({
|
|
1098
1001
|
children,
|
|
1099
|
-
theme
|
|
1100
|
-
portalContainer
|
|
1002
|
+
theme
|
|
1101
1003
|
}) => {
|
|
1102
1004
|
const [charts, setCharts] = _react.useState.call(void 0, () => /* @__PURE__ */ new Map());
|
|
1103
1005
|
const [hiddenSeries, setHiddenSeries] = _react.useState.call(void 0, () => /* @__PURE__ */ new Map());
|
|
1104
1006
|
const wrapperRef = _react.useRef.call(void 0, null);
|
|
1105
|
-
useTooltipPortalRelocator(_nullishCoalesce(portalContainer, () => ( wrapperRef)));
|
|
1106
1007
|
const providerTheme = _react.useMemo.call(void 0, () => {
|
|
1107
1008
|
return theme ? mergeThemes(defaultTheme, theme) : defaultTheme;
|
|
1108
1009
|
}, [theme]);
|
|
@@ -1202,12 +1103,12 @@ var GlobalChartsProvider = ({
|
|
|
1202
1103
|
const isPointPercentageData = data && typeof data === "object" && "value" in data && typeof data.value === "number" && !("data" in data);
|
|
1203
1104
|
return {
|
|
1204
1105
|
color: resolveColor({
|
|
1205
|
-
group: _optionalChain([data, 'optionalAccess',
|
|
1106
|
+
group: _optionalChain([data, 'optionalAccess', _16 => _16.group]),
|
|
1206
1107
|
index,
|
|
1207
|
-
overrideColor: overrideColor || isSeriesData && _optionalChain([data, 'optionalAccess',
|
|
1108
|
+
overrideColor: overrideColor || isSeriesData && _optionalChain([data, 'optionalAccess', _17 => _17.options, 'optionalAccess', _18 => _18.stroke]) || isPointPercentageData && _optionalChain([data, 'optionalAccess', _19 => _19.color])
|
|
1208
1109
|
}),
|
|
1209
1110
|
lineStyles: isSeriesData ? getSeriesLineStyles(data, index, providerTheme) : {},
|
|
1210
|
-
glyph: _optionalChain([providerTheme, 'access',
|
|
1111
|
+
glyph: _optionalChain([providerTheme, 'access', _20 => _20.glyphs, 'optionalAccess', _21 => _21[index]]),
|
|
1211
1112
|
shapeStyles: isSeriesData ? getItemShapeStyles(data, index, providerTheme, legendShape) : {}
|
|
1212
1113
|
};
|
|
1213
1114
|
}, [providerTheme, resolveColor]);
|
|
@@ -1298,7 +1199,7 @@ var useDeepMemo = (value) => {
|
|
|
1298
1199
|
var useXYChartTheme = (data) => {
|
|
1299
1200
|
const theme = useGlobalChartsTheme();
|
|
1300
1201
|
return _react.useMemo.call(void 0, () => {
|
|
1301
|
-
const seriesColors = (_nullishCoalesce(data, () => ( []))).map((series) => _optionalChain([series, 'access',
|
|
1202
|
+
const seriesColors = (_nullishCoalesce(data, () => ( []))).map((series) => _optionalChain([series, 'access', _22 => _22.options, 'optionalAccess', _23 => _23.stroke])).filter((color) => Boolean(color));
|
|
1302
1203
|
return _xychart.buildChartTheme.call(void 0, {
|
|
1303
1204
|
...theme,
|
|
1304
1205
|
colors: [...seriesColors, ..._nullishCoalesce(theme.colors, () => ( []))]
|
|
@@ -1310,7 +1211,7 @@ var useXYChartTheme = (data) => {
|
|
|
1310
1211
|
|
|
1311
1212
|
var useChartDataTransform = (data) => {
|
|
1312
1213
|
return _react.useMemo.call(void 0, () => {
|
|
1313
|
-
const firstPoint = _optionalChain([data, 'optionalAccess',
|
|
1214
|
+
const firstPoint = _optionalChain([data, 'optionalAccess', _24 => _24[0], 'optionalAccess', _25 => _25.data, 'optionalAccess', _26 => _26[0]]);
|
|
1314
1215
|
const hasDateProperties = firstPoint && ("date" in firstPoint || "dateString" in firstPoint);
|
|
1315
1216
|
if (!hasDateProperties) {
|
|
1316
1217
|
return data;
|
|
@@ -1348,9 +1249,9 @@ var DEFAULT_FONT_SIZE = 12;
|
|
|
1348
1249
|
var DEFAULT_TICK_LENGTH = 8;
|
|
1349
1250
|
var DEFAULT_Y_TICK_WIDTH = 40;
|
|
1350
1251
|
var getXAxisLabelMetrics = (theme, orientation) => {
|
|
1351
|
-
const xAxisStyles = orientation === "top" ? _optionalChain([theme, 'access',
|
|
1352
|
-
const fontSize = resolveFontSize(_optionalChain([xAxisStyles, 'optionalAccess',
|
|
1353
|
-
const tickLength = _nullishCoalesce(_optionalChain([xAxisStyles, 'optionalAccess',
|
|
1252
|
+
const xAxisStyles = orientation === "top" ? _optionalChain([theme, 'access', _27 => _27.axisStyles, 'optionalAccess', _28 => _28.x, 'optionalAccess', _29 => _29.top]) : _optionalChain([theme, 'access', _30 => _30.axisStyles, 'optionalAccess', _31 => _31.x, 'optionalAccess', _32 => _32.bottom]);
|
|
1253
|
+
const fontSize = resolveFontSize(_optionalChain([xAxisStyles, 'optionalAccess', _33 => _33.axisLabel, 'optionalAccess', _34 => _34.fontSize])) || resolveFontSize(_optionalChain([theme, 'access', _35 => _35.svgLabelSmall, 'optionalAccess', _36 => _36.fontSize])) || DEFAULT_FONT_SIZE;
|
|
1254
|
+
const tickLength = _nullishCoalesce(_optionalChain([xAxisStyles, 'optionalAccess', _37 => _37.tickLength]), () => ( DEFAULT_TICK_LENGTH));
|
|
1354
1255
|
return {
|
|
1355
1256
|
fontSize,
|
|
1356
1257
|
tickLength
|
|
@@ -1360,7 +1261,10 @@ var useChartMargin = (height, options, data, theme, horizontal = false) => {
|
|
|
1360
1261
|
const yTicks = _react.useMemo.call(void 0, () => {
|
|
1361
1262
|
const allDataPoints = data.flatMap((series) => series.data);
|
|
1362
1263
|
if (horizontal) {
|
|
1363
|
-
return allDataPoints.map((d) => d.label || _optionalChain([options, 'access',
|
|
1264
|
+
return allDataPoints.map((d) => d.label || _optionalChain([options, 'access', _38 => _38.axis, 'optionalAccess', _39 => _39.y, 'optionalAccess', _40 => _40.tickFormat, 'call', _41 => _41(d.date.getTime(), 0, [])]));
|
|
1265
|
+
}
|
|
1266
|
+
if (_optionalChain([options, 'access', _42 => _42.axis, 'optionalAccess', _43 => _43.y, 'optionalAccess', _44 => _44.tickValues, 'optionalAccess', _45 => _45.length])) {
|
|
1267
|
+
return options.axis.y.tickValues;
|
|
1364
1268
|
}
|
|
1365
1269
|
const minY = Math.min(...allDataPoints.map((d) => d.value));
|
|
1366
1270
|
const maxY = Math.max(...allDataPoints.map((d) => d.value));
|
|
@@ -4299,8 +4203,44 @@ var AreaChartInternal = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
|
|
|
4299
4203
|
chartRef,
|
|
4300
4204
|
totalPoints: _optionalChain([dataSorted, 'access', _222 => _222[0], 'optionalAccess', _223 => _223.data, 'access', _224 => _224.length]) || 0
|
|
4301
4205
|
});
|
|
4206
|
+
const fixedYDomain = _react.useMemo.call(void 0, () => {
|
|
4207
|
+
if (!legendInteractive || !dataSorted.length || !dataSorted[0].data.length || stacked && stackOffset !== "none") {
|
|
4208
|
+
return void 0;
|
|
4209
|
+
}
|
|
4210
|
+
if (stacked) {
|
|
4211
|
+
const numPoints = Math.max(...dataSorted.map((s) => s.data.length));
|
|
4212
|
+
let posMax = 0;
|
|
4213
|
+
let negMin = 0;
|
|
4214
|
+
for (let i = 0; i < numPoints; i++) {
|
|
4215
|
+
let posSum = 0;
|
|
4216
|
+
let negSum = 0;
|
|
4217
|
+
for (const series of dataSorted) {
|
|
4218
|
+
const v = Number(_optionalChain([series, 'access', _225 => _225.data, 'access', _226 => _226[i], 'optionalAccess', _227 => _227.value]));
|
|
4219
|
+
if (Number.isNaN(v)) continue;
|
|
4220
|
+
if (v >= 0) posSum += v;
|
|
4221
|
+
else negSum += v;
|
|
4222
|
+
}
|
|
4223
|
+
if (posSum > posMax) posMax = posSum;
|
|
4224
|
+
if (negSum < negMin) negMin = negSum;
|
|
4225
|
+
}
|
|
4226
|
+
return [negMin, posMax];
|
|
4227
|
+
}
|
|
4228
|
+
let max = -Infinity;
|
|
4229
|
+
let min = Infinity;
|
|
4230
|
+
for (const series of dataSorted) {
|
|
4231
|
+
for (const point of series.data) {
|
|
4232
|
+
const v = Number(_optionalChain([point, 'optionalAccess', _228 => _228.value]));
|
|
4233
|
+
if (!Number.isNaN(v)) {
|
|
4234
|
+
if (v > max) max = v;
|
|
4235
|
+
if (v < min) min = v;
|
|
4236
|
+
}
|
|
4237
|
+
}
|
|
4238
|
+
}
|
|
4239
|
+
if (max === -Infinity) return void 0;
|
|
4240
|
+
return [Math.min(0, min), max];
|
|
4241
|
+
}, [dataSorted, stacked, stackOffset, legendInteractive]);
|
|
4302
4242
|
const chartOptions = _react.useMemo.call(void 0, () => {
|
|
4303
|
-
const formatter = _optionalChain([options, 'optionalAccess',
|
|
4243
|
+
const formatter = _optionalChain([options, 'optionalAccess', _229 => _229.axis, 'optionalAccess', _230 => _230.x, 'optionalAccess', _231 => _231.tickFormat]) || getFormatter(dataSorted);
|
|
4304
4244
|
return {
|
|
4305
4245
|
axis: {
|
|
4306
4246
|
x: {
|
|
@@ -4308,29 +4248,32 @@ var AreaChartInternal = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
|
|
|
4308
4248
|
numTicks: guessOptimalNumTicks(dataSorted, width, formatter),
|
|
4309
4249
|
tickFormat: formatter,
|
|
4310
4250
|
display: true,
|
|
4311
|
-
..._optionalChain([options, 'optionalAccess',
|
|
4251
|
+
..._optionalChain([options, 'optionalAccess', _232 => _232.axis, 'optionalAccess', _233 => _233.x])
|
|
4312
4252
|
},
|
|
4313
4253
|
y: {
|
|
4314
4254
|
orientation: "left",
|
|
4315
4255
|
numTicks: 4,
|
|
4316
4256
|
tickFormat: _numberformatters.formatNumberCompact,
|
|
4317
4257
|
display: true,
|
|
4318
|
-
..._optionalChain([options, 'optionalAccess',
|
|
4258
|
+
..._optionalChain([options, 'optionalAccess', _234 => _234.axis, 'optionalAccess', _235 => _235.y])
|
|
4319
4259
|
}
|
|
4320
4260
|
},
|
|
4321
4261
|
xScale: {
|
|
4322
4262
|
type: "time",
|
|
4323
|
-
..._optionalChain([options, 'optionalAccess',
|
|
4263
|
+
..._optionalChain([options, 'optionalAccess', _236 => _236.xScale])
|
|
4324
4264
|
},
|
|
4325
4265
|
yScale: {
|
|
4326
4266
|
type: "linear",
|
|
4327
4267
|
nice: true,
|
|
4328
4268
|
// Stacked areas should always include zero so the baseline is meaningful.
|
|
4329
4269
|
zero: stacked,
|
|
4330
|
-
...
|
|
4270
|
+
...fixedYDomain ? {
|
|
4271
|
+
domain: fixedYDomain
|
|
4272
|
+
} : {},
|
|
4273
|
+
..._optionalChain([options, 'optionalAccess', _237 => _237.yScale])
|
|
4331
4274
|
}
|
|
4332
4275
|
};
|
|
4333
|
-
}, [options, dataSorted, width, stacked]);
|
|
4276
|
+
}, [options, dataSorted, width, stacked, fixedYDomain]);
|
|
4334
4277
|
const defaultMargin = useChartMargin(height, chartOptions, dataSorted, theme);
|
|
4335
4278
|
const error = validateData2(dataSorted);
|
|
4336
4279
|
const isDataValid = !error;
|
|
@@ -4353,10 +4296,33 @@ var AreaChartInternal = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
|
|
|
4353
4296
|
metadata: chartMetadata
|
|
4354
4297
|
});
|
|
4355
4298
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
4299
|
+
const animationEnabled = !!animation && !prefersReducedMotion;
|
|
4356
4300
|
const accessors = {
|
|
4357
|
-
xAccessor: (d) => _optionalChain([d, 'optionalAccess',
|
|
4358
|
-
yAccessor: (d) => _optionalChain([d, 'optionalAccess',
|
|
4301
|
+
xAccessor: (d) => _optionalChain([d, 'optionalAccess', _238 => _238.date]),
|
|
4302
|
+
yAccessor: (d) => _optionalChain([d, 'optionalAccess', _239 => _239.value])
|
|
4359
4303
|
};
|
|
4304
|
+
const zeroYAccessor = _react.useCallback.call(void 0, () => 0, []);
|
|
4305
|
+
const visibleLabels = _react.useMemo.call(void 0, () => new Set(seriesWithVisibility.filter((s) => s.isVisible).map((s) => s.series.label)), [seriesWithVisibility]);
|
|
4306
|
+
const filteredRenderTooltip = _react.useCallback.call(void 0, (params) => {
|
|
4307
|
+
if (!legendInteractive) return renderTooltip(params);
|
|
4308
|
+
const datumByKey = _optionalChain([params, 'optionalAccess', _240 => _240.tooltipData, 'optionalAccess', _241 => _241.datumByKey]);
|
|
4309
|
+
if (!datumByKey) return renderTooltip(params);
|
|
4310
|
+
const filtered = Object.fromEntries(Object.entries(datumByKey).filter(([key]) => visibleLabels.has(key)));
|
|
4311
|
+
if (Object.keys(filtered).length === 0) return null;
|
|
4312
|
+
const nearestDatum = _optionalChain([params, 'optionalAccess', _242 => _242.tooltipData, 'optionalAccess', _243 => _243.nearestDatum]);
|
|
4313
|
+
const nextNearest = nearestDatum && visibleLabels.has(nearestDatum.key) ? nearestDatum : {
|
|
4314
|
+
...Object.values(filtered)[0],
|
|
4315
|
+
distance: _nullishCoalesce(_optionalChain([nearestDatum, 'optionalAccess', _244 => _244.distance]), () => ( 0))
|
|
4316
|
+
};
|
|
4317
|
+
return renderTooltip({
|
|
4318
|
+
...params,
|
|
4319
|
+
tooltipData: {
|
|
4320
|
+
...params.tooltipData,
|
|
4321
|
+
datumByKey: filtered,
|
|
4322
|
+
nearestDatum: nextNearest
|
|
4323
|
+
}
|
|
4324
|
+
});
|
|
4325
|
+
}, [renderTooltip, legendInteractive, visibleLabels]);
|
|
4360
4326
|
const resolvedFillOpacity = _nullishCoalesce(fillOpacity, () => ( (stacked ? 0.85 : 0.4)));
|
|
4361
4327
|
const resolvedWithStroke = _nullishCoalesce(withStroke, () => ( !stacked));
|
|
4362
4328
|
if (error) {
|
|
@@ -4382,6 +4348,35 @@ var AreaChartInternal = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
|
|
|
4382
4348
|
isVisible
|
|
4383
4349
|
}) => isVisible);
|
|
4384
4350
|
const curve = getCurveType(curveType, smoothing);
|
|
4351
|
+
const renderSeries = ({
|
|
4352
|
+
series: seriesData,
|
|
4353
|
+
index,
|
|
4354
|
+
isVisible
|
|
4355
|
+
}) => {
|
|
4356
|
+
const {
|
|
4357
|
+
color,
|
|
4358
|
+
lineStyles
|
|
4359
|
+
} = getElementStyles({
|
|
4360
|
+
data: seriesData,
|
|
4361
|
+
index
|
|
4362
|
+
});
|
|
4363
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.AnimatedAreaSeries, {
|
|
4364
|
+
dataKey: _optionalChain([seriesData, 'optionalAccess', _245 => _245.label]),
|
|
4365
|
+
data: seriesData.data,
|
|
4366
|
+
xAccessor: accessors.xAccessor,
|
|
4367
|
+
yAccessor: isVisible || !legendInteractive ? accessors.yAccessor : zeroYAccessor,
|
|
4368
|
+
fill: color,
|
|
4369
|
+
fillOpacity: resolvedFillOpacity,
|
|
4370
|
+
...stacked ? {} : {
|
|
4371
|
+
renderLine: resolvedWithStroke,
|
|
4372
|
+
curve
|
|
4373
|
+
},
|
|
4374
|
+
lineProps: {
|
|
4375
|
+
stroke: color,
|
|
4376
|
+
...lineStyles
|
|
4377
|
+
}
|
|
4378
|
+
}, _optionalChain([seriesData, 'optionalAccess', _246 => _246.label]) || index);
|
|
4379
|
+
};
|
|
4385
4380
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SingleChartContext.Provider, {
|
|
4386
4381
|
value: {
|
|
4387
4382
|
chartId,
|
|
@@ -4395,7 +4390,7 @@ var AreaChartInternal = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
|
|
|
4395
4390
|
legendChildren,
|
|
4396
4391
|
gap,
|
|
4397
4392
|
className: _clsx2.default.call(void 0, "area-chart", area_chart_module_default["area-chart"], {
|
|
4398
|
-
[area_chart_module_default["area-chart--animated"]]:
|
|
4393
|
+
[area_chart_module_default["area-chart--animated"]]: animationEnabled
|
|
4399
4394
|
}, className),
|
|
4400
4395
|
style: {
|
|
4401
4396
|
width,
|
|
@@ -4444,65 +4439,19 @@ var AreaChartInternal = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
|
|
|
4444
4439
|
width,
|
|
4445
4440
|
height: chartHeight,
|
|
4446
4441
|
children: _i18n.__.call(void 0, "All series are hidden. Click legend items to show data.", "jetpack-charts")
|
|
4447
|
-
}) : null, !allSeriesHidden && stacked && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.
|
|
4442
|
+
}) : null, !allSeriesHidden && stacked && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.AnimatedAreaStack, {
|
|
4448
4443
|
curve,
|
|
4449
4444
|
offset: stackOffset,
|
|
4450
4445
|
renderLine: resolvedWithStroke,
|
|
4451
|
-
children:
|
|
4452
|
-
|
|
4453
|
-
index
|
|
4454
|
-
}) => {
|
|
4455
|
-
const {
|
|
4456
|
-
color,
|
|
4457
|
-
lineStyles
|
|
4458
|
-
} = getElementStyles({
|
|
4459
|
-
data: seriesData,
|
|
4460
|
-
index
|
|
4461
|
-
});
|
|
4462
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.AreaSeries, {
|
|
4463
|
-
dataKey: _optionalChain([seriesData, 'optionalAccess', _236 => _236.label]),
|
|
4464
|
-
data: seriesData.data,
|
|
4465
|
-
...accessors,
|
|
4466
|
-
fill: color,
|
|
4467
|
-
fillOpacity: resolvedFillOpacity,
|
|
4468
|
-
lineProps: {
|
|
4469
|
-
stroke: color,
|
|
4470
|
-
...lineStyles
|
|
4471
|
-
}
|
|
4472
|
-
}, _optionalChain([seriesData, 'optionalAccess', _237 => _237.label]) || index);
|
|
4473
|
-
})
|
|
4474
|
-
}), !allSeriesHidden && !stacked && visibleSeries.map(({
|
|
4475
|
-
series: seriesData,
|
|
4476
|
-
index
|
|
4477
|
-
}) => {
|
|
4478
|
-
const {
|
|
4479
|
-
color,
|
|
4480
|
-
lineStyles
|
|
4481
|
-
} = getElementStyles({
|
|
4482
|
-
data: seriesData,
|
|
4483
|
-
index
|
|
4484
|
-
});
|
|
4485
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.AreaSeries, {
|
|
4486
|
-
dataKey: _optionalChain([seriesData, 'optionalAccess', _238 => _238.label]),
|
|
4487
|
-
data: seriesData.data,
|
|
4488
|
-
...accessors,
|
|
4489
|
-
fill: color,
|
|
4490
|
-
fillOpacity: resolvedFillOpacity,
|
|
4491
|
-
renderLine: resolvedWithStroke,
|
|
4492
|
-
curve,
|
|
4493
|
-
lineProps: {
|
|
4494
|
-
stroke: color,
|
|
4495
|
-
...lineStyles
|
|
4496
|
-
}
|
|
4497
|
-
}, _optionalChain([seriesData, 'optionalAccess', _239 => _239.label]) || index);
|
|
4498
|
-
}), withTooltips && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, {
|
|
4446
|
+
children: seriesWithVisibility.map(renderSeries)
|
|
4447
|
+
}), !allSeriesHidden && !stacked && seriesWithVisibility.map(renderSeries), withTooltips && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, {
|
|
4499
4448
|
children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, AccessibleTooltip, {
|
|
4500
4449
|
detectBounds: true,
|
|
4501
4450
|
snapTooltipToDatumX: true,
|
|
4502
4451
|
snapTooltipToDatumY: !stacked,
|
|
4503
|
-
renderTooltip,
|
|
4504
|
-
showVerticalCrosshair: _optionalChain([withTooltipCrosshairs, 'optionalAccess',
|
|
4505
|
-
showHorizontalCrosshair: _optionalChain([withTooltipCrosshairs, 'optionalAccess',
|
|
4452
|
+
renderTooltip: filteredRenderTooltip,
|
|
4453
|
+
showVerticalCrosshair: _optionalChain([withTooltipCrosshairs, 'optionalAccess', _247 => _247.showVertical]),
|
|
4454
|
+
showHorizontalCrosshair: _optionalChain([withTooltipCrosshairs, 'optionalAccess', _248 => _248.showHorizontal]),
|
|
4506
4455
|
selectedIndex,
|
|
4507
4456
|
tooltipRef,
|
|
4508
4457
|
keyboardFocusedClassName: area_chart_module_default["area-chart__tooltip--keyboard-focused"],
|
|
@@ -4693,12 +4642,12 @@ function useBarChartOptions(data, horizontal, options = {}) {
|
|
|
4693
4642
|
nice: true,
|
|
4694
4643
|
zero: false
|
|
4695
4644
|
};
|
|
4696
|
-
const labelFormatter = _optionalChain([data, 'optionalAccess',
|
|
4645
|
+
const labelFormatter = _optionalChain([data, 'optionalAccess', _249 => _249[0], 'optionalAccess', _250 => _250.data, 'optionalAccess', _251 => _251[0], 'optionalAccess', _252 => _252.label]) ? (label) => label : formatDateTick2;
|
|
4697
4646
|
const valueFormatter = _numberformatters.formatNumberCompact;
|
|
4698
|
-
const labelAccessor = (d) => _optionalChain([d, 'optionalAccess',
|
|
4647
|
+
const labelAccessor = (d) => _optionalChain([d, 'optionalAccess', _253 => _253.label]) || _optionalChain([d, 'optionalAccess', _254 => _254.date]);
|
|
4699
4648
|
const valueAccessor = (d) => {
|
|
4700
4649
|
const enhancedPoint = d;
|
|
4701
|
-
return _optionalChain([enhancedPoint, 'optionalAccess',
|
|
4650
|
+
return _optionalChain([enhancedPoint, 'optionalAccess', _255 => _255.visualValue]) !== void 0 ? enhancedPoint.visualValue : _optionalChain([d, 'optionalAccess', _256 => _256.value]);
|
|
4702
4651
|
};
|
|
4703
4652
|
return {
|
|
4704
4653
|
vertical: {
|
|
@@ -4737,9 +4686,9 @@ function useBarChartOptions(data, horizontal, options = {}) {
|
|
|
4737
4686
|
} = defaultOptions[orientationKey];
|
|
4738
4687
|
const xScale = { ...baseXScale, ...options.xScale || {} };
|
|
4739
4688
|
const yScale = { ...baseYScale, ...options.yScale || {} };
|
|
4740
|
-
const providedToolTipLabelFormatter = horizontal ? _optionalChain([options, 'access',
|
|
4741
|
-
const { labelOverflow: xLabelOverflow, ...xAxisOptions } = _optionalChain([options, 'access',
|
|
4742
|
-
const { labelOverflow: yLabelOverflow, ...yAxisOptions } = _optionalChain([options, 'access',
|
|
4689
|
+
const providedToolTipLabelFormatter = horizontal ? _optionalChain([options, 'access', _257 => _257.axis, 'optionalAccess', _258 => _258.y, 'optionalAccess', _259 => _259.tickFormat]) : _optionalChain([options, 'access', _260 => _260.axis, 'optionalAccess', _261 => _261.x, 'optionalAccess', _262 => _262.tickFormat]);
|
|
4690
|
+
const { labelOverflow: xLabelOverflow, ...xAxisOptions } = _optionalChain([options, 'access', _263 => _263.axis, 'optionalAccess', _264 => _264.x]) || {};
|
|
4691
|
+
const { labelOverflow: yLabelOverflow, ...yAxisOptions } = _optionalChain([options, 'access', _265 => _265.axis, 'optionalAccess', _266 => _266.y]) || {};
|
|
4743
4692
|
return {
|
|
4744
4693
|
gridVisibility,
|
|
4745
4694
|
xScale,
|
|
@@ -4777,7 +4726,7 @@ function useBarChartOptions(data, horizontal, options = {}) {
|
|
|
4777
4726
|
// src/charts/bar-chart/bar-chart.tsx
|
|
4778
4727
|
|
|
4779
4728
|
var validateData3 = (data) => {
|
|
4780
|
-
if (!_optionalChain([data, 'optionalAccess',
|
|
4729
|
+
if (!_optionalChain([data, 'optionalAccess', _267 => _267.length])) return "No data available";
|
|
4781
4730
|
const hasInvalidData = data.some((series) => series.data.some((point) => isNaN(point.value) || point.value === null || point.value === void 0 || !point.label && (!("date" in point && point.date) || isNaN(point.date.getTime()))));
|
|
4782
4731
|
if (hasInvalidData) return "Invalid data";
|
|
4783
4732
|
return null;
|
|
@@ -4827,7 +4776,7 @@ var BarChartInternal = ({
|
|
|
4827
4776
|
}, [height]);
|
|
4828
4777
|
const [selectedIndex, setSelectedIndex] = _react.useState.call(void 0, void 0);
|
|
4829
4778
|
const [isNavigating, setIsNavigating] = _react.useState.call(void 0, false);
|
|
4830
|
-
const totalPoints = Math.max(0, ...data.map((series) => _optionalChain([series, 'access',
|
|
4779
|
+
const totalPoints = Math.max(0, ...data.map((series) => _optionalChain([series, 'access', _268 => _268.data, 'optionalAccess', _269 => _269.length]) || 0)) * data.length;
|
|
4831
4780
|
const {
|
|
4832
4781
|
tooltipRef,
|
|
4833
4782
|
onChartFocus,
|
|
@@ -4871,13 +4820,13 @@ var BarChartInternal = ({
|
|
|
4871
4820
|
const renderDefaultTooltip2 = _react.useCallback.call(void 0, ({
|
|
4872
4821
|
tooltipData
|
|
4873
4822
|
}) => {
|
|
4874
|
-
const nearestDatum = _optionalChain([tooltipData, 'optionalAccess',
|
|
4823
|
+
const nearestDatum = _optionalChain([tooltipData, 'optionalAccess', _270 => _270.nearestDatum, 'optionalAccess', _271 => _271.datum]);
|
|
4875
4824
|
if (!nearestDatum) return null;
|
|
4876
4825
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", {
|
|
4877
4826
|
className: bar_chart_module_default["bar-chart__tooltip"],
|
|
4878
4827
|
children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
4879
4828
|
className: bar_chart_module_default["bar-chart__tooltip-header"],
|
|
4880
|
-
children: _optionalChain([tooltipData, 'optionalAccess',
|
|
4829
|
+
children: _optionalChain([tooltipData, 'optionalAccess', _272 => _272.nearestDatum, 'optionalAccess', _273 => _273.key])
|
|
4881
4830
|
}), /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", {
|
|
4882
4831
|
className: bar_chart_module_default["bar-chart__tooltip-row"],
|
|
4883
4832
|
children: [/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", {
|
|
@@ -5076,12 +5025,12 @@ var BarChartInternal = ({
|
|
|
5076
5025
|
return null;
|
|
5077
5026
|
}
|
|
5078
5027
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.BarSeries, {
|
|
5079
|
-
dataKey: _optionalChain([seriesData, 'optionalAccess',
|
|
5028
|
+
dataKey: _optionalChain([seriesData, 'optionalAccess', _274 => _274.label]),
|
|
5080
5029
|
data: seriesData.data,
|
|
5081
5030
|
yAccessor: chartOptions.accessors.yAccessor,
|
|
5082
5031
|
xAccessor: chartOptions.accessors.xAccessor,
|
|
5083
5032
|
colorAccessor: getBarBackground(index)
|
|
5084
|
-
}, _optionalChain([seriesData, 'optionalAccess',
|
|
5033
|
+
}, _optionalChain([seriesData, 'optionalAccess', _275 => _275.label]));
|
|
5085
5034
|
})
|
|
5086
5035
|
}), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.Axis, {
|
|
5087
5036
|
...chartOptions.axis.x
|
|
@@ -5135,7 +5084,7 @@ var BarChartResponsive = attachSubComponents(withResponsive(BarChartWithProvider
|
|
|
5135
5084
|
|
|
5136
5085
|
var getScaleBandwidth2 = (scale) => {
|
|
5137
5086
|
const s = scale;
|
|
5138
|
-
return s && "bandwidth" in s ? _nullishCoalesce(_optionalChain([s, 'optionalAccess',
|
|
5087
|
+
return s && "bandwidth" in s ? _nullishCoalesce(_optionalChain([s, 'optionalAccess', _276 => _276.bandwidth, 'call', _277 => _277()]), () => ( 0)) : 0;
|
|
5139
5088
|
};
|
|
5140
5089
|
var DefaultLabelComponent = ({
|
|
5141
5090
|
textProps,
|
|
@@ -5196,7 +5145,7 @@ var AxisRenderer = ({
|
|
|
5196
5145
|
delete textProps.dx;
|
|
5197
5146
|
const sum = data.reduce((acc, {
|
|
5198
5147
|
data: seriesData
|
|
5199
|
-
}) => acc + (_nullishCoalesce(_optionalChain([seriesData, 'access',
|
|
5148
|
+
}) => acc + (_nullishCoalesce(_optionalChain([seriesData, 'access', _278 => _278[index], 'optionalAccess', _279 => _279.value]), () => ( 0))), 0);
|
|
5200
5149
|
const y = from2.y + yOffset;
|
|
5201
5150
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _group.Group, {
|
|
5202
5151
|
children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, LabelComponent, {
|
|
@@ -5364,7 +5313,7 @@ var useFunnelSelection = (hideTooltip) => {
|
|
|
5364
5313
|
(stepId) => {
|
|
5365
5314
|
if (clickedStep === stepId) {
|
|
5366
5315
|
setClickedStep(null);
|
|
5367
|
-
_optionalChain([hideTooltip, 'optionalCall',
|
|
5316
|
+
_optionalChain([hideTooltip, 'optionalCall', _280 => _280()]);
|
|
5368
5317
|
} else {
|
|
5369
5318
|
setClickedStep(stepId);
|
|
5370
5319
|
}
|
|
@@ -5377,21 +5326,21 @@ var useFunnelSelection = (hideTooltip) => {
|
|
|
5377
5326
|
event.preventDefault();
|
|
5378
5327
|
if (clickedStep === stepId) {
|
|
5379
5328
|
setClickedStep(null);
|
|
5380
|
-
_optionalChain([hideTooltip, 'optionalCall',
|
|
5329
|
+
_optionalChain([hideTooltip, 'optionalCall', _281 => _281()]);
|
|
5381
5330
|
} else {
|
|
5382
5331
|
setClickedStep(stepId);
|
|
5383
5332
|
}
|
|
5384
5333
|
} else if (event.key === "Escape") {
|
|
5385
5334
|
event.preventDefault();
|
|
5386
5335
|
setClickedStep(null);
|
|
5387
|
-
_optionalChain([hideTooltip, 'optionalCall',
|
|
5336
|
+
_optionalChain([hideTooltip, 'optionalCall', _282 => _282()]);
|
|
5388
5337
|
}
|
|
5389
5338
|
},
|
|
5390
5339
|
[clickedStep, hideTooltip]
|
|
5391
5340
|
);
|
|
5392
5341
|
const clearSelection = _react.useCallback.call(void 0, () => {
|
|
5393
5342
|
setClickedStep(null);
|
|
5394
|
-
_optionalChain([hideTooltip, 'optionalCall',
|
|
5343
|
+
_optionalChain([hideTooltip, 'optionalCall', _283 => _283()]);
|
|
5395
5344
|
}, [hideTooltip]);
|
|
5396
5345
|
const getStepState = _react.useCallback.call(void 0,
|
|
5397
5346
|
(stepId) => ({
|
|
@@ -5553,7 +5502,7 @@ var ConversionFunnelChartInternal = ({
|
|
|
5553
5502
|
document.removeEventListener("mousedown", handleDocumentClick);
|
|
5554
5503
|
};
|
|
5555
5504
|
}, [clearSelectionAndRef]);
|
|
5556
|
-
const resolvedHeight = _nullishCoalesce(_nullishCoalesce(height, () => ( _optionalChain([style, 'optionalAccess',
|
|
5505
|
+
const resolvedHeight = _nullishCoalesce(_nullishCoalesce(height, () => ( _optionalChain([style, 'optionalAccess', _284 => _284.height]))), () => ( "100%"));
|
|
5557
5506
|
const {
|
|
5558
5507
|
primaryColor,
|
|
5559
5508
|
backgroundColor,
|
|
@@ -5568,7 +5517,7 @@ var ConversionFunnelChartInternal = ({
|
|
|
5568
5517
|
}) : {
|
|
5569
5518
|
color: primaryColor || "#000000"
|
|
5570
5519
|
};
|
|
5571
|
-
const isPositiveChange = _optionalChain([changeIndicator, 'optionalAccess',
|
|
5520
|
+
const isPositiveChange = _optionalChain([changeIndicator, 'optionalAccess', _285 => _285.startsWith, 'call', _286 => _286("+")]);
|
|
5572
5521
|
const changeColor = isPositiveChange ? positiveChangeColor : negativeChangeColor;
|
|
5573
5522
|
const barBackgroundColor = backgroundColor || hexToRgba(barColor, 0.08) || "rgba(0, 0, 0, 0.08)";
|
|
5574
5523
|
const renderDefaultMainMetric = () => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, {
|
|
@@ -5599,8 +5548,8 @@ var ConversionFunnelChartInternal = ({
|
|
|
5599
5548
|
const chartMetadata = _react.useMemo.call(void 0, () => ({
|
|
5600
5549
|
mainRate,
|
|
5601
5550
|
changeIndicator,
|
|
5602
|
-
stepsCount: _optionalChain([steps, 'optionalAccess',
|
|
5603
|
-
}), [mainRate, changeIndicator, _optionalChain([steps, 'optionalAccess',
|
|
5551
|
+
stepsCount: _optionalChain([steps, 'optionalAccess', _287 => _287.length]) || 0
|
|
5552
|
+
}), [mainRate, changeIndicator, _optionalChain([steps, 'optionalAccess', _288 => _288.length])]);
|
|
5604
5553
|
useChartRegistration({
|
|
5605
5554
|
chartId,
|
|
5606
5555
|
legendItems: [],
|
|
@@ -5686,8 +5635,8 @@ var ConversionFunnelChartInternal = ({
|
|
|
5686
5635
|
direction: "column",
|
|
5687
5636
|
justify: "flex-end",
|
|
5688
5637
|
className: conversion_funnel_chart_module_default["bar-container"],
|
|
5689
|
-
onClick: _optionalChain([stepHandlers, 'access',
|
|
5690
|
-
onKeyDown: _optionalChain([stepHandlers, 'access',
|
|
5638
|
+
onClick: _optionalChain([stepHandlers, 'access', _289 => _289.get, 'call', _290 => _290(step.id), 'optionalAccess', _291 => _291.onClick]),
|
|
5639
|
+
onKeyDown: _optionalChain([stepHandlers, 'access', _292 => _292.get, 'call', _293 => _293(step.id), 'optionalAccess', _294 => _294.onKeyDown]),
|
|
5691
5640
|
role: "button",
|
|
5692
5641
|
tabIndex: isBlurred ? -1 : 0,
|
|
5693
5642
|
"aria-label": step.label,
|
|
@@ -7697,7 +7646,7 @@ function contextConnect(Component2, namespace) {
|
|
|
7697
7646
|
});
|
|
7698
7647
|
}
|
|
7699
7648
|
function _contextConnect(Component2, namespace, options) {
|
|
7700
|
-
const WrappedComponent = _optionalChain([options, 'optionalAccess',
|
|
7649
|
+
const WrappedComponent = _optionalChain([options, 'optionalAccess', _295 => _295.forwardsRef]) ? _react.forwardRef.call(void 0, Component2) : Component2;
|
|
7701
7650
|
if (typeof namespace === "undefined") {
|
|
7702
7651
|
globalThis.SCRIPT_DEBUG === true ? warning("contextConnect: Please provide a namespace") : void 0;
|
|
7703
7652
|
}
|
|
@@ -7733,7 +7682,7 @@ function useContextSystem(props, namespace) {
|
|
|
7733
7682
|
if (typeof namespace === "undefined") {
|
|
7734
7683
|
globalThis.SCRIPT_DEBUG === true ? warning("useContextSystem: Please provide a namespace") : void 0;
|
|
7735
7684
|
}
|
|
7736
|
-
const contextProps = _optionalChain([contextSystemProps, 'optionalAccess',
|
|
7685
|
+
const contextProps = _optionalChain([contextSystemProps, 'optionalAccess', _296 => _296[namespace]]) || {};
|
|
7737
7686
|
const finalComponentProps = {
|
|
7738
7687
|
...getConnectedNamespace(),
|
|
7739
7688
|
...getNamespace(namespace)
|
|
@@ -8114,7 +8063,7 @@ function useLeaderboardLegendItems({
|
|
|
8114
8063
|
overrideColor: primaryColor || leaderboardChartSettings.primaryColor
|
|
8115
8064
|
});
|
|
8116
8065
|
items.push({
|
|
8117
|
-
label: _optionalChain([legendLabels, 'optionalAccess',
|
|
8066
|
+
label: _optionalChain([legendLabels, 'optionalAccess', _297 => _297.primary]) || _i18n.__.call(void 0, "Current period", "jetpack-charts"),
|
|
8118
8067
|
color: resolvedPrimaryColor
|
|
8119
8068
|
});
|
|
8120
8069
|
if (withComparison && !withOverlayLabel) {
|
|
@@ -8123,7 +8072,7 @@ function useLeaderboardLegendItems({
|
|
|
8123
8072
|
overrideColor: secondaryColor || leaderboardChartSettings.secondaryColor
|
|
8124
8073
|
});
|
|
8125
8074
|
items.push({
|
|
8126
|
-
label: _optionalChain([legendLabels, 'optionalAccess',
|
|
8075
|
+
label: _optionalChain([legendLabels, 'optionalAccess', _298 => _298.comparison]) || _i18n.__.call(void 0, "Previous period", "jetpack-charts"),
|
|
8127
8076
|
color: resolvedSecondaryColor
|
|
8128
8077
|
});
|
|
8129
8078
|
}
|
|
@@ -8782,11 +8731,11 @@ var PieChartInternal = ({
|
|
|
8782
8731
|
groupProps.onMouseLeave = onMouseLeave;
|
|
8783
8732
|
}
|
|
8784
8733
|
const svgLabelSmall = providerTheme.svgLabelSmall;
|
|
8785
|
-
const fontSize = _nullishCoalesce(resolveFontSize(_optionalChain([svgLabelSmall, 'optionalAccess',
|
|
8734
|
+
const fontSize = _nullishCoalesce(resolveFontSize(_optionalChain([svgLabelSmall, 'optionalAccess', _299 => _299.fontSize])), () => ( 12));
|
|
8786
8735
|
const estimatedTextWidth = _chunk7OZEQ5HEcjs.getStringWidth.call(void 0, arc.data.label, {
|
|
8787
8736
|
fontSize,
|
|
8788
|
-
fontFamily: _optionalChain([svgLabelSmall, 'optionalAccess',
|
|
8789
|
-
fontWeight: _optionalChain([svgLabelSmall, 'optionalAccess',
|
|
8737
|
+
fontFamily: _optionalChain([svgLabelSmall, 'optionalAccess', _300 => _300.fontFamily]),
|
|
8738
|
+
fontWeight: _optionalChain([svgLabelSmall, 'optionalAccess', _301 => _301.fontWeight])
|
|
8790
8739
|
});
|
|
8791
8740
|
const labelPadding = 6;
|
|
8792
8741
|
const backgroundWidth = estimatedTextWidth + labelPadding * 2;
|
|
@@ -9236,7 +9185,7 @@ var SparklineComponent = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
|
|
|
9236
9185
|
animation
|
|
9237
9186
|
}, ref) => {
|
|
9238
9187
|
const theme = useGlobalChartsTheme();
|
|
9239
|
-
const themeStrokeWidth = _nullishCoalesce(_optionalChain([theme, 'access',
|
|
9188
|
+
const themeStrokeWidth = _nullishCoalesce(_optionalChain([theme, 'access', _302 => _302.sparkline, 'optionalAccess', _303 => _303.strokeWidth]), () => ( 1.5));
|
|
9240
9189
|
const strokeWidth = _nullishCoalesce(strokeWidthProp, () => ( themeStrokeWidth));
|
|
9241
9190
|
const seriesData = _react.useMemo.call(void 0, () => {
|
|
9242
9191
|
if (!data || data.length === 0) {
|
|
@@ -9245,7 +9194,7 @@ var SparklineComponent = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
|
|
|
9245
9194
|
return transformToSeriesData(data, color, strokeWidth);
|
|
9246
9195
|
}, [data, color, strokeWidth]);
|
|
9247
9196
|
const finalMargin = _react.useMemo.call(void 0, () => {
|
|
9248
|
-
const themeMargin = _nullishCoalesce(_optionalChain([theme, 'access',
|
|
9197
|
+
const themeMargin = _nullishCoalesce(_optionalChain([theme, 'access', _304 => _304.sparkline, 'optionalAccess', _305 => _305.margin]), () => ( {
|
|
9249
9198
|
top: 2,
|
|
9250
9199
|
right: 2,
|
|
9251
9200
|
bottom: 2,
|
|
@@ -9256,7 +9205,7 @@ var SparklineComponent = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
|
|
|
9256
9205
|
...themeMargin,
|
|
9257
9206
|
...margin
|
|
9258
9207
|
};
|
|
9259
|
-
}, [marginProp, _optionalChain([theme, 'access',
|
|
9208
|
+
}, [marginProp, _optionalChain([theme, 'access', _306 => _306.sparkline, 'optionalAccess', _307 => _307.margin])]);
|
|
9260
9209
|
const seriesWithGradient = _react.useMemo.call(void 0, () => {
|
|
9261
9210
|
if (!gradient || seriesData.length === 0) {
|
|
9262
9211
|
return seriesData;
|