@automattic/charts 0.56.5 → 0.56.7
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/AGENTS.md +135 -0
- package/CHANGELOG.md +17 -0
- package/README.md +2 -1
- package/dist/charts/bar-chart/index.cjs +6 -6
- package/dist/charts/bar-chart/index.css +1 -4
- package/dist/charts/bar-chart/index.css.map +1 -1
- package/dist/charts/bar-chart/index.d.cts +2 -8
- package/dist/charts/bar-chart/index.d.ts +2 -8
- package/dist/charts/bar-chart/index.js +5 -5
- package/dist/charts/bar-list-chart/index.cjs +7 -7
- package/dist/charts/bar-list-chart/index.css +1 -4
- package/dist/charts/bar-list-chart/index.css.map +1 -1
- package/dist/charts/bar-list-chart/index.d.cts +2 -2
- package/dist/charts/bar-list-chart/index.d.ts +2 -2
- package/dist/charts/bar-list-chart/index.js +6 -6
- package/dist/charts/conversion-funnel-chart/index.cjs +5 -5
- package/dist/charts/conversion-funnel-chart/index.css +1 -4
- package/dist/charts/conversion-funnel-chart/index.css.map +1 -1
- package/dist/charts/conversion-funnel-chart/index.d.cts +2 -1
- package/dist/charts/conversion-funnel-chart/index.d.ts +2 -1
- package/dist/charts/conversion-funnel-chart/index.js +4 -4
- package/dist/charts/geo-chart/index.cjs +4 -4
- package/dist/charts/geo-chart/index.css +1 -4
- package/dist/charts/geo-chart/index.css.map +1 -1
- package/dist/charts/geo-chart/index.d.cts +2 -1
- package/dist/charts/geo-chart/index.d.ts +2 -1
- package/dist/charts/geo-chart/index.js +3 -3
- package/dist/charts/leaderboard-chart/index.cjs +5 -5
- package/dist/charts/leaderboard-chart/index.css +1 -4
- package/dist/charts/leaderboard-chart/index.css.map +1 -1
- package/dist/charts/leaderboard-chart/index.d.cts +3 -2
- package/dist/charts/leaderboard-chart/index.d.ts +3 -2
- package/dist/charts/leaderboard-chart/index.js +4 -4
- package/dist/charts/line-chart/index.cjs +6 -6
- package/dist/charts/line-chart/index.css +1 -4
- package/dist/charts/line-chart/index.css.map +1 -1
- package/dist/charts/line-chart/index.d.cts +2 -8
- package/dist/charts/line-chart/index.d.ts +2 -8
- package/dist/charts/line-chart/index.js +5 -5
- package/dist/charts/pie-chart/index.cjs +6 -4
- package/dist/charts/pie-chart/index.cjs.map +1 -1
- package/dist/charts/pie-chart/index.css +13 -7
- package/dist/charts/pie-chart/index.css.map +1 -1
- package/dist/charts/pie-chart/index.d.cts +2 -1
- package/dist/charts/pie-chart/index.d.ts +2 -1
- package/dist/charts/pie-chart/index.js +5 -3
- package/dist/charts/pie-semi-circle-chart/index.cjs +6 -4
- package/dist/charts/pie-semi-circle-chart/index.cjs.map +1 -1
- package/dist/charts/pie-semi-circle-chart/index.css +12 -13
- package/dist/charts/pie-semi-circle-chart/index.css.map +1 -1
- package/dist/charts/pie-semi-circle-chart/index.d.cts +5 -2
- package/dist/charts/pie-semi-circle-chart/index.d.ts +5 -2
- package/dist/charts/pie-semi-circle-chart/index.js +5 -3
- package/dist/charts/sparkline/index.cjs +7 -7
- package/dist/charts/sparkline/index.css +1 -4
- package/dist/charts/sparkline/index.css.map +1 -1
- package/dist/charts/sparkline/index.js +6 -6
- package/dist/{chunk-NGHXTIUE.cjs → chunk-3EXJP67N.cjs} +7 -7
- package/dist/{chunk-NGHXTIUE.cjs.map → chunk-3EXJP67N.cjs.map} +1 -1
- package/dist/{chunk-FIFSYVN6.cjs → chunk-55ZCOYDF.cjs} +117 -132
- package/dist/chunk-55ZCOYDF.cjs.map +1 -0
- package/dist/{chunk-LT4YOIMM.js → chunk-7FDQGBY7.js} +145 -119
- package/dist/chunk-7FDQGBY7.js.map +1 -0
- package/dist/{chunk-7QDEU3KN.cjs → chunk-ASLARV7L.cjs} +6 -6
- package/dist/chunk-ASLARV7L.cjs.map +1 -0
- package/dist/chunk-BXFD7JIG.cjs +401 -0
- package/dist/chunk-BXFD7JIG.cjs.map +1 -0
- package/dist/{chunk-XCXAWMJQ.cjs → chunk-CAFJRZPZ.cjs} +12 -12
- package/dist/{chunk-XCXAWMJQ.cjs.map → chunk-CAFJRZPZ.cjs.map} +1 -1
- package/dist/{chunk-KHRPRH4V.js → chunk-E62LCBGD.js} +4 -4
- package/dist/{chunk-PCOI2GT5.js → chunk-GWBS65VC.js} +3 -3
- package/dist/{chunk-MEIVKY4K.js → chunk-IS5YYLTV.js} +18 -18
- package/dist/{chunk-MEIVKY4K.js.map → chunk-IS5YYLTV.js.map} +1 -1
- package/dist/{chunk-Q6G3BGCL.cjs → chunk-K6TGILHX.cjs} +8 -8
- package/dist/{chunk-Q6G3BGCL.cjs.map → chunk-K6TGILHX.cjs.map} +1 -1
- package/dist/{chunk-X6GX4QUJ.js → chunk-KHQPN77E.js} +3 -3
- package/dist/{chunk-SEKPIG5K.js → chunk-KNIMXN6Z.js} +2 -2
- package/dist/{chunk-SEKPIG5K.js.map → chunk-KNIMXN6Z.js.map} +1 -1
- package/dist/{chunk-AFWQR3SM.js → chunk-MDRCAGKZ.js} +4 -4
- package/dist/{chunk-TKPK4RFS.cjs → chunk-NQJE2CC7.cjs} +120 -98
- package/dist/chunk-NQJE2CC7.cjs.map +1 -0
- package/dist/{chunk-FY325WQ4.cjs → chunk-O2JIANHK.cjs} +25 -25
- package/dist/chunk-O2JIANHK.cjs.map +1 -0
- package/dist/{chunk-DLSUC7RN.js → chunk-OMS5QIJN.js} +6 -6
- package/dist/chunk-OMS5QIJN.js.map +1 -0
- package/dist/{chunk-TYIH5LMV.js → chunk-OP6PHB2U.js} +6 -6
- package/dist/chunk-OP6PHB2U.js.map +1 -0
- package/dist/{chunk-32ESS4MV.js → chunk-RFSHE3HL.js} +17 -7
- package/dist/chunk-RFSHE3HL.js.map +1 -0
- package/dist/{chunk-KXSLMOW5.js → chunk-SSFFCBCF.js} +6 -6
- package/dist/chunk-SSFFCBCF.js.map +1 -0
- package/dist/{chunk-I5467ZJ5.cjs → chunk-SUDERBUA.cjs} +2 -2
- package/dist/{chunk-I5467ZJ5.cjs.map → chunk-SUDERBUA.cjs.map} +1 -1
- package/dist/{chunk-SH32YSZO.cjs → chunk-UFRBUT2D.cjs} +19 -19
- package/dist/{chunk-SH32YSZO.cjs.map → chunk-UFRBUT2D.cjs.map} +1 -1
- package/dist/{chunk-7TQSPLIN.js → chunk-VPAEBI2F.js} +109 -87
- package/dist/chunk-VPAEBI2F.js.map +1 -0
- package/dist/{chunk-IHESL7H5.cjs → chunk-X7JL2NYJ.cjs} +24 -24
- package/dist/chunk-X7JL2NYJ.cjs.map +1 -0
- package/dist/{chunk-DBY6C4O2.js → chunk-XD2HV7M5.js} +77 -92
- package/dist/chunk-XD2HV7M5.js.map +1 -0
- package/dist/{chunk-LTPJPIDP.cjs → chunk-YAXY5L7I.cjs} +7 -7
- package/dist/{chunk-LTPJPIDP.cjs.map → chunk-YAXY5L7I.cjs.map} +1 -1
- package/dist/{chunk-EJJO2QNB.cjs → chunk-YDVHT7GS.cjs} +17 -7
- package/dist/chunk-YDVHT7GS.cjs.map +1 -0
- package/dist/components/legend/index.cjs +2 -2
- package/dist/components/legend/index.css +1 -4
- package/dist/components/legend/index.css.map +1 -1
- package/dist/components/legend/index.d.cts +2 -1
- package/dist/components/legend/index.d.ts +2 -1
- package/dist/components/legend/index.js +1 -1
- package/dist/components/tooltip/index.d.cts +2 -1
- package/dist/components/tooltip/index.d.ts +2 -1
- package/dist/hooks/index.cjs +2 -2
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.css +1 -4
- package/dist/hooks/index.css.map +1 -1
- package/dist/hooks/index.d.cts +10 -7
- package/dist/hooks/index.d.ts +10 -7
- package/dist/hooks/index.js +3 -3
- package/dist/index.cjs +14 -14
- package/dist/index.css +24 -16
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +13 -13
- package/dist/{leaderboard-chart-B5gWcqe7.d.ts → leaderboard-chart-BSgEw_Um.d.ts} +1 -1
- package/dist/{leaderboard-chart-C_6QDcqj.d.cts → leaderboard-chart-COtgamhe.d.cts} +1 -1
- package/dist/providers/index.cjs +2 -2
- package/dist/providers/index.css +1 -4
- package/dist/providers/index.css.map +1 -1
- package/dist/providers/index.d.cts +3 -2
- package/dist/providers/index.d.ts +3 -2
- package/dist/providers/index.js +1 -1
- package/dist/{themes-BDVaIfBz.d.cts → themes-CVR5rmIs.d.cts} +1 -1
- package/dist/{themes-mcS8QNkQ.d.ts → themes-DQzmaSze.d.ts} +1 -1
- package/dist/{types-BCFQlzTM.d.ts → types-CzdN7rUe.d.cts} +12 -3
- package/dist/{types-BCFQlzTM.d.cts → types-CzdN7rUe.d.ts} +12 -3
- package/dist/utils/index.d.cts +2 -1
- package/dist/utils/index.d.ts +2 -1
- package/package.json +9 -9
- package/src/charts/bar-chart/bar-chart.tsx +2 -9
- package/src/charts/bar-chart/test/bar-chart.test.tsx +3 -3
- package/src/charts/line-chart/line-chart.tsx +2 -2
- package/src/charts/line-chart/test/line-chart.test.tsx +3 -3
- package/src/charts/line-chart/types.ts +0 -7
- package/src/charts/pie-chart/pie-chart.module.scss +14 -3
- package/src/charts/pie-chart/pie-chart.tsx +172 -148
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.module.scss +17 -11
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.tsx +147 -119
- package/src/charts/pie-semi-circle-chart/test/pie-semi-circle-chart.test.tsx +46 -6
- package/src/charts/private/with-responsive/test/with-responsive.test.tsx +5 -5
- package/src/charts/private/with-responsive/with-responsive.tsx +8 -7
- package/src/hooks/index.ts +1 -1
- package/src/hooks/test/{use-element-height.test.tsx → use-element-size.test.tsx} +45 -36
- package/src/hooks/use-element-size.ts +43 -0
- package/src/hooks/use-tooltip-portal-relocator.module.scss +1 -4
- package/src/hooks/use-tooltip-portal-relocator.ts +11 -0
- package/src/types.ts +13 -3
- package/dist/chunk-32ESS4MV.js.map +0 -1
- package/dist/chunk-7QDEU3KN.cjs.map +0 -1
- package/dist/chunk-7TQSPLIN.js.map +0 -1
- package/dist/chunk-DBY6C4O2.js.map +0 -1
- package/dist/chunk-DLSUC7RN.js.map +0 -1
- package/dist/chunk-EJJO2QNB.cjs.map +0 -1
- package/dist/chunk-FIFSYVN6.cjs.map +0 -1
- package/dist/chunk-FY325WQ4.cjs.map +0 -1
- package/dist/chunk-IHESL7H5.cjs.map +0 -1
- package/dist/chunk-JL4ZKKZU.cjs +0 -375
- package/dist/chunk-JL4ZKKZU.cjs.map +0 -1
- package/dist/chunk-KXSLMOW5.js.map +0 -1
- package/dist/chunk-LT4YOIMM.js.map +0 -1
- package/dist/chunk-TKPK4RFS.cjs.map +0 -1
- package/dist/chunk-TYIH5LMV.js.map +0 -1
- package/src/hooks/use-element-height.ts +0 -37
- /package/dist/{chunk-KHRPRH4V.js.map → chunk-E62LCBGD.js.map} +0 -0
- /package/dist/{chunk-PCOI2GT5.js.map → chunk-GWBS65VC.js.map} +0 -0
- /package/dist/{chunk-X6GX4QUJ.js.map → chunk-KHQPN77E.js.map} +0 -0
- /package/dist/{chunk-AFWQR3SM.js.map → chunk-MDRCAGKZ.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/jetpack/jetpack/projects/js-packages/charts/dist/chunk-FY325WQ4.cjs","../src/charts/line-chart/line-chart.tsx","../src/charts/private/default-glyph/default-glyph.tsx","../src/charts/line-chart/line-chart.module.scss","../src/charts/line-chart/private/line-chart-annotation-label-popover.tsx","../src/charts/line-chart/private/line-chart-annotations-overlay.tsx","../src/charts/line-chart/private/line-chart-annotation.tsx","../src/charts/line-chart/private/line-chart-glyph.tsx"],"names":["_jsx","DataContext","useEffect","useState","useContext","x","y","yMin","yMax","xMin","xMax","_jsxs","useRef","useMemo","toNumber"],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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AAA;AACP,QAAA;AACO,MAAA;AACb,QAAA;AACA,QAAA;AACM,QAAA;AACE,QAAA;AACK,MAAA;AACb,QAAA;AACA,QAAA;AACM,QAAA;AACE,QAAA;AACgB,MAAA;AAClB,QAAA;AACR,QAAA;AACoB,QAAA;AACd,UAAA;AACG,UAAA;AACR,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACe,UAAA;AACf,YAAA;AACA,YAAA;AACD,UAAA;AACF,QAAA;AACeX,MAAAA;AACX,QAAA;AACkB,QAAA;AACrB,UAAA;AACA,UAAA;AACW,UAAA;AACR,UAAA;AACe,UAAA;AACF,UAAA;AACjB,QAAA;AACD,MAAA;AACH,IAAA;AACF,EAAA;AACH;AACO;ANuPuB;AACA;AO3frBC;AACAG;AACe;AACK,EAAA;AACP,EAAA;AACtB;AACwB;AACtB,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACI;AACE,EAAA;AACJ,IAAA;AACA,IAAA;AACwB,EAAA;AACF,EAAA;AACI,EAAA;AACD,EAAA;AACA,EAAA;AACA,EAAA;AACV,EAAA;AACQ,EAAA;AACN,EAAA;AACS,IAAA;AAC1B,IAAA;AACO,IAAA;AACP,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACD,EAAA;AACH;AACO;AP6fuB;AACA;AChhBR;AACD;AACM;AACL,EAAA;AACf,IAAA;AACQ,IAAA;AACZ,EAAA;AACH;AACwB;AACK,EAAA;AACP,EAAA;AACtB;AAS4B;AAEf,EAAA;AACU,IAAA;AACrB,EAAA;AAGc,EAAA;AACP,IAAA;AACI,MAAA;AACJ,IAAA;AACI,MAAA;AACJ,IAAA;AACI,MAAA;AACT,IAAA;AACS,MAAA;AACX,EAAA;AACF;AAC6B;AACrB,EAAA;AACJ,IAAA;AACE,EAAA;AACiB,EAAA;AACK,EAAA;AACJ,EAAA;AACpB,IAAA;AACM,EAAA;AACN,IAAA;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F,EAAA;AACF;AAI0C;AACjBP,EAAAA;AAGH,EAAA;AACCJ,IAAAA;AACf,MAAA;AACH,MAAA;AACD,IAAA;AACH,EAAA;AAGoBA,EAAAA;AACKA,IAAAA;AAClB,MAAA;AACH,MAAA;AACD,IAAA;AACF,EAAA;AACF;AACqB;AACJ;AAChB,EAAA;AACoB,EAAA;AACR,EAAA;AACb;AAC2B;AAC1B,EAAA;AACoB,EAAA;AACR,EAAA;AACb;AD4d6B;AACA;AACA;AACA;AACA","file":"/home/runner/work/jetpack/jetpack/projects/js-packages/charts/dist/chunk-FY325WQ4.cjs","sourcesContent":[null,"import { formatNumberCompact, formatNumber } from '@automattic/number-formatters';\nimport { curveCatmullRom, curveLinear, curveMonotoneX } from '@visx/curve';\nimport { LinearGradient } from '@visx/gradient';\nimport { scaleTime } from '@visx/scale';\nimport { XYChart, AreaSeries, Grid, Axis, DataContext } from '@visx/xychart';\nimport { __ } from '@wordpress/i18n';\nimport { Stack } from '@wordpress/ui';\nimport clsx from 'clsx';\nimport { differenceInHours, differenceInYears } from 'date-fns';\nimport { useMemo, useContext, forwardRef, useImperativeHandle, useState, useRef, createElement as _createElement } from 'react';\nimport { Legend, useChartLegendItems } from '../../components/legend';\nimport { AccessibleTooltip, useKeyboardNavigation } from '../../components/tooltip';\nimport { useXYChartTheme, useChartDataTransform, useChartMargin, useElementHeight, useHasLegendChild, usePrefersReducedMotion } from '../../hooks';\nimport { GlobalChartsProvider, GlobalChartsContext, useChartId, useChartRegistration, useGlobalChartsContext, useGlobalChartsTheme } from '../../providers';\nimport { attachSubComponents } from '../../utils';\nimport { DefaultGlyph } from '../private/default-glyph';\nimport { SingleChartContext } from '../private/single-chart-context';\nimport { withResponsive } from '../private/with-responsive';\nimport styles from './line-chart.module.scss';\nimport { LineChartAnnotation, LineChartAnnotationsOverlay, LineChartGlyph } from './private';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst X_TICK_WIDTH = 60;\nconst defaultRenderGlyph = props => {\n return /*#__PURE__*/_createElement(DefaultGlyph, {\n ...props,\n key: props.key\n });\n};\nconst toNumber = val => {\n const num = typeof val === 'number' ? val : parseFloat(val);\n return isNaN(num) ? undefined : num;\n};\n\n/**\n * Determines the curve type for the line chart based on the provided type and smoothing parameters\n *\n * @param {CurveType} type - The explicit curve type to use\n * @param {boolean} smoothing - Legacy smoothing parameter\n * @return The curve function to use for the line\n */\nconst getCurveType = (type, smoothing) => {\n // If no type specified, use legacy smoothing behavior\n if (!type) {\n return smoothing ? curveCatmullRom : curveLinear;\n }\n\n // Handle explicit curve types\n switch (type) {\n case 'smooth':\n return curveCatmullRom;\n case 'monotone':\n return curveMonotoneX;\n case 'linear':\n return curveLinear;\n default:\n return curveLinear;\n }\n};\nconst renderDefaultTooltip = params => {\n const {\n tooltipData\n } = params;\n const nearestDatum = tooltipData?.nearestDatum?.datum;\n if (!nearestDatum) return null;\n const tooltipPoints = Object.entries(tooltipData?.datumByKey || {}).map(([key, {\n datum\n }]) => ({\n key,\n value: datum.value\n })).sort((a, b) => b.value - a.value);\n return /*#__PURE__*/_jsxs(\"div\", {\n className: styles['line-chart__tooltip'],\n children: [/*#__PURE__*/_jsx(\"div\", {\n className: styles['line-chart__tooltip-date'],\n children: nearestDatum.date?.toLocaleDateString()\n }), tooltipPoints.map(point => /*#__PURE__*/_jsxs(\"div\", {\n className: styles['line-chart__tooltip-row'],\n children: [/*#__PURE__*/_jsxs(\"span\", {\n className: styles['line-chart__tooltip-label'],\n children: [point.key, \":\"]\n }), /*#__PURE__*/_jsx(\"span\", {\n className: styles['line-chart__tooltip-value'],\n children: formatNumber(point.value)\n })]\n }, point.key))]\n });\n};\nconst formatYearTick = timestamp => {\n const date = new Date(timestamp);\n return date.toLocaleDateString(undefined, {\n year: 'numeric'\n });\n};\nconst formatDateTick = timestamp => {\n const date = new Date(timestamp);\n return date.toLocaleDateString(undefined, {\n month: 'short',\n day: 'numeric'\n });\n};\nconst formatHourTick = timestamp => {\n const date = new Date(timestamp);\n return date.toLocaleTimeString(undefined, {\n hour: 'numeric',\n hour12: true\n });\n};\nconst getFormatter = sortedData => {\n const minX = Math.min(...sortedData.map(datom => datom.data.at(0)?.date));\n const maxX = Math.max(...sortedData.map(datom => datom.data.at(-1)?.date));\n const diffInHours = Math.abs(differenceInHours(maxX, minX));\n if (diffInHours <= 24) {\n return formatHourTick;\n }\n const diffInYears = Math.abs(differenceInYears(maxX, minX));\n if (diffInYears <= 1) {\n return formatDateTick;\n }\n return formatYearTick;\n};\nconst guessOptimalNumTicks = (data, chartWidth, tickFormatter) => {\n const minX = Math.min(...data.map(datom => datom.data.at(0)?.date));\n const maxX = Math.max(...data.map(datom => datom.data.at(-1)?.date));\n const xScale = scaleTime({\n domain: [minX, maxX]\n });\n\n // Calculate upper bound of tick numbers based on data points and chart width\n const upperBound = Math.min(data[0]?.data.length || 3,\n // A sane fallback to avoid NaN when no data is present\n Math.ceil(chartWidth / X_TICK_WIDTH));\n let secondBestGuess = 1; // a tick number that's no greater than upperBound\n\n for (let numTicks = upperBound; numTicks > 1; --numTicks) {\n const ticks = xScale.ticks(numTicks).map(d => tickFormatter(d.getTime()));\n\n // The .ticks() function doesn't properly respect the requested number of ticks, so we need to check the length\n if (ticks.length > upperBound) {\n continue;\n }\n secondBestGuess = Math.max(secondBestGuess, ticks.length);\n const uniqueTicks = Array.from(new Set(ticks));\n if (uniqueTicks.length === 1) {\n // All ticks are the same, so skip further processing\n return 1;\n }\n\n // Example: OCT 1 JAN 1 APR 1 JUL 1 OCT 1\n // Here, the two OCTs are not duplicates as they represent October of two different years.\n const hasConsecutiveDuplicate = ticks.some((tick, idx) => idx > 0 && tick === ticks[idx - 1]);\n if (hasConsecutiveDuplicate) {\n continue;\n }\n return ticks.length;\n }\n return secondBestGuess;\n};\nconst validateData = data => {\n if (!data?.length) return 'No data available';\n const hasInvalidData = data.some(series => series.data.some(point => isNaN(point.value) || point.value === null || point.value === undefined || 'date' in point && point.date && isNaN(point.date.getTime())));\n if (hasInvalidData) return 'Invalid data';\n return null;\n};\n\n// Inner component to access DataContext and provide scale data to ref\nconst LineChartScalesRef = ({\n chartRef,\n width,\n height,\n margin\n}) => {\n const context = useContext(DataContext);\n useImperativeHandle(chartRef, () => ({\n getScales: () => {\n if (!context?.xScale || !context?.yScale) {\n return null;\n }\n return {\n xScale: context.xScale,\n yScale: context.yScale\n };\n },\n getChartDimensions: () => ({\n width,\n height,\n margin: margin || {}\n })\n }), [context, width, height, margin]);\n return null; // This component only provides the ref interface\n};\nconst LineChartInternal = /*#__PURE__*/forwardRef(({\n data,\n chartId: providedChartId,\n width,\n height,\n className,\n margin,\n withTooltips = true,\n withTooltipCrosshairs,\n showLegend = false,\n legendOrientation = 'horizontal',\n legendAlignment = 'center',\n legendPosition = 'bottom',\n legendMaxWidth,\n legendTextOverflow = 'wrap',\n legendItemClassName,\n renderGlyph = defaultRenderGlyph,\n glyphStyle = {},\n legendShape = 'line',\n withLegendGlyph = false,\n withGradientFill = false,\n smoothing = true,\n curveType,\n renderTooltip = renderDefaultTooltip,\n withStartGlyphs = false,\n withEndGlyphs = false,\n legendInteractive = false,\n animation,\n options = {},\n onPointerDown = undefined,\n onPointerUp = undefined,\n onPointerMove = undefined,\n onPointerOut = undefined,\n children,\n gridVisibility,\n gap = 'md'\n}, ref) => {\n const providerTheme = useGlobalChartsTheme();\n const theme = useXYChartTheme(data);\n const chartId = useChartId(providedChartId);\n const [svgWrapperRef, svgWrapperHeight] = useElementHeight();\n const chartRef = useRef(null);\n const [selectedIndex, setSelectedIndex] = useState(undefined);\n const [isNavigating, setIsNavigating] = useState(false);\n const internalChartRef = useRef(null);\n\n // Check if children contain a Legend component (composition pattern)\n const hasLegendChild = useHasLegendChild(children);\n\n // Use the measured SVG wrapper height, falling back to the passed height if provided.\n // When there's a legend (via prop or composition), we must wait for measurement because\n // the legend takes space and the svg-wrapper height will be less than the total height.\n const chartHeight = svgWrapperHeight > 0 ? svgWrapperHeight : height;\n const hasLegend = showLegend || hasLegendChild;\n const isWaitingForMeasurement = hasLegend ? svgWrapperHeight === 0 : !chartHeight;\n\n // Forward the external ref to the internal ref\n useImperativeHandle(ref, () => ({\n getScales: () => internalChartRef.current?.getScales() || null,\n getChartDimensions: () => internalChartRef.current?.getChartDimensions() || {\n width: 0,\n height: 0,\n margin: {}\n }\n }), [internalChartRef]);\n const dataSorted = useChartDataTransform(data);\n const {\n getElementStyles,\n isSeriesVisible\n } = useGlobalChartsContext();\n\n // Add visibility information to series when using interactive legends\n const seriesWithVisibility = useMemo(() => {\n if (!chartId || !legendInteractive) {\n return dataSorted.map((series, index) => ({\n series,\n index,\n isVisible: true\n }));\n }\n return dataSorted.map((series, index) => ({\n series,\n index,\n isVisible: isSeriesVisible(chartId, series.label)\n }));\n }, [dataSorted, chartId, isSeriesVisible, legendInteractive]);\n\n // Check if all series are hidden\n const allSeriesHidden = useMemo(() => {\n return seriesWithVisibility.every(({\n isVisible\n }) => !isVisible);\n }, [seriesWithVisibility]);\n\n // Use the keyboard navigation hook\n const {\n tooltipRef,\n onChartFocus,\n onChartBlur,\n onChartKeyDown\n } = useKeyboardNavigation({\n selectedIndex,\n setSelectedIndex,\n isNavigating,\n setIsNavigating,\n chartRef,\n totalPoints: dataSorted[0]?.data.length || 0\n });\n const chartOptions = useMemo(() => {\n const formatter = options?.axis?.x?.tickFormat || getFormatter(dataSorted);\n return {\n axis: {\n x: {\n orientation: 'bottom',\n numTicks: guessOptimalNumTicks(dataSorted, width, formatter),\n tickFormat: formatter,\n display: true,\n ...options?.axis?.x\n },\n y: {\n orientation: 'left',\n numTicks: 4,\n tickFormat: formatNumberCompact,\n display: true,\n ...options?.axis?.y\n }\n },\n xScale: {\n type: 'time',\n ...options?.xScale\n },\n yScale: {\n type: 'linear',\n nice: true,\n zero: false,\n ...options?.yScale\n }\n };\n }, [options, dataSorted, width]);\n const tooltipRenderGlyph = useMemo(() => {\n return props => {\n const seriesIndex = dataSorted.findIndex(series => series.label === props.key || series.data.includes(props.datum));\n const seriesData = dataSorted[seriesIndex];\n const {\n color,\n glyph: themeGlyph\n } = getElementStyles({\n data: seriesData,\n index: seriesIndex\n });\n const propsWithResolvedColor = {\n ...props,\n color\n };\n return themeGlyph ? themeGlyph(propsWithResolvedColor) : renderGlyph(propsWithResolvedColor);\n };\n }, [dataSorted, renderGlyph, getElementStyles]);\n const defaultMargin = useChartMargin(height, chartOptions, dataSorted, theme);\n const error = validateData(dataSorted);\n const isDataValid = !error;\n\n // Memoize legend options to prevent unnecessary re-calculations\n const legendOptions = useMemo(() => ({\n withGlyph: withLegendGlyph,\n glyphSize: Math.max(0, toNumber(glyphStyle?.radius) ?? 4),\n renderGlyph\n }), [withLegendGlyph, glyphStyle?.radius, renderGlyph]);\n\n // Create legend items using the reusable hook\n const legendItems = useChartLegendItems(dataSorted, legendOptions, legendShape);\n\n // Memoize metadata to prevent unnecessary re-registration\n const chartMetadata = useMemo(() => ({\n withGradientFill,\n smoothing,\n curveType,\n withStartGlyphs,\n withEndGlyphs,\n withLegendGlyph\n }), [withGradientFill, smoothing, curveType, withStartGlyphs, withEndGlyphs, withLegendGlyph]);\n\n // Register chart with context only if data is valid\n useChartRegistration({\n chartId,\n legendItems,\n chartType: 'line',\n isDataValid,\n metadata: chartMetadata\n });\n const prefersReducedMotion = usePrefersReducedMotion();\n const accessors = {\n xAccessor: d => d?.date,\n yAccessor: d => d?.value\n };\n\n // Create a custom renderTooltip that includes focus capability\n if (error) {\n return /*#__PURE__*/_jsx(\"div\", {\n className: clsx('line-chart', styles['line-chart']),\n children: error\n });\n }\n const legendElement = showLegend && /*#__PURE__*/_jsx(Legend, {\n orientation: legendOrientation,\n alignment: legendAlignment,\n position: legendPosition,\n maxWidth: legendMaxWidth,\n textOverflow: legendTextOverflow,\n legendItemClassName: legendItemClassName,\n className: styles['line-chart__legend'],\n shape: legendShape,\n chartId: chartId,\n interactive: legendInteractive\n });\n return /*#__PURE__*/_jsx(SingleChartContext.Provider, {\n value: {\n chartId,\n chartRef: internalChartRef,\n chartWidth: width,\n chartHeight\n },\n children: /*#__PURE__*/_jsxs(Stack, {\n direction: \"column\",\n gap: gap,\n className: clsx('line-chart', styles['line-chart'], {\n [styles['line-chart--animated']]: animation && !prefersReducedMotion\n }, className),\n style: {\n width,\n height,\n visibility: isWaitingForMeasurement ? 'hidden' : 'visible'\n },\n children: [legendPosition === 'top' && legendElement, /*#__PURE__*/_jsx(\"div\", {\n className: styles['line-chart__svg-wrapper'],\n ref: svgWrapperRef,\n role: \"grid\",\n \"aria-label\": __('Line chart', 'jetpack-charts'),\n tabIndex: 0,\n onKeyDown: onChartKeyDown,\n onFocus: onChartFocus,\n onBlur: onChartBlur,\n children: !isWaitingForMeasurement && /*#__PURE__*/_jsx(\"div\", {\n ref: chartRef,\n children: /*#__PURE__*/_jsxs(XYChart, {\n theme: theme,\n width: width,\n height: chartHeight,\n margin: {\n ...defaultMargin,\n ...margin\n }\n // xScale and yScale could be set in Axis as well, but they are `scale` props there.\n ,\n xScale: chartOptions.xScale,\n yScale: chartOptions.yScale,\n onPointerDown: onPointerDown,\n onPointerUp: onPointerUp,\n onPointerMove: onPointerMove,\n onPointerOut: onPointerOut,\n pointerEventsDataKey: \"nearest\",\n children: [gridVisibility !== 'none' && /*#__PURE__*/_jsx(Grid, {\n columns: false,\n numTicks: 4\n }), chartOptions.axis.x.display && /*#__PURE__*/_jsx(Axis, {\n ...chartOptions.axis.x\n }), chartOptions.axis.y.display && /*#__PURE__*/_jsx(Axis, {\n ...chartOptions.axis.y\n }), allSeriesHidden ? /*#__PURE__*/_jsx(\"text\", {\n x: width / 2,\n y: chartHeight / 2,\n textAnchor: \"middle\",\n fill: providerTheme.gridStyles?.stroke || '#ccc',\n fontSize: \"14\",\n fontFamily: \"-apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,sans-serif\",\n children: __('All series are hidden. Click legend items to show data.', 'jetpack-charts')\n }) : null, seriesWithVisibility.map(({\n series: seriesData,\n index,\n isVisible\n }) => {\n // Skip rendering invisible series\n if (!isVisible) {\n return null;\n }\n const {\n color,\n lineStyles,\n glyph\n } = getElementStyles({\n data: seriesData,\n index\n });\n const lineProps = {\n stroke: color,\n ...lineStyles\n };\n return /*#__PURE__*/_jsxs(\"g\", {\n children: [withGradientFill && /*#__PURE__*/_jsx(LinearGradient, {\n id: `area-gradient-${chartId}-${index + 1}`,\n from: color,\n fromOpacity: 0.4,\n toOpacity: 0.1,\n to: providerTheme.backgroundColor,\n ...seriesData.options?.gradient,\n children: seriesData.options?.gradient?.stops?.map((stop, stopIndex) => /*#__PURE__*/_jsx(\"stop\", {\n offset: stop.offset,\n stopColor: stop.color || color,\n stopOpacity: stop.opacity ?? 1\n }, `${stop.offset}-${stop.color || color}`))\n }), /*#__PURE__*/_jsx(AreaSeries, {\n dataKey: seriesData?.label,\n data: seriesData.data,\n ...accessors,\n fill: withGradientFill ? `url(#area-gradient-${chartId}-${index + 1})` : 'transparent',\n renderLine: true,\n curve: getCurveType(curveType, smoothing),\n lineProps: lineProps\n }, seriesData?.label), withStartGlyphs && /*#__PURE__*/_jsx(LineChartGlyph, {\n index: index,\n data: seriesData,\n color: color,\n renderGlyph: glyph ?? renderGlyph,\n accessors: accessors,\n glyphStyle: glyphStyle,\n position: \"start\"\n }), withEndGlyphs && /*#__PURE__*/_jsx(LineChartGlyph, {\n index: index,\n data: seriesData,\n color: color,\n renderGlyph: glyph ?? renderGlyph,\n accessors: accessors,\n glyphStyle: glyphStyle,\n position: \"end\"\n })]\n }, seriesData?.label || index);\n }), withTooltips && /*#__PURE__*/_jsx(AccessibleTooltip, {\n detectBounds: true,\n snapTooltipToDatumX: true,\n snapTooltipToDatumY: true,\n showSeriesGlyphs: true,\n renderTooltip: renderTooltip,\n renderGlyph: tooltipRenderGlyph,\n glyphStyle: glyphStyle,\n showVerticalCrosshair: withTooltipCrosshairs?.showVertical,\n showHorizontalCrosshair: withTooltipCrosshairs?.showHorizontal,\n selectedIndex: selectedIndex,\n tooltipRef: tooltipRef,\n keyboardFocusedClassName: styles['line-chart__tooltip--keyboard-focused'],\n series: dataSorted\n }), /*#__PURE__*/_jsx(LineChartScalesRef, {\n chartRef: internalChartRef,\n width: width,\n height: height,\n margin: margin\n })]\n })\n })\n }), legendPosition === 'bottom' && legendElement, children]\n })\n });\n});\n\n// Component type definitions for composition API\n\nconst LineChartWithProvider = /*#__PURE__*/forwardRef((props, ref) => {\n const existingContext = useContext(GlobalChartsContext);\n\n // If we're already in a GlobalChartsProvider context, render the core component directly\n if (existingContext) {\n return /*#__PURE__*/_jsx(LineChartInternal, {\n ...props,\n ref: ref\n });\n }\n\n // Otherwise, wrap with our own GlobalChartsProvider\n return /*#__PURE__*/_jsx(GlobalChartsProvider, {\n children: /*#__PURE__*/_jsx(LineChartInternal, {\n ...props,\n ref: ref\n })\n });\n});\nLineChartWithProvider.displayName = 'LineChart';\nconst LineChart = attachSubComponents(LineChartWithProvider, {\n Legend: Legend,\n AnnotationsOverlay: LineChartAnnotationsOverlay,\n Annotation: LineChartAnnotation\n});\nconst LineChartResponsive = attachSubComponents(withResponsive(LineChartWithProvider), {\n Legend: Legend,\n AnnotationsOverlay: LineChartAnnotationsOverlay,\n Annotation: LineChartAnnotation\n});\nexport { LineChartResponsive as default, LineChart as LineChartUnresponsive };","import { DataContext } from '@visx/xychart';\nimport { useContext } from 'react';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport const DefaultGlyph = props => {\n const {\n theme\n } = useContext(DataContext) || {};\n const position = props.position || 'start';\n return /*#__PURE__*/_jsx(\"circle\", {\n cx: props.x,\n cy: props.y,\n r: props.size,\n fill: props.color,\n stroke: theme?.backgroundColor,\n strokeWidth: 1.5,\n paintOrder: \"fill\",\n ...props.glyphStyle\n });\n};","import 'css-chunk:src/charts/line-chart/line-chart.module.scss';export default {\n \"line-chart\": \"a8ccharts-v-oO8E\",\n \"line-chart__svg-wrapper\": \"a8ccharts-cpMNjj\",\n \"line-chart--animated\": \"a8ccharts-QrkuTW\",\n \"rise\": \"a8ccharts--rxDU3\",\n \"line-chart__tooltip\": \"a8ccharts-Tu0rR-\",\n \"line-chart__annotation-label-popover\": \"a8ccharts--RSWXi\",\n \"line-chart__tooltip-date\": \"a8ccharts-Q-b5A1\",\n \"line-chart__tooltip-row\": \"a8ccharts-19N7T9\",\n \"line-chart__tooltip-label\": \"a8ccharts-HOAXrD\",\n \"line-chart__annotations-overlay\": \"a8ccharts-rQiY8O\",\n \"line-chart__annotation-label\": \"a8ccharts-8AKWOe\",\n \"line-chart__annotation-label-trigger-button\": \"a8ccharts-7mh3Cl\",\n \"line-chart__annotation-label-popover--visible\": \"a8ccharts-VAeVuJ\",\n \"line-chart__annotation-label-popover--safari\": \"a8ccharts-TEe-iV\",\n \"line-chart__annotation-label-popover-header\": \"a8ccharts-LAUpx7\",\n \"line-chart__annotation-label-popover-content\": \"a8ccharts-b76gEu\",\n \"line-chart__annotation-label-popover-close-button\": \"a8ccharts-LIpFoS\"\n};","import { __ } from '@wordpress/i18n';\nimport clsx from 'clsx';\nimport Gridicon from 'gridicons';\nimport { useEffect, useId, useRef, useState } from 'react';\nimport { isSafari } from '../../../utils';\nimport styles from '../line-chart.module.scss';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nexport const POPOVER_BUTTON_SIZE = 44;\nconst LineChartAnnotationLabelWithPopover = ({\n title,\n subtitle,\n renderLabel,\n renderLabelPopover\n}) => {\n const popoverId = useId();\n const buttonRef = useRef(null);\n const popoverRef = useRef(null);\n const [isPositioned, setIsPositioned] = useState(false);\n const isBrowserSafari = isSafari();\n useEffect(() => {\n const button = buttonRef.current;\n const popover = popoverRef.current;\n if (!button || !popover) return;\n const positionPopover = () => {\n // Popover positioning in Safari is complicated due to issues with SVG foreign objects (https://bugs.webkit.org/show_bug.cgi?id=23113), so let it be positioned in the centre of the viewport.\n if (!isBrowserSafari) {\n const buttonRect = button.getBoundingClientRect();\n popover.style.left = `${buttonRect.right}px`;\n popover.style.top = `${buttonRect.top}px`;\n }\n setIsPositioned(true);\n };\n\n // Position when popover shows\n popover.addEventListener('toggle', e => {\n if (e.newState === 'open') {\n positionPopover();\n }\n });\n\n // Initial positioning if already open\n try {\n if (popover.matches(':popover-open')) {\n positionPopover();\n }\n } catch {\n // Ignore errors in test environments (e.g., JSDOM does not support :popover-open)\n }\n }, [isBrowserSafari]);\n return /*#__PURE__*/_jsxs(\"div\", {\n className: styles['line-chart__annotation-label'],\n children: [/*#__PURE__*/_jsx(\"button\", {\n ref: buttonRef,\n popovertarget: popoverId,\n className: styles['line-chart__annotation-label-trigger-button'],\n style: {\n width: `${POPOVER_BUTTON_SIZE}px`,\n height: `${POPOVER_BUTTON_SIZE}px`,\n transform: `translate(${POPOVER_BUTTON_SIZE / 2}px, 0)`\n },\n \"aria-label\": title || __('View details', 'jetpack-charts'),\n children: renderLabel({\n title,\n subtitle\n })\n }), /*#__PURE__*/_jsx(\"div\", {\n ref: popoverRef,\n id: popoverId,\n popover: 'auto',\n className: clsx(styles['line-chart__annotation-label-popover'], isPositioned && styles['line-chart__annotation-label-popover--visible'], isBrowserSafari && styles['line-chart__annotation-label-popover--safari']),\n children: /*#__PURE__*/_jsxs(\"div\", {\n className: styles['line-chart__annotation-label-popover-header'],\n children: [/*#__PURE__*/_jsx(\"div\", {\n className: styles['line-chart__annotation-label-popover-content'],\n children: renderLabelPopover({\n title,\n subtitle\n })\n }), /*#__PURE__*/_jsx(\"button\", {\n popovertarget: popoverId,\n popovertargetaction: 'hide',\n className: styles['line-chart__annotation-label-popover-close-button'],\n \"aria-label\": __('Close', 'jetpack-charts'),\n children: /*#__PURE__*/_jsx(Gridicon, {\n icon: \"cross\",\n size: 16\n })\n })]\n })\n })]\n });\n};\nexport default LineChartAnnotationLabelWithPopover;","import { DataContext } from '@visx/xychart';\nimport { useEffect, useState, useCallback } from 'react';\nimport { useSingleChartContext } from '../../private/single-chart-context';\nimport styles from '../line-chart.module.scss';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst LineChartAnnotationsOverlay = ({\n children\n}) => {\n const {\n chartRef,\n chartWidth,\n chartHeight\n } = useSingleChartContext();\n const [scales, setScales] = useState(null);\n const [scalesStable, setScalesStable] = useState(false);\n\n // Create a signature for scale data to enable easy comparison\n const createScaleSignature = useCallback(scaleData => {\n const xDomain = scaleData.xScale.domain();\n const yDomain = scaleData.yScale.domain();\n const xRange = scaleData.xScale.range();\n const yRange = scaleData.yScale.range();\n return `${xDomain.join(',')}-${yDomain.join(',')}-${xRange.join(',')}-${yRange.join(',')}`;\n }, []);\n\n // Get scales from chart ref and return them with signature for comparison\n const getScalesData = useCallback(() => {\n if (chartRef?.current) {\n const scaleData = chartRef.current.getScales();\n if (scaleData) {\n const scaleInfo = {\n xScale: scaleData.xScale,\n yScale: scaleData.yScale\n };\n return {\n scales: scaleInfo,\n signature: createScaleSignature(scaleInfo)\n };\n }\n }\n return null;\n }, [chartRef, createScaleSignature]);\n\n // The chart resizes on render so we need to monitor the scales until they stabilize\n useEffect(() => {\n let timeoutId = null;\n let lastSignature = null;\n let retryCount = 0;\n const maxRetries = 20; // 20 * 50ms = 1 second max\n const checkInterval = 50; // Check every 50ms\n\n // Reset stability state when monitoring starts\n setScalesStable(false);\n const monitorScales = () => {\n const currentScaleData = getScalesData();\n\n // If we got scales, compare signatures\n if (currentScaleData) {\n // Check if scales have settled by comparing signatures\n const scalesSettled = lastSignature && currentScaleData.signature === lastSignature;\n if (scalesSettled) {\n // Scales have stabilized, mark as stable\n setScalesStable(true);\n return;\n }\n\n // Update scales and remember signature for next comparison\n setScales(currentScaleData.scales);\n lastSignature = currentScaleData.signature;\n }\n\n // Continue monitoring if we haven't exceeded max retries\n if (retryCount < maxRetries) {\n retryCount++;\n timeoutId = setTimeout(monitorScales, checkInterval);\n }\n };\n monitorScales();\n return () => {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n };\n }, [getScalesData, chartWidth, chartHeight]);\n\n // Early return if no chart data available\n if (!chartRef || !children) {\n return null;\n }\n if (!scales || !scalesStable) {\n return null;\n }\n\n // Create a DataContext value that mimics what visx provides\n // We're intentionally providing minimal context for annotations to work\n const dataContextValue = {\n xScale: scales.xScale,\n yScale: scales.yScale,\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n width: chartWidth,\n height: chartHeight\n };\n return /*#__PURE__*/_jsx(DataContext.Provider, {\n value: dataContextValue,\n children: /*#__PURE__*/_jsx(\"svg\", {\n width: chartWidth,\n height: chartHeight,\n className: styles['line-chart__annotations-overlay'],\n children: children\n })\n });\n};\nexport default LineChartAnnotationsOverlay;","import { Annotation, CircleSubject, Connector, HtmlLabel, Label, LineSubject } from '@visx/annotation';\nimport { DataContext } from '@visx/xychart';\nimport merge from 'deepmerge';\nimport { useContext, useRef, useEffect, useState, useMemo } from 'react';\nimport { useGlobalChartsTheme } from '../../../providers';\nimport { isSafari } from '../../../utils';\nimport LineChartAnnotationLabelWithPopover, { POPOVER_BUTTON_SIZE } from './line-chart-annotation-label-popover';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst ANNOTATION_MAX_WIDTH = 125; // visx default\nconst ANNOTATION_INIT_HEIGHT = 100;\nexport const getLabelPosition = ({\n subjectType,\n x,\n xMax,\n y,\n yMin,\n yMax,\n maxWidth,\n height\n}) => {\n const annotationMaxWidth = maxWidth ?? ANNOTATION_MAX_WIDTH;\n const annotationHeight = height ?? ANNOTATION_INIT_HEIGHT;\n let dx = 15;\n let dy = 15;\n let isFlippedHorizontally = false;\n let isFlippedVertically = false;\n if (subjectType === 'line-horizontal') {\n dx = 0;\n dy = 20;\n }\n if (subjectType === 'line-vertical') {\n dx = 20;\n dy = 0;\n }\n\n // Smart horizontal positioning: if annotation would extend beyond right edge, position it to the left\n // Account for the connector offset (dx) in boundary calculations\n const effectiveX = x + dx;\n if (effectiveX + annotationMaxWidth > xMax) {\n isFlippedHorizontally = true;\n if (subjectType === 'circle') {\n dx = -dx; // Just flip to the left side with same offset\n } else if (subjectType === 'line-vertical') {\n dx = -20; // Position to the left of the line\n }\n }\n\n // Smart vertical positioning: check both top and bottom edges\n // For circle annotations, they are positioned below by default (dy > 0)\n // Only flip when close to bottom edge to position above\n if (subjectType === 'circle') {\n // Check if positioning below would extend beyond bottom edge\n if (y + dy + annotationHeight > yMin) {\n // Too close to bottom edge, position above\n isFlippedVertically = true;\n dy = -Math.abs(dy); // Ensure negative value to position above the point\n }\n // When close to top edge, keep default below positioning (no flip needed)\n } else if (y - annotationHeight < yMax) {\n // Too close to top edge, position below\n if (subjectType === 'line-horizontal') {\n isFlippedVertically = true;\n dy = Math.abs(dy); // Ensure positive value to position below the point\n } else if (subjectType === 'line-vertical') {\n isFlippedVertically = true; // For anchor adjustment only\n }\n } else if (y + annotationHeight > yMin) {\n // Too close to bottom edge, position above\n if (subjectType === 'line-horizontal') {\n isFlippedVertically = true;\n dy = -Math.abs(dy); // Ensure negative value to position above the point\n } else if (subjectType === 'line-vertical') {\n isFlippedVertically = true; // For anchor adjustment only\n }\n }\n return {\n dx,\n dy,\n isFlippedHorizontally,\n isFlippedVertically\n };\n};\nconst getHorizontalAnchor = (subjectType, isFlippedHorizontally) => {\n if (subjectType === 'line-horizontal') {\n return isFlippedHorizontally ? 'end' : 'start';\n }\n return undefined;\n};\nconst getVerticalAnchor = (subjectType, isFlippedVertically, y, yMax, height) => {\n if (subjectType === 'line-vertical') {\n if (isFlippedVertically) {\n // If flipped due to top edge, anchor to top; if flipped due to bottom edge, anchor to bottom\n return y - height < yMax ? 'start' : 'end';\n }\n return 'start';\n }\n return undefined;\n};\nconst LineChartAnnotation = ({\n datum,\n title,\n subtitle,\n subjectType = 'circle',\n styles: datumStyles,\n testId,\n renderLabel,\n renderLabelPopover\n}) => {\n const providerTheme = useGlobalChartsTheme();\n const {\n xScale,\n yScale\n } = useContext(DataContext) || {};\n const labelRef = useRef(null);\n const [height, setHeight] = useState(null);\n\n // Deep merge styles to preserve nested object properties\n const styles = merge(providerTheme.annotationStyles ?? {}, datumStyles ?? {});\n\n // Measure the label height once after initial render\n useEffect(() => {\n if (labelRef.current?.getBBox) {\n const bbox = labelRef.current.getBBox();\n setHeight(bbox.height);\n }\n }, []);\n const positionData = useMemo(() => {\n if (!datum || !datum.date || datum.value == null || !xScale || !yScale) return null;\n const x = xScale(datum.date);\n const y = yScale(datum.value);\n if (typeof x !== 'number' || typeof y !== 'number') return null;\n const [yMin, yMax] = yScale.range().map(Number);\n const [xMin, xMax] = xScale.range().map(Number);\n\n // If a custom label is provided, use the provided position\n if (renderLabel) {\n return {\n x,\n dx: 0,\n y,\n dy: 0,\n yMin,\n yMax,\n xMin,\n xMax,\n isFlippedHorizontally: false,\n isFlippedVertically: false\n };\n }\n const position = getLabelPosition({\n subjectType,\n x,\n xMax,\n y,\n yMin,\n yMax,\n maxWidth: styles?.label?.maxWidth,\n height\n });\n return {\n x,\n y,\n yMin,\n yMax,\n xMin,\n xMax,\n ...position\n };\n }, [datum, xScale, yScale, subjectType, styles?.label?.maxWidth, height, renderLabel]);\n if (!positionData) return null;\n const {\n x,\n y,\n yMin,\n yMax,\n xMin,\n xMax,\n dx,\n dy,\n isFlippedHorizontally,\n isFlippedVertically\n } = positionData;\n const getLabelY = () => {\n const labelY = styles?.label?.y;\n if (labelY === 'start') return yMax;\n if (labelY === 'end') return yMin;\n return labelY;\n };\n const getLabelX = () => {\n const labelX = styles?.label?.x;\n if (labelX === 'start') return xMin;\n if (labelX === 'end') return xMax;\n return labelX;\n };\n const labelPosition = {\n x: getLabelX(),\n y: getLabelY()\n };\n\n // Safari has a bug where children of an SVG foreignObject are not positioned correctly https://bugs.webkit.org/show_bug.cgi?id=23113\n // This is a workaround to position the label correctly\n const getSafariHTMLLabelPosition = () => {\n const labelWidth = POPOVER_BUTTON_SIZE;\n const labelHeight = POPOVER_BUTTON_SIZE;\n return isSafari() ? {\n transform: `translate(${x + (dx || 0) + (typeof labelPosition.x === 'number' ? labelPosition.x - x : 0) - labelWidth}px, ${y + (dy || 0) + (typeof labelPosition.y === 'number' ? labelPosition.y - y : 0) - labelHeight}px)`,\n width: labelWidth,\n height: labelHeight\n } : undefined;\n };\n return /*#__PURE__*/_jsx(\"g\", {\n children: /*#__PURE__*/_jsxs(Annotation, {\n x: x,\n y: y,\n dx: dx,\n dy: dy,\n children: [/*#__PURE__*/_jsx(Connector, {\n ...styles?.connector\n }), subjectType === 'circle' && /*#__PURE__*/_jsx(CircleSubject, {\n ...styles?.circleSubject\n }), subjectType === 'line-vertical' && /*#__PURE__*/_jsx(LineSubject, {\n min: yMax,\n max: yMin,\n ...styles?.lineSubject,\n orientation: 'vertical'\n }), subjectType === 'line-horizontal' && /*#__PURE__*/_jsx(LineSubject, {\n min: xMin,\n max: xMax,\n ...styles?.lineSubject,\n orientation: 'horizontal'\n }), renderLabel ? /*#__PURE__*/_jsx(HtmlLabel, {\n ...styles?.label,\n ...labelPosition,\n children: /*#__PURE__*/_jsx(\"div\", {\n style: getSafariHTMLLabelPosition(),\n children: renderLabelPopover ? /*#__PURE__*/_jsx(LineChartAnnotationLabelWithPopover, {\n title: title,\n subtitle: subtitle,\n renderLabel: renderLabel,\n renderLabelPopover: renderLabelPopover\n }) : renderLabel({\n title,\n subtitle\n })\n })\n }) : /*#__PURE__*/_jsx(\"g\", {\n ref: labelRef,\n children: /*#__PURE__*/_jsx(Label, {\n title: title,\n subtitle: subtitle,\n ...styles?.label,\n ...labelPosition,\n horizontalAnchor: getHorizontalAnchor(subjectType, isFlippedHorizontally),\n verticalAnchor: getVerticalAnchor(subjectType, isFlippedVertically, y, yMax, height ?? ANNOTATION_INIT_HEIGHT)\n })\n })]\n })\n });\n};\nexport default LineChartAnnotation;","import { DataContext } from '@visx/xychart';\nimport { useContext } from 'react';\nconst toNumber = val => {\n const num = typeof val === 'number' ? val : parseFloat(val);\n return isNaN(num) ? undefined : num;\n};\nconst LineChartGlyph = ({\n data,\n index,\n color,\n glyphStyle,\n renderGlyph,\n accessors,\n position\n}) => {\n const {\n xScale,\n yScale\n } = useContext(DataContext) || {};\n if (!xScale || !yScale) return null;\n if (data.data.length === 0) return null;\n const point = position === 'start' ? data.data[0] : data.data[data.data.length - 1];\n const x = xScale(accessors.xAccessor(point));\n const y = yScale(accessors.yAccessor(point));\n if (typeof x !== 'number' || typeof y !== 'number') return null;\n const size = Math.max(0, toNumber(glyphStyle?.radius) ?? 4);\n return renderGlyph({\n key: `${position}-glyph-${data.label}`,\n index,\n datum: point,\n color,\n size,\n x,\n y,\n glyphStyle,\n position\n });\n};\nexport default LineChartGlyph;"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/jetpack/jetpack/projects/js-packages/charts/dist/chunk-IHESL7H5.cjs","../src/charts/bar-chart/bar-chart.tsx","../src/charts/bar-chart/bar-chart.module.scss","../src/charts/bar-chart/private/use-bar-chart-options.ts","../src/charts/bar-chart/private/truncated-tick-component.tsx"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACjCA,iEAA6B;AAC7B,wCAA4E;AAC5E,wCAAyD;AACzD,uCAAmB;AAEnB,wEAAiB;AACjB,8BAAmE;ADkCnE;AACA;AEzC8D,IAAO,yBAAA,EAAQ;AAAA,EAC3E,wBAAA,EAA0B,kBAAA;AAAA,EAC1B,WAAA,EAAa,kBAAA;AAAA,EACb,qBAAA,EAAuB,kBAAA;AAAA,EACvB,MAAA,EAAQ,kBAAA;AAAA,EACR,gCAAA,EAAkC,kBAAA;AAAA,EAClC,SAAA,EAAW;AACb,CAAA;AF2CA;AACA;AGnDA;AACA;AHqDA;AACA;AIvDA;AACA;AAEA,+CAA4B;AAO5B,IAAM,kBAAA,EAAoB,CAAA,KAAA,EAAA,GAAS;AACjC,EAAA,OAAO,M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;AACD;AAG6D;AAC5D,EAAA;AACD;ADoMsE;AACA;AACA;AACA;AACA","file":"/home/runner/work/jetpack/jetpack/projects/js-packages/charts/dist/chunk-IHESL7H5.cjs","sourcesContent":[null,"import { formatNumber } from '@automattic/number-formatters';\nimport { PatternLines, PatternCircles, PatternWaves, PatternHexagons } from '@visx/pattern';\nimport { Axis, BarSeries, BarGroup, Grid, XYChart } from '@visx/xychart';\nimport { __ } from '@wordpress/i18n';\nimport { Stack } from '@wordpress/ui';\nimport clsx from 'clsx';\nimport { useCallback, useContext, useState, useRef, useMemo } from 'react';\nimport { Legend, useChartLegendItems } from '../../components/legend';\nimport { AccessibleTooltip, useKeyboardNavigation } from '../../components/tooltip';\nimport { useXYChartTheme, useChartDataTransform, useZeroValueDisplay, useChartMargin, useElementHeight, useHasLegendChild, usePrefersReducedMotion } from '../../hooks';\nimport { GlobalChartsProvider, useChartId, useChartRegistration, useGlobalChartsContext, useGlobalChartsTheme, GlobalChartsContext } from '../../providers';\nimport { attachSubComponents } from '../../utils';\nimport { SingleChartContext } from '../private/single-chart-context';\nimport { withResponsive } from '../private/with-responsive';\nimport styles from './bar-chart.module.scss';\nimport { useBarChartOptions } from './private';\n\n// Base props type with optional responsive properties\n\n// Composition API types\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\n// Validation function similar to LineChart\nconst validateData = data => {\n if (!data?.length) return 'No data available';\n const hasInvalidData = data.some(series => series.data.some(point => isNaN(point.value) || point.value === null || point.value === undefined || !point.label && (!('date' in point && point.date) || isNaN(point.date.getTime()))));\n if (hasInvalidData) return 'Invalid data';\n return null;\n};\nconst getPatternId = (chartId, index) => `bar-pattern-${chartId}-${index}`;\nconst BarChartInternal = ({\n data,\n chartId: providedChartId,\n width,\n height,\n className,\n margin,\n withTooltips = false,\n showLegend = false,\n legendOrientation = 'horizontal',\n legendPosition = 'bottom',\n legendAlignment = 'center',\n legendMaxWidth,\n legendTextOverflow = 'wrap',\n legendItemClassName,\n legendShape = 'rect',\n gridVisibility: gridVisibilityProp,\n renderTooltip,\n options = {},\n orientation = 'vertical',\n withPatterns = false,\n showZeroValues = false,\n legendInteractive = false,\n animation,\n children,\n gap = 'md'\n}) => {\n const horizontal = orientation === 'horizontal';\n const chartId = useChartId(providedChartId);\n const theme = useXYChartTheme(data);\n const dataSorted = useChartDataTransform(data);\n\n // Transform data to add a small value for zero bars to make them visible\n const dataWithVisibleZeros = useZeroValueDisplay(dataSorted, {\n enabled: showZeroValues\n });\n\n // Create legend items using the reusable hook\n const legendItems = useChartLegendItems(dataSorted);\n const chartOptions = useBarChartOptions(dataWithVisibleZeros, horizontal, options);\n const defaultMargin = useChartMargin(height, chartOptions, dataSorted, theme, horizontal);\n const [svgWrapperRef, svgWrapperHeight] = useElementHeight();\n const chartRef = useRef(null);\n\n // Check if children contain a Legend component (composition pattern)\n const hasLegendChild = useHasLegendChild(children);\n\n // Use the measured SVG wrapper height, falling back to the passed height if provided.\n // When there's a legend (via prop or composition), we must wait for measurement because\n // the legend takes space and the svg-wrapper height will be less than the total height.\n const chartHeight = svgWrapperHeight > 0 ? svgWrapperHeight : height;\n const hasLegend = showLegend || hasLegendChild;\n const isWaitingForMeasurement = hasLegend ? svgWrapperHeight === 0 : !chartHeight;\n const [selectedIndex, setSelectedIndex] = useState(undefined);\n const [isNavigating, setIsNavigating] = useState(false);\n const totalPoints = Math.max(0, ...data.map(series => series.data?.length || 0)) * data.length;\n\n // Use the keyboard navigation hook\n const {\n tooltipRef,\n onChartFocus,\n onChartBlur,\n onChartKeyDown\n } = useKeyboardNavigation({\n selectedIndex,\n setSelectedIndex,\n isNavigating,\n setIsNavigating,\n chartRef,\n totalPoints\n });\n const {\n getElementStyles,\n isSeriesVisible\n } = useGlobalChartsContext();\n const providerTheme = useGlobalChartsTheme();\n\n // Add visibility information to series when using interactive legends\n const seriesWithVisibility = useMemo(() => {\n if (!chartId || !legendInteractive) {\n return dataWithVisibleZeros.map((series, index) => ({\n series,\n index,\n isVisible: true\n }));\n }\n return dataWithVisibleZeros.map((series, index) => ({\n series,\n index,\n isVisible: isSeriesVisible(chartId, series.label)\n }));\n }, [dataWithVisibleZeros, chartId, isSeriesVisible, legendInteractive]);\n\n // Check if all series are hidden\n const allSeriesHidden = useMemo(() => {\n return seriesWithVisibility.every(({\n isVisible\n }) => !isVisible);\n }, [seriesWithVisibility]);\n const getBarBackground = useCallback(index => () => withPatterns ? `url(#${getPatternId(chartId, index)})` : getElementStyles({\n data: dataSorted[index],\n index\n }).color, [withPatterns, getElementStyles, dataSorted, chartId]);\n const renderDefaultTooltip = useCallback(({\n tooltipData\n }) => {\n const nearestDatum = tooltipData?.nearestDatum?.datum;\n if (!nearestDatum) return null;\n return /*#__PURE__*/_jsxs(\"div\", {\n className: styles['bar-chart__tooltip'],\n children: [/*#__PURE__*/_jsx(\"div\", {\n className: styles['bar-chart__tooltip-header'],\n children: tooltipData?.nearestDatum?.key\n }), /*#__PURE__*/_jsxs(\"div\", {\n className: styles['bar-chart__tooltip-row'],\n children: [/*#__PURE__*/_jsxs(\"span\", {\n className: styles['bar-chart__tooltip-label'],\n children: [chartOptions.tooltip.labelFormatter(nearestDatum.label || (nearestDatum.date ? nearestDatum.date.getTime() : 0), 0, []), \":\"]\n }), /*#__PURE__*/_jsx(\"span\", {\n className: styles['bar-chart__tooltip-value'],\n children: formatNumber(nearestDatum.value)\n })]\n })]\n });\n }, [chartOptions.tooltip]);\n const renderPattern = useCallback((index, color) => {\n const patternType = index % 4;\n const id = getPatternId(chartId, index);\n const commonProps = {\n id,\n stroke: 'white',\n strokeWidth: 1,\n background: color\n };\n switch (patternType) {\n case 0:\n default:\n return /*#__PURE__*/_jsx(PatternLines, {\n ...commonProps,\n width: 5,\n height: 5,\n orientation: ['diagonal']\n }, id);\n case 1:\n return /*#__PURE__*/_jsx(PatternCircles, {\n ...commonProps,\n width: 6,\n height: 6,\n fill: \"white\"\n }, id);\n case 2:\n return /*#__PURE__*/_jsx(PatternWaves, {\n ...commonProps,\n width: 4,\n height: 4\n }, id);\n case 3:\n return /*#__PURE__*/_jsx(PatternHexagons, {\n ...commonProps,\n size: 8,\n height: 3\n }, id);\n }\n }, [chartId]);\n const createPatternBorderStyle = useCallback((index, color) => {\n const patternId = getPatternId(chartId, index);\n return `\n\t\t\t.visx-bar[fill=\"url(#${patternId})\"] {\n\t\t\t\tstroke: ${color};\n\t\t\t\tstroke-width: 1;\n\t\t\t\t}\n\t\t\t`;\n }, [chartId]);\n const createKeyboardHighlightStyle = useCallback(() => {\n if (selectedIndex === undefined) return '';\n\n // Calculate which bar should be highlighted based on selectedIndex\n // Pattern: [series1[0], series2[0], series3[0], series1[1], series2[1], series3[1], ...]\n const maxDataPoints = Math.max(...data.map(s => s.data.length));\n const dataPointIndex = Math.floor(selectedIndex / data.length);\n const seriesIndex = selectedIndex % data.length;\n\n // Only highlight if we're within valid bounds\n if (dataPointIndex >= maxDataPoints || seriesIndex >= data.length) {\n return '';\n }\n const seriesData = data[seriesIndex];\n if (dataPointIndex >= seriesData.data.length) {\n return '';\n }\n\n // Based on the DOM structure analysis:\n // - All bars are in a single .visx-bar-group\n // - Bars are ordered as: [series1[0], series1[1], series2[0], series2[1], ...]\n // - So we need to calculate the actual bar index in the DOM\n const actualBarIndex = seriesIndex * maxDataPoints + dataPointIndex;\n\n // Use a CSS class selector instead of ID since useId() generates invalid CSS ID characters\n const generatedStyles = `\n\t\t\t.bar-chart[data-chart-id=\"bar-chart-${chartId}\"] .visx-bar-group .visx-bar:nth-child(${actualBarIndex + 1}) {\n\t\t\t\tstroke: #005fcc;\n\t\t\t\tstroke-width: 2px;\n\t\t\t}\n\t\t`;\n return generatedStyles;\n }, [selectedIndex, data, chartId]);\n\n // Validate data first\n const error = validateData(dataSorted);\n const isDataValid = !error;\n\n // Memoize metadata to prevent unnecessary re-registration\n const chartMetadata = useMemo(() => ({\n orientation,\n withPatterns\n }), [orientation, withPatterns]);\n\n // Register chart with context only if data is valid\n useChartRegistration({\n chartId,\n legendItems,\n chartType: 'bar',\n isDataValid,\n metadata: chartMetadata\n });\n const prefersReducedMotion = usePrefersReducedMotion();\n if (error) {\n return /*#__PURE__*/_jsx(\"div\", {\n className: clsx('bar-chart', styles['bar-chart']),\n children: error\n });\n }\n const gridVisibility = gridVisibilityProp ?? chartOptions.gridVisibility;\n const highlightedBarStyle = createKeyboardHighlightStyle();\n const legendElement = showLegend && /*#__PURE__*/_jsx(Legend, {\n orientation: legendOrientation,\n position: legendPosition,\n alignment: legendAlignment,\n maxWidth: legendMaxWidth,\n textOverflow: legendTextOverflow,\n legendItemClassName: legendItemClassName,\n className: styles['bar-chart__legend'],\n shape: legendShape,\n chartId: chartId,\n interactive: legendInteractive\n });\n return /*#__PURE__*/_jsx(SingleChartContext.Provider, {\n value: {\n chartId,\n chartWidth: width,\n chartHeight\n },\n children: /*#__PURE__*/_jsxs(Stack, {\n direction: \"column\",\n gap: gap,\n className: clsx('bar-chart', styles['bar-chart'], {\n [styles[`bar-chart--animated${horizontal ? '-horizontal' : ''}`]]: animation && !prefersReducedMotion\n }, className),\n style: {\n width,\n height,\n visibility: isWaitingForMeasurement ? 'hidden' : 'visible'\n },\n \"data-chart-id\": `bar-chart-${chartId}`,\n children: [legendPosition === 'top' && legendElement, /*#__PURE__*/_jsx(\"div\", {\n className: styles['bar-chart__svg-wrapper'],\n ref: svgWrapperRef,\n role: \"grid\",\n \"aria-label\": __('Bar chart', 'jetpack-charts'),\n tabIndex: 0,\n onKeyDown: onChartKeyDown,\n onFocus: onChartFocus,\n onBlur: onChartBlur,\n children: !isWaitingForMeasurement && /*#__PURE__*/_jsx(\"div\", {\n ref: chartRef,\n children: /*#__PURE__*/_jsxs(XYChart, {\n theme: theme,\n width: width,\n height: chartHeight,\n margin: {\n ...defaultMargin,\n ...margin\n },\n xScale: chartOptions.xScale,\n yScale: chartOptions.yScale,\n horizontal: horizontal,\n pointerEventsDataKey: \"nearest\",\n children: [/*#__PURE__*/_jsx(Grid, {\n columns: gridVisibility.includes('y'),\n rows: gridVisibility.includes('x'),\n numTicks: 4\n }), withPatterns && /*#__PURE__*/_jsxs(_Fragment, {\n children: [/*#__PURE__*/_jsx(\"defs\", {\n children: dataSorted.map((seriesData, index) => renderPattern(index, getElementStyles({\n data: seriesData,\n index\n }).color))\n }), /*#__PURE__*/_jsx(\"style\", {\n children: dataSorted.map((seriesData, index) => createPatternBorderStyle(index, getElementStyles({\n data: seriesData,\n index\n }).color))\n })]\n }), highlightedBarStyle && /*#__PURE__*/_jsx(\"style\", {\n children: highlightedBarStyle\n }), allSeriesHidden ? /*#__PURE__*/_jsx(\"text\", {\n x: width / 2,\n y: chartHeight / 2,\n textAnchor: \"middle\",\n fill: providerTheme.gridStyles?.stroke || '#ccc',\n fontSize: \"14\",\n fontFamily: \"-apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,sans-serif\",\n children: __('All series are hidden. Click legend items to show data.', 'jetpack-charts')\n }) : null, /*#__PURE__*/_jsx(BarGroup, {\n padding: chartOptions.barGroup.padding,\n children: seriesWithVisibility.map(({\n series: seriesData,\n index,\n isVisible\n }) => {\n // Skip rendering invisible series\n if (!isVisible) {\n return null;\n }\n return /*#__PURE__*/_jsx(BarSeries, {\n dataKey: seriesData?.label,\n data: seriesData.data,\n yAccessor: chartOptions.accessors.yAccessor,\n xAccessor: chartOptions.accessors.xAccessor,\n colorAccessor: getBarBackground(index)\n }, seriesData?.label);\n })\n }), /*#__PURE__*/_jsx(Axis, {\n ...chartOptions.axis.x\n }), /*#__PURE__*/_jsx(Axis, {\n ...chartOptions.axis.y\n }), withTooltips && /*#__PURE__*/_jsx(AccessibleTooltip, {\n detectBounds: true,\n snapTooltipToDatumX: true,\n snapTooltipToDatumY: true,\n renderTooltip: renderTooltip || renderDefaultTooltip,\n selectedIndex: selectedIndex,\n tooltipRef: tooltipRef,\n keyboardFocusedClassName: styles['bar-chart__tooltip--keyboard-focused'],\n series: data,\n mode: \"individual\"\n })]\n })\n })\n }), legendPosition === 'bottom' && legendElement, children]\n })\n });\n};\nconst BarChartWithProvider = props => {\n const existingContext = useContext(GlobalChartsContext);\n\n // If we're already in a GlobalChartsProvider context, don't create a new one\n if (existingContext) {\n return /*#__PURE__*/_jsx(BarChartInternal, {\n ...props\n });\n }\n\n // Otherwise, create our own GlobalChartsProvider\n return /*#__PURE__*/_jsx(GlobalChartsProvider, {\n children: /*#__PURE__*/_jsx(BarChartInternal, {\n ...props\n })\n });\n};\nBarChartWithProvider.displayName = 'BarChart';\n\n// Create BarChart with composition API\nconst BarChart = attachSubComponents(BarChartWithProvider, {\n Legend: Legend\n});\n\n// Create responsive BarChart with composition API\nconst BarChartResponsive = attachSubComponents(withResponsive(BarChartWithProvider), {\n Legend: Legend\n});\nexport { BarChartResponsive as default, BarChart as BarChartUnresponsive };","import 'css-chunk:src/charts/bar-chart/bar-chart.module.scss';export default {\n \"bar-chart__svg-wrapper\": \"a8ccharts-9CsqC0\",\n \"bar-chart\": \"a8ccharts-3gflnB\",\n \"bar-chart--animated\": \"a8ccharts-98W-yu\",\n \"rise\": \"a8ccharts-z6AsiQ\",\n \"bar-chart--animated-horizontal\": \"a8ccharts-HFA3FF\",\n \"stretch\": \"a8ccharts-DQp37O\"\n};","import { formatNumberCompact } from '@automattic/number-formatters';\nimport { useMemo } from 'react';\nimport { TruncatedXTickComponent, TruncatedYTickComponent } from './truncated-tick-component';\nimport type { EnhancedDataPoint } from '../../../hooks/use-zero-value-display';\nimport type { DataPointDate, BaseChartProps, SeriesData } from '../../../types';\nimport type { TickFormatter } from '@visx/axis';\n\nconst formatDateTick = ( timestamp: number ) => {\n\tconst date = new Date( timestamp );\n\treturn date.toLocaleDateString( undefined, {\n\t\tmonth: 'short',\n\t\tday: 'numeric',\n\t} );\n};\n\n/**\n * Get the group padding of a scale.\n *\n * @param scale - The scale to get the group padding of.\n * @return The group padding of the scale.\n */\nconst getGroupPadding = ( scale: Record< string, unknown > ): number => {\n\treturn typeof scale.paddingInner === 'number' ? ( scale.paddingInner as number ) : 0;\n};\n\n/**\n * Returns the merged options for the bar chart, including axis and scale configuration based on the orientation.\n *\n * @param data - The data to be displayed in the chart.\n * @param horizontal - Whether the chart is horizontal or vertical.\n * @param options - The options for the chart.\n * @return The merged options for the chart.\n */\nexport function useBarChartOptions(\n\tdata: SeriesData[],\n\thorizontal: boolean,\n\toptions: BaseChartProps[ 'options' ] = {}\n) {\n\tconst defaultOptions = useMemo( () => {\n\t\tconst bandScale = {\n\t\t\ttype: 'band' as const,\n\t\t\tpadding: 0.2,\n\t\t\tpaddingInner: 0.1,\n\t\t};\n\t\tconst linearScale = {\n\t\t\ttype: 'linear' as const,\n\t\t\tnice: true,\n\t\t\tzero: false,\n\t\t};\n\n\t\tconst labelFormatter = data?.[ 0 ]?.data?.[ 0 ]?.label\n\t\t\t? ( label: string ) => label\n\t\t\t: formatDateTick;\n\t\tconst valueFormatter = formatNumberCompact as TickFormatter< unknown >;\n\n\t\tconst labelAccessor = ( d: DataPointDate ) => d?.label || d?.date;\n\t\tconst valueAccessor = ( d: DataPointDate | EnhancedDataPoint ) => {\n\t\t\t// Use visualValue for bar rendering if available (for zero values), otherwise use value\n\t\t\tconst enhancedPoint = d as EnhancedDataPoint;\n\t\t\treturn enhancedPoint?.visualValue !== undefined ? enhancedPoint.visualValue : d?.value;\n\t\t};\n\n\t\treturn {\n\t\t\tvertical: {\n\t\t\t\txTickFormat: labelFormatter,\n\t\t\t\tyTickFormat: valueFormatter,\n\t\t\t\ttooltipLabelFormatter: labelFormatter,\n\t\t\t\txAccessor: labelAccessor,\n\t\t\t\tyAccessor: valueAccessor,\n\t\t\t\tgridVisibility: 'x',\n\t\t\t\txScale: bandScale,\n\t\t\t\tyScale: linearScale,\n\t\t\t},\n\t\t\thorizontal: {\n\t\t\t\txTickFormat: valueFormatter,\n\t\t\t\tyTickFormat: labelFormatter,\n\t\t\t\ttooltipLabelFormatter: labelFormatter,\n\t\t\t\txAccessor: valueAccessor,\n\t\t\t\tyAccessor: labelAccessor,\n\t\t\t\tgridVisibility: 'y',\n\t\t\t\txScale: linearScale,\n\t\t\t\tyScale: bandScale,\n\t\t\t},\n\t\t};\n\t}, [ data ] );\n\n\treturn useMemo( () => {\n\t\tconst orientationKey = horizontal ? 'horizontal' : 'vertical';\n\t\tconst {\n\t\t\txTickFormat,\n\t\t\tyTickFormat,\n\t\t\ttooltipLabelFormatter: defaultTooltipLabelFormatter,\n\t\t\txAccessor,\n\t\t\tyAccessor,\n\t\t\tgridVisibility,\n\t\t\txScale: baseXScale,\n\t\t\tyScale: baseYScale,\n\t\t} = defaultOptions[ orientationKey ];\n\n\t\tconst xScale = { ...baseXScale, ...( options.xScale || {} ) };\n\t\tconst yScale = { ...baseYScale, ...( options.yScale || {} ) };\n\t\tconst providedToolTipLabelFormatter = horizontal\n\t\t\t? options.axis?.y?.tickFormat\n\t\t\t: options.axis?.x?.tickFormat;\n\n\t\tconst { labelOverflow: xLabelOverflow, ...xAxisOptions } = options.axis?.x || {};\n\t\tconst { labelOverflow: yLabelOverflow, ...yAxisOptions } = options.axis?.y || {};\n\n\t\treturn {\n\t\t\tgridVisibility,\n\t\t\txScale,\n\t\t\tyScale,\n\t\t\taccessors: {\n\t\t\t\txAccessor,\n\t\t\t\tyAccessor,\n\t\t\t},\n\t\t\taxis: {\n\t\t\t\tx: {\n\t\t\t\t\torientation: 'bottom' as const,\n\t\t\t\t\tnumTicks: 4,\n\t\t\t\t\ttickFormat: xTickFormat,\n\t\t\t\t\t...( xLabelOverflow === 'ellipsis' ? { tickComponent: TruncatedXTickComponent } : {} ),\n\t\t\t\t\t...xAxisOptions,\n\t\t\t\t},\n\t\t\t\ty: {\n\t\t\t\t\torientation: 'left' as const,\n\t\t\t\t\tnumTicks: 4,\n\t\t\t\t\ttickFormat: yTickFormat,\n\t\t\t\t\t...( yLabelOverflow === 'ellipsis' ? { tickComponent: TruncatedYTickComponent } : {} ),\n\t\t\t\t\t...yAxisOptions,\n\t\t\t\t},\n\t\t\t},\n\t\t\tbarGroup: {\n\t\t\t\tpadding: getGroupPadding( horizontal ? yScale : xScale ),\n\t\t\t},\n\t\t\ttooltip: {\n\t\t\t\tlabelFormatter: providedToolTipLabelFormatter || defaultTooltipLabelFormatter,\n\t\t\t},\n\t\t};\n\t}, [ defaultOptions, options, horizontal ] );\n}\n","import { DataContext } from '@visx/xychart';\nimport { useContext } from 'react';\nimport { isSafari } from '../../../utils';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\n/**\n * Get the bandwidth of a scale\n *\n * @param scale - The scale to get the bandwidth of\n * @return The bandwidth of the scale\n */\nconst getScaleBandwidth = scale => {\n return scale && 'bandwidth' in scale ? scale.bandwidth() ?? 0 : 0;\n};\n/**\n * Minimum width in pixels for tick labels when scale bandwidth is very small.\n * Prevents labels from collapsing to unreadable widths on dense charts.\n *\n * Trade-off: When bandwidth is less than this minimum (e.g., many bars in a narrow chart),\n * adjacent labels may overlap since each label uses this minimum width regardless of\n * available space. This prioritizes label readability over preventing overlap.\n *\n * For very dense charts where overlap occurs, consider:\n * - Using `numTicks` option to reduce the number of displayed labels\n * - Using `tickFormat` to abbreviate label text\n * - Increasing chart width or reducing data points\n */\nconst MIN_TICK_LABEL_WIDTH = 20;\n\n/**\n * A tick component that renders labels with text truncation (ellipsis) when they exceed\n * the available bandwidth. Shows the full text on hover via native title attribute.\n *\n * Uses foreignObject to embed HTML within SVG, enabling CSS text-overflow: ellipsis.\n * Inherits text styles from tickLabelProps passed by visx Axis component.\n *\n * Note: A minimum label width (MIN_TICK_LABEL_WIDTH) is enforced to keep labels readable.\n * On very dense charts where bandwidth < 20px, this may cause label overlap.\n * See MIN_TICK_LABEL_WIDTH documentation for mitigation strategies.\n *\n * @param props - The props for the truncated tick component\n * @param props.x - The x position of the tick\n * @param props.y - The y position of the tick\n * @param props.formattedValue - The formatted value of the tick\n * @param props.axis - The axis this tick belongs to\n * @param props.textAnchor - The text anchor of the tick\n * @param props.fill - The fill color of the tick\n * @param props.dy - The dy offset of the tick\n *\n * @return The truncated tick component\n */\nexport const TruncatedTickComponent = ({\n x,\n y,\n formattedValue,\n axis,\n textAnchor,\n fill,\n dy,\n ...textProps\n}) => {\n // Get max width of the tick label\n const {\n xScale,\n yScale\n } = useContext(DataContext) || {};\n const scale = axis === 'x' ? xScale : yScale;\n const bandwidth = getScaleBandwidth(scale);\n const maxWidth = Math.max(bandwidth, MIN_TICK_LABEL_WIDTH);\n\n // Map SVG textAnchor to CSS textAlign\n let textAlign = 'center';\n if (textAnchor === 'start') {\n textAlign = 'left';\n } else if (textAnchor === 'end') {\n textAlign = 'right';\n } else if (textAnchor === 'middle') {\n textAlign = 'center';\n }\n\n // Calculate x offset based on text alignment\n let xOffset = 0;\n if (textAlign === 'center') {\n xOffset = -maxWidth / 2;\n } else if (textAlign === 'right') {\n xOffset = -maxWidth;\n }\n\n // Extract compatible style properties from SVG text props\n const {\n fontSize,\n fontFamily,\n fontWeight,\n fontStyle,\n letterSpacing,\n opacity\n } = textProps;\n const textStyles = {\n /**\n * SVG <text> elements are vertically aligned to the baseline by default, but HTML <div> elements inside <foreignObject>\n * are positioned relative to the top-left corner. To visually align the tick label like SVG text,\n * we shift the div up by 100% of its height and adjust by twice the SVG dy value (from visx) to approximate original placement.\n */\n transform: `translateY(calc(-100% + ${dy ?? '0'} * 2))`,\n // Safari doesn't work well with foreignObject positioning. Use position: fixed as a workaround.\n ...(isSafari() ? {\n position: 'fixed'\n } : {}),\n // Apply compatible SVG text styles\n fontSize,\n fontFamily,\n fontWeight,\n fontStyle,\n letterSpacing,\n opacity,\n // Convert svg text styles to CSS styles for the div\n color: fill ?? 'inherit',\n textAlign,\n // Ensure text is truncated with ellipsis, remains on one line, and shows the full value in a tooltip on hover.\n // The surrounding div uses CSS to handle overflow, and the 'title' attribute is set for accessibility.\n width: maxWidth,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n cursor: 'default',\n pointerEvents: 'auto'\n };\n return /*#__PURE__*/_jsx(\"foreignObject\", {\n x: x + xOffset,\n y: y,\n width: maxWidth,\n height: 0,\n overflow: \"visible\",\n children: /*#__PURE__*/_jsx(\"div\", {\n style: textStyles,\n title: formattedValue,\n children: formattedValue\n })\n });\n};\n\n/**\n * Factory function to create a truncated tick component for a specific axis.\n * Returns a component that can be passed to visx's tickComponent prop.\n *\n * @param axis - The axis this tick component is for ('x' or 'y')\n * @return A tick component function compatible with visx's TickRendererProps\n */\nconst createTruncatedTickComponent = axis => props => {\n return /*#__PURE__*/_jsx(TruncatedTickComponent, {\n ...props,\n axis: axis\n });\n};\n\n/**\n * Pre-created tick components for x and y axes.\n * These functions are created once at module initialization and reused,\n * avoiding repeated factory calls when configuring axes.\n */\nexport const TruncatedXTickComponent = createTruncatedTickComponent('x');\nexport const TruncatedYTickComponent = createTruncatedTickComponent('y');"]}
|
package/dist/chunk-JL4ZKKZU.cjs
DELETED
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
-
|
|
3
|
-
var _chunk7OZEQ5HEcjs = require('./chunk-7OZEQ5HE.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunk2A34OA5Ocjs = require('./chunk-2A34OA5O.cjs');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _chunkRCY6XLGUcjs = require('./chunk-RCY6XLGU.cjs');
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _chunkY3NNQMAXcjs = require('./chunk-Y3NNQMAX.cjs');
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var _chunk7QDEU3KNcjs = require('./chunk-7QDEU3KN.cjs');
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var _chunkEJJO2QNBcjs = require('./chunk-EJJO2QNB.cjs');
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var _chunkZVGEDXDPcjs = require('./chunk-ZVGEDXDP.cjs');
|
|
35
|
-
|
|
36
|
-
// src/charts/pie-chart/pie-chart.tsx
|
|
37
|
-
var _group = require('@visx/group');
|
|
38
|
-
var _shape = require('@visx/shape');
|
|
39
|
-
var _tooltip = require('@visx/tooltip');
|
|
40
|
-
var _i18n = require('@wordpress/i18n');
|
|
41
|
-
var _clsx = require('clsx'); var _clsx2 = _interopRequireDefault(_clsx);
|
|
42
|
-
var _react = require('react');
|
|
43
|
-
|
|
44
|
-
// src/charts/pie-chart/pie-chart.module.scss
|
|
45
|
-
var pie_chart_module_default = {
|
|
46
|
-
"pie-chart": "a8ccharts-C-n-Gu",
|
|
47
|
-
"pie-chart--legend-top": "a8ccharts-Mu0uxl"
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// src/charts/pie-chart/pie-chart.tsx
|
|
51
|
-
var _jsxruntime = require('react/jsx-runtime');
|
|
52
|
-
var renderDefaultPieTooltip = ({
|
|
53
|
-
tooltipData
|
|
54
|
-
}) => {
|
|
55
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY3NNQMAXcjs.BaseTooltip, {
|
|
56
|
-
data: tooltipData,
|
|
57
|
-
top: 0,
|
|
58
|
-
left: 0,
|
|
59
|
-
renderContainer: false
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
var validateData = (data) => {
|
|
63
|
-
if (!data.length) {
|
|
64
|
-
return {
|
|
65
|
-
isValid: false,
|
|
66
|
-
message: "No data available"
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
const hasNegativeValues = data.some((item) => item.percentage < 0 || item.value < 0);
|
|
70
|
-
if (hasNegativeValues) {
|
|
71
|
-
return {
|
|
72
|
-
isValid: false,
|
|
73
|
-
message: "Invalid data: Negative values are not allowed"
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
const totalPercentage = data.reduce((sum, item) => sum + item.percentage, 0);
|
|
77
|
-
if (Math.abs(totalPercentage - 100) > 0.01) {
|
|
78
|
-
return {
|
|
79
|
-
isValid: false,
|
|
80
|
-
message: "Invalid percentage total: Must equal 100"
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
isValid: true,
|
|
85
|
-
message: ""
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
var PieChartInternal = ({
|
|
89
|
-
data,
|
|
90
|
-
chartId: providedChartId,
|
|
91
|
-
withTooltips = false,
|
|
92
|
-
className,
|
|
93
|
-
showLegend = false,
|
|
94
|
-
legendOrientation = "horizontal",
|
|
95
|
-
legendPosition = "bottom",
|
|
96
|
-
legendAlignment = "center",
|
|
97
|
-
legendMaxWidth,
|
|
98
|
-
legendTextOverflow = "wrap",
|
|
99
|
-
legendItemClassName,
|
|
100
|
-
legendShape = "circle",
|
|
101
|
-
size,
|
|
102
|
-
animation,
|
|
103
|
-
thickness = 1,
|
|
104
|
-
padding = 0,
|
|
105
|
-
gapScale = 0,
|
|
106
|
-
cornerScale = 0,
|
|
107
|
-
showLabels = true,
|
|
108
|
-
legendValueDisplay = "percentage",
|
|
109
|
-
legendInteractive = false,
|
|
110
|
-
children = null,
|
|
111
|
-
tooltipOffsetX = 0,
|
|
112
|
-
tooltipOffsetY = -15,
|
|
113
|
-
renderTooltip = renderDefaultPieTooltip
|
|
114
|
-
}) => {
|
|
115
|
-
const providerTheme = _chunkEJJO2QNBcjs.useGlobalChartsTheme.call(void 0, );
|
|
116
|
-
const chartId = _chunkEJJO2QNBcjs.useChartId.call(void 0, providedChartId);
|
|
117
|
-
const [legendRef, legendHeight] = _chunkEJJO2QNBcjs.useElementHeight.call(void 0, );
|
|
118
|
-
const {
|
|
119
|
-
tooltipOpen,
|
|
120
|
-
tooltipLeft,
|
|
121
|
-
tooltipTop,
|
|
122
|
-
tooltipData,
|
|
123
|
-
hideTooltip,
|
|
124
|
-
showTooltip
|
|
125
|
-
} = _tooltip.useTooltip.call(void 0, );
|
|
126
|
-
const {
|
|
127
|
-
containerRef,
|
|
128
|
-
TooltipInPortal,
|
|
129
|
-
containerBounds
|
|
130
|
-
} = _tooltip.useTooltipInPortal.call(void 0, {
|
|
131
|
-
detectBounds: true,
|
|
132
|
-
scroll: true,
|
|
133
|
-
debounce: 0
|
|
134
|
-
});
|
|
135
|
-
const onMouseLeave = _react.useCallback.call(void 0, () => {
|
|
136
|
-
if (!withTooltips) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
hideTooltip();
|
|
140
|
-
}, [withTooltips, hideTooltip]);
|
|
141
|
-
const {
|
|
142
|
-
getElementStyles,
|
|
143
|
-
isSeriesVisible
|
|
144
|
-
} = _chunkEJJO2QNBcjs.useGlobalChartsContext.call(void 0, );
|
|
145
|
-
const {
|
|
146
|
-
visibleData,
|
|
147
|
-
allSegmentsHidden,
|
|
148
|
-
legendData
|
|
149
|
-
} = _chunkEJJO2QNBcjs.useInteractiveLegendData.call(void 0, {
|
|
150
|
-
data,
|
|
151
|
-
chartId,
|
|
152
|
-
legendInteractive,
|
|
153
|
-
isSeriesVisible
|
|
154
|
-
});
|
|
155
|
-
const legendOptions = _react.useMemo.call(void 0, () => ({
|
|
156
|
-
showValues: true,
|
|
157
|
-
legendValueDisplay
|
|
158
|
-
}), [legendValueDisplay]);
|
|
159
|
-
const legendItems = _chunkEJJO2QNBcjs.useChartLegendItems.call(void 0, legendData, legendOptions);
|
|
160
|
-
const {
|
|
161
|
-
isValid,
|
|
162
|
-
message
|
|
163
|
-
} = validateData(data);
|
|
164
|
-
const {
|
|
165
|
-
svgChildren,
|
|
166
|
-
htmlChildren,
|
|
167
|
-
otherChildren
|
|
168
|
-
} = _chunkRCY6XLGUcjs.useChartChildren.call(void 0, children, "PieChart");
|
|
169
|
-
const chartMetadata = _react.useMemo.call(void 0, () => ({
|
|
170
|
-
thickness,
|
|
171
|
-
gapScale,
|
|
172
|
-
cornerScale
|
|
173
|
-
}), [thickness, gapScale, cornerScale]);
|
|
174
|
-
_chunkEJJO2QNBcjs.useChartRegistration.call(void 0, {
|
|
175
|
-
chartId,
|
|
176
|
-
legendItems,
|
|
177
|
-
chartType: "pie",
|
|
178
|
-
isDataValid: isValid,
|
|
179
|
-
metadata: chartMetadata
|
|
180
|
-
});
|
|
181
|
-
const prefersReducedMotion = _chunkEJJO2QNBcjs.usePrefersReducedMotion.call(void 0, );
|
|
182
|
-
if (!isValid) {
|
|
183
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
184
|
-
className: _clsx2.default.call(void 0, "pie-chart", pie_chart_module_default["pie-chart"], className),
|
|
185
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
186
|
-
className: pie_chart_module_default["error-message"],
|
|
187
|
-
children: message
|
|
188
|
-
})
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
const width = size;
|
|
192
|
-
const height = size;
|
|
193
|
-
const adjustedHeight = showLegend && legendPosition === "top" ? height - legendHeight : height;
|
|
194
|
-
const radius = Math.min(width, adjustedHeight) / 2;
|
|
195
|
-
const centerX = width / 2;
|
|
196
|
-
const centerY = adjustedHeight / 2;
|
|
197
|
-
const padAngle = gapScale * (2 * Math.PI / data.length);
|
|
198
|
-
const outerRadius = radius - padding;
|
|
199
|
-
const innerRadius = thickness === 0 ? 0 : outerRadius * (1 - thickness);
|
|
200
|
-
const maxCornerRadius = (outerRadius - innerRadius) / 2;
|
|
201
|
-
const cornerRadius = cornerScale ? Math.min(cornerScale * outerRadius, maxCornerRadius) : 0;
|
|
202
|
-
const dataWithIndex = visibleData.map((d) => {
|
|
203
|
-
const originalIndex = data.findIndex((item) => item.label === d.label);
|
|
204
|
-
return {
|
|
205
|
-
...d,
|
|
206
|
-
index: originalIndex >= 0 ? originalIndex : 0
|
|
207
|
-
};
|
|
208
|
-
});
|
|
209
|
-
const accessors = {
|
|
210
|
-
value: (d) => d.value,
|
|
211
|
-
fill: (d) => {
|
|
212
|
-
return getElementStyles({
|
|
213
|
-
data: d,
|
|
214
|
-
index: d.index
|
|
215
|
-
}).color;
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkEJJO2QNBcjs.SingleChartContext.Provider, {
|
|
219
|
-
value: {
|
|
220
|
-
chartId,
|
|
221
|
-
chartWidth: width,
|
|
222
|
-
chartHeight: adjustedHeight
|
|
223
|
-
},
|
|
224
|
-
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", {
|
|
225
|
-
ref: containerRef,
|
|
226
|
-
className: _clsx2.default.call(void 0, "pie-chart", pie_chart_module_default["pie-chart"], {
|
|
227
|
-
[pie_chart_module_default["pie-chart--legend-top"]]: showLegend && legendPosition === "top"
|
|
228
|
-
}, className),
|
|
229
|
-
children: [/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "svg", {
|
|
230
|
-
viewBox: `0 0 ${width} ${adjustedHeight}`,
|
|
231
|
-
preserveAspectRatio: "xMidYMid meet",
|
|
232
|
-
width,
|
|
233
|
-
height: adjustedHeight,
|
|
234
|
-
children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "defs", {
|
|
235
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2A34OA5Ocjs.radial_wipe_animation_default, {
|
|
236
|
-
id: `radial-wipe-${chartId}`,
|
|
237
|
-
radius: outerRadius,
|
|
238
|
-
innerRadius
|
|
239
|
-
})
|
|
240
|
-
}), /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _group.Group, {
|
|
241
|
-
top: centerY,
|
|
242
|
-
left: centerX,
|
|
243
|
-
mask: animation && !prefersReducedMotion ? `url(#radial-wipe-${chartId})` : null,
|
|
244
|
-
children: [allSegmentsHidden ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "text", {
|
|
245
|
-
textAnchor: "middle",
|
|
246
|
-
dy: ".33em",
|
|
247
|
-
fill: providerTheme.gridColor || "#ccc",
|
|
248
|
-
fontSize: "14",
|
|
249
|
-
fontFamily: "-apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,sans-serif",
|
|
250
|
-
children: _i18n.__.call(void 0, "All segments are hidden. Click legend items to show data.", "jetpack-charts")
|
|
251
|
-
}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _shape.Pie, {
|
|
252
|
-
data: dataWithIndex,
|
|
253
|
-
pieValue: accessors.value,
|
|
254
|
-
outerRadius,
|
|
255
|
-
innerRadius,
|
|
256
|
-
padAngle,
|
|
257
|
-
cornerRadius,
|
|
258
|
-
children: (pie) => {
|
|
259
|
-
return pie.arcs.map((arc, index) => {
|
|
260
|
-
const [centroidX, centroidY] = pie.path.centroid(arc);
|
|
261
|
-
const hasSpaceForLabel = arc.endAngle - arc.startAngle >= 0.25;
|
|
262
|
-
const handleMouseMove = (event) => {
|
|
263
|
-
if (!withTooltips) {
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
if (containerBounds.width === 0 || containerBounds.height === 0) {
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
showTooltip({
|
|
270
|
-
tooltipData: arc.data,
|
|
271
|
-
tooltipLeft: event.clientX - containerBounds.left + tooltipOffsetX,
|
|
272
|
-
tooltipTop: event.clientY - containerBounds.top + tooltipOffsetY
|
|
273
|
-
});
|
|
274
|
-
};
|
|
275
|
-
const pathProps = {
|
|
276
|
-
d: pie.path(arc) || "",
|
|
277
|
-
fill: accessors.fill(arc.data)
|
|
278
|
-
};
|
|
279
|
-
const groupProps = {};
|
|
280
|
-
if (withTooltips) {
|
|
281
|
-
groupProps.onMouseMove = handleMouseMove;
|
|
282
|
-
groupProps.onMouseLeave = onMouseLeave;
|
|
283
|
-
}
|
|
284
|
-
const fontSize = 12;
|
|
285
|
-
const estimatedTextWidth = _chunk7OZEQ5HEcjs.getStringWidth.call(void 0, arc.data.label, {
|
|
286
|
-
fontSize
|
|
287
|
-
});
|
|
288
|
-
const labelPadding = 6;
|
|
289
|
-
const backgroundWidth = estimatedTextWidth + labelPadding * 2;
|
|
290
|
-
const backgroundHeight = fontSize + labelPadding * 2;
|
|
291
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "g", {
|
|
292
|
-
...groupProps,
|
|
293
|
-
children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", {
|
|
294
|
-
...pathProps
|
|
295
|
-
}), showLabels && hasSpaceForLabel && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "g", {
|
|
296
|
-
children: [providerTheme.labelBackgroundColor && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "rect", {
|
|
297
|
-
x: centroidX - backgroundWidth / 2,
|
|
298
|
-
y: centroidY - backgroundHeight / 2,
|
|
299
|
-
width: backgroundWidth,
|
|
300
|
-
height: backgroundHeight,
|
|
301
|
-
fill: providerTheme.labelBackgroundColor,
|
|
302
|
-
rx: 4,
|
|
303
|
-
ry: 4,
|
|
304
|
-
pointerEvents: "none"
|
|
305
|
-
}), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "text", {
|
|
306
|
-
x: centroidX,
|
|
307
|
-
y: centroidY,
|
|
308
|
-
dy: ".33em",
|
|
309
|
-
fill: providerTheme.labelTextColor || "#333",
|
|
310
|
-
fontSize,
|
|
311
|
-
textAnchor: "middle",
|
|
312
|
-
pointerEvents: "none",
|
|
313
|
-
children: arc.data.label
|
|
314
|
-
})]
|
|
315
|
-
})]
|
|
316
|
-
}, `arc-${index}`);
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
}), !allSegmentsHidden && svgChildren]
|
|
320
|
-
})]
|
|
321
|
-
}), showLegend && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkEJJO2QNBcjs.Legend, {
|
|
322
|
-
orientation: legendOrientation,
|
|
323
|
-
position: legendPosition,
|
|
324
|
-
alignment: legendAlignment,
|
|
325
|
-
maxWidth: legendMaxWidth,
|
|
326
|
-
textOverflow: legendTextOverflow,
|
|
327
|
-
legendItemClassName,
|
|
328
|
-
className: pie_chart_module_default["pie-chart-legend"],
|
|
329
|
-
shape: legendShape,
|
|
330
|
-
ref: legendRef,
|
|
331
|
-
chartId,
|
|
332
|
-
interactive: legendInteractive
|
|
333
|
-
}), withTooltips && tooltipOpen && tooltipData && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipInPortal, {
|
|
334
|
-
top: tooltipTop || 0,
|
|
335
|
-
left: tooltipLeft || 0,
|
|
336
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
337
|
-
role: "tooltip",
|
|
338
|
-
children: renderTooltip({
|
|
339
|
-
tooltipData
|
|
340
|
-
})
|
|
341
|
-
})
|
|
342
|
-
}), htmlChildren, otherChildren]
|
|
343
|
-
})
|
|
344
|
-
});
|
|
345
|
-
};
|
|
346
|
-
var PieChartWithProvider = (props) => {
|
|
347
|
-
const existingContext = _react.useContext.call(void 0, _chunkEJJO2QNBcjs.GlobalChartsContext);
|
|
348
|
-
if (existingContext) {
|
|
349
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PieChartInternal, {
|
|
350
|
-
...props
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkEJJO2QNBcjs.GlobalChartsProvider, {
|
|
354
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PieChartInternal, {
|
|
355
|
-
...props
|
|
356
|
-
})
|
|
357
|
-
});
|
|
358
|
-
};
|
|
359
|
-
PieChartWithProvider.displayName = "PieChart";
|
|
360
|
-
var PieChart = _chunkZVGEDXDPcjs.attachSubComponents.call(void 0, PieChartWithProvider, {
|
|
361
|
-
Legend: _chunkEJJO2QNBcjs.Legend,
|
|
362
|
-
SVG: _chunkRCY6XLGUcjs.ChartSVG,
|
|
363
|
-
HTML: _chunkRCY6XLGUcjs.ChartHTML
|
|
364
|
-
});
|
|
365
|
-
var PieChartResponsive = _chunkZVGEDXDPcjs.attachSubComponents.call(void 0, _chunk7QDEU3KNcjs.withResponsive.call(void 0, PieChartWithProvider), {
|
|
366
|
-
Legend: _chunkEJJO2QNBcjs.Legend,
|
|
367
|
-
SVG: _chunkRCY6XLGUcjs.ChartSVG,
|
|
368
|
-
HTML: _chunkRCY6XLGUcjs.ChartHTML
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
exports.PieChart = PieChart; exports.PieChartResponsive = PieChartResponsive;
|
|
375
|
-
//# sourceMappingURL=chunk-JL4ZKKZU.cjs.map
|