@automattic/charts 1.4.0 → 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 CHANGED
@@ -5,15 +5,18 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.4.1] - 2026-05-19
9
+ ### Changed
10
+ - Keep stacked area chart paths mounted on legend toggle so only the hidden series animates down and the y-axis stays fixed. [#48804]
11
+
8
12
  ## [1.4.0] - 2026-05-14
9
13
  ### Changed
10
- - Charts: expose a source-side `./style.css` alias so monorepo consumers can resolve the import without a prior build. [#48682]
11
- - Charts: expose tickValues on AxisOptions and nice on ScaleOptions so callers can force exact axis ticks. [#48722]
12
- - Update package dependencies. [#48695]
13
- - Update package dependencies. [#48696]
14
+ - Charts: Expose a source-side `./style.css` alias so monorepo consumers can resolve the import without a prior build. [#48682]
15
+ - Charts: Expose tickValues on AxisOptions and nice on ScaleOptions so callers can force exact axis ticks. [#48722]
16
+ - Update package dependencies. [#48695] [#48696]
14
17
 
15
18
  ### Removed
16
- - Charts: remove the `useTooltipPortalRelocator` hook and the `portalContainer` prop on `GlobalChartsProvider`. The relocator (added in #47118 / 0.56.4) caused tooltip glyphs and the tooltip box to drift away from the chart line by exactly the page scroll offset on scrolled pages. [#48617]
19
+ - Charts: Remove the `useTooltipPortalRelocator` hook and the `portalContainer` prop on `GlobalChartsProvider`. The relocator (added in #47118 / 0.56.4) caused tooltip glyphs and the tooltip box to drift away from the chart line by exactly the page scroll offset on scrolled pages. [#48617]
17
20
 
18
21
  ## [1.3.1] - 2026-05-11
19
22
  ### Changed
@@ -830,6 +833,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
830
833
  - Fixed lints following ESLint rule changes for TS [#40584]
831
834
  - Fixing a bug in Chart storybook data. [#40640]
832
835
 
836
+ [1.4.1]: https://github.com/Automattic/charts/compare/v1.4.0...v1.4.1
833
837
  [1.4.0]: https://github.com/Automattic/charts/compare/v1.3.1...v1.4.0
834
838
  [1.3.1]: https://github.com/Automattic/charts/compare/v1.3.0...v1.3.1
835
839
  [1.3.0]: https://github.com/Automattic/charts/compare/v1.2.1...v1.3.0
package/dist/index.cjs CHANGED
@@ -4203,8 +4203,44 @@ var AreaChartInternal = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
4203
4203
  chartRef,
4204
4204
  totalPoints: _optionalChain([dataSorted, 'access', _222 => _222[0], 'optionalAccess', _223 => _223.data, 'access', _224 => _224.length]) || 0
4205
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]);
4206
4242
  const chartOptions = _react.useMemo.call(void 0, () => {
4207
- const formatter = _optionalChain([options, 'optionalAccess', _225 => _225.axis, 'optionalAccess', _226 => _226.x, 'optionalAccess', _227 => _227.tickFormat]) || getFormatter(dataSorted);
4243
+ const formatter = _optionalChain([options, 'optionalAccess', _229 => _229.axis, 'optionalAccess', _230 => _230.x, 'optionalAccess', _231 => _231.tickFormat]) || getFormatter(dataSorted);
4208
4244
  return {
4209
4245
  axis: {
4210
4246
  x: {
@@ -4212,29 +4248,32 @@ var AreaChartInternal = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
4212
4248
  numTicks: guessOptimalNumTicks(dataSorted, width, formatter),
4213
4249
  tickFormat: formatter,
4214
4250
  display: true,
4215
- ..._optionalChain([options, 'optionalAccess', _228 => _228.axis, 'optionalAccess', _229 => _229.x])
4251
+ ..._optionalChain([options, 'optionalAccess', _232 => _232.axis, 'optionalAccess', _233 => _233.x])
4216
4252
  },
4217
4253
  y: {
4218
4254
  orientation: "left",
4219
4255
  numTicks: 4,
4220
4256
  tickFormat: _numberformatters.formatNumberCompact,
4221
4257
  display: true,
4222
- ..._optionalChain([options, 'optionalAccess', _230 => _230.axis, 'optionalAccess', _231 => _231.y])
4258
+ ..._optionalChain([options, 'optionalAccess', _234 => _234.axis, 'optionalAccess', _235 => _235.y])
4223
4259
  }
4224
4260
  },
4225
4261
  xScale: {
4226
4262
  type: "time",
4227
- ..._optionalChain([options, 'optionalAccess', _232 => _232.xScale])
4263
+ ..._optionalChain([options, 'optionalAccess', _236 => _236.xScale])
4228
4264
  },
4229
4265
  yScale: {
4230
4266
  type: "linear",
4231
4267
  nice: true,
4232
4268
  // Stacked areas should always include zero so the baseline is meaningful.
4233
4269
  zero: stacked,
4234
- ..._optionalChain([options, 'optionalAccess', _233 => _233.yScale])
4270
+ ...fixedYDomain ? {
4271
+ domain: fixedYDomain
4272
+ } : {},
4273
+ ..._optionalChain([options, 'optionalAccess', _237 => _237.yScale])
4235
4274
  }
4236
4275
  };
4237
- }, [options, dataSorted, width, stacked]);
4276
+ }, [options, dataSorted, width, stacked, fixedYDomain]);
4238
4277
  const defaultMargin = useChartMargin(height, chartOptions, dataSorted, theme);
4239
4278
  const error = validateData2(dataSorted);
4240
4279
  const isDataValid = !error;
@@ -4257,10 +4296,33 @@ var AreaChartInternal = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
4257
4296
  metadata: chartMetadata
4258
4297
  });
4259
4298
  const prefersReducedMotion = usePrefersReducedMotion();
4299
+ const animationEnabled = !!animation && !prefersReducedMotion;
4260
4300
  const accessors = {
4261
- xAccessor: (d) => _optionalChain([d, 'optionalAccess', _234 => _234.date]),
4262
- yAccessor: (d) => _optionalChain([d, 'optionalAccess', _235 => _235.value])
4301
+ xAccessor: (d) => _optionalChain([d, 'optionalAccess', _238 => _238.date]),
4302
+ yAccessor: (d) => _optionalChain([d, 'optionalAccess', _239 => _239.value])
4263
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]);
4264
4326
  const resolvedFillOpacity = _nullishCoalesce(fillOpacity, () => ( (stacked ? 0.85 : 0.4)));
4265
4327
  const resolvedWithStroke = _nullishCoalesce(withStroke, () => ( !stacked));
4266
4328
  if (error) {
@@ -4286,6 +4348,35 @@ var AreaChartInternal = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
4286
4348
  isVisible
4287
4349
  }) => isVisible);
4288
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
+ };
4289
4380
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SingleChartContext.Provider, {
4290
4381
  value: {
4291
4382
  chartId,
@@ -4299,7 +4390,7 @@ var AreaChartInternal = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
4299
4390
  legendChildren,
4300
4391
  gap,
4301
4392
  className: _clsx2.default.call(void 0, "area-chart", area_chart_module_default["area-chart"], {
4302
- [area_chart_module_default["area-chart--animated"]]: animation && !prefersReducedMotion
4393
+ [area_chart_module_default["area-chart--animated"]]: animationEnabled
4303
4394
  }, className),
4304
4395
  style: {
4305
4396
  width,
@@ -4348,65 +4439,19 @@ var AreaChartInternal = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
4348
4439
  width,
4349
4440
  height: chartHeight,
4350
4441
  children: _i18n.__.call(void 0, "All series are hidden. Click legend items to show data.", "jetpack-charts")
4351
- }) : null, !allSeriesHidden && stacked && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.AreaStack, {
4442
+ }) : null, !allSeriesHidden && stacked && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.AnimatedAreaStack, {
4352
4443
  curve,
4353
4444
  offset: stackOffset,
4354
4445
  renderLine: resolvedWithStroke,
4355
- children: visibleSeries.map(({
4356
- series: seriesData,
4357
- index
4358
- }) => {
4359
- const {
4360
- color,
4361
- lineStyles
4362
- } = getElementStyles({
4363
- data: seriesData,
4364
- index
4365
- });
4366
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.AreaSeries, {
4367
- dataKey: _optionalChain([seriesData, 'optionalAccess', _236 => _236.label]),
4368
- data: seriesData.data,
4369
- ...accessors,
4370
- fill: color,
4371
- fillOpacity: resolvedFillOpacity,
4372
- lineProps: {
4373
- stroke: color,
4374
- ...lineStyles
4375
- }
4376
- }, _optionalChain([seriesData, 'optionalAccess', _237 => _237.label]) || index);
4377
- })
4378
- }), !allSeriesHidden && !stacked && visibleSeries.map(({
4379
- series: seriesData,
4380
- index
4381
- }) => {
4382
- const {
4383
- color,
4384
- lineStyles
4385
- } = getElementStyles({
4386
- data: seriesData,
4387
- index
4388
- });
4389
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.AreaSeries, {
4390
- dataKey: _optionalChain([seriesData, 'optionalAccess', _238 => _238.label]),
4391
- data: seriesData.data,
4392
- ...accessors,
4393
- fill: color,
4394
- fillOpacity: resolvedFillOpacity,
4395
- renderLine: resolvedWithStroke,
4396
- curve,
4397
- lineProps: {
4398
- stroke: color,
4399
- ...lineStyles
4400
- }
4401
- }, _optionalChain([seriesData, 'optionalAccess', _239 => _239.label]) || index);
4402
- }), 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, {
4403
4448
  children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, AccessibleTooltip, {
4404
4449
  detectBounds: true,
4405
4450
  snapTooltipToDatumX: true,
4406
4451
  snapTooltipToDatumY: !stacked,
4407
- renderTooltip,
4408
- showVerticalCrosshair: _optionalChain([withTooltipCrosshairs, 'optionalAccess', _240 => _240.showVertical]),
4409
- showHorizontalCrosshair: _optionalChain([withTooltipCrosshairs, 'optionalAccess', _241 => _241.showHorizontal]),
4452
+ renderTooltip: filteredRenderTooltip,
4453
+ showVerticalCrosshair: _optionalChain([withTooltipCrosshairs, 'optionalAccess', _247 => _247.showVertical]),
4454
+ showHorizontalCrosshair: _optionalChain([withTooltipCrosshairs, 'optionalAccess', _248 => _248.showHorizontal]),
4410
4455
  selectedIndex,
4411
4456
  tooltipRef,
4412
4457
  keyboardFocusedClassName: area_chart_module_default["area-chart__tooltip--keyboard-focused"],
@@ -4597,12 +4642,12 @@ function useBarChartOptions(data, horizontal, options = {}) {
4597
4642
  nice: true,
4598
4643
  zero: false
4599
4644
  };
4600
- const labelFormatter = _optionalChain([data, 'optionalAccess', _242 => _242[0], 'optionalAccess', _243 => _243.data, 'optionalAccess', _244 => _244[0], 'optionalAccess', _245 => _245.label]) ? (label) => label : formatDateTick2;
4645
+ const labelFormatter = _optionalChain([data, 'optionalAccess', _249 => _249[0], 'optionalAccess', _250 => _250.data, 'optionalAccess', _251 => _251[0], 'optionalAccess', _252 => _252.label]) ? (label) => label : formatDateTick2;
4601
4646
  const valueFormatter = _numberformatters.formatNumberCompact;
4602
- const labelAccessor = (d) => _optionalChain([d, 'optionalAccess', _246 => _246.label]) || _optionalChain([d, 'optionalAccess', _247 => _247.date]);
4647
+ const labelAccessor = (d) => _optionalChain([d, 'optionalAccess', _253 => _253.label]) || _optionalChain([d, 'optionalAccess', _254 => _254.date]);
4603
4648
  const valueAccessor = (d) => {
4604
4649
  const enhancedPoint = d;
4605
- return _optionalChain([enhancedPoint, 'optionalAccess', _248 => _248.visualValue]) !== void 0 ? enhancedPoint.visualValue : _optionalChain([d, 'optionalAccess', _249 => _249.value]);
4650
+ return _optionalChain([enhancedPoint, 'optionalAccess', _255 => _255.visualValue]) !== void 0 ? enhancedPoint.visualValue : _optionalChain([d, 'optionalAccess', _256 => _256.value]);
4606
4651
  };
4607
4652
  return {
4608
4653
  vertical: {
@@ -4641,9 +4686,9 @@ function useBarChartOptions(data, horizontal, options = {}) {
4641
4686
  } = defaultOptions[orientationKey];
4642
4687
  const xScale = { ...baseXScale, ...options.xScale || {} };
4643
4688
  const yScale = { ...baseYScale, ...options.yScale || {} };
4644
- const providedToolTipLabelFormatter = horizontal ? _optionalChain([options, 'access', _250 => _250.axis, 'optionalAccess', _251 => _251.y, 'optionalAccess', _252 => _252.tickFormat]) : _optionalChain([options, 'access', _253 => _253.axis, 'optionalAccess', _254 => _254.x, 'optionalAccess', _255 => _255.tickFormat]);
4645
- const { labelOverflow: xLabelOverflow, ...xAxisOptions } = _optionalChain([options, 'access', _256 => _256.axis, 'optionalAccess', _257 => _257.x]) || {};
4646
- const { labelOverflow: yLabelOverflow, ...yAxisOptions } = _optionalChain([options, 'access', _258 => _258.axis, 'optionalAccess', _259 => _259.y]) || {};
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]) || {};
4647
4692
  return {
4648
4693
  gridVisibility,
4649
4694
  xScale,
@@ -4681,7 +4726,7 @@ function useBarChartOptions(data, horizontal, options = {}) {
4681
4726
  // src/charts/bar-chart/bar-chart.tsx
4682
4727
 
4683
4728
  var validateData3 = (data) => {
4684
- if (!_optionalChain([data, 'optionalAccess', _260 => _260.length])) return "No data available";
4729
+ if (!_optionalChain([data, 'optionalAccess', _267 => _267.length])) return "No data available";
4685
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()))));
4686
4731
  if (hasInvalidData) return "Invalid data";
4687
4732
  return null;
@@ -4731,7 +4776,7 @@ var BarChartInternal = ({
4731
4776
  }, [height]);
4732
4777
  const [selectedIndex, setSelectedIndex] = _react.useState.call(void 0, void 0);
4733
4778
  const [isNavigating, setIsNavigating] = _react.useState.call(void 0, false);
4734
- const totalPoints = Math.max(0, ...data.map((series) => _optionalChain([series, 'access', _261 => _261.data, 'optionalAccess', _262 => _262.length]) || 0)) * data.length;
4779
+ const totalPoints = Math.max(0, ...data.map((series) => _optionalChain([series, 'access', _268 => _268.data, 'optionalAccess', _269 => _269.length]) || 0)) * data.length;
4735
4780
  const {
4736
4781
  tooltipRef,
4737
4782
  onChartFocus,
@@ -4775,13 +4820,13 @@ var BarChartInternal = ({
4775
4820
  const renderDefaultTooltip2 = _react.useCallback.call(void 0, ({
4776
4821
  tooltipData
4777
4822
  }) => {
4778
- const nearestDatum = _optionalChain([tooltipData, 'optionalAccess', _263 => _263.nearestDatum, 'optionalAccess', _264 => _264.datum]);
4823
+ const nearestDatum = _optionalChain([tooltipData, 'optionalAccess', _270 => _270.nearestDatum, 'optionalAccess', _271 => _271.datum]);
4779
4824
  if (!nearestDatum) return null;
4780
4825
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", {
4781
4826
  className: bar_chart_module_default["bar-chart__tooltip"],
4782
4827
  children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
4783
4828
  className: bar_chart_module_default["bar-chart__tooltip-header"],
4784
- children: _optionalChain([tooltipData, 'optionalAccess', _265 => _265.nearestDatum, 'optionalAccess', _266 => _266.key])
4829
+ children: _optionalChain([tooltipData, 'optionalAccess', _272 => _272.nearestDatum, 'optionalAccess', _273 => _273.key])
4785
4830
  }), /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", {
4786
4831
  className: bar_chart_module_default["bar-chart__tooltip-row"],
4787
4832
  children: [/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", {
@@ -4980,12 +5025,12 @@ var BarChartInternal = ({
4980
5025
  return null;
4981
5026
  }
4982
5027
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.BarSeries, {
4983
- dataKey: _optionalChain([seriesData, 'optionalAccess', _267 => _267.label]),
5028
+ dataKey: _optionalChain([seriesData, 'optionalAccess', _274 => _274.label]),
4984
5029
  data: seriesData.data,
4985
5030
  yAccessor: chartOptions.accessors.yAccessor,
4986
5031
  xAccessor: chartOptions.accessors.xAccessor,
4987
5032
  colorAccessor: getBarBackground(index)
4988
- }, _optionalChain([seriesData, 'optionalAccess', _268 => _268.label]));
5033
+ }, _optionalChain([seriesData, 'optionalAccess', _275 => _275.label]));
4989
5034
  })
4990
5035
  }), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _xychart.Axis, {
4991
5036
  ...chartOptions.axis.x
@@ -5039,7 +5084,7 @@ var BarChartResponsive = attachSubComponents(withResponsive(BarChartWithProvider
5039
5084
 
5040
5085
  var getScaleBandwidth2 = (scale) => {
5041
5086
  const s = scale;
5042
- return s && "bandwidth" in s ? _nullishCoalesce(_optionalChain([s, 'optionalAccess', _269 => _269.bandwidth, 'call', _270 => _270()]), () => ( 0)) : 0;
5087
+ return s && "bandwidth" in s ? _nullishCoalesce(_optionalChain([s, 'optionalAccess', _276 => _276.bandwidth, 'call', _277 => _277()]), () => ( 0)) : 0;
5043
5088
  };
5044
5089
  var DefaultLabelComponent = ({
5045
5090
  textProps,
@@ -5100,7 +5145,7 @@ var AxisRenderer = ({
5100
5145
  delete textProps.dx;
5101
5146
  const sum = data.reduce((acc, {
5102
5147
  data: seriesData
5103
- }) => acc + (_nullishCoalesce(_optionalChain([seriesData, 'access', _271 => _271[index], 'optionalAccess', _272 => _272.value]), () => ( 0))), 0);
5148
+ }) => acc + (_nullishCoalesce(_optionalChain([seriesData, 'access', _278 => _278[index], 'optionalAccess', _279 => _279.value]), () => ( 0))), 0);
5104
5149
  const y = from2.y + yOffset;
5105
5150
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _group.Group, {
5106
5151
  children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, LabelComponent, {
@@ -5268,7 +5313,7 @@ var useFunnelSelection = (hideTooltip) => {
5268
5313
  (stepId) => {
5269
5314
  if (clickedStep === stepId) {
5270
5315
  setClickedStep(null);
5271
- _optionalChain([hideTooltip, 'optionalCall', _273 => _273()]);
5316
+ _optionalChain([hideTooltip, 'optionalCall', _280 => _280()]);
5272
5317
  } else {
5273
5318
  setClickedStep(stepId);
5274
5319
  }
@@ -5281,21 +5326,21 @@ var useFunnelSelection = (hideTooltip) => {
5281
5326
  event.preventDefault();
5282
5327
  if (clickedStep === stepId) {
5283
5328
  setClickedStep(null);
5284
- _optionalChain([hideTooltip, 'optionalCall', _274 => _274()]);
5329
+ _optionalChain([hideTooltip, 'optionalCall', _281 => _281()]);
5285
5330
  } else {
5286
5331
  setClickedStep(stepId);
5287
5332
  }
5288
5333
  } else if (event.key === "Escape") {
5289
5334
  event.preventDefault();
5290
5335
  setClickedStep(null);
5291
- _optionalChain([hideTooltip, 'optionalCall', _275 => _275()]);
5336
+ _optionalChain([hideTooltip, 'optionalCall', _282 => _282()]);
5292
5337
  }
5293
5338
  },
5294
5339
  [clickedStep, hideTooltip]
5295
5340
  );
5296
5341
  const clearSelection = _react.useCallback.call(void 0, () => {
5297
5342
  setClickedStep(null);
5298
- _optionalChain([hideTooltip, 'optionalCall', _276 => _276()]);
5343
+ _optionalChain([hideTooltip, 'optionalCall', _283 => _283()]);
5299
5344
  }, [hideTooltip]);
5300
5345
  const getStepState = _react.useCallback.call(void 0,
5301
5346
  (stepId) => ({
@@ -5457,7 +5502,7 @@ var ConversionFunnelChartInternal = ({
5457
5502
  document.removeEventListener("mousedown", handleDocumentClick);
5458
5503
  };
5459
5504
  }, [clearSelectionAndRef]);
5460
- const resolvedHeight = _nullishCoalesce(_nullishCoalesce(height, () => ( _optionalChain([style, 'optionalAccess', _277 => _277.height]))), () => ( "100%"));
5505
+ const resolvedHeight = _nullishCoalesce(_nullishCoalesce(height, () => ( _optionalChain([style, 'optionalAccess', _284 => _284.height]))), () => ( "100%"));
5461
5506
  const {
5462
5507
  primaryColor,
5463
5508
  backgroundColor,
@@ -5472,7 +5517,7 @@ var ConversionFunnelChartInternal = ({
5472
5517
  }) : {
5473
5518
  color: primaryColor || "#000000"
5474
5519
  };
5475
- const isPositiveChange = _optionalChain([changeIndicator, 'optionalAccess', _278 => _278.startsWith, 'call', _279 => _279("+")]);
5520
+ const isPositiveChange = _optionalChain([changeIndicator, 'optionalAccess', _285 => _285.startsWith, 'call', _286 => _286("+")]);
5476
5521
  const changeColor = isPositiveChange ? positiveChangeColor : negativeChangeColor;
5477
5522
  const barBackgroundColor = backgroundColor || hexToRgba(barColor, 0.08) || "rgba(0, 0, 0, 0.08)";
5478
5523
  const renderDefaultMainMetric = () => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, {
@@ -5503,8 +5548,8 @@ var ConversionFunnelChartInternal = ({
5503
5548
  const chartMetadata = _react.useMemo.call(void 0, () => ({
5504
5549
  mainRate,
5505
5550
  changeIndicator,
5506
- stepsCount: _optionalChain([steps, 'optionalAccess', _280 => _280.length]) || 0
5507
- }), [mainRate, changeIndicator, _optionalChain([steps, 'optionalAccess', _281 => _281.length])]);
5551
+ stepsCount: _optionalChain([steps, 'optionalAccess', _287 => _287.length]) || 0
5552
+ }), [mainRate, changeIndicator, _optionalChain([steps, 'optionalAccess', _288 => _288.length])]);
5508
5553
  useChartRegistration({
5509
5554
  chartId,
5510
5555
  legendItems: [],
@@ -5590,8 +5635,8 @@ var ConversionFunnelChartInternal = ({
5590
5635
  direction: "column",
5591
5636
  justify: "flex-end",
5592
5637
  className: conversion_funnel_chart_module_default["bar-container"],
5593
- onClick: _optionalChain([stepHandlers, 'access', _282 => _282.get, 'call', _283 => _283(step.id), 'optionalAccess', _284 => _284.onClick]),
5594
- onKeyDown: _optionalChain([stepHandlers, 'access', _285 => _285.get, 'call', _286 => _286(step.id), 'optionalAccess', _287 => _287.onKeyDown]),
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]),
5595
5640
  role: "button",
5596
5641
  tabIndex: isBlurred ? -1 : 0,
5597
5642
  "aria-label": step.label,
@@ -7601,7 +7646,7 @@ function contextConnect(Component2, namespace) {
7601
7646
  });
7602
7647
  }
7603
7648
  function _contextConnect(Component2, namespace, options) {
7604
- const WrappedComponent = _optionalChain([options, 'optionalAccess', _288 => _288.forwardsRef]) ? _react.forwardRef.call(void 0, Component2) : Component2;
7649
+ const WrappedComponent = _optionalChain([options, 'optionalAccess', _295 => _295.forwardsRef]) ? _react.forwardRef.call(void 0, Component2) : Component2;
7605
7650
  if (typeof namespace === "undefined") {
7606
7651
  globalThis.SCRIPT_DEBUG === true ? warning("contextConnect: Please provide a namespace") : void 0;
7607
7652
  }
@@ -7637,7 +7682,7 @@ function useContextSystem(props, namespace) {
7637
7682
  if (typeof namespace === "undefined") {
7638
7683
  globalThis.SCRIPT_DEBUG === true ? warning("useContextSystem: Please provide a namespace") : void 0;
7639
7684
  }
7640
- const contextProps = _optionalChain([contextSystemProps, 'optionalAccess', _289 => _289[namespace]]) || {};
7685
+ const contextProps = _optionalChain([contextSystemProps, 'optionalAccess', _296 => _296[namespace]]) || {};
7641
7686
  const finalComponentProps = {
7642
7687
  ...getConnectedNamespace(),
7643
7688
  ...getNamespace(namespace)
@@ -8018,7 +8063,7 @@ function useLeaderboardLegendItems({
8018
8063
  overrideColor: primaryColor || leaderboardChartSettings.primaryColor
8019
8064
  });
8020
8065
  items.push({
8021
- label: _optionalChain([legendLabels, 'optionalAccess', _290 => _290.primary]) || _i18n.__.call(void 0, "Current period", "jetpack-charts"),
8066
+ label: _optionalChain([legendLabels, 'optionalAccess', _297 => _297.primary]) || _i18n.__.call(void 0, "Current period", "jetpack-charts"),
8022
8067
  color: resolvedPrimaryColor
8023
8068
  });
8024
8069
  if (withComparison && !withOverlayLabel) {
@@ -8027,7 +8072,7 @@ function useLeaderboardLegendItems({
8027
8072
  overrideColor: secondaryColor || leaderboardChartSettings.secondaryColor
8028
8073
  });
8029
8074
  items.push({
8030
- label: _optionalChain([legendLabels, 'optionalAccess', _291 => _291.comparison]) || _i18n.__.call(void 0, "Previous period", "jetpack-charts"),
8075
+ label: _optionalChain([legendLabels, 'optionalAccess', _298 => _298.comparison]) || _i18n.__.call(void 0, "Previous period", "jetpack-charts"),
8031
8076
  color: resolvedSecondaryColor
8032
8077
  });
8033
8078
  }
@@ -8686,11 +8731,11 @@ var PieChartInternal = ({
8686
8731
  groupProps.onMouseLeave = onMouseLeave;
8687
8732
  }
8688
8733
  const svgLabelSmall = providerTheme.svgLabelSmall;
8689
- const fontSize = _nullishCoalesce(resolveFontSize(_optionalChain([svgLabelSmall, 'optionalAccess', _292 => _292.fontSize])), () => ( 12));
8734
+ const fontSize = _nullishCoalesce(resolveFontSize(_optionalChain([svgLabelSmall, 'optionalAccess', _299 => _299.fontSize])), () => ( 12));
8690
8735
  const estimatedTextWidth = _chunk7OZEQ5HEcjs.getStringWidth.call(void 0, arc.data.label, {
8691
8736
  fontSize,
8692
- fontFamily: _optionalChain([svgLabelSmall, 'optionalAccess', _293 => _293.fontFamily]),
8693
- fontWeight: _optionalChain([svgLabelSmall, 'optionalAccess', _294 => _294.fontWeight])
8737
+ fontFamily: _optionalChain([svgLabelSmall, 'optionalAccess', _300 => _300.fontFamily]),
8738
+ fontWeight: _optionalChain([svgLabelSmall, 'optionalAccess', _301 => _301.fontWeight])
8694
8739
  });
8695
8740
  const labelPadding = 6;
8696
8741
  const backgroundWidth = estimatedTextWidth + labelPadding * 2;
@@ -9140,7 +9185,7 @@ var SparklineComponent = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
9140
9185
  animation
9141
9186
  }, ref) => {
9142
9187
  const theme = useGlobalChartsTheme();
9143
- const themeStrokeWidth = _nullishCoalesce(_optionalChain([theme, 'access', _295 => _295.sparkline, 'optionalAccess', _296 => _296.strokeWidth]), () => ( 1.5));
9188
+ const themeStrokeWidth = _nullishCoalesce(_optionalChain([theme, 'access', _302 => _302.sparkline, 'optionalAccess', _303 => _303.strokeWidth]), () => ( 1.5));
9144
9189
  const strokeWidth = _nullishCoalesce(strokeWidthProp, () => ( themeStrokeWidth));
9145
9190
  const seriesData = _react.useMemo.call(void 0, () => {
9146
9191
  if (!data || data.length === 0) {
@@ -9149,7 +9194,7 @@ var SparklineComponent = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
9149
9194
  return transformToSeriesData(data, color, strokeWidth);
9150
9195
  }, [data, color, strokeWidth]);
9151
9196
  const finalMargin = _react.useMemo.call(void 0, () => {
9152
- const themeMargin = _nullishCoalesce(_optionalChain([theme, 'access', _297 => _297.sparkline, 'optionalAccess', _298 => _298.margin]), () => ( {
9197
+ const themeMargin = _nullishCoalesce(_optionalChain([theme, 'access', _304 => _304.sparkline, 'optionalAccess', _305 => _305.margin]), () => ( {
9153
9198
  top: 2,
9154
9199
  right: 2,
9155
9200
  bottom: 2,
@@ -9160,7 +9205,7 @@ var SparklineComponent = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
9160
9205
  ...themeMargin,
9161
9206
  ...margin
9162
9207
  };
9163
- }, [marginProp, _optionalChain([theme, 'access', _299 => _299.sparkline, 'optionalAccess', _300 => _300.margin])]);
9208
+ }, [marginProp, _optionalChain([theme, 'access', _306 => _306.sparkline, 'optionalAccess', _307 => _307.margin])]);
9164
9209
  const seriesWithGradient = _react.useMemo.call(void 0, () => {
9165
9210
  if (!gradient || seriesData.length === 0) {
9166
9211
  return seriesData;