@automattic/charts 1.4.3 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/SECURITY.md +0 -1
- package/dist/index.cjs +544 -195
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +38 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +22 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.js +839 -490
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/charts/area-chart/area-chart.tsx +39 -21
- package/src/charts/area-chart/test/area-chart.test.tsx +83 -3
- package/src/charts/area-chart/types.ts +15 -0
- package/src/charts/line-chart/line-chart.tsx +102 -84
- package/src/charts/line-chart/test/line-chart.test.tsx +41 -0
- package/src/charts/line-chart/types.ts +6 -0
- package/src/charts/private/test/x-zoom.test.tsx +142 -0
- package/src/charts/private/x-zoom.module.scss +45 -0
- package/src/charts/private/x-zoom.tsx +209 -0
- package/src/types.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -468,9 +468,9 @@ var require_es6 = __commonJS({
|
|
|
468
468
|
// src/charts/area-chart/area-chart.tsx
|
|
469
469
|
import { formatNumberCompact as formatNumberCompact3 } from "@automattic/number-formatters";
|
|
470
470
|
import { XYChart as XYChart2, AnimatedAreaSeries, AnimatedAreaStack, Grid as Grid2, Axis as Axis2 } from "@visx/xychart";
|
|
471
|
-
import { __ as
|
|
471
|
+
import { __ as __5 } from "@wordpress/i18n";
|
|
472
472
|
import clsx5 from "clsx";
|
|
473
|
-
import { useMemo as
|
|
473
|
+
import { useMemo as useMemo17, useContext as useContext14, forwardRef as forwardRef5, useImperativeHandle as useImperativeHandle4, useState as useState11, useRef as useRef10, useCallback as useCallback10 } from "react";
|
|
474
474
|
|
|
475
475
|
// src/components/legend/legend.tsx
|
|
476
476
|
import { useContext as useContext6, useMemo as useMemo10, forwardRef as forwardRef3 } from "react";
|
|
@@ -2112,20 +2112,94 @@ function useRender(params) {
|
|
|
2112
2112
|
return useRenderElement(params.defaultTagName ?? "div", params, params);
|
|
2113
2113
|
}
|
|
2114
2114
|
|
|
2115
|
-
// ../../../node_modules/.pnpm/@wordpress+ui@0.
|
|
2115
|
+
// ../../../node_modules/.pnpm/@wordpress+ui@0.13.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/ui/build-module/text/text.mjs
|
|
2116
2116
|
import clsx from "clsx";
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2117
|
+
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
2118
|
+
function getRuntime() {
|
|
2119
|
+
const globalScope = globalThis;
|
|
2120
|
+
if (globalScope.__wpStyleRuntime) {
|
|
2121
|
+
return globalScope.__wpStyleRuntime;
|
|
2122
|
+
}
|
|
2123
|
+
globalScope.__wpStyleRuntime = {
|
|
2124
|
+
documents: /* @__PURE__ */ new Map(),
|
|
2125
|
+
styles: /* @__PURE__ */ new Map(),
|
|
2126
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
2127
|
+
};
|
|
2128
|
+
if (typeof document !== "undefined") {
|
|
2129
|
+
registerDocument(document);
|
|
2130
|
+
}
|
|
2131
|
+
return globalScope.__wpStyleRuntime;
|
|
2132
|
+
}
|
|
2133
|
+
function documentContainsStyleHash(targetDocument, hash2) {
|
|
2134
|
+
if (!targetDocument.head) {
|
|
2135
|
+
return false;
|
|
2136
|
+
}
|
|
2137
|
+
for (const style of targetDocument.head.querySelectorAll(
|
|
2138
|
+
`style[${STYLE_HASH_ATTRIBUTE}]`
|
|
2139
|
+
)) {
|
|
2140
|
+
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash2) {
|
|
2141
|
+
return true;
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
return false;
|
|
2145
|
+
}
|
|
2146
|
+
function injectStyle(targetDocument, hash2, css3) {
|
|
2147
|
+
if (!targetDocument.head) {
|
|
2148
|
+
return;
|
|
2149
|
+
}
|
|
2150
|
+
const runtime = getRuntime();
|
|
2151
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
2152
|
+
if (!injectedStyles) {
|
|
2153
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
2154
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
2155
|
+
}
|
|
2156
|
+
if (injectedStyles.has(hash2)) {
|
|
2157
|
+
return;
|
|
2158
|
+
}
|
|
2159
|
+
if (documentContainsStyleHash(targetDocument, hash2)) {
|
|
2160
|
+
injectedStyles.add(hash2);
|
|
2161
|
+
return;
|
|
2162
|
+
}
|
|
2163
|
+
const style = targetDocument.createElement("style");
|
|
2164
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash2);
|
|
2165
|
+
style.appendChild(targetDocument.createTextNode(css3));
|
|
2166
|
+
targetDocument.head.appendChild(style);
|
|
2167
|
+
injectedStyles.add(hash2);
|
|
2168
|
+
}
|
|
2169
|
+
function registerDocument(targetDocument) {
|
|
2170
|
+
const runtime = getRuntime();
|
|
2171
|
+
runtime.documents.set(
|
|
2172
|
+
targetDocument,
|
|
2173
|
+
(runtime.documents.get(targetDocument) ?? 0) + 1
|
|
2174
|
+
);
|
|
2175
|
+
for (const [hash2, css3] of runtime.styles) {
|
|
2176
|
+
injectStyle(targetDocument, hash2, css3);
|
|
2177
|
+
}
|
|
2178
|
+
return () => {
|
|
2179
|
+
const count = runtime.documents.get(targetDocument);
|
|
2180
|
+
if (count === void 0) {
|
|
2181
|
+
return;
|
|
2182
|
+
}
|
|
2183
|
+
if (count <= 1) {
|
|
2184
|
+
runtime.documents.delete(targetDocument);
|
|
2185
|
+
return;
|
|
2186
|
+
}
|
|
2187
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
2188
|
+
};
|
|
2189
|
+
}
|
|
2190
|
+
function registerStyle(hash2, css3) {
|
|
2191
|
+
const runtime = getRuntime();
|
|
2192
|
+
runtime.styles.set(hash2, css3);
|
|
2193
|
+
for (const targetDocument of runtime.documents.keys()) {
|
|
2194
|
+
injectStyle(targetDocument, hash2, css3);
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
2198
|
+
registerStyle("0c8601dd83", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._83ed8a8da5dd50ea__text{margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-p-line-height:var(--wpds-typography-line-height-2xl,40px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}');
|
|
2122
2199
|
}
|
|
2123
2200
|
var style_default = { "text": "_83ed8a8da5dd50ea__text", "heading-2xl": "_14437cfb77831647__heading-2xl", "heading-xl": "_3c78b7fa9b4072dd__heading-xl", "heading-lg": "aa58f227716bcde2__heading-lg", "heading-md": "fc4da56d8dfe52c4__heading-md", "heading-sm": "a9b78c7c82e8dff7__heading-sm", "body-xl": "_305ff559e52180d5__body-xl", "body-lg": "ca1aa3fc2029e958__body-lg", "body-md": "_131101940be12424__body-md", "body-sm": "_0e8d87a42c1f75fa__body-sm" };
|
|
2124
|
-
if (typeof
|
|
2125
|
-
|
|
2126
|
-
style.setAttribute("data-wp-hash", "1fb29d3a3c");
|
|
2127
|
-
style.appendChild(document.createTextNode("._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,#0000);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 #0000);color:var(--_gcd-input-color,var(--wpds-color-fg-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,#0000);border-color:var(--_gcd-input-border-color-disabled,#0000);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid #0000)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid #0000);transition:var(--_gcd-a-transition,none)}"));
|
|
2128
|
-
document.head.appendChild(style);
|
|
2201
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
2202
|
+
registerStyle("1fb29d3a3c", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,#0000);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 #0000);color:var(--_gcd-input-color,var(--wpds-color-fg-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,#0000);border-color:var(--_gcd-input-border-color-disabled,#0000);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid #0000)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid #0000);transition:var(--_gcd-a-transition,none)}");
|
|
2129
2203
|
}
|
|
2130
2204
|
var global_css_defense_default = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" };
|
|
2131
2205
|
var Text = forwardRef(function Text2({ variant = "body-md", render, className, ...props }, ref) {
|
|
@@ -2136,8 +2210,8 @@ var Text = forwardRef(function Text2({ variant = "body-md", render, className, .
|
|
|
2136
2210
|
props: mergeProps(props, {
|
|
2137
2211
|
className: clsx(
|
|
2138
2212
|
style_default.text,
|
|
2139
|
-
|
|
2140
|
-
|
|
2213
|
+
global_css_defense_default.heading,
|
|
2214
|
+
global_css_defense_default.p,
|
|
2141
2215
|
style_default[variant],
|
|
2142
2216
|
className
|
|
2143
2217
|
)
|
|
@@ -2146,12 +2220,89 @@ var Text = forwardRef(function Text2({ variant = "body-md", render, className, .
|
|
|
2146
2220
|
return element;
|
|
2147
2221
|
});
|
|
2148
2222
|
|
|
2149
|
-
// ../../../node_modules/.pnpm/@wordpress+ui@0.
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2223
|
+
// ../../../node_modules/.pnpm/@wordpress+ui@0.13.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/ui/build-module/stack/stack.mjs
|
|
2224
|
+
var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
|
|
2225
|
+
function getRuntime2() {
|
|
2226
|
+
const globalScope = globalThis;
|
|
2227
|
+
if (globalScope.__wpStyleRuntime) {
|
|
2228
|
+
return globalScope.__wpStyleRuntime;
|
|
2229
|
+
}
|
|
2230
|
+
globalScope.__wpStyleRuntime = {
|
|
2231
|
+
documents: /* @__PURE__ */ new Map(),
|
|
2232
|
+
styles: /* @__PURE__ */ new Map(),
|
|
2233
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
2234
|
+
};
|
|
2235
|
+
if (typeof document !== "undefined") {
|
|
2236
|
+
registerDocument2(document);
|
|
2237
|
+
}
|
|
2238
|
+
return globalScope.__wpStyleRuntime;
|
|
2239
|
+
}
|
|
2240
|
+
function documentContainsStyleHash2(targetDocument, hash2) {
|
|
2241
|
+
if (!targetDocument.head) {
|
|
2242
|
+
return false;
|
|
2243
|
+
}
|
|
2244
|
+
for (const style of targetDocument.head.querySelectorAll(
|
|
2245
|
+
`style[${STYLE_HASH_ATTRIBUTE2}]`
|
|
2246
|
+
)) {
|
|
2247
|
+
if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash2) {
|
|
2248
|
+
return true;
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
return false;
|
|
2252
|
+
}
|
|
2253
|
+
function injectStyle2(targetDocument, hash2, css3) {
|
|
2254
|
+
if (!targetDocument.head) {
|
|
2255
|
+
return;
|
|
2256
|
+
}
|
|
2257
|
+
const runtime = getRuntime2();
|
|
2258
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
2259
|
+
if (!injectedStyles) {
|
|
2260
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
2261
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
2262
|
+
}
|
|
2263
|
+
if (injectedStyles.has(hash2)) {
|
|
2264
|
+
return;
|
|
2265
|
+
}
|
|
2266
|
+
if (documentContainsStyleHash2(targetDocument, hash2)) {
|
|
2267
|
+
injectedStyles.add(hash2);
|
|
2268
|
+
return;
|
|
2269
|
+
}
|
|
2270
|
+
const style = targetDocument.createElement("style");
|
|
2271
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash2);
|
|
2272
|
+
style.appendChild(targetDocument.createTextNode(css3));
|
|
2273
|
+
targetDocument.head.appendChild(style);
|
|
2274
|
+
injectedStyles.add(hash2);
|
|
2275
|
+
}
|
|
2276
|
+
function registerDocument2(targetDocument) {
|
|
2277
|
+
const runtime = getRuntime2();
|
|
2278
|
+
runtime.documents.set(
|
|
2279
|
+
targetDocument,
|
|
2280
|
+
(runtime.documents.get(targetDocument) ?? 0) + 1
|
|
2281
|
+
);
|
|
2282
|
+
for (const [hash2, css3] of runtime.styles) {
|
|
2283
|
+
injectStyle2(targetDocument, hash2, css3);
|
|
2284
|
+
}
|
|
2285
|
+
return () => {
|
|
2286
|
+
const count = runtime.documents.get(targetDocument);
|
|
2287
|
+
if (count === void 0) {
|
|
2288
|
+
return;
|
|
2289
|
+
}
|
|
2290
|
+
if (count <= 1) {
|
|
2291
|
+
runtime.documents.delete(targetDocument);
|
|
2292
|
+
return;
|
|
2293
|
+
}
|
|
2294
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
2295
|
+
};
|
|
2296
|
+
}
|
|
2297
|
+
function registerStyle2(hash2, css3) {
|
|
2298
|
+
const runtime = getRuntime2();
|
|
2299
|
+
runtime.styles.set(hash2, css3);
|
|
2300
|
+
for (const targetDocument of runtime.documents.keys()) {
|
|
2301
|
+
injectStyle2(targetDocument, hash2, css3);
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
2305
|
+
registerStyle2("b51ff41489", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}");
|
|
2155
2306
|
}
|
|
2156
2307
|
var style_default2 = { "stack": "_19ce0419607e1896__stack" };
|
|
2157
2308
|
var gapTokens = {
|
|
@@ -2743,10 +2894,10 @@ var useKeyboardNavigation = ({
|
|
|
2743
2894
|
// src/charts/line-chart/line-chart.tsx
|
|
2744
2895
|
import { formatNumberCompact as formatNumberCompact2, formatNumber as formatNumber5 } from "@automattic/number-formatters";
|
|
2745
2896
|
import { LinearGradient } from "@visx/gradient";
|
|
2746
|
-
import { XYChart, AreaSeries, Grid, Axis, DataContext as
|
|
2747
|
-
import { __ as
|
|
2897
|
+
import { XYChart, AreaSeries, Grid, Axis, DataContext as DataContext6 } from "@visx/xychart";
|
|
2898
|
+
import { __ as __3 } from "@wordpress/i18n";
|
|
2748
2899
|
import clsx4 from "clsx";
|
|
2749
|
-
import { useMemo as
|
|
2900
|
+
import { useMemo as useMemo16, useContext as useContext12, forwardRef as forwardRef4, useImperativeHandle as useImperativeHandle2, useState as useState10, useRef as useRef9, useCallback as useCallback9, createElement as _createElement2 } from "react";
|
|
2750
2901
|
|
|
2751
2902
|
// src/charts/private/chart-composition/chart-svg.tsx
|
|
2752
2903
|
import { Fragment as _Fragment2, jsx as _jsx6 } from "react/jsx-runtime";
|
|
@@ -3079,6 +3230,155 @@ function withResponsive(WrappedComponent) {
|
|
|
3079
3230
|
};
|
|
3080
3231
|
}
|
|
3081
3232
|
|
|
3233
|
+
// src/charts/private/x-zoom.tsx
|
|
3234
|
+
import { DataContext as DataContext2 } from "@visx/xychart";
|
|
3235
|
+
import { __ } from "@wordpress/i18n";
|
|
3236
|
+
import { useCallback as useCallback7, useContext as useContext9, useMemo as useMemo14, useState as useState6 } from "react";
|
|
3237
|
+
|
|
3238
|
+
// src/charts/private/x-zoom.module.scss
|
|
3239
|
+
var x_zoom_module_default = {
|
|
3240
|
+
"x-zoom__selection": "a8ccharts-KeNSrO",
|
|
3241
|
+
"x-zoom__reset": "a8ccharts-gg6Kte",
|
|
3242
|
+
"x-zoom__reset-icon": "a8ccharts-bQEoeo"
|
|
3243
|
+
};
|
|
3244
|
+
|
|
3245
|
+
// src/charts/private/x-zoom.tsx
|
|
3246
|
+
import { jsx as _jsx12, Fragment as _Fragment4, jsxs as _jsxs4 } from "react/jsx-runtime";
|
|
3247
|
+
var MIN_DRAG_PIXELS = 6;
|
|
3248
|
+
function useXZoom({
|
|
3249
|
+
enabled,
|
|
3250
|
+
chartRef,
|
|
3251
|
+
userHandlers
|
|
3252
|
+
}) {
|
|
3253
|
+
const [domain, setDomain] = useState6(null);
|
|
3254
|
+
const [drag, setDrag] = useState6(null);
|
|
3255
|
+
const reset = useCallback7(() => setDomain(null), []);
|
|
3256
|
+
const onPointerDown = useCallback7((params) => {
|
|
3257
|
+
userHandlers?.onPointerDown?.(params);
|
|
3258
|
+
if (!enabled || !params.svgPoint) return;
|
|
3259
|
+
setDrag({
|
|
3260
|
+
a: params.svgPoint.x,
|
|
3261
|
+
b: params.svgPoint.x
|
|
3262
|
+
});
|
|
3263
|
+
}, [enabled, userHandlers]);
|
|
3264
|
+
const onPointerMove = useCallback7((params) => {
|
|
3265
|
+
userHandlers?.onPointerMove?.(params);
|
|
3266
|
+
if (!enabled || !params.svgPoint) return;
|
|
3267
|
+
setDrag((current) => current ? {
|
|
3268
|
+
a: current.a,
|
|
3269
|
+
b: params.svgPoint.x
|
|
3270
|
+
} : current);
|
|
3271
|
+
}, [enabled, userHandlers]);
|
|
3272
|
+
const onPointerUp = useCallback7((params) => {
|
|
3273
|
+
userHandlers?.onPointerUp?.(params);
|
|
3274
|
+
if (!enabled) return;
|
|
3275
|
+
const finalDrag = drag;
|
|
3276
|
+
setDrag(null);
|
|
3277
|
+
if (!finalDrag) return;
|
|
3278
|
+
const lo = Math.min(finalDrag.a, finalDrag.b);
|
|
3279
|
+
const hi = Math.max(finalDrag.a, finalDrag.b);
|
|
3280
|
+
if (hi - lo < MIN_DRAG_PIXELS) return;
|
|
3281
|
+
const xScale = chartRef.current?.getScales()?.xScale;
|
|
3282
|
+
if (!xScale || typeof xScale.invert !== "function") return;
|
|
3283
|
+
setDomain([xScale.invert(lo), xScale.invert(hi)]);
|
|
3284
|
+
}, [enabled, drag, chartRef, userHandlers]);
|
|
3285
|
+
return useMemo14(() => ({
|
|
3286
|
+
domain,
|
|
3287
|
+
drag,
|
|
3288
|
+
reset,
|
|
3289
|
+
handlers: {
|
|
3290
|
+
onPointerDown,
|
|
3291
|
+
onPointerMove,
|
|
3292
|
+
onPointerUp
|
|
3293
|
+
}
|
|
3294
|
+
}), [domain, drag, reset, onPointerDown, onPointerMove, onPointerUp]);
|
|
3295
|
+
}
|
|
3296
|
+
function ZoomSelectionRect({
|
|
3297
|
+
drag
|
|
3298
|
+
}) {
|
|
3299
|
+
const {
|
|
3300
|
+
margin,
|
|
3301
|
+
innerHeight
|
|
3302
|
+
} = useContext9(DataContext2);
|
|
3303
|
+
if (!drag || drag.a === drag.b) return null;
|
|
3304
|
+
const x = Math.min(drag.a, drag.b);
|
|
3305
|
+
const w = Math.abs(drag.b - drag.a);
|
|
3306
|
+
return /* @__PURE__ */ _jsx12("rect", {
|
|
3307
|
+
className: x_zoom_module_default["x-zoom__selection"],
|
|
3308
|
+
x,
|
|
3309
|
+
y: margin?.top ?? 0,
|
|
3310
|
+
width: w,
|
|
3311
|
+
height: innerHeight ?? 0
|
|
3312
|
+
});
|
|
3313
|
+
}
|
|
3314
|
+
function ZoomClip({
|
|
3315
|
+
active,
|
|
3316
|
+
chartId,
|
|
3317
|
+
children
|
|
3318
|
+
}) {
|
|
3319
|
+
const {
|
|
3320
|
+
margin,
|
|
3321
|
+
innerWidth,
|
|
3322
|
+
innerHeight
|
|
3323
|
+
} = useContext9(DataContext2);
|
|
3324
|
+
const id = `chart-zoom-clip-${String(chartId ?? "").replace(/[^A-Za-z0-9_-]/g, "")}`;
|
|
3325
|
+
const clip = active && (innerWidth ?? 0) > 0 && (innerHeight ?? 0) > 0;
|
|
3326
|
+
return /* @__PURE__ */ _jsxs4(_Fragment4, {
|
|
3327
|
+
children: [clip && /* @__PURE__ */ _jsx12("defs", {
|
|
3328
|
+
children: /* @__PURE__ */ _jsx12("clipPath", {
|
|
3329
|
+
id,
|
|
3330
|
+
children: /* @__PURE__ */ _jsx12("rect", {
|
|
3331
|
+
x: margin?.left ?? 0,
|
|
3332
|
+
y: margin?.top ?? 0,
|
|
3333
|
+
width: innerWidth,
|
|
3334
|
+
height: innerHeight
|
|
3335
|
+
})
|
|
3336
|
+
})
|
|
3337
|
+
}), /* @__PURE__ */ _jsx12("g", {
|
|
3338
|
+
clipPath: clip ? `url(#${id})` : void 0,
|
|
3339
|
+
children
|
|
3340
|
+
})]
|
|
3341
|
+
});
|
|
3342
|
+
}
|
|
3343
|
+
function ZoomResetButton({
|
|
3344
|
+
onClick
|
|
3345
|
+
}) {
|
|
3346
|
+
const label = __("Reset zoom", "jetpack-charts");
|
|
3347
|
+
return /* @__PURE__ */ _jsx12("button", {
|
|
3348
|
+
type: "button",
|
|
3349
|
+
className: x_zoom_module_default["x-zoom__reset"],
|
|
3350
|
+
onClick,
|
|
3351
|
+
"aria-label": label,
|
|
3352
|
+
title: label,
|
|
3353
|
+
children: /* @__PURE__ */ _jsxs4("svg", {
|
|
3354
|
+
className: x_zoom_module_default["x-zoom__reset-icon"],
|
|
3355
|
+
viewBox: "0 0 24 24",
|
|
3356
|
+
fill: "none",
|
|
3357
|
+
stroke: "currentColor",
|
|
3358
|
+
strokeWidth: "2",
|
|
3359
|
+
strokeLinecap: "round",
|
|
3360
|
+
strokeLinejoin: "round",
|
|
3361
|
+
"aria-hidden": "true",
|
|
3362
|
+
focusable: "false",
|
|
3363
|
+
children: [/* @__PURE__ */ _jsx12("circle", {
|
|
3364
|
+
cx: "10",
|
|
3365
|
+
cy: "10",
|
|
3366
|
+
r: "6"
|
|
3367
|
+
}), /* @__PURE__ */ _jsx12("line", {
|
|
3368
|
+
x1: "15",
|
|
3369
|
+
y1: "15",
|
|
3370
|
+
x2: "20",
|
|
3371
|
+
y2: "20"
|
|
3372
|
+
}), /* @__PURE__ */ _jsx12("line", {
|
|
3373
|
+
x1: "7",
|
|
3374
|
+
y1: "10",
|
|
3375
|
+
x2: "13",
|
|
3376
|
+
y2: "10"
|
|
3377
|
+
})]
|
|
3378
|
+
})
|
|
3379
|
+
});
|
|
3380
|
+
}
|
|
3381
|
+
|
|
3082
3382
|
// src/charts/line-chart/line-chart.module.scss
|
|
3083
3383
|
var line_chart_module_default = {
|
|
3084
3384
|
"line-chart": "a8ccharts-v-oO8E",
|
|
@@ -3099,11 +3399,11 @@ var line_chart_module_default = {
|
|
|
3099
3399
|
};
|
|
3100
3400
|
|
|
3101
3401
|
// src/charts/line-chart/private/line-chart-annotation-label-popover.tsx
|
|
3102
|
-
import { __ } from "@wordpress/i18n";
|
|
3402
|
+
import { __ as __2 } from "@wordpress/i18n";
|
|
3103
3403
|
import { Icon, close } from "@wordpress/icons";
|
|
3104
3404
|
import clsx3 from "clsx";
|
|
3105
|
-
import { useEffect as useEffect7, useId as useId3, useRef as useRef7, useState as
|
|
3106
|
-
import { jsx as
|
|
3405
|
+
import { useEffect as useEffect7, useId as useId3, useRef as useRef7, useState as useState7 } from "react";
|
|
3406
|
+
import { jsx as _jsx13, jsxs as _jsxs5 } from "react/jsx-runtime";
|
|
3107
3407
|
var POPOVER_BUTTON_SIZE = 44;
|
|
3108
3408
|
var LineChartAnnotationLabelWithPopover = ({
|
|
3109
3409
|
title,
|
|
@@ -3114,7 +3414,7 @@ var LineChartAnnotationLabelWithPopover = ({
|
|
|
3114
3414
|
const popoverId = useId3();
|
|
3115
3415
|
const buttonRef = useRef7(null);
|
|
3116
3416
|
const popoverRef = useRef7(null);
|
|
3117
|
-
const [isPositioned, setIsPositioned] =
|
|
3417
|
+
const [isPositioned, setIsPositioned] = useState7(false);
|
|
3118
3418
|
const isBrowserSafari = isSafari();
|
|
3119
3419
|
useEffect7(() => {
|
|
3120
3420
|
const button = buttonRef.current;
|
|
@@ -3140,9 +3440,9 @@ var LineChartAnnotationLabelWithPopover = ({
|
|
|
3140
3440
|
} catch {
|
|
3141
3441
|
}
|
|
3142
3442
|
}, [isBrowserSafari]);
|
|
3143
|
-
return /* @__PURE__ */
|
|
3443
|
+
return /* @__PURE__ */ _jsxs5("div", {
|
|
3144
3444
|
className: line_chart_module_default["line-chart__annotation-label"],
|
|
3145
|
-
children: [/* @__PURE__ */
|
|
3445
|
+
children: [/* @__PURE__ */ _jsx13("button", {
|
|
3146
3446
|
ref: buttonRef,
|
|
3147
3447
|
popovertarget: popoverId,
|
|
3148
3448
|
className: line_chart_module_default["line-chart__annotation-label-trigger-button"],
|
|
@@ -3151,32 +3451,32 @@ var LineChartAnnotationLabelWithPopover = ({
|
|
|
3151
3451
|
height: `${POPOVER_BUTTON_SIZE}px`,
|
|
3152
3452
|
transform: `translate(${POPOVER_BUTTON_SIZE / 2}px, 0)`
|
|
3153
3453
|
},
|
|
3154
|
-
"aria-label": title ||
|
|
3454
|
+
"aria-label": title || __2("View details", "jetpack-charts"),
|
|
3155
3455
|
children: renderLabel({
|
|
3156
3456
|
title,
|
|
3157
3457
|
subtitle
|
|
3158
3458
|
})
|
|
3159
|
-
}), /* @__PURE__ */
|
|
3459
|
+
}), /* @__PURE__ */ _jsx13("div", {
|
|
3160
3460
|
ref: popoverRef,
|
|
3161
3461
|
id: popoverId,
|
|
3162
3462
|
popover: "auto",
|
|
3163
3463
|
className: clsx3(line_chart_module_default["line-chart__annotation-label-popover"], isPositioned && line_chart_module_default["line-chart__annotation-label-popover--visible"], isBrowserSafari && line_chart_module_default["line-chart__annotation-label-popover--safari"]),
|
|
3164
|
-
children: /* @__PURE__ */
|
|
3464
|
+
children: /* @__PURE__ */ _jsxs5(Stack, {
|
|
3165
3465
|
direction: "row",
|
|
3166
3466
|
align: "flex-start",
|
|
3167
3467
|
justify: "space-between",
|
|
3168
|
-
children: [/* @__PURE__ */
|
|
3468
|
+
children: [/* @__PURE__ */ _jsx13("div", {
|
|
3169
3469
|
className: line_chart_module_default["line-chart__annotation-label-popover-content"],
|
|
3170
3470
|
children: renderLabelPopover({
|
|
3171
3471
|
title,
|
|
3172
3472
|
subtitle
|
|
3173
3473
|
})
|
|
3174
|
-
}), /* @__PURE__ */
|
|
3474
|
+
}), /* @__PURE__ */ _jsx13("button", {
|
|
3175
3475
|
popovertarget: popoverId,
|
|
3176
3476
|
popovertargetaction: "hide",
|
|
3177
3477
|
className: line_chart_module_default["line-chart__annotation-label-popover-close-button"],
|
|
3178
|
-
"aria-label":
|
|
3179
|
-
children: /* @__PURE__ */
|
|
3478
|
+
"aria-label": __2("Close", "jetpack-charts"),
|
|
3479
|
+
children: /* @__PURE__ */ _jsx13(Icon, {
|
|
3180
3480
|
icon: close,
|
|
3181
3481
|
size: 16
|
|
3182
3482
|
})
|
|
@@ -3188,9 +3488,9 @@ var LineChartAnnotationLabelWithPopover = ({
|
|
|
3188
3488
|
var line_chart_annotation_label_popover_default = LineChartAnnotationLabelWithPopover;
|
|
3189
3489
|
|
|
3190
3490
|
// src/charts/line-chart/private/line-chart-annotations-overlay.tsx
|
|
3191
|
-
import { DataContext as
|
|
3192
|
-
import { useEffect as useEffect8, useState as
|
|
3193
|
-
import { jsx as
|
|
3491
|
+
import { DataContext as DataContext3 } from "@visx/xychart";
|
|
3492
|
+
import { useEffect as useEffect8, useState as useState8, useCallback as useCallback8 } from "react";
|
|
3493
|
+
import { jsx as _jsx14 } from "react/jsx-runtime";
|
|
3194
3494
|
var LineChartAnnotationsOverlay = ({
|
|
3195
3495
|
children
|
|
3196
3496
|
}) => {
|
|
@@ -3199,16 +3499,16 @@ var LineChartAnnotationsOverlay = ({
|
|
|
3199
3499
|
chartWidth,
|
|
3200
3500
|
chartHeight
|
|
3201
3501
|
} = useSingleChartContext();
|
|
3202
|
-
const [scales, setScales] =
|
|
3203
|
-
const [scalesStable, setScalesStable] =
|
|
3204
|
-
const createScaleSignature =
|
|
3502
|
+
const [scales, setScales] = useState8(null);
|
|
3503
|
+
const [scalesStable, setScalesStable] = useState8(false);
|
|
3504
|
+
const createScaleSignature = useCallback8((scaleData) => {
|
|
3205
3505
|
const xDomain = scaleData.xScale.domain();
|
|
3206
3506
|
const yDomain = scaleData.yScale.domain();
|
|
3207
3507
|
const xRange = scaleData.xScale.range();
|
|
3208
3508
|
const yRange = scaleData.yScale.range();
|
|
3209
3509
|
return `${xDomain.join(",")}-${yDomain.join(",")}-${xRange.join(",")}-${yRange.join(",")}`;
|
|
3210
3510
|
}, []);
|
|
3211
|
-
const getScalesData =
|
|
3511
|
+
const getScalesData = useCallback8(() => {
|
|
3212
3512
|
if (chartRef?.current) {
|
|
3213
3513
|
const scaleData = chartRef.current.getScales();
|
|
3214
3514
|
if (scaleData) {
|
|
@@ -3272,9 +3572,9 @@ var LineChartAnnotationsOverlay = ({
|
|
|
3272
3572
|
width: chartWidth,
|
|
3273
3573
|
height: chartHeight
|
|
3274
3574
|
};
|
|
3275
|
-
return /* @__PURE__ */
|
|
3575
|
+
return /* @__PURE__ */ _jsx14(DataContext3.Provider, {
|
|
3276
3576
|
value: dataContextValue,
|
|
3277
|
-
children: /* @__PURE__ */
|
|
3577
|
+
children: /* @__PURE__ */ _jsx14("svg", {
|
|
3278
3578
|
width: chartWidth,
|
|
3279
3579
|
height: chartHeight,
|
|
3280
3580
|
className: line_chart_module_default["line-chart__annotations-overlay"],
|
|
@@ -3286,10 +3586,10 @@ var line_chart_annotations_overlay_default = LineChartAnnotationsOverlay;
|
|
|
3286
3586
|
|
|
3287
3587
|
// src/charts/line-chart/private/line-chart-annotation.tsx
|
|
3288
3588
|
import { Annotation, CircleSubject, Connector, HtmlLabel, Label, LineSubject } from "@visx/annotation";
|
|
3289
|
-
import { DataContext as
|
|
3589
|
+
import { DataContext as DataContext4 } from "@visx/xychart";
|
|
3290
3590
|
import merge from "deepmerge";
|
|
3291
|
-
import { useContext as
|
|
3292
|
-
import { jsx as
|
|
3591
|
+
import { useContext as useContext10, useRef as useRef8, useEffect as useEffect9, useState as useState9, useMemo as useMemo15 } from "react";
|
|
3592
|
+
import { jsx as _jsx15, jsxs as _jsxs6 } from "react/jsx-runtime";
|
|
3293
3593
|
var ANNOTATION_MAX_WIDTH = 125;
|
|
3294
3594
|
var ANNOTATION_INIT_HEIGHT = 100;
|
|
3295
3595
|
var getLabelPosition = ({
|
|
@@ -3381,9 +3681,9 @@ var LineChartAnnotation = ({
|
|
|
3381
3681
|
const {
|
|
3382
3682
|
xScale,
|
|
3383
3683
|
yScale
|
|
3384
|
-
} =
|
|
3684
|
+
} = useContext10(DataContext4) || {};
|
|
3385
3685
|
const labelRef = useRef8(null);
|
|
3386
|
-
const [height, setHeight] =
|
|
3686
|
+
const [height, setHeight] = useState9(null);
|
|
3387
3687
|
const styles = merge(providerTheme.annotationStyles ?? {}, datumStyles ?? {});
|
|
3388
3688
|
useEffect9(() => {
|
|
3389
3689
|
if (labelRef.current?.getBBox) {
|
|
@@ -3391,7 +3691,7 @@ var LineChartAnnotation = ({
|
|
|
3391
3691
|
setHeight(bbox.height);
|
|
3392
3692
|
}
|
|
3393
3693
|
}, []);
|
|
3394
|
-
const positionData =
|
|
3694
|
+
const positionData = useMemo15(() => {
|
|
3395
3695
|
if (!datum || !datum.date || datum.value == null || !xScale || !yScale) return null;
|
|
3396
3696
|
const x2 = xScale(datum.date);
|
|
3397
3697
|
const y2 = yScale(datum.value);
|
|
@@ -3470,32 +3770,32 @@ var LineChartAnnotation = ({
|
|
|
3470
3770
|
height: labelHeight
|
|
3471
3771
|
} : void 0;
|
|
3472
3772
|
};
|
|
3473
|
-
return /* @__PURE__ */
|
|
3474
|
-
children: /* @__PURE__ */
|
|
3773
|
+
return /* @__PURE__ */ _jsx15("g", {
|
|
3774
|
+
children: /* @__PURE__ */ _jsxs6(Annotation, {
|
|
3475
3775
|
x,
|
|
3476
3776
|
y,
|
|
3477
3777
|
dx,
|
|
3478
3778
|
dy,
|
|
3479
|
-
children: [/* @__PURE__ */
|
|
3779
|
+
children: [/* @__PURE__ */ _jsx15(Connector, {
|
|
3480
3780
|
...styles?.connector
|
|
3481
|
-
}), subjectType === "circle" && /* @__PURE__ */
|
|
3781
|
+
}), subjectType === "circle" && /* @__PURE__ */ _jsx15(CircleSubject, {
|
|
3482
3782
|
...styles?.circleSubject
|
|
3483
|
-
}), subjectType === "line-vertical" && /* @__PURE__ */
|
|
3783
|
+
}), subjectType === "line-vertical" && /* @__PURE__ */ _jsx15(LineSubject, {
|
|
3484
3784
|
min: yMax,
|
|
3485
3785
|
max: yMin,
|
|
3486
3786
|
...styles?.lineSubject,
|
|
3487
3787
|
orientation: "vertical"
|
|
3488
|
-
}), subjectType === "line-horizontal" && /* @__PURE__ */
|
|
3788
|
+
}), subjectType === "line-horizontal" && /* @__PURE__ */ _jsx15(LineSubject, {
|
|
3489
3789
|
min: xMin,
|
|
3490
3790
|
max: xMax,
|
|
3491
3791
|
...styles?.lineSubject,
|
|
3492
3792
|
orientation: "horizontal"
|
|
3493
|
-
}), renderLabel ? /* @__PURE__ */
|
|
3793
|
+
}), renderLabel ? /* @__PURE__ */ _jsx15(HtmlLabel, {
|
|
3494
3794
|
...styles?.label,
|
|
3495
3795
|
...labelPosition,
|
|
3496
|
-
children: /* @__PURE__ */
|
|
3796
|
+
children: /* @__PURE__ */ _jsx15("div", {
|
|
3497
3797
|
style: getSafariHTMLLabelPosition(),
|
|
3498
|
-
children: renderLabelPopover ? /* @__PURE__ */
|
|
3798
|
+
children: renderLabelPopover ? /* @__PURE__ */ _jsx15(line_chart_annotation_label_popover_default, {
|
|
3499
3799
|
title,
|
|
3500
3800
|
subtitle,
|
|
3501
3801
|
renderLabel,
|
|
@@ -3505,9 +3805,9 @@ var LineChartAnnotation = ({
|
|
|
3505
3805
|
subtitle
|
|
3506
3806
|
})
|
|
3507
3807
|
})
|
|
3508
|
-
}) : /* @__PURE__ */
|
|
3808
|
+
}) : /* @__PURE__ */ _jsx15("g", {
|
|
3509
3809
|
ref: labelRef,
|
|
3510
|
-
children: /* @__PURE__ */
|
|
3810
|
+
children: /* @__PURE__ */ _jsx15(Label, {
|
|
3511
3811
|
title,
|
|
3512
3812
|
subtitle,
|
|
3513
3813
|
...styles?.label,
|
|
@@ -3522,8 +3822,8 @@ var LineChartAnnotation = ({
|
|
|
3522
3822
|
var line_chart_annotation_default = LineChartAnnotation;
|
|
3523
3823
|
|
|
3524
3824
|
// src/charts/line-chart/private/line-chart-glyph.tsx
|
|
3525
|
-
import { DataContext as
|
|
3526
|
-
import { useContext as
|
|
3825
|
+
import { DataContext as DataContext5 } from "@visx/xychart";
|
|
3826
|
+
import { useContext as useContext11 } from "react";
|
|
3527
3827
|
var toNumber = (val) => {
|
|
3528
3828
|
const num = typeof val === "number" ? val : parseFloat(val);
|
|
3529
3829
|
return isNaN(num) ? void 0 : num;
|
|
@@ -3540,7 +3840,7 @@ var LineChartGlyph = ({
|
|
|
3540
3840
|
const {
|
|
3541
3841
|
xScale,
|
|
3542
3842
|
yScale
|
|
3543
|
-
} =
|
|
3843
|
+
} = useContext11(DataContext5) || {};
|
|
3544
3844
|
if (!xScale || !yScale) return null;
|
|
3545
3845
|
if (data.data.length === 0) return null;
|
|
3546
3846
|
const point = position2 === "start" ? data.data[0] : data.data[data.data.length - 1];
|
|
@@ -3563,7 +3863,7 @@ var LineChartGlyph = ({
|
|
|
3563
3863
|
var line_chart_glyph_default = LineChartGlyph;
|
|
3564
3864
|
|
|
3565
3865
|
// src/charts/line-chart/line-chart.tsx
|
|
3566
|
-
import { jsx as
|
|
3866
|
+
import { jsx as _jsx16, jsxs as _jsxs7 } from "react/jsx-runtime";
|
|
3567
3867
|
var defaultRenderGlyph = (props) => {
|
|
3568
3868
|
return /* @__PURE__ */ _createElement2(DefaultGlyph, {
|
|
3569
3869
|
...props,
|
|
@@ -3586,20 +3886,20 @@ var renderDefaultTooltip = (params) => {
|
|
|
3586
3886
|
key,
|
|
3587
3887
|
value: datum.value
|
|
3588
3888
|
})).sort((a, b) => b.value - a.value);
|
|
3589
|
-
return /* @__PURE__ */
|
|
3889
|
+
return /* @__PURE__ */ _jsxs7("div", {
|
|
3590
3890
|
className: line_chart_module_default["line-chart__tooltip"],
|
|
3591
|
-
children: [/* @__PURE__ */
|
|
3891
|
+
children: [/* @__PURE__ */ _jsx16("div", {
|
|
3592
3892
|
className: line_chart_module_default["line-chart__tooltip-date"],
|
|
3593
3893
|
children: nearestDatum.date?.toLocaleDateString()
|
|
3594
|
-
}), tooltipPoints.map((point) => /* @__PURE__ */
|
|
3894
|
+
}), tooltipPoints.map((point) => /* @__PURE__ */ _jsxs7(Stack, {
|
|
3595
3895
|
direction: "row",
|
|
3596
3896
|
align: "center",
|
|
3597
3897
|
justify: "space-between",
|
|
3598
3898
|
className: line_chart_module_default["line-chart__tooltip-row"],
|
|
3599
|
-
children: [/* @__PURE__ */
|
|
3899
|
+
children: [/* @__PURE__ */ _jsxs7("span", {
|
|
3600
3900
|
className: line_chart_module_default["line-chart__tooltip-label"],
|
|
3601
3901
|
children: [point.key, ":"]
|
|
3602
|
-
}), /* @__PURE__ */
|
|
3902
|
+
}), /* @__PURE__ */ _jsx16("span", {
|
|
3603
3903
|
className: line_chart_module_default["line-chart__tooltip-value"],
|
|
3604
3904
|
children: formatNumber5(point.value)
|
|
3605
3905
|
})]
|
|
@@ -3618,7 +3918,7 @@ var LineChartScalesRef = ({
|
|
|
3618
3918
|
height,
|
|
3619
3919
|
margin
|
|
3620
3920
|
}) => {
|
|
3621
|
-
const context =
|
|
3921
|
+
const context = useContext12(DataContext6);
|
|
3622
3922
|
useImperativeHandle2(chartRef, () => ({
|
|
3623
3923
|
getScales: () => {
|
|
3624
3924
|
if (!context?.xScale || !context?.yScale) {
|
|
@@ -3663,6 +3963,7 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3663
3963
|
onPointerUp = void 0,
|
|
3664
3964
|
onPointerMove = void 0,
|
|
3665
3965
|
onPointerOut = void 0,
|
|
3966
|
+
zoomable = false,
|
|
3666
3967
|
children,
|
|
3667
3968
|
gridVisibility,
|
|
3668
3969
|
gap = "md"
|
|
@@ -3674,15 +3975,24 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3674
3975
|
const theme = useXYChartTheme(data);
|
|
3675
3976
|
const chartId = useChartId(providedChartId);
|
|
3676
3977
|
const chartRef = useRef9(null);
|
|
3677
|
-
const [selectedIndex, setSelectedIndex] =
|
|
3678
|
-
const [isNavigating, setIsNavigating] =
|
|
3978
|
+
const [selectedIndex, setSelectedIndex] = useState10(void 0);
|
|
3979
|
+
const [isNavigating, setIsNavigating] = useState10(false);
|
|
3679
3980
|
const internalChartRef = useRef9(null);
|
|
3981
|
+
const zoom = useXZoom({
|
|
3982
|
+
enabled: zoomable,
|
|
3983
|
+
chartRef: internalChartRef,
|
|
3984
|
+
userHandlers: {
|
|
3985
|
+
onPointerDown,
|
|
3986
|
+
onPointerMove,
|
|
3987
|
+
onPointerUp
|
|
3988
|
+
}
|
|
3989
|
+
});
|
|
3680
3990
|
const {
|
|
3681
3991
|
legendChildren,
|
|
3682
3992
|
nonLegendChildren
|
|
3683
3993
|
} = useChartChildren(children, "LineChart");
|
|
3684
|
-
const [measuredChartHeight, setMeasuredChartHeight] =
|
|
3685
|
-
const handleContentHeightChange =
|
|
3994
|
+
const [measuredChartHeight, setMeasuredChartHeight] = useState10();
|
|
3995
|
+
const handleContentHeightChange = useCallback9((contentHeight) => {
|
|
3686
3996
|
const chartHeight = contentHeight > 0 ? contentHeight : height;
|
|
3687
3997
|
setMeasuredChartHeight(chartHeight);
|
|
3688
3998
|
}, [height]);
|
|
@@ -3699,7 +4009,7 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3699
4009
|
getElementStyles,
|
|
3700
4010
|
isSeriesVisible
|
|
3701
4011
|
} = useGlobalChartsContext();
|
|
3702
|
-
const seriesWithVisibility =
|
|
4012
|
+
const seriesWithVisibility = useMemo16(() => {
|
|
3703
4013
|
if (!chartId || !legendInteractive) {
|
|
3704
4014
|
return dataSorted.map((series, index) => ({
|
|
3705
4015
|
series,
|
|
@@ -3713,7 +4023,7 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3713
4023
|
isVisible: isSeriesVisible(chartId, series.label)
|
|
3714
4024
|
}));
|
|
3715
4025
|
}, [dataSorted, chartId, isSeriesVisible, legendInteractive]);
|
|
3716
|
-
const allSeriesHidden =
|
|
4026
|
+
const allSeriesHidden = useMemo16(() => {
|
|
3717
4027
|
return seriesWithVisibility.every(({
|
|
3718
4028
|
isVisible
|
|
3719
4029
|
}) => !isVisible);
|
|
@@ -3731,7 +4041,7 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3731
4041
|
chartRef,
|
|
3732
4042
|
totalPoints: dataSorted[0]?.data.length || 0
|
|
3733
4043
|
});
|
|
3734
|
-
const chartOptions =
|
|
4044
|
+
const chartOptions = useMemo16(() => {
|
|
3735
4045
|
const formatter = options?.axis?.x?.tickFormat || getFormatter(dataSorted);
|
|
3736
4046
|
return {
|
|
3737
4047
|
axis: {
|
|
@@ -3752,7 +4062,10 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3752
4062
|
},
|
|
3753
4063
|
xScale: {
|
|
3754
4064
|
type: "time",
|
|
3755
|
-
...options?.xScale
|
|
4065
|
+
...options?.xScale,
|
|
4066
|
+
...zoom.domain ? {
|
|
4067
|
+
domain: zoom.domain
|
|
4068
|
+
} : {}
|
|
3756
4069
|
},
|
|
3757
4070
|
yScale: {
|
|
3758
4071
|
type: "linear",
|
|
@@ -3761,8 +4074,8 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3761
4074
|
...options?.yScale
|
|
3762
4075
|
}
|
|
3763
4076
|
};
|
|
3764
|
-
}, [options, dataSorted, width]);
|
|
3765
|
-
const tooltipRenderGlyph =
|
|
4077
|
+
}, [options, dataSorted, width, zoom.domain]);
|
|
4078
|
+
const tooltipRenderGlyph = useMemo16(() => {
|
|
3766
4079
|
return (props) => {
|
|
3767
4080
|
const seriesIndex = dataSorted.findIndex((series) => series.label === props.key || series.data.includes(props.datum));
|
|
3768
4081
|
const seriesData = dataSorted[seriesIndex];
|
|
@@ -3783,13 +4096,13 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3783
4096
|
const defaultMargin = useChartMargin(height, chartOptions, dataSorted, theme);
|
|
3784
4097
|
const error = validateData(dataSorted);
|
|
3785
4098
|
const isDataValid = !error;
|
|
3786
|
-
const legendOptions =
|
|
4099
|
+
const legendOptions = useMemo16(() => ({
|
|
3787
4100
|
withGlyph: withLegendGlyph,
|
|
3788
4101
|
glyphSize: Math.max(0, toNumber2(glyphStyle?.radius) ?? 4),
|
|
3789
4102
|
renderGlyph
|
|
3790
4103
|
}), [withLegendGlyph, glyphStyle?.radius, renderGlyph]);
|
|
3791
4104
|
const legendItems = useChartLegendItems(dataSorted, legendOptions, legendShape);
|
|
3792
|
-
const chartMetadata =
|
|
4105
|
+
const chartMetadata = useMemo16(() => ({
|
|
3793
4106
|
withGradientFill,
|
|
3794
4107
|
smoothing,
|
|
3795
4108
|
curveType,
|
|
@@ -3810,12 +4123,12 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3810
4123
|
yAccessor: (d) => d?.value
|
|
3811
4124
|
};
|
|
3812
4125
|
if (error) {
|
|
3813
|
-
return /* @__PURE__ */
|
|
4126
|
+
return /* @__PURE__ */ _jsx16("div", {
|
|
3814
4127
|
className: clsx4("line-chart", line_chart_module_default["line-chart"]),
|
|
3815
4128
|
children: error
|
|
3816
4129
|
});
|
|
3817
4130
|
}
|
|
3818
|
-
const legendElement = showLegend && /* @__PURE__ */
|
|
4131
|
+
const legendElement = showLegend && /* @__PURE__ */ _jsx16(Legend, {
|
|
3819
4132
|
orientation: legend.orientation ?? "horizontal",
|
|
3820
4133
|
alignment: legend.alignment ?? "center",
|
|
3821
4134
|
position: legendPosition,
|
|
@@ -3828,14 +4141,14 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3828
4141
|
chartId,
|
|
3829
4142
|
interactive: legendInteractive
|
|
3830
4143
|
});
|
|
3831
|
-
return /* @__PURE__ */
|
|
4144
|
+
return /* @__PURE__ */ _jsx16(SingleChartContext.Provider, {
|
|
3832
4145
|
value: {
|
|
3833
4146
|
chartId,
|
|
3834
4147
|
chartRef: internalChartRef,
|
|
3835
4148
|
chartWidth: width,
|
|
3836
4149
|
chartHeight: measuredChartHeight || 0
|
|
3837
4150
|
},
|
|
3838
|
-
children: /* @__PURE__ */
|
|
4151
|
+
children: /* @__PURE__ */ _jsx16(ChartLayout, {
|
|
3839
4152
|
legendPosition,
|
|
3840
4153
|
legendElement,
|
|
3841
4154
|
legendChildren,
|
|
@@ -3853,16 +4166,21 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3853
4166
|
contentHeight
|
|
3854
4167
|
}) => {
|
|
3855
4168
|
const chartHeight = contentHeight > 0 ? contentHeight : height;
|
|
3856
|
-
return /* @__PURE__ */
|
|
4169
|
+
return /* @__PURE__ */ _jsx16("div", {
|
|
3857
4170
|
role: "grid",
|
|
3858
|
-
"aria-label":
|
|
4171
|
+
"aria-label": __3("Line chart", "jetpack-charts"),
|
|
3859
4172
|
tabIndex: 0,
|
|
3860
4173
|
onKeyDown: onChartKeyDown,
|
|
3861
4174
|
onFocus: onChartFocus,
|
|
3862
4175
|
onBlur: onChartBlur,
|
|
3863
|
-
children: chartHeight > 0 && /* @__PURE__ */
|
|
4176
|
+
children: chartHeight > 0 && /* @__PURE__ */ _jsxs7("div", {
|
|
3864
4177
|
ref: chartRef,
|
|
3865
|
-
|
|
4178
|
+
style: {
|
|
4179
|
+
position: "relative"
|
|
4180
|
+
},
|
|
4181
|
+
children: [zoomable && zoom.domain && /* @__PURE__ */ _jsx16(ZoomResetButton, {
|
|
4182
|
+
onClick: zoom.reset
|
|
4183
|
+
}), /* @__PURE__ */ _jsxs7(XYChart, {
|
|
3866
4184
|
theme,
|
|
3867
4185
|
width,
|
|
3868
4186
|
height: chartHeight,
|
|
@@ -3872,84 +4190,88 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3872
4190
|
},
|
|
3873
4191
|
xScale: chartOptions.xScale,
|
|
3874
4192
|
yScale: chartOptions.yScale,
|
|
3875
|
-
onPointerDown,
|
|
3876
|
-
onPointerUp,
|
|
3877
|
-
onPointerMove,
|
|
4193
|
+
onPointerDown: zoom.handlers.onPointerDown,
|
|
4194
|
+
onPointerUp: zoom.handlers.onPointerUp,
|
|
4195
|
+
onPointerMove: zoom.handlers.onPointerMove,
|
|
3878
4196
|
onPointerOut,
|
|
3879
4197
|
pointerEventsDataKey: "nearest",
|
|
3880
|
-
children: [gridVisibility !== "none" && /* @__PURE__ */
|
|
4198
|
+
children: [gridVisibility !== "none" && /* @__PURE__ */ _jsx16(Grid, {
|
|
3881
4199
|
columns: false,
|
|
3882
4200
|
numTicks: 4
|
|
3883
|
-
}), chartOptions.axis.x.display && /* @__PURE__ */
|
|
4201
|
+
}), chartOptions.axis.x.display && /* @__PURE__ */ _jsx16(Axis, {
|
|
3884
4202
|
...chartOptions.axis.x
|
|
3885
|
-
}), chartOptions.axis.y.display && /* @__PURE__ */
|
|
4203
|
+
}), chartOptions.axis.y.display && /* @__PURE__ */ _jsx16(Axis, {
|
|
3886
4204
|
...chartOptions.axis.y
|
|
3887
|
-
}), allSeriesHidden ? /* @__PURE__ */
|
|
4205
|
+
}), allSeriesHidden ? /* @__PURE__ */ _jsx16(SvgEmptyState, {
|
|
3888
4206
|
x: width / 2,
|
|
3889
4207
|
y: chartHeight / 2,
|
|
3890
4208
|
width,
|
|
3891
4209
|
height: chartHeight,
|
|
3892
|
-
children:
|
|
3893
|
-
}) : null,
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
}
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
} = getElementStyles({
|
|
3906
|
-
data: seriesData,
|
|
3907
|
-
index
|
|
3908
|
-
});
|
|
3909
|
-
const lineProps = {
|
|
3910
|
-
stroke: color,
|
|
3911
|
-
...lineStyles
|
|
3912
|
-
};
|
|
3913
|
-
return /* @__PURE__ */ _jsxs6("g", {
|
|
3914
|
-
children: [withGradientFill && /* @__PURE__ */ _jsx15(LinearGradient, {
|
|
3915
|
-
id: `area-gradient-${chartId}-${index + 1}`,
|
|
3916
|
-
from: color,
|
|
3917
|
-
fromOpacity: 0.4,
|
|
3918
|
-
toOpacity: 0.1,
|
|
3919
|
-
to: providerTheme.backgroundColor,
|
|
3920
|
-
...seriesData.options?.gradient,
|
|
3921
|
-
children: seriesData.options?.gradient?.stops?.map((stop, stopIndex) => /* @__PURE__ */ _jsx15("stop", {
|
|
3922
|
-
offset: stop.offset,
|
|
3923
|
-
stopColor: stop.color || color,
|
|
3924
|
-
stopOpacity: stop.opacity ?? 1
|
|
3925
|
-
}, `${stop.offset}-${stop.color || color}`))
|
|
3926
|
-
}), /* @__PURE__ */ _jsx15(AreaSeries, {
|
|
3927
|
-
dataKey: seriesData?.label,
|
|
3928
|
-
data: seriesData.data,
|
|
3929
|
-
...accessors,
|
|
3930
|
-
fill: withGradientFill ? `url(#area-gradient-${chartId}-${index + 1})` : "transparent",
|
|
3931
|
-
renderLine: true,
|
|
3932
|
-
curve: getCurveType(curveType, smoothing),
|
|
3933
|
-
lineProps
|
|
3934
|
-
}, seriesData?.label), withStartGlyphs && /* @__PURE__ */ _jsx15(line_chart_glyph_default, {
|
|
3935
|
-
index,
|
|
3936
|
-
data: seriesData,
|
|
4210
|
+
children: __3("All series are hidden. Click legend items to show data.", "jetpack-charts")
|
|
4211
|
+
}) : null, /* @__PURE__ */ _jsx16(ZoomClip, {
|
|
4212
|
+
active: zoomable && !!zoom.domain,
|
|
4213
|
+
chartId,
|
|
4214
|
+
children: seriesWithVisibility.map(({
|
|
4215
|
+
series: seriesData,
|
|
4216
|
+
index,
|
|
4217
|
+
isVisible
|
|
4218
|
+
}) => {
|
|
4219
|
+
if (!isVisible) {
|
|
4220
|
+
return null;
|
|
4221
|
+
}
|
|
4222
|
+
const {
|
|
3937
4223
|
color,
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
position: "start"
|
|
3942
|
-
}), withEndGlyphs && /* @__PURE__ */ _jsx15(line_chart_glyph_default, {
|
|
3943
|
-
index,
|
|
4224
|
+
lineStyles,
|
|
4225
|
+
glyph
|
|
4226
|
+
} = getElementStyles({
|
|
3944
4227
|
data: seriesData,
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
}
|
|
3951
|
-
|
|
3952
|
-
|
|
4228
|
+
index
|
|
4229
|
+
});
|
|
4230
|
+
const lineProps = {
|
|
4231
|
+
stroke: color,
|
|
4232
|
+
...lineStyles
|
|
4233
|
+
};
|
|
4234
|
+
return /* @__PURE__ */ _jsxs7("g", {
|
|
4235
|
+
children: [withGradientFill && /* @__PURE__ */ _jsx16(LinearGradient, {
|
|
4236
|
+
id: `area-gradient-${chartId}-${index + 1}`,
|
|
4237
|
+
from: color,
|
|
4238
|
+
fromOpacity: 0.4,
|
|
4239
|
+
toOpacity: 0.1,
|
|
4240
|
+
to: providerTheme.backgroundColor,
|
|
4241
|
+
...seriesData.options?.gradient,
|
|
4242
|
+
children: seriesData.options?.gradient?.stops?.map((stop, stopIndex) => /* @__PURE__ */ _jsx16("stop", {
|
|
4243
|
+
offset: stop.offset,
|
|
4244
|
+
stopColor: stop.color || color,
|
|
4245
|
+
stopOpacity: stop.opacity ?? 1
|
|
4246
|
+
}, `${stop.offset}-${stop.color || color}`))
|
|
4247
|
+
}), /* @__PURE__ */ _jsx16(AreaSeries, {
|
|
4248
|
+
dataKey: seriesData?.label,
|
|
4249
|
+
data: seriesData.data,
|
|
4250
|
+
...accessors,
|
|
4251
|
+
fill: withGradientFill ? `url(#area-gradient-${chartId}-${index + 1})` : "transparent",
|
|
4252
|
+
renderLine: true,
|
|
4253
|
+
curve: getCurveType(curveType, smoothing),
|
|
4254
|
+
lineProps
|
|
4255
|
+
}, seriesData?.label), withStartGlyphs && /* @__PURE__ */ _jsx16(line_chart_glyph_default, {
|
|
4256
|
+
index,
|
|
4257
|
+
data: seriesData,
|
|
4258
|
+
color,
|
|
4259
|
+
renderGlyph: glyph ?? renderGlyph,
|
|
4260
|
+
accessors,
|
|
4261
|
+
glyphStyle,
|
|
4262
|
+
position: "start"
|
|
4263
|
+
}), withEndGlyphs && /* @__PURE__ */ _jsx16(line_chart_glyph_default, {
|
|
4264
|
+
index,
|
|
4265
|
+
data: seriesData,
|
|
4266
|
+
color,
|
|
4267
|
+
renderGlyph: glyph ?? renderGlyph,
|
|
4268
|
+
accessors,
|
|
4269
|
+
glyphStyle,
|
|
4270
|
+
position: "end"
|
|
4271
|
+
})]
|
|
4272
|
+
}, seriesData?.label || index);
|
|
4273
|
+
})
|
|
4274
|
+
}), withTooltips && /* @__PURE__ */ _jsx16(AccessibleTooltip, {
|
|
3953
4275
|
detectBounds: true,
|
|
3954
4276
|
snapTooltipToDatumX: true,
|
|
3955
4277
|
snapTooltipToDatumY: true,
|
|
@@ -3963,13 +4285,15 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3963
4285
|
tooltipRef,
|
|
3964
4286
|
keyboardFocusedClassName: line_chart_module_default["line-chart__tooltip--keyboard-focused"],
|
|
3965
4287
|
series: dataSorted
|
|
3966
|
-
}), /* @__PURE__ */
|
|
4288
|
+
}), /* @__PURE__ */ _jsx16(LineChartScalesRef, {
|
|
3967
4289
|
chartRef: internalChartRef,
|
|
3968
4290
|
width,
|
|
3969
4291
|
height,
|
|
3970
4292
|
margin
|
|
4293
|
+
}), zoomable && /* @__PURE__ */ _jsx16(ZoomSelectionRect, {
|
|
4294
|
+
drag: zoom.drag
|
|
3971
4295
|
})]
|
|
3972
|
-
})
|
|
4296
|
+
})]
|
|
3973
4297
|
})
|
|
3974
4298
|
});
|
|
3975
4299
|
}
|
|
@@ -3977,15 +4301,15 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3977
4301
|
});
|
|
3978
4302
|
});
|
|
3979
4303
|
var LineChartWithProvider = /* @__PURE__ */ forwardRef4((props, ref) => {
|
|
3980
|
-
const existingContext =
|
|
4304
|
+
const existingContext = useContext12(GlobalChartsContext);
|
|
3981
4305
|
if (existingContext) {
|
|
3982
|
-
return /* @__PURE__ */
|
|
4306
|
+
return /* @__PURE__ */ _jsx16(LineChartInternal, {
|
|
3983
4307
|
...props,
|
|
3984
4308
|
ref
|
|
3985
4309
|
});
|
|
3986
4310
|
}
|
|
3987
|
-
return /* @__PURE__ */
|
|
3988
|
-
children: /* @__PURE__ */
|
|
4311
|
+
return /* @__PURE__ */ _jsx16(GlobalChartsProvider, {
|
|
4312
|
+
children: /* @__PURE__ */ _jsx16(LineChartInternal, {
|
|
3989
4313
|
...props,
|
|
3990
4314
|
ref
|
|
3991
4315
|
})
|
|
@@ -4011,31 +4335,31 @@ var area_chart_module_default = {
|
|
|
4011
4335
|
};
|
|
4012
4336
|
|
|
4013
4337
|
// src/charts/area-chart/private/validate-data.ts
|
|
4014
|
-
import { __ as
|
|
4338
|
+
import { __ as __4 } from "@wordpress/i18n";
|
|
4015
4339
|
var validateData2 = (data) => {
|
|
4016
|
-
if (!data?.length) return
|
|
4340
|
+
if (!data?.length) return __4("No data available", "jetpack-charts");
|
|
4017
4341
|
const hasEmptySeries = data.some((series) => !series.data?.length);
|
|
4018
|
-
if (hasEmptySeries) return
|
|
4342
|
+
if (hasEmptySeries) return __4("No data available", "jetpack-charts");
|
|
4019
4343
|
const hasInvalidData = data.some(
|
|
4020
4344
|
(series) => series.data.some(
|
|
4021
4345
|
(point) => isNaN(point.value) || point.value === null || point.value === void 0 || "date" in point && point.date && isNaN(point.date.getTime())
|
|
4022
4346
|
)
|
|
4023
4347
|
);
|
|
4024
|
-
if (hasInvalidData) return
|
|
4348
|
+
if (hasInvalidData) return __4("Invalid data", "jetpack-charts");
|
|
4025
4349
|
return null;
|
|
4026
4350
|
};
|
|
4027
4351
|
|
|
4028
4352
|
// src/charts/area-chart/private/overlays.tsx
|
|
4029
|
-
import { DataContext as
|
|
4030
|
-
import { useContext as
|
|
4031
|
-
import { jsx as
|
|
4353
|
+
import { DataContext as DataContext7, TooltipContext as TooltipContext2 } from "@visx/xychart";
|
|
4354
|
+
import { useContext as useContext13, useImperativeHandle as useImperativeHandle3 } from "react";
|
|
4355
|
+
import { jsx as _jsx17 } from "react/jsx-runtime";
|
|
4032
4356
|
var AreaChartScalesRef = ({
|
|
4033
4357
|
chartRef,
|
|
4034
4358
|
width,
|
|
4035
4359
|
height,
|
|
4036
4360
|
margin
|
|
4037
4361
|
}) => {
|
|
4038
|
-
const context =
|
|
4362
|
+
const context = useContext13(DataContext7);
|
|
4039
4363
|
useImperativeHandle3(chartRef, () => ({
|
|
4040
4364
|
getScales: () => {
|
|
4041
4365
|
if (!context?.xScale || !context?.yScale) return null;
|
|
@@ -4059,8 +4383,8 @@ var HoverGlyphs = ({
|
|
|
4059
4383
|
getElementStyles,
|
|
4060
4384
|
strokeColor
|
|
4061
4385
|
}) => {
|
|
4062
|
-
const dataContext =
|
|
4063
|
-
const tooltipContext =
|
|
4386
|
+
const dataContext = useContext13(DataContext7);
|
|
4387
|
+
const tooltipContext = useContext13(TooltipContext2);
|
|
4064
4388
|
const xScale = dataContext?.xScale;
|
|
4065
4389
|
const yScale = dataContext?.yScale;
|
|
4066
4390
|
const tooltipOpen = tooltipContext?.tooltipOpen;
|
|
@@ -4093,7 +4417,7 @@ var HoverGlyphs = ({
|
|
|
4093
4417
|
data: series,
|
|
4094
4418
|
index
|
|
4095
4419
|
});
|
|
4096
|
-
circles.push(/* @__PURE__ */
|
|
4420
|
+
circles.push(/* @__PURE__ */ _jsx17("circle", {
|
|
4097
4421
|
cx: xPx,
|
|
4098
4422
|
cy: yPx,
|
|
4099
4423
|
r: 4,
|
|
@@ -4104,7 +4428,7 @@ var HoverGlyphs = ({
|
|
|
4104
4428
|
}, series.label || index));
|
|
4105
4429
|
}
|
|
4106
4430
|
if (circles.length === 0) return null;
|
|
4107
|
-
return /* @__PURE__ */
|
|
4431
|
+
return /* @__PURE__ */ _jsx17("g", {
|
|
4108
4432
|
pointerEvents: "none",
|
|
4109
4433
|
className: "area-chart__hover-glyphs",
|
|
4110
4434
|
children: circles
|
|
@@ -4112,7 +4436,7 @@ var HoverGlyphs = ({
|
|
|
4112
4436
|
};
|
|
4113
4437
|
|
|
4114
4438
|
// src/charts/area-chart/area-chart.tsx
|
|
4115
|
-
import { jsx as
|
|
4439
|
+
import { jsx as _jsx18, jsxs as _jsxs8, Fragment as _Fragment5 } from "react/jsx-runtime";
|
|
4116
4440
|
var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
4117
4441
|
data,
|
|
4118
4442
|
chartId: providedChartId,
|
|
@@ -4137,6 +4461,8 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4137
4461
|
onPointerUp,
|
|
4138
4462
|
onPointerMove,
|
|
4139
4463
|
onPointerOut,
|
|
4464
|
+
zoomable = false,
|
|
4465
|
+
rescaleYOnLegendToggle = true,
|
|
4140
4466
|
children,
|
|
4141
4467
|
gridVisibility,
|
|
4142
4468
|
gap = "md"
|
|
@@ -4148,15 +4474,24 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4148
4474
|
const theme = useXYChartTheme(data);
|
|
4149
4475
|
const chartId = useChartId(providedChartId);
|
|
4150
4476
|
const chartRef = useRef10(null);
|
|
4151
|
-
const [selectedIndex, setSelectedIndex] =
|
|
4152
|
-
const [isNavigating, setIsNavigating] =
|
|
4477
|
+
const [selectedIndex, setSelectedIndex] = useState11(void 0);
|
|
4478
|
+
const [isNavigating, setIsNavigating] = useState11(false);
|
|
4153
4479
|
const internalChartRef = useRef10(null);
|
|
4480
|
+
const zoom = useXZoom({
|
|
4481
|
+
enabled: zoomable,
|
|
4482
|
+
chartRef: internalChartRef,
|
|
4483
|
+
userHandlers: {
|
|
4484
|
+
onPointerDown,
|
|
4485
|
+
onPointerMove,
|
|
4486
|
+
onPointerUp
|
|
4487
|
+
}
|
|
4488
|
+
});
|
|
4154
4489
|
const {
|
|
4155
4490
|
legendChildren,
|
|
4156
4491
|
nonLegendChildren
|
|
4157
4492
|
} = useChartChildren(children, "AreaChart");
|
|
4158
|
-
const [measuredChartHeight, setMeasuredChartHeight] =
|
|
4159
|
-
const handleContentHeightChange =
|
|
4493
|
+
const [measuredChartHeight, setMeasuredChartHeight] = useState11();
|
|
4494
|
+
const handleContentHeightChange = useCallback10((contentHeight) => {
|
|
4160
4495
|
const chartHeight = contentHeight > 0 ? contentHeight : height;
|
|
4161
4496
|
setMeasuredChartHeight(chartHeight);
|
|
4162
4497
|
}, [height]);
|
|
@@ -4173,7 +4508,7 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4173
4508
|
getElementStyles,
|
|
4174
4509
|
isSeriesVisible
|
|
4175
4510
|
} = useGlobalChartsContext();
|
|
4176
|
-
const seriesWithVisibility =
|
|
4511
|
+
const seriesWithVisibility = useMemo17(() => {
|
|
4177
4512
|
if (!chartId || !legendInteractive) {
|
|
4178
4513
|
return dataSorted.map((series, index) => ({
|
|
4179
4514
|
series,
|
|
@@ -4187,7 +4522,7 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4187
4522
|
isVisible: isSeriesVisible(chartId, series.label)
|
|
4188
4523
|
}));
|
|
4189
4524
|
}, [dataSorted, chartId, isSeriesVisible, legendInteractive]);
|
|
4190
|
-
const allSeriesHidden =
|
|
4525
|
+
const allSeriesHidden = useMemo17(() => seriesWithVisibility.every(({
|
|
4191
4526
|
isVisible
|
|
4192
4527
|
}) => !isVisible), [seriesWithVisibility]);
|
|
4193
4528
|
const {
|
|
@@ -4203,8 +4538,8 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4203
4538
|
chartRef,
|
|
4204
4539
|
totalPoints: dataSorted[0]?.data.length || 0
|
|
4205
4540
|
});
|
|
4206
|
-
const fixedYDomain =
|
|
4207
|
-
if (!legendInteractive || !dataSorted.length || !dataSorted[0].data.length || stacked && stackOffset !== "none") {
|
|
4541
|
+
const fixedYDomain = useMemo17(() => {
|
|
4542
|
+
if (rescaleYOnLegendToggle || !legendInteractive || !dataSorted.length || !dataSorted[0].data.length || stacked && stackOffset !== "none") {
|
|
4208
4543
|
return void 0;
|
|
4209
4544
|
}
|
|
4210
4545
|
if (stacked) {
|
|
@@ -4238,8 +4573,8 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4238
4573
|
}
|
|
4239
4574
|
if (max === -Infinity) return void 0;
|
|
4240
4575
|
return [Math.min(0, min), max];
|
|
4241
|
-
}, [dataSorted, stacked, stackOffset, legendInteractive]);
|
|
4242
|
-
const chartOptions =
|
|
4576
|
+
}, [dataSorted, stacked, stackOffset, legendInteractive, rescaleYOnLegendToggle]);
|
|
4577
|
+
const chartOptions = useMemo17(() => {
|
|
4243
4578
|
const formatter = options?.axis?.x?.tickFormat || getFormatter(dataSorted);
|
|
4244
4579
|
return {
|
|
4245
4580
|
axis: {
|
|
@@ -4260,7 +4595,10 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4260
4595
|
},
|
|
4261
4596
|
xScale: {
|
|
4262
4597
|
type: "time",
|
|
4263
|
-
...options?.xScale
|
|
4598
|
+
...options?.xScale,
|
|
4599
|
+
...zoom.domain ? {
|
|
4600
|
+
domain: zoom.domain
|
|
4601
|
+
} : {}
|
|
4264
4602
|
},
|
|
4265
4603
|
yScale: {
|
|
4266
4604
|
type: "linear",
|
|
@@ -4273,16 +4611,16 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4273
4611
|
...options?.yScale
|
|
4274
4612
|
}
|
|
4275
4613
|
};
|
|
4276
|
-
}, [options, dataSorted, width, stacked, fixedYDomain]);
|
|
4614
|
+
}, [options, dataSorted, width, stacked, fixedYDomain, zoom.domain]);
|
|
4277
4615
|
const defaultMargin = useChartMargin(height, chartOptions, dataSorted, theme);
|
|
4278
4616
|
const error = validateData2(dataSorted);
|
|
4279
4617
|
const isDataValid = !error;
|
|
4280
|
-
const legendOptions =
|
|
4618
|
+
const legendOptions = useMemo17(() => ({
|
|
4281
4619
|
withGlyph: false,
|
|
4282
4620
|
glyphSize: 0
|
|
4283
4621
|
}), []);
|
|
4284
4622
|
const legendItems = useChartLegendItems(dataSorted, legendOptions, legendShape);
|
|
4285
|
-
const chartMetadata =
|
|
4623
|
+
const chartMetadata = useMemo17(() => ({
|
|
4286
4624
|
stacked,
|
|
4287
4625
|
stackOffset,
|
|
4288
4626
|
smoothing,
|
|
@@ -4301,9 +4639,9 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4301
4639
|
xAccessor: (d) => d?.date,
|
|
4302
4640
|
yAccessor: (d) => d?.value
|
|
4303
4641
|
};
|
|
4304
|
-
const zeroYAccessor =
|
|
4305
|
-
const visibleLabels =
|
|
4306
|
-
const filteredRenderTooltip =
|
|
4642
|
+
const zeroYAccessor = useCallback10(() => 0, []);
|
|
4643
|
+
const visibleLabels = useMemo17(() => new Set(seriesWithVisibility.filter((s) => s.isVisible).map((s) => s.series.label)), [seriesWithVisibility]);
|
|
4644
|
+
const filteredRenderTooltip = useCallback10((params) => {
|
|
4307
4645
|
if (!legendInteractive) return renderTooltip(params);
|
|
4308
4646
|
const datumByKey = params?.tooltipData?.datumByKey;
|
|
4309
4647
|
if (!datumByKey) return renderTooltip(params);
|
|
@@ -4326,12 +4664,12 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4326
4664
|
const resolvedFillOpacity = fillOpacity ?? (stacked ? 0.85 : 0.4);
|
|
4327
4665
|
const resolvedWithStroke = withStroke ?? !stacked;
|
|
4328
4666
|
if (error) {
|
|
4329
|
-
return /* @__PURE__ */
|
|
4667
|
+
return /* @__PURE__ */ _jsx18("div", {
|
|
4330
4668
|
className: clsx5("area-chart", area_chart_module_default["area-chart"]),
|
|
4331
4669
|
children: error
|
|
4332
4670
|
});
|
|
4333
4671
|
}
|
|
4334
|
-
const legendElement = showLegend && /* @__PURE__ */
|
|
4672
|
+
const legendElement = showLegend && /* @__PURE__ */ _jsx18(Legend, {
|
|
4335
4673
|
orientation: legend.orientation ?? "horizontal",
|
|
4336
4674
|
alignment: legend.alignment ?? "center",
|
|
4337
4675
|
position: legendPosition,
|
|
@@ -4360,7 +4698,7 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4360
4698
|
data: seriesData,
|
|
4361
4699
|
index
|
|
4362
4700
|
});
|
|
4363
|
-
return /* @__PURE__ */
|
|
4701
|
+
return /* @__PURE__ */ _jsx18(AnimatedAreaSeries, {
|
|
4364
4702
|
dataKey: seriesData?.label,
|
|
4365
4703
|
data: seriesData.data,
|
|
4366
4704
|
xAccessor: accessors.xAccessor,
|
|
@@ -4377,14 +4715,14 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4377
4715
|
}
|
|
4378
4716
|
}, seriesData?.label || index);
|
|
4379
4717
|
};
|
|
4380
|
-
return /* @__PURE__ */
|
|
4718
|
+
return /* @__PURE__ */ _jsx18(SingleChartContext.Provider, {
|
|
4381
4719
|
value: {
|
|
4382
4720
|
chartId,
|
|
4383
4721
|
chartRef: internalChartRef,
|
|
4384
4722
|
chartWidth: width,
|
|
4385
4723
|
chartHeight: measuredChartHeight || 0
|
|
4386
4724
|
},
|
|
4387
|
-
children: /* @__PURE__ */
|
|
4725
|
+
children: /* @__PURE__ */ _jsx18(ChartLayout, {
|
|
4388
4726
|
legendPosition,
|
|
4389
4727
|
legendElement,
|
|
4390
4728
|
legendChildren,
|
|
@@ -4402,16 +4740,21 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4402
4740
|
contentHeight
|
|
4403
4741
|
}) => {
|
|
4404
4742
|
const chartHeight = contentHeight > 0 ? contentHeight : height;
|
|
4405
|
-
return /* @__PURE__ */
|
|
4743
|
+
return /* @__PURE__ */ _jsx18("div", {
|
|
4406
4744
|
role: "grid",
|
|
4407
|
-
"aria-label":
|
|
4745
|
+
"aria-label": __5("Area chart", "jetpack-charts"),
|
|
4408
4746
|
tabIndex: 0,
|
|
4409
4747
|
onKeyDown: onChartKeyDown,
|
|
4410
4748
|
onFocus: onChartFocus,
|
|
4411
4749
|
onBlur: onChartBlur,
|
|
4412
|
-
children: chartHeight > 0 && /* @__PURE__ */
|
|
4750
|
+
children: chartHeight > 0 && /* @__PURE__ */ _jsxs8("div", {
|
|
4413
4751
|
ref: chartRef,
|
|
4414
|
-
|
|
4752
|
+
style: {
|
|
4753
|
+
position: "relative"
|
|
4754
|
+
},
|
|
4755
|
+
children: [zoomable && zoom.domain && /* @__PURE__ */ _jsx18(ZoomResetButton, {
|
|
4756
|
+
onClick: zoom.reset
|
|
4757
|
+
}), /* @__PURE__ */ _jsxs8(XYChart2, {
|
|
4415
4758
|
theme,
|
|
4416
4759
|
width,
|
|
4417
4760
|
height: chartHeight,
|
|
@@ -4421,31 +4764,35 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4421
4764
|
},
|
|
4422
4765
|
xScale: chartOptions.xScale,
|
|
4423
4766
|
yScale: chartOptions.yScale,
|
|
4424
|
-
onPointerDown,
|
|
4425
|
-
onPointerUp,
|
|
4426
|
-
onPointerMove,
|
|
4767
|
+
onPointerDown: zoom.handlers.onPointerDown,
|
|
4768
|
+
onPointerUp: zoom.handlers.onPointerUp,
|
|
4769
|
+
onPointerMove: zoom.handlers.onPointerMove,
|
|
4427
4770
|
onPointerOut,
|
|
4428
4771
|
pointerEventsDataKey: "nearest",
|
|
4429
|
-
children: [gridVisibility !== "none" && /* @__PURE__ */
|
|
4772
|
+
children: [gridVisibility !== "none" && /* @__PURE__ */ _jsx18(Grid2, {
|
|
4430
4773
|
columns: false,
|
|
4431
4774
|
numTicks: 4
|
|
4432
|
-
}), chartOptions.axis.x.display && /* @__PURE__ */
|
|
4775
|
+
}), chartOptions.axis.x.display && /* @__PURE__ */ _jsx18(Axis2, {
|
|
4433
4776
|
...chartOptions.axis.x
|
|
4434
|
-
}), chartOptions.axis.y.display && /* @__PURE__ */
|
|
4777
|
+
}), chartOptions.axis.y.display && /* @__PURE__ */ _jsx18(Axis2, {
|
|
4435
4778
|
...chartOptions.axis.y
|
|
4436
|
-
}), allSeriesHidden ? /* @__PURE__ */
|
|
4779
|
+
}), allSeriesHidden ? /* @__PURE__ */ _jsx18(SvgEmptyState, {
|
|
4437
4780
|
x: width / 2,
|
|
4438
4781
|
y: chartHeight / 2,
|
|
4439
4782
|
width,
|
|
4440
4783
|
height: chartHeight,
|
|
4441
|
-
children:
|
|
4442
|
-
}) : null,
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4784
|
+
children: __5("All series are hidden. Click legend items to show data.", "jetpack-charts")
|
|
4785
|
+
}) : null, /* @__PURE__ */ _jsxs8(ZoomClip, {
|
|
4786
|
+
active: zoomable,
|
|
4787
|
+
chartId,
|
|
4788
|
+
children: [!allSeriesHidden && stacked && /* @__PURE__ */ _jsx18(AnimatedAreaStack, {
|
|
4789
|
+
curve,
|
|
4790
|
+
offset: stackOffset,
|
|
4791
|
+
renderLine: resolvedWithStroke,
|
|
4792
|
+
children: seriesWithVisibility.map(renderSeries)
|
|
4793
|
+
}), !allSeriesHidden && !stacked && seriesWithVisibility.map(renderSeries)]
|
|
4794
|
+
}), withTooltips && /* @__PURE__ */ _jsxs8(_Fragment5, {
|
|
4795
|
+
children: [/* @__PURE__ */ _jsx18(AccessibleTooltip, {
|
|
4449
4796
|
detectBounds: true,
|
|
4450
4797
|
snapTooltipToDatumX: true,
|
|
4451
4798
|
snapTooltipToDatumY: !stacked,
|
|
@@ -4456,20 +4803,22 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4456
4803
|
tooltipRef,
|
|
4457
4804
|
keyboardFocusedClassName: area_chart_module_default["area-chart__tooltip--keyboard-focused"],
|
|
4458
4805
|
series: dataSorted
|
|
4459
|
-
}), /* @__PURE__ */
|
|
4806
|
+
}), /* @__PURE__ */ _jsx18(HoverGlyphs, {
|
|
4460
4807
|
visibleSeries,
|
|
4461
4808
|
stacked,
|
|
4462
4809
|
stackOffset,
|
|
4463
4810
|
getElementStyles,
|
|
4464
4811
|
strokeColor: providerTheme.backgroundColor
|
|
4465
4812
|
})]
|
|
4466
|
-
}), /* @__PURE__ */
|
|
4813
|
+
}), /* @__PURE__ */ _jsx18(AreaChartScalesRef, {
|
|
4467
4814
|
chartRef: internalChartRef,
|
|
4468
4815
|
width,
|
|
4469
4816
|
height: height || chartHeight,
|
|
4470
4817
|
margin
|
|
4818
|
+
}), zoomable && /* @__PURE__ */ _jsx18(ZoomSelectionRect, {
|
|
4819
|
+
drag: zoom.drag
|
|
4471
4820
|
})]
|
|
4472
|
-
})
|
|
4821
|
+
})]
|
|
4473
4822
|
})
|
|
4474
4823
|
});
|
|
4475
4824
|
}
|
|
@@ -4477,15 +4826,15 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4477
4826
|
});
|
|
4478
4827
|
});
|
|
4479
4828
|
var AreaChartWithProvider = /* @__PURE__ */ forwardRef5((props, ref) => {
|
|
4480
|
-
const existingContext =
|
|
4829
|
+
const existingContext = useContext14(GlobalChartsContext);
|
|
4481
4830
|
if (existingContext) {
|
|
4482
|
-
return /* @__PURE__ */
|
|
4831
|
+
return /* @__PURE__ */ _jsx18(AreaChartInternal, {
|
|
4483
4832
|
...props,
|
|
4484
4833
|
ref
|
|
4485
4834
|
});
|
|
4486
4835
|
}
|
|
4487
|
-
return /* @__PURE__ */
|
|
4488
|
-
children: /* @__PURE__ */
|
|
4836
|
+
return /* @__PURE__ */ _jsx18(GlobalChartsProvider, {
|
|
4837
|
+
children: /* @__PURE__ */ _jsx18(AreaChartInternal, {
|
|
4489
4838
|
...props,
|
|
4490
4839
|
ref
|
|
4491
4840
|
})
|
|
@@ -4503,9 +4852,9 @@ var AreaChartResponsive = attachSubComponents(withResponsive(AreaChartWithProvid
|
|
|
4503
4852
|
import { formatNumber as formatNumber6 } from "@automattic/number-formatters";
|
|
4504
4853
|
import { PatternLines, PatternCircles, PatternWaves, PatternHexagons } from "@visx/pattern";
|
|
4505
4854
|
import { Axis as Axis3, BarSeries, BarGroup, Grid as Grid3, XYChart as XYChart3 } from "@visx/xychart";
|
|
4506
|
-
import { __ as
|
|
4855
|
+
import { __ as __6 } from "@wordpress/i18n";
|
|
4507
4856
|
import clsx6 from "clsx";
|
|
4508
|
-
import { useCallback as
|
|
4857
|
+
import { useCallback as useCallback11, useContext as useContext16, useState as useState12, useRef as useRef11, useMemo as useMemo19 } from "react";
|
|
4509
4858
|
|
|
4510
4859
|
// src/charts/bar-chart/bar-chart.module.scss
|
|
4511
4860
|
var bar_chart_module_default = {
|
|
@@ -4518,12 +4867,12 @@ var bar_chart_module_default = {
|
|
|
4518
4867
|
|
|
4519
4868
|
// src/charts/bar-chart/private/use-bar-chart-options.ts
|
|
4520
4869
|
import { formatNumberCompact as formatNumberCompact4 } from "@automattic/number-formatters";
|
|
4521
|
-
import { useMemo as
|
|
4870
|
+
import { useMemo as useMemo18 } from "react";
|
|
4522
4871
|
|
|
4523
4872
|
// src/charts/bar-chart/private/truncated-tick-component.tsx
|
|
4524
|
-
import { DataContext as
|
|
4525
|
-
import { useContext as
|
|
4526
|
-
import { jsx as
|
|
4873
|
+
import { DataContext as DataContext8 } from "@visx/xychart";
|
|
4874
|
+
import { useContext as useContext15 } from "react";
|
|
4875
|
+
import { jsx as _jsx19 } from "react/jsx-runtime";
|
|
4527
4876
|
var getScaleBandwidth = (scale) => {
|
|
4528
4877
|
return scale && "bandwidth" in scale ? scale.bandwidth() ?? 0 : 0;
|
|
4529
4878
|
};
|
|
@@ -4541,7 +4890,7 @@ var TruncatedTickComponent = ({
|
|
|
4541
4890
|
const {
|
|
4542
4891
|
xScale,
|
|
4543
4892
|
yScale
|
|
4544
|
-
} =
|
|
4893
|
+
} = useContext15(DataContext8) || {};
|
|
4545
4894
|
const scale = axis === "x" ? xScale : yScale;
|
|
4546
4895
|
const bandwidth = getScaleBandwidth(scale);
|
|
4547
4896
|
const maxWidth = Math.max(bandwidth, MIN_TICK_LABEL_WIDTH);
|
|
@@ -4597,13 +4946,13 @@ var TruncatedTickComponent = ({
|
|
|
4597
4946
|
cursor: "default",
|
|
4598
4947
|
pointerEvents: "auto"
|
|
4599
4948
|
};
|
|
4600
|
-
return /* @__PURE__ */
|
|
4949
|
+
return /* @__PURE__ */ _jsx19("foreignObject", {
|
|
4601
4950
|
x: x + xOffset,
|
|
4602
4951
|
y,
|
|
4603
4952
|
width: maxWidth,
|
|
4604
4953
|
height: 0,
|
|
4605
4954
|
overflow: "visible",
|
|
4606
|
-
children: /* @__PURE__ */
|
|
4955
|
+
children: /* @__PURE__ */ _jsx19("div", {
|
|
4607
4956
|
style: textStyles,
|
|
4608
4957
|
title: formattedValue,
|
|
4609
4958
|
children: formattedValue
|
|
@@ -4611,7 +4960,7 @@ var TruncatedTickComponent = ({
|
|
|
4611
4960
|
});
|
|
4612
4961
|
};
|
|
4613
4962
|
var createTruncatedTickComponent = (axis) => (props) => {
|
|
4614
|
-
return /* @__PURE__ */
|
|
4963
|
+
return /* @__PURE__ */ _jsx19(TruncatedTickComponent, {
|
|
4615
4964
|
...props,
|
|
4616
4965
|
axis
|
|
4617
4966
|
});
|
|
@@ -4631,7 +4980,7 @@ var getGroupPadding = (scale) => {
|
|
|
4631
4980
|
return typeof scale.paddingInner === "number" ? scale.paddingInner : 0;
|
|
4632
4981
|
};
|
|
4633
4982
|
function useBarChartOptions(data, horizontal, options = {}) {
|
|
4634
|
-
const defaultOptions =
|
|
4983
|
+
const defaultOptions = useMemo18(() => {
|
|
4635
4984
|
const bandScale = {
|
|
4636
4985
|
type: "band",
|
|
4637
4986
|
padding: 0.2,
|
|
@@ -4672,7 +5021,7 @@ function useBarChartOptions(data, horizontal, options = {}) {
|
|
|
4672
5021
|
}
|
|
4673
5022
|
};
|
|
4674
5023
|
}, [data]);
|
|
4675
|
-
return
|
|
5024
|
+
return useMemo18(() => {
|
|
4676
5025
|
const orientationKey = horizontal ? "horizontal" : "vertical";
|
|
4677
5026
|
const {
|
|
4678
5027
|
xTickFormat,
|
|
@@ -4724,7 +5073,7 @@ function useBarChartOptions(data, horizontal, options = {}) {
|
|
|
4724
5073
|
}
|
|
4725
5074
|
|
|
4726
5075
|
// src/charts/bar-chart/bar-chart.tsx
|
|
4727
|
-
import { jsx as
|
|
5076
|
+
import { jsx as _jsx20, jsxs as _jsxs9, Fragment as _Fragment6 } from "react/jsx-runtime";
|
|
4728
5077
|
var validateData3 = (data) => {
|
|
4729
5078
|
if (!data?.length) return "No data available";
|
|
4730
5079
|
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()))));
|
|
@@ -4769,13 +5118,13 @@ var BarChartInternal = ({
|
|
|
4769
5118
|
legendChildren,
|
|
4770
5119
|
nonLegendChildren
|
|
4771
5120
|
} = useChartChildren(children, "BarChart");
|
|
4772
|
-
const [measuredChartHeight, setMeasuredChartHeight] =
|
|
4773
|
-
const handleContentHeightChange =
|
|
5121
|
+
const [measuredChartHeight, setMeasuredChartHeight] = useState12();
|
|
5122
|
+
const handleContentHeightChange = useCallback11((contentHeight) => {
|
|
4774
5123
|
const chartHeight = contentHeight > 0 ? contentHeight : height;
|
|
4775
5124
|
setMeasuredChartHeight(chartHeight);
|
|
4776
5125
|
}, [height]);
|
|
4777
|
-
const [selectedIndex, setSelectedIndex] =
|
|
4778
|
-
const [isNavigating, setIsNavigating] =
|
|
5126
|
+
const [selectedIndex, setSelectedIndex] = useState12(void 0);
|
|
5127
|
+
const [isNavigating, setIsNavigating] = useState12(false);
|
|
4779
5128
|
const totalPoints = Math.max(0, ...data.map((series) => series.data?.length || 0)) * data.length;
|
|
4780
5129
|
const {
|
|
4781
5130
|
tooltipRef,
|
|
@@ -4794,7 +5143,7 @@ var BarChartInternal = ({
|
|
|
4794
5143
|
getElementStyles,
|
|
4795
5144
|
isSeriesVisible
|
|
4796
5145
|
} = useGlobalChartsContext();
|
|
4797
|
-
const seriesWithVisibility =
|
|
5146
|
+
const seriesWithVisibility = useMemo19(() => {
|
|
4798
5147
|
if (!chartId || !legendInteractive) {
|
|
4799
5148
|
return dataWithVisibleZeros.map((series, index) => ({
|
|
4800
5149
|
series,
|
|
@@ -4808,38 +5157,38 @@ var BarChartInternal = ({
|
|
|
4808
5157
|
isVisible: isSeriesVisible(chartId, series.label)
|
|
4809
5158
|
}));
|
|
4810
5159
|
}, [dataWithVisibleZeros, chartId, isSeriesVisible, legendInteractive]);
|
|
4811
|
-
const allSeriesHidden =
|
|
5160
|
+
const allSeriesHidden = useMemo19(() => {
|
|
4812
5161
|
return seriesWithVisibility.every(({
|
|
4813
5162
|
isVisible
|
|
4814
5163
|
}) => !isVisible);
|
|
4815
5164
|
}, [seriesWithVisibility]);
|
|
4816
|
-
const getBarBackground =
|
|
5165
|
+
const getBarBackground = useCallback11((index) => () => withPatterns ? `url(#${getPatternId(chartId, index)})` : getElementStyles({
|
|
4817
5166
|
data: dataSorted[index],
|
|
4818
5167
|
index
|
|
4819
5168
|
}).color, [withPatterns, getElementStyles, dataSorted, chartId]);
|
|
4820
|
-
const renderDefaultTooltip2 =
|
|
5169
|
+
const renderDefaultTooltip2 = useCallback11(({
|
|
4821
5170
|
tooltipData
|
|
4822
5171
|
}) => {
|
|
4823
5172
|
const nearestDatum = tooltipData?.nearestDatum?.datum;
|
|
4824
5173
|
if (!nearestDatum) return null;
|
|
4825
|
-
return /* @__PURE__ */
|
|
5174
|
+
return /* @__PURE__ */ _jsxs9("div", {
|
|
4826
5175
|
className: bar_chart_module_default["bar-chart__tooltip"],
|
|
4827
|
-
children: [/* @__PURE__ */
|
|
5176
|
+
children: [/* @__PURE__ */ _jsx20("div", {
|
|
4828
5177
|
className: bar_chart_module_default["bar-chart__tooltip-header"],
|
|
4829
5178
|
children: tooltipData?.nearestDatum?.key
|
|
4830
|
-
}), /* @__PURE__ */
|
|
5179
|
+
}), /* @__PURE__ */ _jsxs9("div", {
|
|
4831
5180
|
className: bar_chart_module_default["bar-chart__tooltip-row"],
|
|
4832
|
-
children: [/* @__PURE__ */
|
|
5181
|
+
children: [/* @__PURE__ */ _jsxs9("span", {
|
|
4833
5182
|
className: bar_chart_module_default["bar-chart__tooltip-label"],
|
|
4834
5183
|
children: [chartOptions.tooltip.labelFormatter(nearestDatum.label || (nearestDatum.date ? nearestDatum.date.getTime() : 0), 0, []), ":"]
|
|
4835
|
-
}), /* @__PURE__ */
|
|
5184
|
+
}), /* @__PURE__ */ _jsx20("span", {
|
|
4836
5185
|
className: bar_chart_module_default["bar-chart__tooltip-value"],
|
|
4837
5186
|
children: formatNumber6(nearestDatum.value)
|
|
4838
5187
|
})]
|
|
4839
5188
|
})]
|
|
4840
5189
|
});
|
|
4841
5190
|
}, [chartOptions.tooltip]);
|
|
4842
|
-
const renderPattern =
|
|
5191
|
+
const renderPattern = useCallback11((index, color) => {
|
|
4843
5192
|
const patternType = index % 4;
|
|
4844
5193
|
const id = getPatternId(chartId, index);
|
|
4845
5194
|
const commonProps = {
|
|
@@ -4851,34 +5200,34 @@ var BarChartInternal = ({
|
|
|
4851
5200
|
switch (patternType) {
|
|
4852
5201
|
case 0:
|
|
4853
5202
|
default:
|
|
4854
|
-
return /* @__PURE__ */
|
|
5203
|
+
return /* @__PURE__ */ _jsx20(PatternLines, {
|
|
4855
5204
|
...commonProps,
|
|
4856
5205
|
width: 5,
|
|
4857
5206
|
height: 5,
|
|
4858
5207
|
orientation: ["diagonal"]
|
|
4859
5208
|
}, id);
|
|
4860
5209
|
case 1:
|
|
4861
|
-
return /* @__PURE__ */
|
|
5210
|
+
return /* @__PURE__ */ _jsx20(PatternCircles, {
|
|
4862
5211
|
...commonProps,
|
|
4863
5212
|
width: 6,
|
|
4864
5213
|
height: 6,
|
|
4865
5214
|
fill: "white"
|
|
4866
5215
|
}, id);
|
|
4867
5216
|
case 2:
|
|
4868
|
-
return /* @__PURE__ */
|
|
5217
|
+
return /* @__PURE__ */ _jsx20(PatternWaves, {
|
|
4869
5218
|
...commonProps,
|
|
4870
5219
|
width: 4,
|
|
4871
5220
|
height: 4
|
|
4872
5221
|
}, id);
|
|
4873
5222
|
case 3:
|
|
4874
|
-
return /* @__PURE__ */
|
|
5223
|
+
return /* @__PURE__ */ _jsx20(PatternHexagons, {
|
|
4875
5224
|
...commonProps,
|
|
4876
5225
|
size: 8,
|
|
4877
5226
|
height: 3
|
|
4878
5227
|
}, id);
|
|
4879
5228
|
}
|
|
4880
5229
|
}, [chartId]);
|
|
4881
|
-
const createPatternBorderStyle =
|
|
5230
|
+
const createPatternBorderStyle = useCallback11((index, color) => {
|
|
4882
5231
|
const patternId = getPatternId(chartId, index);
|
|
4883
5232
|
return `
|
|
4884
5233
|
.visx-bar[fill="url(#${patternId})"] {
|
|
@@ -4887,7 +5236,7 @@ var BarChartInternal = ({
|
|
|
4887
5236
|
}
|
|
4888
5237
|
`;
|
|
4889
5238
|
}, [chartId]);
|
|
4890
|
-
const createKeyboardHighlightStyle =
|
|
5239
|
+
const createKeyboardHighlightStyle = useCallback11(() => {
|
|
4891
5240
|
if (selectedIndex === void 0) return "";
|
|
4892
5241
|
const maxDataPoints = Math.max(...data.map((s) => s.data.length));
|
|
4893
5242
|
const dataPointIndex = Math.floor(selectedIndex / data.length);
|
|
@@ -4910,7 +5259,7 @@ var BarChartInternal = ({
|
|
|
4910
5259
|
}, [selectedIndex, data, chartId]);
|
|
4911
5260
|
const error = validateData3(dataSorted);
|
|
4912
5261
|
const isDataValid = !error;
|
|
4913
|
-
const chartMetadata =
|
|
5262
|
+
const chartMetadata = useMemo19(() => ({
|
|
4914
5263
|
orientation,
|
|
4915
5264
|
withPatterns
|
|
4916
5265
|
}), [orientation, withPatterns]);
|
|
@@ -4923,7 +5272,7 @@ var BarChartInternal = ({
|
|
|
4923
5272
|
});
|
|
4924
5273
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
4925
5274
|
if (error) {
|
|
4926
|
-
return /* @__PURE__ */
|
|
5275
|
+
return /* @__PURE__ */ _jsx20("div", {
|
|
4927
5276
|
className: clsx6("bar-chart", bar_chart_module_default["bar-chart"]),
|
|
4928
5277
|
children: error
|
|
4929
5278
|
});
|
|
@@ -4931,7 +5280,7 @@ var BarChartInternal = ({
|
|
|
4931
5280
|
const gridVisibility = gridVisibilityProp ?? chartOptions.gridVisibility;
|
|
4932
5281
|
const highlightedBarStyle = createKeyboardHighlightStyle();
|
|
4933
5282
|
const legendPosition = legend.position ?? "bottom";
|
|
4934
|
-
const legendElement = showLegend && /* @__PURE__ */
|
|
5283
|
+
const legendElement = showLegend && /* @__PURE__ */ _jsx20(Legend, {
|
|
4935
5284
|
orientation: legend.orientation ?? "horizontal",
|
|
4936
5285
|
position: legendPosition,
|
|
4937
5286
|
alignment: legend.alignment ?? "center",
|
|
@@ -4944,13 +5293,13 @@ var BarChartInternal = ({
|
|
|
4944
5293
|
chartId,
|
|
4945
5294
|
interactive: legendInteractive
|
|
4946
5295
|
});
|
|
4947
|
-
return /* @__PURE__ */
|
|
5296
|
+
return /* @__PURE__ */ _jsx20(SingleChartContext.Provider, {
|
|
4948
5297
|
value: {
|
|
4949
5298
|
chartId,
|
|
4950
5299
|
chartWidth: width,
|
|
4951
5300
|
chartHeight: measuredChartHeight || 0
|
|
4952
5301
|
},
|
|
4953
|
-
children: /* @__PURE__ */
|
|
5302
|
+
children: /* @__PURE__ */ _jsx20(ChartLayout, {
|
|
4954
5303
|
legendPosition,
|
|
4955
5304
|
legendElement,
|
|
4956
5305
|
legendChildren,
|
|
@@ -4969,16 +5318,16 @@ var BarChartInternal = ({
|
|
|
4969
5318
|
contentHeight
|
|
4970
5319
|
}) => {
|
|
4971
5320
|
const chartHeight = contentHeight > 0 ? contentHeight : height;
|
|
4972
|
-
return /* @__PURE__ */
|
|
5321
|
+
return /* @__PURE__ */ _jsx20("div", {
|
|
4973
5322
|
role: "grid",
|
|
4974
|
-
"aria-label":
|
|
5323
|
+
"aria-label": __6("Bar chart", "jetpack-charts"),
|
|
4975
5324
|
tabIndex: 0,
|
|
4976
5325
|
onKeyDown: onChartKeyDown,
|
|
4977
5326
|
onFocus: onChartFocus,
|
|
4978
5327
|
onBlur: onChartBlur,
|
|
4979
|
-
children: chartHeight > 0 && /* @__PURE__ */
|
|
5328
|
+
children: chartHeight > 0 && /* @__PURE__ */ _jsx20("div", {
|
|
4980
5329
|
ref: chartRef,
|
|
4981
|
-
children: /* @__PURE__ */
|
|
5330
|
+
children: /* @__PURE__ */ _jsxs9(XYChart3, {
|
|
4982
5331
|
theme,
|
|
4983
5332
|
width,
|
|
4984
5333
|
height: chartHeight,
|
|
@@ -4990,31 +5339,31 @@ var BarChartInternal = ({
|
|
|
4990
5339
|
yScale: chartOptions.yScale,
|
|
4991
5340
|
horizontal,
|
|
4992
5341
|
pointerEventsDataKey: "nearest",
|
|
4993
|
-
children: [/* @__PURE__ */
|
|
5342
|
+
children: [/* @__PURE__ */ _jsx20(Grid3, {
|
|
4994
5343
|
columns: gridVisibility.includes("y"),
|
|
4995
5344
|
rows: gridVisibility.includes("x"),
|
|
4996
5345
|
numTicks: 4
|
|
4997
|
-
}), withPatterns && /* @__PURE__ */
|
|
4998
|
-
children: [/* @__PURE__ */
|
|
5346
|
+
}), withPatterns && /* @__PURE__ */ _jsxs9(_Fragment6, {
|
|
5347
|
+
children: [/* @__PURE__ */ _jsx20("defs", {
|
|
4999
5348
|
children: dataSorted.map((seriesData, index) => renderPattern(index, getElementStyles({
|
|
5000
5349
|
data: seriesData,
|
|
5001
5350
|
index
|
|
5002
5351
|
}).color))
|
|
5003
|
-
}), /* @__PURE__ */
|
|
5352
|
+
}), /* @__PURE__ */ _jsx20("style", {
|
|
5004
5353
|
children: dataSorted.map((seriesData, index) => createPatternBorderStyle(index, getElementStyles({
|
|
5005
5354
|
data: seriesData,
|
|
5006
5355
|
index
|
|
5007
5356
|
}).color))
|
|
5008
5357
|
})]
|
|
5009
|
-
}), highlightedBarStyle && /* @__PURE__ */
|
|
5358
|
+
}), highlightedBarStyle && /* @__PURE__ */ _jsx20("style", {
|
|
5010
5359
|
children: highlightedBarStyle
|
|
5011
|
-
}), allSeriesHidden ? /* @__PURE__ */
|
|
5360
|
+
}), allSeriesHidden ? /* @__PURE__ */ _jsx20(SvgEmptyState, {
|
|
5012
5361
|
x: width / 2,
|
|
5013
5362
|
y: chartHeight / 2,
|
|
5014
5363
|
width,
|
|
5015
5364
|
height: chartHeight,
|
|
5016
|
-
children:
|
|
5017
|
-
}) : null, /* @__PURE__ */
|
|
5365
|
+
children: __6("All series are hidden. Click legend items to show data.", "jetpack-charts")
|
|
5366
|
+
}) : null, /* @__PURE__ */ _jsx20(BarGroup, {
|
|
5018
5367
|
padding: chartOptions.barGroup.padding,
|
|
5019
5368
|
children: seriesWithVisibility.map(({
|
|
5020
5369
|
series: seriesData,
|
|
@@ -5024,7 +5373,7 @@ var BarChartInternal = ({
|
|
|
5024
5373
|
if (!isVisible) {
|
|
5025
5374
|
return null;
|
|
5026
5375
|
}
|
|
5027
|
-
return /* @__PURE__ */
|
|
5376
|
+
return /* @__PURE__ */ _jsx20(BarSeries, {
|
|
5028
5377
|
dataKey: seriesData?.label,
|
|
5029
5378
|
data: seriesData.data,
|
|
5030
5379
|
yAccessor: chartOptions.accessors.yAccessor,
|
|
@@ -5032,11 +5381,11 @@ var BarChartInternal = ({
|
|
|
5032
5381
|
colorAccessor: getBarBackground(index)
|
|
5033
5382
|
}, seriesData?.label);
|
|
5034
5383
|
})
|
|
5035
|
-
}), /* @__PURE__ */
|
|
5384
|
+
}), /* @__PURE__ */ _jsx20(Axis3, {
|
|
5036
5385
|
...chartOptions.axis.x
|
|
5037
|
-
}), /* @__PURE__ */
|
|
5386
|
+
}), /* @__PURE__ */ _jsx20(Axis3, {
|
|
5038
5387
|
...chartOptions.axis.y
|
|
5039
|
-
}), withTooltips && /* @__PURE__ */
|
|
5388
|
+
}), withTooltips && /* @__PURE__ */ _jsx20(AccessibleTooltip, {
|
|
5040
5389
|
detectBounds: true,
|
|
5041
5390
|
snapTooltipToDatumX: true,
|
|
5042
5391
|
snapTooltipToDatumY: true,
|
|
@@ -5055,14 +5404,14 @@ var BarChartInternal = ({
|
|
|
5055
5404
|
});
|
|
5056
5405
|
};
|
|
5057
5406
|
var BarChartWithProvider = (props) => {
|
|
5058
|
-
const existingContext =
|
|
5407
|
+
const existingContext = useContext16(GlobalChartsContext);
|
|
5059
5408
|
if (existingContext) {
|
|
5060
|
-
return /* @__PURE__ */
|
|
5409
|
+
return /* @__PURE__ */ _jsx20(BarChartInternal, {
|
|
5061
5410
|
...props
|
|
5062
5411
|
});
|
|
5063
5412
|
}
|
|
5064
|
-
return /* @__PURE__ */
|
|
5065
|
-
children: /* @__PURE__ */
|
|
5413
|
+
return /* @__PURE__ */ _jsx20(GlobalChartsProvider, {
|
|
5414
|
+
children: /* @__PURE__ */ _jsx20(BarChartInternal, {
|
|
5066
5415
|
...props
|
|
5067
5416
|
})
|
|
5068
5417
|
});
|
|
@@ -5080,8 +5429,8 @@ import { formatNumberCompact as formatNumberCompact5 } from "@automattic/number-
|
|
|
5080
5429
|
import { Group as Group3 } from "@visx/group";
|
|
5081
5430
|
import { createScale as createScale2, scaleBand } from "@visx/scale";
|
|
5082
5431
|
import { Text as Text3 } from "@visx/text";
|
|
5083
|
-
import { useContext as
|
|
5084
|
-
import { jsx as
|
|
5432
|
+
import { useContext as useContext17, useMemo as useMemo20 } from "react";
|
|
5433
|
+
import { jsx as _jsx21, jsxs as _jsxs10 } from "react/jsx-runtime";
|
|
5085
5434
|
var getScaleBandwidth2 = (scale) => {
|
|
5086
5435
|
const s = scale;
|
|
5087
5436
|
return s && "bandwidth" in s ? s?.bandwidth() ?? 0 : 0;
|
|
@@ -5093,7 +5442,7 @@ var DefaultLabelComponent = ({
|
|
|
5093
5442
|
label,
|
|
5094
5443
|
formatter
|
|
5095
5444
|
}) => {
|
|
5096
|
-
return /* @__PURE__ */
|
|
5445
|
+
return /* @__PURE__ */ _jsx21(Text3, {
|
|
5097
5446
|
...textProps,
|
|
5098
5447
|
textAnchor: "start",
|
|
5099
5448
|
x,
|
|
@@ -5108,7 +5457,7 @@ var DefaultValueComponent = ({
|
|
|
5108
5457
|
value,
|
|
5109
5458
|
formatter
|
|
5110
5459
|
}) => {
|
|
5111
|
-
return /* @__PURE__ */
|
|
5460
|
+
return /* @__PURE__ */ _jsx21(Text3, {
|
|
5112
5461
|
...textProps,
|
|
5113
5462
|
textAnchor: "end",
|
|
5114
5463
|
x,
|
|
@@ -5147,14 +5496,14 @@ var AxisRenderer = ({
|
|
|
5147
5496
|
data: seriesData
|
|
5148
5497
|
}) => acc + (seriesData[index]?.value ?? 0), 0);
|
|
5149
5498
|
const y = from2.y + yOffset;
|
|
5150
|
-
return /* @__PURE__ */
|
|
5151
|
-
children: [/* @__PURE__ */
|
|
5499
|
+
return /* @__PURE__ */ _jsxs10(Group3, {
|
|
5500
|
+
children: [/* @__PURE__ */ _jsx21(LabelComponent, {
|
|
5152
5501
|
textProps,
|
|
5153
5502
|
x: labelPosition,
|
|
5154
5503
|
y,
|
|
5155
5504
|
label: formattedValue,
|
|
5156
5505
|
formatter: labelFormatter
|
|
5157
|
-
}), /* @__PURE__ */
|
|
5506
|
+
}), /* @__PURE__ */ _jsx21(ValueComponent, {
|
|
5158
5507
|
textProps,
|
|
5159
5508
|
x: valuePosition,
|
|
5160
5509
|
y,
|
|
@@ -5201,7 +5550,7 @@ var BarListChartInternal = ({
|
|
|
5201
5550
|
},
|
|
5202
5551
|
...rest
|
|
5203
5552
|
}) => {
|
|
5204
|
-
const chartOptions =
|
|
5553
|
+
const chartOptions = useMemo20(() => {
|
|
5205
5554
|
const isMultiSeries = data.length > 1;
|
|
5206
5555
|
const defaultYScale = {
|
|
5207
5556
|
// For multi series, set default padding larger to look better.
|
|
@@ -5230,7 +5579,7 @@ var BarListChartInternal = ({
|
|
|
5230
5579
|
yOffset: options.yOffset ?? getDefaultYOffset(data, yScale, height, isMultiSeries)
|
|
5231
5580
|
};
|
|
5232
5581
|
}, [options, width, data, height]);
|
|
5233
|
-
return /* @__PURE__ */
|
|
5582
|
+
return /* @__PURE__ */ _jsx21(BarChart, {
|
|
5234
5583
|
orientation: "horizontal",
|
|
5235
5584
|
gridVisibility: "none",
|
|
5236
5585
|
data,
|
|
@@ -5240,7 +5589,7 @@ var BarListChartInternal = ({
|
|
|
5240
5589
|
options: {
|
|
5241
5590
|
axis: {
|
|
5242
5591
|
y: {
|
|
5243
|
-
children: (renderProps) => /* @__PURE__ */
|
|
5592
|
+
children: (renderProps) => /* @__PURE__ */ _jsx21(AxisRenderer, {
|
|
5244
5593
|
...renderProps,
|
|
5245
5594
|
data,
|
|
5246
5595
|
yOffset: chartOptions.yOffset,
|
|
@@ -5263,14 +5612,14 @@ var BarListChartInternal = ({
|
|
|
5263
5612
|
});
|
|
5264
5613
|
};
|
|
5265
5614
|
var BarListChart = (props) => {
|
|
5266
|
-
const existingContext =
|
|
5615
|
+
const existingContext = useContext17(GlobalChartsContext);
|
|
5267
5616
|
if (existingContext) {
|
|
5268
|
-
return /* @__PURE__ */
|
|
5617
|
+
return /* @__PURE__ */ _jsx21(BarListChartInternal, {
|
|
5269
5618
|
...props
|
|
5270
5619
|
});
|
|
5271
5620
|
}
|
|
5272
|
-
return /* @__PURE__ */
|
|
5273
|
-
children: /* @__PURE__ */
|
|
5621
|
+
return /* @__PURE__ */ _jsx21(GlobalChartsProvider, {
|
|
5622
|
+
children: /* @__PURE__ */ _jsx21(BarListChartInternal, {
|
|
5274
5623
|
...props
|
|
5275
5624
|
})
|
|
5276
5625
|
});
|
|
@@ -5281,7 +5630,7 @@ var BarListChartResponsive = withResponsive(BarListChart);
|
|
|
5281
5630
|
// src/charts/conversion-funnel-chart/conversion-funnel-chart.tsx
|
|
5282
5631
|
import { useTooltip, useTooltipInPortal } from "@visx/tooltip";
|
|
5283
5632
|
import clsx7 from "clsx";
|
|
5284
|
-
import { useRef as useRef12, useMemo as
|
|
5633
|
+
import { useRef as useRef12, useMemo as useMemo21, useEffect as useEffect10, useCallback as useCallback13, useContext as useContext18 } from "react";
|
|
5285
5634
|
|
|
5286
5635
|
// src/charts/conversion-funnel-chart/conversion-funnel-chart.module.scss
|
|
5287
5636
|
var conversion_funnel_chart_module_default = {
|
|
@@ -5306,10 +5655,10 @@ var conversion_funnel_chart_module_default = {
|
|
|
5306
5655
|
};
|
|
5307
5656
|
|
|
5308
5657
|
// src/charts/conversion-funnel-chart/private/use-funnel-selection.ts
|
|
5309
|
-
import { useCallback as
|
|
5658
|
+
import { useCallback as useCallback12, useState as useState13 } from "react";
|
|
5310
5659
|
var useFunnelSelection = (hideTooltip) => {
|
|
5311
|
-
const [clickedStep, setClickedStep] =
|
|
5312
|
-
const handleBarClick =
|
|
5660
|
+
const [clickedStep, setClickedStep] = useState13(null);
|
|
5661
|
+
const handleBarClick = useCallback12(
|
|
5313
5662
|
(stepId) => {
|
|
5314
5663
|
if (clickedStep === stepId) {
|
|
5315
5664
|
setClickedStep(null);
|
|
@@ -5320,7 +5669,7 @@ var useFunnelSelection = (hideTooltip) => {
|
|
|
5320
5669
|
},
|
|
5321
5670
|
[clickedStep, hideTooltip]
|
|
5322
5671
|
);
|
|
5323
|
-
const handleBarKeyDown =
|
|
5672
|
+
const handleBarKeyDown = useCallback12(
|
|
5324
5673
|
(stepId, event) => {
|
|
5325
5674
|
if (event.key === "Enter" || event.key === " ") {
|
|
5326
5675
|
event.preventDefault();
|
|
@@ -5338,11 +5687,11 @@ var useFunnelSelection = (hideTooltip) => {
|
|
|
5338
5687
|
},
|
|
5339
5688
|
[clickedStep, hideTooltip]
|
|
5340
5689
|
);
|
|
5341
|
-
const clearSelection =
|
|
5690
|
+
const clearSelection = useCallback12(() => {
|
|
5342
5691
|
setClickedStep(null);
|
|
5343
5692
|
hideTooltip?.();
|
|
5344
5693
|
}, [hideTooltip]);
|
|
5345
|
-
const getStepState =
|
|
5694
|
+
const getStepState = useCallback12(
|
|
5346
5695
|
(stepId) => ({
|
|
5347
5696
|
isClicked: clickedStep === stepId,
|
|
5348
5697
|
isBlurred: clickedStep !== null && clickedStep !== stepId
|
|
@@ -5359,7 +5708,7 @@ var useFunnelSelection = (hideTooltip) => {
|
|
|
5359
5708
|
};
|
|
5360
5709
|
|
|
5361
5710
|
// src/charts/conversion-funnel-chart/conversion-funnel-chart.tsx
|
|
5362
|
-
import { jsx as
|
|
5711
|
+
import { jsx as _jsx22, Fragment as _Fragment7, jsxs as _jsxs11 } from "react/jsx-runtime";
|
|
5363
5712
|
var ConversionFunnelChartInternal = ({
|
|
5364
5713
|
mainRate,
|
|
5365
5714
|
changeIndicator,
|
|
@@ -5409,19 +5758,19 @@ var ConversionFunnelChartInternal = ({
|
|
|
5409
5758
|
// when tooltip containers are scrolled, this will correctly update the Tooltip position
|
|
5410
5759
|
scroll: true
|
|
5411
5760
|
});
|
|
5412
|
-
const clearSelectionAndRef =
|
|
5761
|
+
const clearSelectionAndRef = useCallback13(() => {
|
|
5413
5762
|
clearSelection();
|
|
5414
5763
|
selectedBarRef.current = null;
|
|
5415
5764
|
hideTooltip();
|
|
5416
5765
|
}, [clearSelection, hideTooltip]);
|
|
5417
|
-
const showTooltipAt =
|
|
5766
|
+
const showTooltipAt = useCallback13((step, x, y) => {
|
|
5418
5767
|
showTooltip({
|
|
5419
5768
|
tooltipData: step,
|
|
5420
5769
|
tooltipLeft: x,
|
|
5421
5770
|
tooltipTop: y - 10
|
|
5422
5771
|
});
|
|
5423
5772
|
}, [showTooltip]);
|
|
5424
|
-
const getMouseTooltipCoords =
|
|
5773
|
+
const getMouseTooltipCoords = useCallback13((event) => {
|
|
5425
5774
|
if (containerBounds.width === 0 || containerBounds.height === 0) {
|
|
5426
5775
|
return null;
|
|
5427
5776
|
}
|
|
@@ -5430,7 +5779,7 @@ var ConversionFunnelChartInternal = ({
|
|
|
5430
5779
|
y: event.clientY - containerBounds.top
|
|
5431
5780
|
};
|
|
5432
5781
|
}, [containerBounds.width, containerBounds.height, containerBounds.left, containerBounds.top]);
|
|
5433
|
-
const getKeyboardTooltipCoords =
|
|
5782
|
+
const getKeyboardTooltipCoords = useCallback13((event) => {
|
|
5434
5783
|
if (containerBounds.width === 0 || containerBounds.height === 0) {
|
|
5435
5784
|
return null;
|
|
5436
5785
|
}
|
|
@@ -5442,7 +5791,7 @@ var ConversionFunnelChartInternal = ({
|
|
|
5442
5791
|
y
|
|
5443
5792
|
};
|
|
5444
5793
|
}, [containerBounds.width, containerBounds.height, containerBounds.left, containerBounds.top]);
|
|
5445
|
-
const handleStepInteraction =
|
|
5794
|
+
const handleStepInteraction = useCallback13((step, event, interactionType) => {
|
|
5446
5795
|
selectedBarRef.current = event.currentTarget;
|
|
5447
5796
|
const {
|
|
5448
5797
|
isClicked
|
|
@@ -5469,7 +5818,7 @@ var ConversionFunnelChartInternal = ({
|
|
|
5469
5818
|
}
|
|
5470
5819
|
}
|
|
5471
5820
|
}, [getStepState, handleBarClick, handleBarKeyDown, showTooltipAt, getMouseTooltipCoords, getKeyboardTooltipCoords]);
|
|
5472
|
-
const stepHandlers =
|
|
5821
|
+
const stepHandlers = useMemo21(() => {
|
|
5473
5822
|
const handlers = /* @__PURE__ */ new Map();
|
|
5474
5823
|
steps.forEach((step) => {
|
|
5475
5824
|
const onClick = (event) => {
|
|
@@ -5520,11 +5869,11 @@ var ConversionFunnelChartInternal = ({
|
|
|
5520
5869
|
const isPositiveChange = changeIndicator?.startsWith("+");
|
|
5521
5870
|
const changeColor = isPositiveChange ? positiveChangeColor : negativeChangeColor;
|
|
5522
5871
|
const barBackgroundColor = backgroundColor || hexToRgba(barColor, 0.08) || "rgba(0, 0, 0, 0.08)";
|
|
5523
|
-
const renderDefaultMainMetric = () => /* @__PURE__ */
|
|
5524
|
-
children: [/* @__PURE__ */
|
|
5872
|
+
const renderDefaultMainMetric = () => /* @__PURE__ */ _jsxs11(_Fragment7, {
|
|
5873
|
+
children: [/* @__PURE__ */ _jsx22("span", {
|
|
5525
5874
|
className: conversion_funnel_chart_module_default["main-rate"],
|
|
5526
5875
|
children: formatPercentage(mainRate)
|
|
5527
|
-
}), changeIndicator && /* @__PURE__ */
|
|
5876
|
+
}), changeIndicator && /* @__PURE__ */ _jsx22("span", {
|
|
5528
5877
|
className: conversion_funnel_chart_module_default["change-indicator"],
|
|
5529
5878
|
style: {
|
|
5530
5879
|
color: changeColor
|
|
@@ -5532,20 +5881,20 @@ var ConversionFunnelChartInternal = ({
|
|
|
5532
5881
|
children: changeIndicator
|
|
5533
5882
|
})]
|
|
5534
5883
|
});
|
|
5535
|
-
const renderDefaultTooltip2 = (step) => /* @__PURE__ */
|
|
5884
|
+
const renderDefaultTooltip2 = (step) => /* @__PURE__ */ _jsxs11(Stack, {
|
|
5536
5885
|
direction: "column",
|
|
5537
5886
|
align: "flex-start",
|
|
5538
5887
|
gap: "xs",
|
|
5539
|
-
children: [/* @__PURE__ */
|
|
5888
|
+
children: [/* @__PURE__ */ _jsx22("div", {
|
|
5540
5889
|
className: conversion_funnel_chart_module_default["tooltip-title"],
|
|
5541
5890
|
children: step.label
|
|
5542
|
-
}), /* @__PURE__ */
|
|
5891
|
+
}), /* @__PURE__ */ _jsxs11("div", {
|
|
5543
5892
|
className: conversion_funnel_chart_module_default["tooltip-content"],
|
|
5544
5893
|
children: [formatPercentage(step.rate), ` \u2022 ${step.count ?? "no"} items`]
|
|
5545
5894
|
})]
|
|
5546
5895
|
});
|
|
5547
5896
|
const isDataValid = Boolean(steps && steps.length > 0);
|
|
5548
|
-
const chartMetadata =
|
|
5897
|
+
const chartMetadata = useMemo21(() => ({
|
|
5549
5898
|
mainRate,
|
|
5550
5899
|
changeIndicator,
|
|
5551
5900
|
stepsCount: steps?.length || 0
|
|
@@ -5559,7 +5908,7 @@ var ConversionFunnelChartInternal = ({
|
|
|
5559
5908
|
});
|
|
5560
5909
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
5561
5910
|
if (!isDataValid) {
|
|
5562
|
-
return /* @__PURE__ */
|
|
5911
|
+
return /* @__PURE__ */ _jsx22(Stack, {
|
|
5563
5912
|
direction: "column",
|
|
5564
5913
|
align: "center",
|
|
5565
5914
|
justify: "center",
|
|
@@ -5568,15 +5917,15 @@ var ConversionFunnelChartInternal = ({
|
|
|
5568
5917
|
...style,
|
|
5569
5918
|
height: resolvedHeight
|
|
5570
5919
|
},
|
|
5571
|
-
children: /* @__PURE__ */
|
|
5920
|
+
children: /* @__PURE__ */ _jsx22("div", {
|
|
5572
5921
|
className: conversion_funnel_chart_module_default["empty-state"],
|
|
5573
5922
|
children: loading ? "Loading..." : "No data available"
|
|
5574
5923
|
})
|
|
5575
5924
|
});
|
|
5576
5925
|
}
|
|
5577
5926
|
const maxRate = Math.max(...steps.map((step) => step.rate));
|
|
5578
|
-
return /* @__PURE__ */
|
|
5579
|
-
children: [/* @__PURE__ */
|
|
5927
|
+
return /* @__PURE__ */ _jsxs11(_Fragment7, {
|
|
5928
|
+
children: [/* @__PURE__ */ _jsxs11(Stack, {
|
|
5580
5929
|
direction: "column",
|
|
5581
5930
|
gap: "xl",
|
|
5582
5931
|
ref: (node2) => {
|
|
@@ -5593,13 +5942,13 @@ var ConversionFunnelChartInternal = ({
|
|
|
5593
5942
|
changeIndicator,
|
|
5594
5943
|
className: conversion_funnel_chart_module_default["main-metric"],
|
|
5595
5944
|
changeColor
|
|
5596
|
-
}) : /* @__PURE__ */
|
|
5945
|
+
}) : /* @__PURE__ */ _jsx22(Stack, {
|
|
5597
5946
|
direction: "row",
|
|
5598
5947
|
align: "baseline",
|
|
5599
5948
|
gap: "sm",
|
|
5600
5949
|
className: conversion_funnel_chart_module_default["main-metric"],
|
|
5601
5950
|
children: renderDefaultMainMetric()
|
|
5602
|
-
}), /* @__PURE__ */
|
|
5951
|
+
}), /* @__PURE__ */ _jsx22(Stack, {
|
|
5603
5952
|
direction: "row",
|
|
5604
5953
|
align: "flex-end",
|
|
5605
5954
|
gap: "lg",
|
|
@@ -5609,29 +5958,29 @@ var ConversionFunnelChartInternal = ({
|
|
|
5609
5958
|
const {
|
|
5610
5959
|
isBlurred
|
|
5611
5960
|
} = getStepState(step.id);
|
|
5612
|
-
return /* @__PURE__ */
|
|
5961
|
+
return /* @__PURE__ */ _jsxs11(Stack, {
|
|
5613
5962
|
direction: "column",
|
|
5614
5963
|
className: clsx7(conversion_funnel_chart_module_default["funnel-step"], isColorPaletteResolved && conversion_funnel_chart_module_default["funnel-step--animated"], isBlurred && conversion_funnel_chart_module_default["funnel-step--blurred"]),
|
|
5615
5964
|
gap: "xl",
|
|
5616
|
-
children: [/* @__PURE__ */
|
|
5965
|
+
children: [/* @__PURE__ */ _jsxs11(Stack, {
|
|
5617
5966
|
direction: "column",
|
|
5618
5967
|
gap: "xs",
|
|
5619
5968
|
children: [renderStepLabel ? renderStepLabel({
|
|
5620
5969
|
step,
|
|
5621
5970
|
index,
|
|
5622
5971
|
className: conversion_funnel_chart_module_default["step-label"]
|
|
5623
|
-
}) : /* @__PURE__ */
|
|
5972
|
+
}) : /* @__PURE__ */ _jsx22("span", {
|
|
5624
5973
|
className: conversion_funnel_chart_module_default["step-label"],
|
|
5625
5974
|
children: step.label
|
|
5626
5975
|
}), renderStepRate ? renderStepRate({
|
|
5627
5976
|
step,
|
|
5628
5977
|
index,
|
|
5629
5978
|
className: conversion_funnel_chart_module_default["step-rate"]
|
|
5630
|
-
}) : /* @__PURE__ */
|
|
5979
|
+
}) : /* @__PURE__ */ _jsx22("span", {
|
|
5631
5980
|
className: conversion_funnel_chart_module_default["step-rate"],
|
|
5632
5981
|
children: formatPercentage(step.rate)
|
|
5633
5982
|
})]
|
|
5634
|
-
}), /* @__PURE__ */
|
|
5983
|
+
}), /* @__PURE__ */ _jsx22(Stack, {
|
|
5635
5984
|
direction: "column",
|
|
5636
5985
|
justify: "flex-end",
|
|
5637
5986
|
className: conversion_funnel_chart_module_default["bar-container"],
|
|
@@ -5643,7 +5992,7 @@ var ConversionFunnelChartInternal = ({
|
|
|
5643
5992
|
style: {
|
|
5644
5993
|
backgroundColor: barBackgroundColor
|
|
5645
5994
|
},
|
|
5646
|
-
children: /* @__PURE__ */
|
|
5995
|
+
children: /* @__PURE__ */ _jsx22("div", {
|
|
5647
5996
|
className: clsx7(conversion_funnel_chart_module_default["funnel-bar"], {
|
|
5648
5997
|
[conversion_funnel_chart_module_default["funnel-bar--animated"]]: animation && !loading && !prefersReducedMotion
|
|
5649
5998
|
}),
|
|
@@ -5665,7 +6014,7 @@ var ConversionFunnelChartInternal = ({
|
|
|
5665
6014
|
className: conversion_funnel_chart_module_default["tooltip-wrapper"]
|
|
5666
6015
|
}) : renderDefaultTooltip2(tooltipData);
|
|
5667
6016
|
if (!tooltipContent) return null;
|
|
5668
|
-
return /* @__PURE__ */
|
|
6017
|
+
return /* @__PURE__ */ _jsx22(
|
|
5669
6018
|
TooltipInPortal,
|
|
5670
6019
|
{
|
|
5671
6020
|
top: tooltipTop,
|
|
@@ -5679,14 +6028,14 @@ var ConversionFunnelChartInternal = ({
|
|
|
5679
6028
|
});
|
|
5680
6029
|
};
|
|
5681
6030
|
var ConversionFunnelChartWithProvider = (props) => {
|
|
5682
|
-
const existingContext =
|
|
6031
|
+
const existingContext = useContext18(GlobalChartsContext);
|
|
5683
6032
|
if (existingContext) {
|
|
5684
|
-
return /* @__PURE__ */
|
|
6033
|
+
return /* @__PURE__ */ _jsx22(ConversionFunnelChartInternal, {
|
|
5685
6034
|
...props
|
|
5686
6035
|
});
|
|
5687
6036
|
}
|
|
5688
|
-
return /* @__PURE__ */
|
|
5689
|
-
children: /* @__PURE__ */
|
|
6037
|
+
return /* @__PURE__ */ _jsx22(GlobalChartsProvider, {
|
|
6038
|
+
children: /* @__PURE__ */ _jsx22(ConversionFunnelChartInternal, {
|
|
5690
6039
|
...props
|
|
5691
6040
|
})
|
|
5692
6041
|
});
|
|
@@ -5694,9 +6043,9 @@ var ConversionFunnelChartWithProvider = (props) => {
|
|
|
5694
6043
|
ConversionFunnelChartWithProvider.displayName = "ConversionFunnelChart";
|
|
5695
6044
|
|
|
5696
6045
|
// src/charts/geo-chart/geo-chart.tsx
|
|
5697
|
-
import { __ as
|
|
6046
|
+
import { __ as __7 } from "@wordpress/i18n";
|
|
5698
6047
|
import clsx8 from "clsx";
|
|
5699
|
-
import { useContext as
|
|
6048
|
+
import { useContext as useContext19, useMemo as useMemo22 } from "react";
|
|
5700
6049
|
import { Chart } from "react-google-charts";
|
|
5701
6050
|
|
|
5702
6051
|
// src/utils/sanitize-html.ts
|
|
@@ -5742,7 +6091,7 @@ var geo_chart_module_default = {
|
|
|
5742
6091
|
};
|
|
5743
6092
|
|
|
5744
6093
|
// src/charts/geo-chart/geo-chart.tsx
|
|
5745
|
-
import { jsx as
|
|
6094
|
+
import { jsx as _jsx23 } from "react/jsx-runtime";
|
|
5746
6095
|
var DEFAULT_FEATURE_FILL_COLOR = "#ffffff";
|
|
5747
6096
|
var DEFAULT_BACKGROUND_COLOR = "#ffffff";
|
|
5748
6097
|
var GeoChartInternal = ({
|
|
@@ -5763,7 +6112,7 @@ var GeoChartInternal = ({
|
|
|
5763
6112
|
backgroundColor
|
|
5764
6113
|
}
|
|
5765
6114
|
} = useGlobalChartsContext();
|
|
5766
|
-
const loadingPlaceholder = /* @__PURE__ */
|
|
6115
|
+
const loadingPlaceholder = /* @__PURE__ */ _jsx23(Stack, {
|
|
5767
6116
|
align: "center",
|
|
5768
6117
|
justify: "center",
|
|
5769
6118
|
className: clsx8("geo-chart", geo_chart_module_default.container, className),
|
|
@@ -5771,7 +6120,7 @@ var GeoChartInternal = ({
|
|
|
5771
6120
|
width,
|
|
5772
6121
|
height
|
|
5773
6122
|
},
|
|
5774
|
-
children: renderPlaceholder ? renderPlaceholder() :
|
|
6123
|
+
children: renderPlaceholder ? renderPlaceholder() : __7("Loading map", "jetpack-charts")
|
|
5775
6124
|
});
|
|
5776
6125
|
const fullColorHex = getElementStyles({
|
|
5777
6126
|
index: 0
|
|
@@ -5779,7 +6128,7 @@ var GeoChartInternal = ({
|
|
|
5779
6128
|
const lightColorHex = lightenHexColor(fullColorHex, 0.8);
|
|
5780
6129
|
const backgroundColorHex = normalizeColorToHex(backgroundColor, null, resolveCssVariable) || DEFAULT_BACKGROUND_COLOR;
|
|
5781
6130
|
const defaultFillColorHex = normalizeColorToHex(featureFillColor, null, resolveCssVariable) || DEFAULT_FEATURE_FILL_COLOR;
|
|
5782
|
-
const sanitizedData =
|
|
6131
|
+
const sanitizedData = useMemo22(() => {
|
|
5783
6132
|
if (data.length === 0) {
|
|
5784
6133
|
return {
|
|
5785
6134
|
data,
|
|
@@ -5813,7 +6162,7 @@ var GeoChartInternal = ({
|
|
|
5813
6162
|
hasHtmlTooltips: true
|
|
5814
6163
|
};
|
|
5815
6164
|
}, [data]);
|
|
5816
|
-
const options =
|
|
6165
|
+
const options = useMemo22(() => ({
|
|
5817
6166
|
...region !== "world" && {
|
|
5818
6167
|
region
|
|
5819
6168
|
},
|
|
@@ -5833,7 +6182,7 @@ var GeoChartInternal = ({
|
|
|
5833
6182
|
legend: "none",
|
|
5834
6183
|
keepAspectRatio: true
|
|
5835
6184
|
}), [region, resolution, lightColorHex, fullColorHex, backgroundColorHex, defaultFillColorHex, sanitizedData.hasHtmlTooltips]);
|
|
5836
|
-
return /* @__PURE__ */
|
|
6185
|
+
return /* @__PURE__ */ _jsx23(Stack, {
|
|
5837
6186
|
align: "center",
|
|
5838
6187
|
justify: "center",
|
|
5839
6188
|
className: clsx8("geo-chart", geo_chart_module_default.container, className),
|
|
@@ -5842,7 +6191,7 @@ var GeoChartInternal = ({
|
|
|
5842
6191
|
height,
|
|
5843
6192
|
backgroundColor
|
|
5844
6193
|
},
|
|
5845
|
-
children: /* @__PURE__ */
|
|
6194
|
+
children: /* @__PURE__ */ _jsx23(Chart, {
|
|
5846
6195
|
chartType: "GeoChart",
|
|
5847
6196
|
width,
|
|
5848
6197
|
height,
|
|
@@ -5853,14 +6202,14 @@ var GeoChartInternal = ({
|
|
|
5853
6202
|
});
|
|
5854
6203
|
};
|
|
5855
6204
|
var GeoChartWithProvider = (props) => {
|
|
5856
|
-
const existingContext =
|
|
6205
|
+
const existingContext = useContext19(GlobalChartsContext);
|
|
5857
6206
|
if (existingContext) {
|
|
5858
|
-
return /* @__PURE__ */
|
|
6207
|
+
return /* @__PURE__ */ _jsx23(GeoChartInternal, {
|
|
5859
6208
|
...props
|
|
5860
6209
|
});
|
|
5861
6210
|
}
|
|
5862
|
-
return /* @__PURE__ */
|
|
5863
|
-
children: /* @__PURE__ */
|
|
6211
|
+
return /* @__PURE__ */ _jsx23(GlobalChartsProvider, {
|
|
6212
|
+
children: /* @__PURE__ */ _jsx23(GeoChartInternal, {
|
|
5864
6213
|
...props
|
|
5865
6214
|
})
|
|
5866
6215
|
});
|
|
@@ -5886,7 +6235,7 @@ var use_update_effect_default = useUpdateEffect;
|
|
|
5886
6235
|
|
|
5887
6236
|
// ../../../node_modules/.pnpm/@emotion+react@11.14.0_@types+react@18.3.28_react@18.3.1/node_modules/@emotion/react/dist/emotion-element-d59e098f.esm.js
|
|
5888
6237
|
import * as React6 from "react";
|
|
5889
|
-
import { useContext as
|
|
6238
|
+
import { useContext as useContext21, forwardRef as forwardRef7 } from "react";
|
|
5890
6239
|
|
|
5891
6240
|
// ../../../node_modules/.pnpm/@emotion+sheet@1.4.0/node_modules/@emotion/sheet/dist/emotion-sheet.esm.js
|
|
5892
6241
|
var isDevelopment = false;
|
|
@@ -7077,18 +7426,18 @@ var EmotionCacheContext = /* @__PURE__ */ React6.createContext(
|
|
|
7077
7426
|
);
|
|
7078
7427
|
var CacheProvider = EmotionCacheContext.Provider;
|
|
7079
7428
|
var __unsafe_useEmotionCache = function useEmotionCache() {
|
|
7080
|
-
return
|
|
7429
|
+
return useContext21(EmotionCacheContext);
|
|
7081
7430
|
};
|
|
7082
7431
|
var withEmotionCache = function withEmotionCache2(func) {
|
|
7083
7432
|
return /* @__PURE__ */ forwardRef7(function(props, ref) {
|
|
7084
|
-
var cache2 =
|
|
7433
|
+
var cache2 = useContext21(EmotionCacheContext);
|
|
7085
7434
|
return func(props, cache2, ref);
|
|
7086
7435
|
});
|
|
7087
7436
|
};
|
|
7088
7437
|
if (!isBrowser4) {
|
|
7089
7438
|
withEmotionCache = function withEmotionCache3(func) {
|
|
7090
7439
|
return function(props) {
|
|
7091
|
-
var cache2 =
|
|
7440
|
+
var cache2 = useContext21(EmotionCacheContext);
|
|
7092
7441
|
if (cache2 === null) {
|
|
7093
7442
|
cache2 = createCache({
|
|
7094
7443
|
key: "css"
|
|
@@ -7186,10 +7535,10 @@ var jsx = function jsx2(type, props) {
|
|
|
7186
7535
|
}
|
|
7187
7536
|
return React7.createElement.apply(null, createElementArgArray);
|
|
7188
7537
|
};
|
|
7189
|
-
(function(
|
|
7538
|
+
(function(_jsx33) {
|
|
7190
7539
|
var JSX;
|
|
7191
7540
|
/* @__PURE__ */ (function(_JSX) {
|
|
7192
|
-
})(JSX || (JSX =
|
|
7541
|
+
})(JSX || (JSX = _jsx33.JSX || (_jsx33.JSX = {})));
|
|
7193
7542
|
})(jsx || (jsx = {}));
|
|
7194
7543
|
function css() {
|
|
7195
7544
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -7588,7 +7937,7 @@ function warning(message) {
|
|
|
7588
7937
|
}
|
|
7589
7938
|
|
|
7590
7939
|
// ../../../node_modules/.pnpm/@wordpress+components@33.1.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/context/context-system-provider.mjs
|
|
7591
|
-
import { jsx as
|
|
7940
|
+
import { jsx as _jsx24 } from "react/jsx-runtime";
|
|
7592
7941
|
var ComponentsContext = createContext3(
|
|
7593
7942
|
/** @type {Record<string, any>} */
|
|
7594
7943
|
{}
|
|
@@ -7623,7 +7972,7 @@ var BaseContextSystemProvider = ({
|
|
|
7623
7972
|
const contextValue = useContextSystemBridge({
|
|
7624
7973
|
value
|
|
7625
7974
|
});
|
|
7626
|
-
return /* @__PURE__ */
|
|
7975
|
+
return /* @__PURE__ */ _jsx24(ComponentsContext.Provider, {
|
|
7627
7976
|
value: contextValue,
|
|
7628
7977
|
children
|
|
7629
7978
|
});
|
|
@@ -7864,7 +8213,7 @@ var createStyled = function createStyled2(tag, options) {
|
|
|
7864
8213
|
};
|
|
7865
8214
|
|
|
7866
8215
|
// ../../../node_modules/.pnpm/@wordpress+components@33.1.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/view/component.mjs
|
|
7867
|
-
import { jsx as
|
|
8216
|
+
import { jsx as _jsx25 } from "react/jsx-runtime";
|
|
7868
8217
|
var PolymorphicDiv = /* @__PURE__ */ createStyled("div", process.env.NODE_ENV === "production" ? {
|
|
7869
8218
|
target: "e19lxcc00"
|
|
7870
8219
|
} : {
|
|
@@ -7875,7 +8224,7 @@ function UnforwardedView({
|
|
|
7875
8224
|
as,
|
|
7876
8225
|
...restProps
|
|
7877
8226
|
}, ref) {
|
|
7878
|
-
return /* @__PURE__ */
|
|
8227
|
+
return /* @__PURE__ */ _jsx25(PolymorphicDiv, {
|
|
7879
8228
|
as,
|
|
7880
8229
|
ref,
|
|
7881
8230
|
...restProps
|
|
@@ -8027,10 +8376,10 @@ function useGrid(props) {
|
|
|
8027
8376
|
}
|
|
8028
8377
|
|
|
8029
8378
|
// ../../../node_modules/.pnpm/@wordpress+components@33.1.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/grid/component.mjs
|
|
8030
|
-
import { jsx as
|
|
8379
|
+
import { jsx as _jsx26 } from "react/jsx-runtime";
|
|
8031
8380
|
function UnconnectedGrid(props, forwardedRef) {
|
|
8032
8381
|
const gridProps = useGrid(props);
|
|
8033
|
-
return /* @__PURE__ */
|
|
8382
|
+
return /* @__PURE__ */ _jsx26(component_default, {
|
|
8034
8383
|
...gridProps,
|
|
8035
8384
|
ref: forwardedRef
|
|
8036
8385
|
});
|
|
@@ -8039,13 +8388,13 @@ var Grid4 = contextConnect(UnconnectedGrid, "Grid");
|
|
|
8039
8388
|
var component_default2 = Grid4;
|
|
8040
8389
|
|
|
8041
8390
|
// src/charts/leaderboard-chart/leaderboard-chart.tsx
|
|
8042
|
-
import { __ as
|
|
8391
|
+
import { __ as __9 } from "@wordpress/i18n";
|
|
8043
8392
|
import clsx9 from "clsx";
|
|
8044
|
-
import { useContext as
|
|
8393
|
+
import { useContext as useContext24, useMemo as useMemo24 } from "react";
|
|
8045
8394
|
|
|
8046
8395
|
// src/charts/leaderboard-chart/hooks/use-leaderboard-legend-items.ts
|
|
8047
|
-
import { __ as
|
|
8048
|
-
import { useMemo as
|
|
8396
|
+
import { __ as __8 } from "@wordpress/i18n";
|
|
8397
|
+
import { useMemo as useMemo23 } from "react";
|
|
8049
8398
|
function useLeaderboardLegendItems({
|
|
8050
8399
|
data,
|
|
8051
8400
|
primaryColor,
|
|
@@ -8056,7 +8405,7 @@ function useLeaderboardLegendItems({
|
|
|
8056
8405
|
}) {
|
|
8057
8406
|
const { leaderboardChart: leaderboardChartSettings } = useGlobalChartsTheme();
|
|
8058
8407
|
const { getElementStyles } = useGlobalChartsContext();
|
|
8059
|
-
return
|
|
8408
|
+
return useMemo23(() => {
|
|
8060
8409
|
if (!data || data.length === 0) {
|
|
8061
8410
|
return [];
|
|
8062
8411
|
}
|
|
@@ -8066,7 +8415,7 @@ function useLeaderboardLegendItems({
|
|
|
8066
8415
|
overrideColor: primaryColor || leaderboardChartSettings.primaryColor
|
|
8067
8416
|
});
|
|
8068
8417
|
items.push({
|
|
8069
|
-
label: legendLabels?.primary ||
|
|
8418
|
+
label: legendLabels?.primary || __8("Current period", "jetpack-charts"),
|
|
8070
8419
|
color: resolvedPrimaryColor
|
|
8071
8420
|
});
|
|
8072
8421
|
if (withComparison && !withOverlayLabel) {
|
|
@@ -8075,7 +8424,7 @@ function useLeaderboardLegendItems({
|
|
|
8075
8424
|
overrideColor: secondaryColor || leaderboardChartSettings.secondaryColor
|
|
8076
8425
|
});
|
|
8077
8426
|
items.push({
|
|
8078
|
-
label: legendLabels?.comparison ||
|
|
8427
|
+
label: legendLabels?.comparison || __8("Previous period", "jetpack-charts"),
|
|
8079
8428
|
color: resolvedSecondaryColor
|
|
8080
8429
|
});
|
|
8081
8430
|
}
|
|
@@ -8110,7 +8459,7 @@ var leaderboard_chart_module_default = {
|
|
|
8110
8459
|
};
|
|
8111
8460
|
|
|
8112
8461
|
// src/charts/leaderboard-chart/leaderboard-chart.tsx
|
|
8113
|
-
import { jsx as
|
|
8462
|
+
import { jsx as _jsx27, Fragment as _Fragment8, jsxs as _jsxs12 } from "react/jsx-runtime";
|
|
8114
8463
|
var defaultValueFormatter = (value) => {
|
|
8115
8464
|
return formatMetricValue(value, "number", {
|
|
8116
8465
|
useMultipliers: true,
|
|
@@ -8125,8 +8474,8 @@ var defaultDeltaFormatter = (value) => {
|
|
|
8125
8474
|
};
|
|
8126
8475
|
var BarLabel = ({
|
|
8127
8476
|
label
|
|
8128
|
-
}) => /* @__PURE__ */
|
|
8129
|
-
children: typeof label === "string" ? /* @__PURE__ */
|
|
8477
|
+
}) => /* @__PURE__ */ _jsx27(_Fragment8, {
|
|
8478
|
+
children: typeof label === "string" ? /* @__PURE__ */ _jsx27(Text, {
|
|
8130
8479
|
className: leaderboard_chart_module_default.label,
|
|
8131
8480
|
children: label
|
|
8132
8481
|
}) : label
|
|
@@ -8140,13 +8489,13 @@ var BarWithLabel = ({
|
|
|
8140
8489
|
animation,
|
|
8141
8490
|
isPrimaryVisible = true,
|
|
8142
8491
|
isComparisonVisible = true
|
|
8143
|
-
}) => /* @__PURE__ */
|
|
8492
|
+
}) => /* @__PURE__ */ _jsxs12("div", {
|
|
8144
8493
|
className: clsx9(leaderboard_chart_module_default.barWithLabelContainer, {
|
|
8145
8494
|
[leaderboard_chart_module_default["is-overlay"]]: withOverlayLabel
|
|
8146
8495
|
}),
|
|
8147
|
-
children: [/* @__PURE__ */
|
|
8496
|
+
children: [/* @__PURE__ */ _jsx27(BarLabel, {
|
|
8148
8497
|
label: entry.label
|
|
8149
|
-
}), isPrimaryVisible && /* @__PURE__ */
|
|
8498
|
+
}), isPrimaryVisible && /* @__PURE__ */ _jsx27("div", {
|
|
8150
8499
|
className: clsx9(leaderboard_chart_module_default.bar, {
|
|
8151
8500
|
[leaderboard_chart_module_default["bar--animated"]]: animation
|
|
8152
8501
|
}),
|
|
@@ -8154,7 +8503,7 @@ var BarWithLabel = ({
|
|
|
8154
8503
|
width: entry.currentShare + "%",
|
|
8155
8504
|
backgroundColor: primaryColor
|
|
8156
8505
|
}
|
|
8157
|
-
}), withComparison && !withOverlayLabel && isComparisonVisible && /* @__PURE__ */
|
|
8506
|
+
}), withComparison && !withOverlayLabel && isComparisonVisible && /* @__PURE__ */ _jsx27("div", {
|
|
8158
8507
|
className: clsx9(leaderboard_chart_module_default.bar, {
|
|
8159
8508
|
[leaderboard_chart_module_default["bar--animated"]]: animation
|
|
8160
8509
|
}),
|
|
@@ -8232,19 +8581,19 @@ var LeaderboardChartInternal = ({
|
|
|
8232
8581
|
withOverlayLabel,
|
|
8233
8582
|
legendLabels
|
|
8234
8583
|
});
|
|
8235
|
-
const isPrimaryVisible =
|
|
8584
|
+
const isPrimaryVisible = useMemo24(() => {
|
|
8236
8585
|
if (!chartId || !legendInteractive || legendItems.length === 0) {
|
|
8237
8586
|
return true;
|
|
8238
8587
|
}
|
|
8239
8588
|
return isSeriesVisible(chartId, legendItems[0].label);
|
|
8240
8589
|
}, [chartId, legendInteractive, legendItems, isSeriesVisible]);
|
|
8241
|
-
const isComparisonVisible =
|
|
8590
|
+
const isComparisonVisible = useMemo24(() => {
|
|
8242
8591
|
if (!chartId || !legendInteractive || legendItems.length < 2) {
|
|
8243
8592
|
return true;
|
|
8244
8593
|
}
|
|
8245
8594
|
return isSeriesVisible(chartId, legendItems[1].label);
|
|
8246
8595
|
}, [chartId, legendInteractive, legendItems, isSeriesVisible]);
|
|
8247
|
-
const allSeriesHidden =
|
|
8596
|
+
const allSeriesHidden = useMemo24(() => {
|
|
8248
8597
|
if (!legendInteractive) return false;
|
|
8249
8598
|
if (withComparison && !withOverlayLabel) {
|
|
8250
8599
|
return !isPrimaryVisible && !isComparisonVisible;
|
|
@@ -8252,7 +8601,7 @@ var LeaderboardChartInternal = ({
|
|
|
8252
8601
|
return !isPrimaryVisible;
|
|
8253
8602
|
}, [legendInteractive, isPrimaryVisible, isComparisonVisible, withComparison, withOverlayLabel]);
|
|
8254
8603
|
const isDataValid = Boolean(data && data.length > 0);
|
|
8255
|
-
const chartMetadata =
|
|
8604
|
+
const chartMetadata = useMemo24(() => ({
|
|
8256
8605
|
withComparison,
|
|
8257
8606
|
withOverlayLabel
|
|
8258
8607
|
}), [withComparison, withOverlayLabel]);
|
|
@@ -8265,11 +8614,11 @@ var LeaderboardChartInternal = ({
|
|
|
8265
8614
|
});
|
|
8266
8615
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
8267
8616
|
if (!data || data.length === 0) {
|
|
8268
|
-
return /* @__PURE__ */
|
|
8617
|
+
return /* @__PURE__ */ _jsx27(SingleChartContext.Provider, {
|
|
8269
8618
|
value: {
|
|
8270
8619
|
chartId
|
|
8271
8620
|
},
|
|
8272
|
-
children: /* @__PURE__ */
|
|
8621
|
+
children: /* @__PURE__ */ _jsx27(ChartLayout, {
|
|
8273
8622
|
legendPosition,
|
|
8274
8623
|
legendElement: false,
|
|
8275
8624
|
legendChildren,
|
|
@@ -8284,14 +8633,14 @@ var LeaderboardChartInternal = ({
|
|
|
8284
8633
|
height: propHeight || void 0
|
|
8285
8634
|
},
|
|
8286
8635
|
trailingContent: nonLegendChildren,
|
|
8287
|
-
children: /* @__PURE__ */
|
|
8636
|
+
children: /* @__PURE__ */ _jsx27("div", {
|
|
8288
8637
|
className: leaderboard_chart_module_default.emptyState,
|
|
8289
|
-
children: loading ?
|
|
8638
|
+
children: loading ? __9("Loading\u2026", "jetpack-charts") : __9("No data available", "jetpack-charts")
|
|
8290
8639
|
})
|
|
8291
8640
|
})
|
|
8292
8641
|
});
|
|
8293
8642
|
}
|
|
8294
|
-
const legendElement = showLegend && /* @__PURE__ */
|
|
8643
|
+
const legendElement = showLegend && /* @__PURE__ */ _jsx27(Legend, {
|
|
8295
8644
|
orientation: legend.orientation ?? "horizontal",
|
|
8296
8645
|
position: legendPosition,
|
|
8297
8646
|
alignment: legend.alignment ?? "center",
|
|
@@ -8303,11 +8652,11 @@ var LeaderboardChartInternal = ({
|
|
|
8303
8652
|
chartId,
|
|
8304
8653
|
interactive: legendInteractive
|
|
8305
8654
|
});
|
|
8306
|
-
return /* @__PURE__ */
|
|
8655
|
+
return /* @__PURE__ */ _jsx27(SingleChartContext.Provider, {
|
|
8307
8656
|
value: {
|
|
8308
8657
|
chartId
|
|
8309
8658
|
},
|
|
8310
|
-
children: /* @__PURE__ */
|
|
8659
|
+
children: /* @__PURE__ */ _jsx27(ChartLayout, {
|
|
8311
8660
|
legendPosition,
|
|
8312
8661
|
legendElement,
|
|
8313
8662
|
legendChildren,
|
|
@@ -8322,23 +8671,23 @@ var LeaderboardChartInternal = ({
|
|
|
8322
8671
|
height: propHeight || void 0
|
|
8323
8672
|
},
|
|
8324
8673
|
trailingContent: nonLegendChildren,
|
|
8325
|
-
children: /* @__PURE__ */
|
|
8674
|
+
children: /* @__PURE__ */ _jsx27("div", {
|
|
8326
8675
|
className: leaderboard_chart_module_default.leaderboardChart__content,
|
|
8327
|
-
children: allSeriesHidden ? /* @__PURE__ */
|
|
8676
|
+
children: allSeriesHidden ? /* @__PURE__ */ _jsx27("div", {
|
|
8328
8677
|
className: leaderboard_chart_module_default.emptyState,
|
|
8329
|
-
children:
|
|
8330
|
-
}) : /* @__PURE__ */
|
|
8678
|
+
children: __9("All series are hidden. Click legend items to show data.", "jetpack-charts")
|
|
8679
|
+
}) : /* @__PURE__ */ _jsx27(component_default2, {
|
|
8331
8680
|
templateColumns: "minmax(0, 1fr) auto",
|
|
8332
8681
|
rowGap,
|
|
8333
8682
|
columnGap,
|
|
8334
8683
|
children: data.map((entry) => {
|
|
8335
8684
|
const colorIndex = Math.sign(entry.delta) + 1;
|
|
8336
8685
|
const deltaColor = deltaColors[colorIndex];
|
|
8337
|
-
return /* @__PURE__ */
|
|
8338
|
-
children: [/* @__PURE__ */
|
|
8686
|
+
return /* @__PURE__ */ _jsxs12(Fragment, {
|
|
8687
|
+
children: [/* @__PURE__ */ _jsx27(Stack, {
|
|
8339
8688
|
direction: "column",
|
|
8340
8689
|
gap: labelSpacing,
|
|
8341
|
-
children: /* @__PURE__ */
|
|
8690
|
+
children: /* @__PURE__ */ _jsx27(BarWithLabel, {
|
|
8342
8691
|
entry,
|
|
8343
8692
|
withComparison,
|
|
8344
8693
|
withOverlayLabel,
|
|
@@ -8348,15 +8697,15 @@ var LeaderboardChartInternal = ({
|
|
|
8348
8697
|
isComparisonVisible,
|
|
8349
8698
|
animation: animation && !loading && !prefersReducedMotion
|
|
8350
8699
|
})
|
|
8351
|
-
}), /* @__PURE__ */
|
|
8700
|
+
}), /* @__PURE__ */ _jsxs12(Stack, {
|
|
8352
8701
|
direction: "row",
|
|
8353
8702
|
gap: "xs",
|
|
8354
8703
|
className: clsx9(leaderboard_chart_module_default.valueContainer, {
|
|
8355
8704
|
[leaderboard_chart_module_default.overlayLabel]: withOverlayLabel
|
|
8356
8705
|
}),
|
|
8357
|
-
children: [isPrimaryVisible && /* @__PURE__ */
|
|
8706
|
+
children: [isPrimaryVisible && /* @__PURE__ */ _jsx27(Text, {
|
|
8358
8707
|
children: valueFormatter(entry.currentValue)
|
|
8359
|
-
}), withComparison && isComparisonVisible && /* @__PURE__ */
|
|
8708
|
+
}), withComparison && isComparisonVisible && /* @__PURE__ */ _jsx27(Text, {
|
|
8360
8709
|
style: {
|
|
8361
8710
|
color: deltaColor
|
|
8362
8711
|
},
|
|
@@ -8371,14 +8720,14 @@ var LeaderboardChartInternal = ({
|
|
|
8371
8720
|
});
|
|
8372
8721
|
};
|
|
8373
8722
|
var LeaderboardChartWithProvider = (props) => {
|
|
8374
|
-
const existingContext =
|
|
8723
|
+
const existingContext = useContext24(GlobalChartsContext);
|
|
8375
8724
|
if (existingContext) {
|
|
8376
|
-
return /* @__PURE__ */
|
|
8725
|
+
return /* @__PURE__ */ _jsx27(LeaderboardChartInternal, {
|
|
8377
8726
|
...props
|
|
8378
8727
|
});
|
|
8379
8728
|
}
|
|
8380
|
-
return /* @__PURE__ */
|
|
8381
|
-
children: /* @__PURE__ */
|
|
8729
|
+
return /* @__PURE__ */ _jsx27(GlobalChartsProvider, {
|
|
8730
|
+
children: /* @__PURE__ */ _jsx27(LeaderboardChartInternal, {
|
|
8382
8731
|
...props
|
|
8383
8732
|
})
|
|
8384
8733
|
});
|
|
@@ -8395,12 +8744,12 @@ var LeaderboardChartResponsive = attachSubComponents(withResponsive(LeaderboardC
|
|
|
8395
8744
|
import { Group as Group4 } from "@visx/group";
|
|
8396
8745
|
import { Pie } from "@visx/shape";
|
|
8397
8746
|
import { useTooltip as useTooltip2, useTooltipInPortal as useTooltipInPortal2 } from "@visx/tooltip";
|
|
8398
|
-
import { __ as
|
|
8747
|
+
import { __ as __10 } from "@wordpress/i18n";
|
|
8399
8748
|
import clsx10 from "clsx";
|
|
8400
|
-
import { useCallback as
|
|
8749
|
+
import { useCallback as useCallback14, useContext as useContext25, useMemo as useMemo25 } from "react";
|
|
8401
8750
|
|
|
8402
8751
|
// src/charts/private/radial-wipe-animation/radial-wipe-animation.tsx
|
|
8403
|
-
import { jsx as
|
|
8752
|
+
import { jsx as _jsx28 } from "react/jsx-runtime";
|
|
8404
8753
|
function RadialWipeAnimation({
|
|
8405
8754
|
id,
|
|
8406
8755
|
radius,
|
|
@@ -8416,9 +8765,9 @@ function RadialWipeAnimation({
|
|
|
8416
8765
|
const isValidWipePercentage = 0 < wipePercentage && wipePercentage <= 100;
|
|
8417
8766
|
const animationDuration = `${// If wipePercentage is invalid, set animation duration to 0 to disable animation.
|
|
8418
8767
|
isValidWipePercentage ? durationMs * (100 / wipePercentage) : 0}ms`;
|
|
8419
|
-
return /* @__PURE__ */
|
|
8768
|
+
return /* @__PURE__ */ _jsx28("mask", {
|
|
8420
8769
|
id,
|
|
8421
|
-
children: /* @__PURE__ */
|
|
8770
|
+
children: /* @__PURE__ */ _jsx28("circle", {
|
|
8422
8771
|
cx: 0,
|
|
8423
8772
|
cy: 0,
|
|
8424
8773
|
r: radius,
|
|
@@ -8431,7 +8780,7 @@ function RadialWipeAnimation({
|
|
|
8431
8780
|
style: {
|
|
8432
8781
|
transform: `rotate(${startAngle}) scaleY(${scaleY})`
|
|
8433
8782
|
},
|
|
8434
|
-
children: /* @__PURE__ */
|
|
8783
|
+
children: /* @__PURE__ */ _jsx28("animate", {
|
|
8435
8784
|
attributeName: "stroke-dashoffset",
|
|
8436
8785
|
from: "0",
|
|
8437
8786
|
to: "100.1",
|
|
@@ -8454,11 +8803,11 @@ var pie_chart_module_default = {
|
|
|
8454
8803
|
};
|
|
8455
8804
|
|
|
8456
8805
|
// src/charts/pie-chart/pie-chart.tsx
|
|
8457
|
-
import { jsx as
|
|
8806
|
+
import { jsx as _jsx29, Fragment as _Fragment9, jsxs as _jsxs13 } from "react/jsx-runtime";
|
|
8458
8807
|
var renderDefaultPieTooltip = ({
|
|
8459
8808
|
tooltipData
|
|
8460
8809
|
}) => {
|
|
8461
|
-
return /* @__PURE__ */
|
|
8810
|
+
return /* @__PURE__ */ _jsx29(BaseTooltip, {
|
|
8462
8811
|
data: tooltipData,
|
|
8463
8812
|
top: 0,
|
|
8464
8813
|
left: 0,
|
|
@@ -8535,7 +8884,7 @@ var PieChartInternal = ({
|
|
|
8535
8884
|
scroll: true,
|
|
8536
8885
|
debounce: 0
|
|
8537
8886
|
});
|
|
8538
|
-
const onMouseLeave =
|
|
8887
|
+
const onMouseLeave = useCallback14(() => {
|
|
8539
8888
|
if (!withTooltips) {
|
|
8540
8889
|
return;
|
|
8541
8890
|
}
|
|
@@ -8556,7 +8905,7 @@ var PieChartInternal = ({
|
|
|
8556
8905
|
legendInteractive,
|
|
8557
8906
|
isSeriesVisible
|
|
8558
8907
|
});
|
|
8559
|
-
const legendOptions =
|
|
8908
|
+
const legendOptions = useMemo25(() => ({
|
|
8560
8909
|
showValues: true,
|
|
8561
8910
|
legendValueDisplay
|
|
8562
8911
|
}), [legendValueDisplay]);
|
|
@@ -8571,7 +8920,7 @@ var PieChartInternal = ({
|
|
|
8571
8920
|
legendChildren,
|
|
8572
8921
|
otherChildren
|
|
8573
8922
|
} = useChartChildren(children, "PieChart");
|
|
8574
|
-
const chartMetadata =
|
|
8923
|
+
const chartMetadata = useMemo25(() => ({
|
|
8575
8924
|
thickness,
|
|
8576
8925
|
gapScale,
|
|
8577
8926
|
cornerScale
|
|
@@ -8585,9 +8934,9 @@ var PieChartInternal = ({
|
|
|
8585
8934
|
});
|
|
8586
8935
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
8587
8936
|
if (!isValid2) {
|
|
8588
|
-
return /* @__PURE__ */
|
|
8937
|
+
return /* @__PURE__ */ _jsx29("div", {
|
|
8589
8938
|
className: clsx10("pie-chart", pie_chart_module_default["pie-chart"], className),
|
|
8590
|
-
children: /* @__PURE__ */
|
|
8939
|
+
children: /* @__PURE__ */ _jsx29("div", {
|
|
8591
8940
|
className: pie_chart_module_default["error-message"],
|
|
8592
8941
|
children: message
|
|
8593
8942
|
})
|
|
@@ -8610,7 +8959,7 @@ var PieChartInternal = ({
|
|
|
8610
8959
|
}).color;
|
|
8611
8960
|
}
|
|
8612
8961
|
};
|
|
8613
|
-
const legendElement = showLegend && /* @__PURE__ */
|
|
8962
|
+
const legendElement = showLegend && /* @__PURE__ */ _jsx29(Legend, {
|
|
8614
8963
|
orientation: legend.orientation ?? "horizontal",
|
|
8615
8964
|
position: legendPosition,
|
|
8616
8965
|
alignment: legend.alignment ?? "center",
|
|
@@ -8622,11 +8971,11 @@ var PieChartInternal = ({
|
|
|
8622
8971
|
chartId,
|
|
8623
8972
|
interactive: legendInteractive
|
|
8624
8973
|
});
|
|
8625
|
-
return /* @__PURE__ */
|
|
8974
|
+
return /* @__PURE__ */ _jsx29(SingleChartContext.Provider, {
|
|
8626
8975
|
value: {
|
|
8627
8976
|
chartId
|
|
8628
8977
|
},
|
|
8629
|
-
children: /* @__PURE__ */
|
|
8978
|
+
children: /* @__PURE__ */ _jsx29(ChartLayout, {
|
|
8630
8979
|
legendPosition,
|
|
8631
8980
|
legendElement,
|
|
8632
8981
|
legendChildren,
|
|
@@ -8644,11 +8993,11 @@ var PieChartInternal = ({
|
|
|
8644
8993
|
width: propWidth || void 0,
|
|
8645
8994
|
height: propHeight || void 0
|
|
8646
8995
|
},
|
|
8647
|
-
trailingContent: /* @__PURE__ */
|
|
8648
|
-
children: [withTooltips && tooltipOpen && tooltipData && /* @__PURE__ */
|
|
8996
|
+
trailingContent: /* @__PURE__ */ _jsxs13(_Fragment9, {
|
|
8997
|
+
children: [withTooltips && tooltipOpen && tooltipData && /* @__PURE__ */ _jsx29(TooltipInPortal, {
|
|
8649
8998
|
top: tooltipTop || 0,
|
|
8650
8999
|
left: tooltipLeft || 0,
|
|
8651
|
-
children: /* @__PURE__ */
|
|
9000
|
+
children: /* @__PURE__ */ _jsx29("div", {
|
|
8652
9001
|
role: "tooltip",
|
|
8653
9002
|
children: renderTooltip({
|
|
8654
9003
|
tooltipData
|
|
@@ -8673,33 +9022,33 @@ var PieChartInternal = ({
|
|
|
8673
9022
|
const innerRadius = thickness === 0 ? 0 : outerRadius * (1 - thickness);
|
|
8674
9023
|
const maxCornerRadius = (outerRadius - innerRadius) / 2;
|
|
8675
9024
|
const cornerRadius = cornerScale ? Math.min(cornerScale * outerRadius, maxCornerRadius) : 0;
|
|
8676
|
-
return /* @__PURE__ */
|
|
9025
|
+
return /* @__PURE__ */ _jsx29(Stack, {
|
|
8677
9026
|
ref: containerRef,
|
|
8678
9027
|
align: "center",
|
|
8679
9028
|
justify: "center",
|
|
8680
9029
|
className: pie_chart_module_default["pie-chart__centering"],
|
|
8681
|
-
children: /* @__PURE__ */
|
|
9030
|
+
children: /* @__PURE__ */ _jsxs13("svg", {
|
|
8682
9031
|
viewBox: `0 0 ${width} ${height}`,
|
|
8683
9032
|
preserveAspectRatio: "xMidYMid meet",
|
|
8684
9033
|
width,
|
|
8685
9034
|
height,
|
|
8686
|
-
children: [/* @__PURE__ */
|
|
8687
|
-
children: /* @__PURE__ */
|
|
9035
|
+
children: [/* @__PURE__ */ _jsx29("defs", {
|
|
9036
|
+
children: /* @__PURE__ */ _jsx29(radial_wipe_animation_default, {
|
|
8688
9037
|
id: `radial-wipe-${chartId}`,
|
|
8689
9038
|
radius: outerRadius,
|
|
8690
9039
|
innerRadius
|
|
8691
9040
|
})
|
|
8692
|
-
}), /* @__PURE__ */
|
|
9041
|
+
}), /* @__PURE__ */ _jsxs13(Group4, {
|
|
8693
9042
|
top: centerY,
|
|
8694
9043
|
left: centerX,
|
|
8695
9044
|
mask: animation && !prefersReducedMotion ? `url(#radial-wipe-${chartId})` : null,
|
|
8696
|
-
children: [allSegmentsHidden ? /* @__PURE__ */
|
|
9045
|
+
children: [allSegmentsHidden ? /* @__PURE__ */ _jsx29(SvgEmptyState, {
|
|
8697
9046
|
x: 0,
|
|
8698
9047
|
y: 0,
|
|
8699
9048
|
width,
|
|
8700
9049
|
height,
|
|
8701
|
-
children:
|
|
8702
|
-
}) : /* @__PURE__ */
|
|
9050
|
+
children: __10("All segments are hidden. Click legend items to show data.", "jetpack-charts")
|
|
9051
|
+
}) : /* @__PURE__ */ _jsx29(Pie, {
|
|
8703
9052
|
data: dataWithIndex,
|
|
8704
9053
|
pieValue: accessors.value,
|
|
8705
9054
|
outerRadius,
|
|
@@ -8743,12 +9092,12 @@ var PieChartInternal = ({
|
|
|
8743
9092
|
const labelPadding = 6;
|
|
8744
9093
|
const backgroundWidth = estimatedTextWidth + labelPadding * 2;
|
|
8745
9094
|
const backgroundHeight = fontSize + labelPadding * 2;
|
|
8746
|
-
return /* @__PURE__ */
|
|
9095
|
+
return /* @__PURE__ */ _jsxs13("g", {
|
|
8747
9096
|
...groupProps,
|
|
8748
|
-
children: [/* @__PURE__ */
|
|
9097
|
+
children: [/* @__PURE__ */ _jsx29("path", {
|
|
8749
9098
|
...pathProps
|
|
8750
|
-
}), showLabels && hasSpaceForLabel && /* @__PURE__ */
|
|
8751
|
-
children: [providerTheme.labelBackgroundColor && /* @__PURE__ */
|
|
9099
|
+
}), showLabels && hasSpaceForLabel && /* @__PURE__ */ _jsxs13("g", {
|
|
9100
|
+
children: [providerTheme.labelBackgroundColor && /* @__PURE__ */ _jsx29("rect", {
|
|
8752
9101
|
x: centroidX - backgroundWidth / 2,
|
|
8753
9102
|
y: centroidY - backgroundHeight / 2,
|
|
8754
9103
|
width: backgroundWidth,
|
|
@@ -8757,7 +9106,7 @@ var PieChartInternal = ({
|
|
|
8757
9106
|
rx: 4,
|
|
8758
9107
|
ry: 4,
|
|
8759
9108
|
pointerEvents: "none"
|
|
8760
|
-
}), /* @__PURE__ */
|
|
9109
|
+
}), /* @__PURE__ */ _jsx29("text", {
|
|
8761
9110
|
x: centroidX,
|
|
8762
9111
|
y: centroidY,
|
|
8763
9112
|
dy: ".33em",
|
|
@@ -8780,14 +9129,14 @@ var PieChartInternal = ({
|
|
|
8780
9129
|
});
|
|
8781
9130
|
};
|
|
8782
9131
|
var PieChartWithProvider = (props) => {
|
|
8783
|
-
const existingContext =
|
|
9132
|
+
const existingContext = useContext25(GlobalChartsContext);
|
|
8784
9133
|
if (existingContext) {
|
|
8785
|
-
return /* @__PURE__ */
|
|
9134
|
+
return /* @__PURE__ */ _jsx29(PieChartInternal, {
|
|
8786
9135
|
...props
|
|
8787
9136
|
});
|
|
8788
9137
|
}
|
|
8789
|
-
return /* @__PURE__ */
|
|
8790
|
-
children: /* @__PURE__ */
|
|
9138
|
+
return /* @__PURE__ */ _jsx29(GlobalChartsProvider, {
|
|
9139
|
+
children: /* @__PURE__ */ _jsx29(PieChartInternal, {
|
|
8791
9140
|
...props
|
|
8792
9141
|
})
|
|
8793
9142
|
});
|
|
@@ -8809,9 +9158,9 @@ import { Group as Group5 } from "@visx/group";
|
|
|
8809
9158
|
import { Pie as Pie2 } from "@visx/shape";
|
|
8810
9159
|
import { Text as Text4 } from "@visx/text";
|
|
8811
9160
|
import { useTooltip as useTooltip3, useTooltipInPortal as useTooltipInPortal3 } from "@visx/tooltip";
|
|
8812
|
-
import { __ as
|
|
9161
|
+
import { __ as __11 } from "@wordpress/i18n";
|
|
8813
9162
|
import clsx11 from "clsx";
|
|
8814
|
-
import { useCallback as
|
|
9163
|
+
import { useCallback as useCallback15, useContext as useContext26, useMemo as useMemo26 } from "react";
|
|
8815
9164
|
|
|
8816
9165
|
// src/charts/pie-semi-circle-chart/pie-semi-circle-chart.module.scss
|
|
8817
9166
|
var pie_semi_circle_chart_module_default = {
|
|
@@ -8823,11 +9172,11 @@ var pie_semi_circle_chart_module_default = {
|
|
|
8823
9172
|
};
|
|
8824
9173
|
|
|
8825
9174
|
// src/charts/pie-semi-circle-chart/pie-semi-circle-chart.tsx
|
|
8826
|
-
import { jsx as
|
|
9175
|
+
import { jsx as _jsx30, Fragment as _Fragment10, jsxs as _jsxs14 } from "react/jsx-runtime";
|
|
8827
9176
|
var renderDefaultPieSemiCircleTooltip = ({
|
|
8828
9177
|
tooltipData
|
|
8829
9178
|
}) => {
|
|
8830
|
-
return /* @__PURE__ */
|
|
9179
|
+
return /* @__PURE__ */ _jsx30(BaseTooltip, {
|
|
8831
9180
|
data: tooltipData,
|
|
8832
9181
|
top: 0,
|
|
8833
9182
|
left: 0,
|
|
@@ -8903,7 +9252,7 @@ var PieSemiCircleChartInternal = ({
|
|
|
8903
9252
|
scroll: true,
|
|
8904
9253
|
debounce: 0
|
|
8905
9254
|
});
|
|
8906
|
-
const handleMouseMove =
|
|
9255
|
+
const handleMouseMove = useCallback15((event, arc) => {
|
|
8907
9256
|
if (containerBounds.width === 0 || containerBounds.height === 0) {
|
|
8908
9257
|
return;
|
|
8909
9258
|
}
|
|
@@ -8913,10 +9262,10 @@ var PieSemiCircleChartInternal = ({
|
|
|
8913
9262
|
tooltipTop: event.clientY - containerBounds.top + tooltipOffsetY
|
|
8914
9263
|
});
|
|
8915
9264
|
}, [containerBounds.width, containerBounds.height, containerBounds.left, containerBounds.top, showTooltip, tooltipOffsetX, tooltipOffsetY]);
|
|
8916
|
-
const handleMouseLeave =
|
|
9265
|
+
const handleMouseLeave = useCallback15(() => {
|
|
8917
9266
|
hideTooltip();
|
|
8918
9267
|
}, [hideTooltip]);
|
|
8919
|
-
const handleArcMouseMove =
|
|
9268
|
+
const handleArcMouseMove = useCallback15((arc) => (event) => {
|
|
8920
9269
|
handleMouseMove(event, arc);
|
|
8921
9270
|
}, [handleMouseMove]);
|
|
8922
9271
|
const {
|
|
@@ -8938,7 +9287,7 @@ var PieSemiCircleChartInternal = ({
|
|
|
8938
9287
|
legendInteractive,
|
|
8939
9288
|
isSeriesVisible
|
|
8940
9289
|
});
|
|
8941
|
-
const accessors =
|
|
9290
|
+
const accessors = useMemo26(() => ({
|
|
8942
9291
|
value: (d) => d.value,
|
|
8943
9292
|
sort: (a, b) => b.value - a.value,
|
|
8944
9293
|
fill: (d) => getElementStyles({
|
|
@@ -8946,7 +9295,7 @@ var PieSemiCircleChartInternal = ({
|
|
|
8946
9295
|
index: d.index
|
|
8947
9296
|
}).color
|
|
8948
9297
|
}), [getElementStyles]);
|
|
8949
|
-
const legendOptions =
|
|
9298
|
+
const legendOptions = useMemo26(() => ({
|
|
8950
9299
|
showValues: true,
|
|
8951
9300
|
legendValueDisplay
|
|
8952
9301
|
}), [legendValueDisplay]);
|
|
@@ -8957,7 +9306,7 @@ var PieSemiCircleChartInternal = ({
|
|
|
8957
9306
|
legendChildren,
|
|
8958
9307
|
otherChildren
|
|
8959
9308
|
} = useChartChildren(children, "PieSemiCircleChart");
|
|
8960
|
-
const chartMetadata =
|
|
9309
|
+
const chartMetadata = useMemo26(() => ({
|
|
8961
9310
|
thickness,
|
|
8962
9311
|
clockwise
|
|
8963
9312
|
}), [thickness, clockwise]);
|
|
@@ -8973,12 +9322,12 @@ var PieSemiCircleChartInternal = ({
|
|
|
8973
9322
|
if (!isValid2) {
|
|
8974
9323
|
const errorWidth = propHeight ? Math.min(propWidth || propHeight * 2, propHeight * 2) : effectiveWidth;
|
|
8975
9324
|
const errorHeight = errorWidth / 2;
|
|
8976
|
-
return /* @__PURE__ */
|
|
9325
|
+
return /* @__PURE__ */ _jsx30("div", {
|
|
8977
9326
|
className: pie_semi_circle_chart_module_default["pie-semi-circle-chart"],
|
|
8978
|
-
children: /* @__PURE__ */
|
|
9327
|
+
children: /* @__PURE__ */ _jsx30("svg", {
|
|
8979
9328
|
width: errorWidth,
|
|
8980
9329
|
height: errorHeight,
|
|
8981
|
-
children: /* @__PURE__ */
|
|
9330
|
+
children: /* @__PURE__ */ _jsx30("text", {
|
|
8982
9331
|
x: "50%",
|
|
8983
9332
|
y: "50%",
|
|
8984
9333
|
textAnchor: "middle",
|
|
@@ -8997,7 +9346,7 @@ var PieSemiCircleChartInternal = ({
|
|
|
8997
9346
|
});
|
|
8998
9347
|
const startAngle = clockwise ? -Math.PI / 2 : Math.PI / 2;
|
|
8999
9348
|
const endAngle = clockwise ? Math.PI / 2 : -Math.PI / 2;
|
|
9000
|
-
const legendElement = showLegend && /* @__PURE__ */
|
|
9349
|
+
const legendElement = showLegend && /* @__PURE__ */ _jsx30(Legend, {
|
|
9001
9350
|
orientation: legend.orientation ?? "horizontal",
|
|
9002
9351
|
position: legendPosition,
|
|
9003
9352
|
alignment: legend.alignment ?? "center",
|
|
@@ -9009,11 +9358,11 @@ var PieSemiCircleChartInternal = ({
|
|
|
9009
9358
|
chartId,
|
|
9010
9359
|
interactive: legendInteractive
|
|
9011
9360
|
});
|
|
9012
|
-
return /* @__PURE__ */
|
|
9361
|
+
return /* @__PURE__ */ _jsx30(SingleChartContext.Provider, {
|
|
9013
9362
|
value: {
|
|
9014
9363
|
chartId
|
|
9015
9364
|
},
|
|
9016
|
-
children: /* @__PURE__ */
|
|
9365
|
+
children: /* @__PURE__ */ _jsx30(ChartLayout, {
|
|
9017
9366
|
legendPosition,
|
|
9018
9367
|
legendElement,
|
|
9019
9368
|
legendChildren,
|
|
@@ -9025,11 +9374,11 @@ var PieSemiCircleChartInternal = ({
|
|
|
9025
9374
|
width: propWidth || void 0,
|
|
9026
9375
|
height: propHeight || void 0
|
|
9027
9376
|
},
|
|
9028
|
-
trailingContent: /* @__PURE__ */
|
|
9029
|
-
children: [withTooltips && tooltipOpen && tooltipData && /* @__PURE__ */
|
|
9377
|
+
trailingContent: /* @__PURE__ */ _jsxs14(_Fragment10, {
|
|
9378
|
+
children: [withTooltips && tooltipOpen && tooltipData && /* @__PURE__ */ _jsx30(TooltipInPortal, {
|
|
9030
9379
|
top: tooltipTop || 0,
|
|
9031
9380
|
left: tooltipLeft || 0,
|
|
9032
|
-
children: /* @__PURE__ */
|
|
9381
|
+
children: /* @__PURE__ */ _jsx30("div", {
|
|
9033
9382
|
role: "tooltip",
|
|
9034
9383
|
children: renderTooltip({
|
|
9035
9384
|
tooltipData
|
|
@@ -9047,35 +9396,35 @@ var PieSemiCircleChartInternal = ({
|
|
|
9047
9396
|
const height = width / 2;
|
|
9048
9397
|
const radius = height;
|
|
9049
9398
|
const innerRadius = radius * (1 - thickness);
|
|
9050
|
-
return /* @__PURE__ */
|
|
9399
|
+
return /* @__PURE__ */ _jsx30(Stack, {
|
|
9051
9400
|
ref: containerRef,
|
|
9052
9401
|
align: "center",
|
|
9053
9402
|
justify: "center",
|
|
9054
9403
|
className: pie_semi_circle_chart_module_default["pie-semi-circle-chart__centering"],
|
|
9055
|
-
children: /* @__PURE__ */
|
|
9404
|
+
children: /* @__PURE__ */ _jsxs14("svg", {
|
|
9056
9405
|
width,
|
|
9057
9406
|
height,
|
|
9058
9407
|
viewBox: `0 0 ${width} ${height}`,
|
|
9059
|
-
children: [/* @__PURE__ */
|
|
9060
|
-
children: /* @__PURE__ */
|
|
9408
|
+
children: [/* @__PURE__ */ _jsx30("defs", {
|
|
9409
|
+
children: /* @__PURE__ */ _jsx30(radial_wipe_animation_default, {
|
|
9061
9410
|
id: `radial-wipe-${chartId}`,
|
|
9062
9411
|
radius,
|
|
9063
9412
|
innerRadius,
|
|
9064
9413
|
startAngle: "-180deg",
|
|
9065
9414
|
wipePercentage: 50
|
|
9066
9415
|
})
|
|
9067
|
-
}), /* @__PURE__ */
|
|
9416
|
+
}), /* @__PURE__ */ _jsx30(Group5, {
|
|
9068
9417
|
top: height,
|
|
9069
9418
|
left: width / 2,
|
|
9070
9419
|
mask: animation && !prefersReducedMotion ? `url(#radial-wipe-${chartId})` : null,
|
|
9071
|
-
children: allSegmentsHidden ? /* @__PURE__ */
|
|
9420
|
+
children: allSegmentsHidden ? /* @__PURE__ */ _jsx30(SvgEmptyState, {
|
|
9072
9421
|
x: 0,
|
|
9073
9422
|
y: -radius / 2,
|
|
9074
9423
|
width,
|
|
9075
9424
|
height,
|
|
9076
|
-
children:
|
|
9077
|
-
}) : /* @__PURE__ */
|
|
9078
|
-
children: [/* @__PURE__ */
|
|
9425
|
+
children: __11("All segments are hidden. Click legend items to show data.", "jetpack-charts")
|
|
9426
|
+
}) : /* @__PURE__ */ _jsxs14(_Fragment10, {
|
|
9427
|
+
children: [/* @__PURE__ */ _jsx30(Pie2, {
|
|
9079
9428
|
data: dataWithIndex,
|
|
9080
9429
|
pieValue: accessors.value,
|
|
9081
9430
|
outerRadius: radius,
|
|
@@ -9086,23 +9435,23 @@ var PieSemiCircleChartInternal = ({
|
|
|
9086
9435
|
endAngle,
|
|
9087
9436
|
pieSort: accessors.sort,
|
|
9088
9437
|
children: (pie) => {
|
|
9089
|
-
return pie.arcs.map((arc) => /* @__PURE__ */
|
|
9438
|
+
return pie.arcs.map((arc) => /* @__PURE__ */ _jsx30("g", {
|
|
9090
9439
|
onMouseMove: withTooltips ? handleArcMouseMove(arc) : void 0,
|
|
9091
9440
|
onMouseLeave: withTooltips ? handleMouseLeave : void 0,
|
|
9092
|
-
children: /* @__PURE__ */
|
|
9441
|
+
children: /* @__PURE__ */ _jsx30("path", {
|
|
9093
9442
|
d: pie.path(arc) || "",
|
|
9094
9443
|
fill: accessors.fill(arc.data)
|
|
9095
9444
|
})
|
|
9096
9445
|
}, arc.data.label));
|
|
9097
9446
|
}
|
|
9098
|
-
}), /* @__PURE__ */
|
|
9099
|
-
children: [/* @__PURE__ */
|
|
9447
|
+
}), /* @__PURE__ */ _jsxs14(Group5, {
|
|
9448
|
+
children: [/* @__PURE__ */ _jsx30(Text4, {
|
|
9100
9449
|
textAnchor: "middle",
|
|
9101
9450
|
verticalAnchor: "start",
|
|
9102
9451
|
y: -40,
|
|
9103
9452
|
className: pie_semi_circle_chart_module_default.label,
|
|
9104
9453
|
children: label
|
|
9105
|
-
}), /* @__PURE__ */
|
|
9454
|
+
}), /* @__PURE__ */ _jsx30(Text4, {
|
|
9106
9455
|
textAnchor: "middle",
|
|
9107
9456
|
verticalAnchor: "start",
|
|
9108
9457
|
y: -20,
|
|
@@ -9119,14 +9468,14 @@ var PieSemiCircleChartInternal = ({
|
|
|
9119
9468
|
});
|
|
9120
9469
|
};
|
|
9121
9470
|
var PieSemiCircleChartWithProvider = (props) => {
|
|
9122
|
-
const existingContext =
|
|
9471
|
+
const existingContext = useContext26(GlobalChartsContext);
|
|
9123
9472
|
if (existingContext) {
|
|
9124
|
-
return /* @__PURE__ */
|
|
9473
|
+
return /* @__PURE__ */ _jsx30(PieSemiCircleChartInternal, {
|
|
9125
9474
|
...props
|
|
9126
9475
|
});
|
|
9127
9476
|
}
|
|
9128
|
-
return /* @__PURE__ */
|
|
9129
|
-
children: /* @__PURE__ */
|
|
9477
|
+
return /* @__PURE__ */ _jsx30(GlobalChartsProvider, {
|
|
9478
|
+
children: /* @__PURE__ */ _jsx30(PieSemiCircleChartInternal, {
|
|
9130
9479
|
...props
|
|
9131
9480
|
})
|
|
9132
9481
|
});
|
|
@@ -9145,7 +9494,7 @@ var PieSemiCircleChartResponsive = attachSubComponents(withResponsive(PieSemiCir
|
|
|
9145
9494
|
|
|
9146
9495
|
// src/charts/sparkline/sparkline.tsx
|
|
9147
9496
|
import clsx12 from "clsx";
|
|
9148
|
-
import { useMemo as
|
|
9497
|
+
import { useMemo as useMemo27, forwardRef as forwardRef8 } from "react";
|
|
9149
9498
|
|
|
9150
9499
|
// src/charts/sparkline/sparkline.module.scss
|
|
9151
9500
|
var sparkline_module_default = {
|
|
@@ -9154,7 +9503,7 @@ var sparkline_module_default = {
|
|
|
9154
9503
|
};
|
|
9155
9504
|
|
|
9156
9505
|
// src/charts/sparkline/sparkline.tsx
|
|
9157
|
-
import { jsx as
|
|
9506
|
+
import { jsx as _jsx31 } from "react/jsx-runtime";
|
|
9158
9507
|
var DEFAULT_WIDTH2 = 100;
|
|
9159
9508
|
var DEFAULT_HEIGHT = 40;
|
|
9160
9509
|
var transformToSeriesData = (data, color, strokeWidth) => {
|
|
@@ -9190,13 +9539,13 @@ var SparklineComponent = /* @__PURE__ */ forwardRef8(({
|
|
|
9190
9539
|
const theme = useGlobalChartsTheme();
|
|
9191
9540
|
const themeStrokeWidth = theme.sparkline?.strokeWidth ?? 1.5;
|
|
9192
9541
|
const strokeWidth = strokeWidthProp ?? themeStrokeWidth;
|
|
9193
|
-
const seriesData =
|
|
9542
|
+
const seriesData = useMemo27(() => {
|
|
9194
9543
|
if (!data || data.length === 0) {
|
|
9195
9544
|
return [];
|
|
9196
9545
|
}
|
|
9197
9546
|
return transformToSeriesData(data, color, strokeWidth);
|
|
9198
9547
|
}, [data, color, strokeWidth]);
|
|
9199
|
-
const finalMargin =
|
|
9548
|
+
const finalMargin = useMemo27(() => {
|
|
9200
9549
|
const themeMargin = theme.sparkline?.margin ?? {
|
|
9201
9550
|
top: 2,
|
|
9202
9551
|
right: 2,
|
|
@@ -9209,7 +9558,7 @@ var SparklineComponent = /* @__PURE__ */ forwardRef8(({
|
|
|
9209
9558
|
...margin
|
|
9210
9559
|
};
|
|
9211
9560
|
}, [marginProp, theme.sparkline?.margin]);
|
|
9212
|
-
const seriesWithGradient =
|
|
9561
|
+
const seriesWithGradient = useMemo27(() => {
|
|
9213
9562
|
if (!gradient || seriesData.length === 0) {
|
|
9214
9563
|
return seriesData;
|
|
9215
9564
|
}
|
|
@@ -9227,7 +9576,7 @@ var SparklineComponent = /* @__PURE__ */ forwardRef8(({
|
|
|
9227
9576
|
}));
|
|
9228
9577
|
}, [seriesData, gradient, color]);
|
|
9229
9578
|
if (!data || data.length === 0) {
|
|
9230
|
-
return /* @__PURE__ */
|
|
9579
|
+
return /* @__PURE__ */ _jsx31("div", {
|
|
9231
9580
|
ref,
|
|
9232
9581
|
className: clsx12("sparkline", sparkline_module_default.sparkline, sparkline_module_default["sparkline--empty"], className),
|
|
9233
9582
|
style: {
|
|
@@ -9240,18 +9589,18 @@ var SparklineComponent = /* @__PURE__ */ forwardRef8(({
|
|
|
9240
9589
|
const cx2 = width / 2;
|
|
9241
9590
|
const cy = height / 2;
|
|
9242
9591
|
const resolvedColor = color || "#000000";
|
|
9243
|
-
return /* @__PURE__ */
|
|
9592
|
+
return /* @__PURE__ */ _jsx31("div", {
|
|
9244
9593
|
ref,
|
|
9245
9594
|
className: clsx12("sparkline", sparkline_module_default.sparkline, sparkline_module_default["sparkline--single-point"], className),
|
|
9246
9595
|
style: {
|
|
9247
9596
|
width,
|
|
9248
9597
|
height
|
|
9249
9598
|
},
|
|
9250
|
-
children: /* @__PURE__ */
|
|
9599
|
+
children: /* @__PURE__ */ _jsx31("svg", {
|
|
9251
9600
|
width,
|
|
9252
9601
|
height,
|
|
9253
9602
|
"aria-hidden": "true",
|
|
9254
|
-
children: /* @__PURE__ */
|
|
9603
|
+
children: /* @__PURE__ */ _jsx31("circle", {
|
|
9255
9604
|
cx: cx2,
|
|
9256
9605
|
cy,
|
|
9257
9606
|
r: strokeWidth * 1.5,
|
|
@@ -9260,10 +9609,10 @@ var SparklineComponent = /* @__PURE__ */ forwardRef8(({
|
|
|
9260
9609
|
})
|
|
9261
9610
|
});
|
|
9262
9611
|
}
|
|
9263
|
-
return /* @__PURE__ */
|
|
9612
|
+
return /* @__PURE__ */ _jsx31("div", {
|
|
9264
9613
|
ref,
|
|
9265
9614
|
className: clsx12("sparkline", sparkline_module_default.sparkline, className),
|
|
9266
|
-
children: /* @__PURE__ */
|
|
9615
|
+
children: /* @__PURE__ */ _jsx31(LineChart, {
|
|
9267
9616
|
data: seriesWithGradient,
|
|
9268
9617
|
width,
|
|
9269
9618
|
height,
|
|
@@ -9307,7 +9656,7 @@ var trend_indicator_module_default = {
|
|
|
9307
9656
|
};
|
|
9308
9657
|
|
|
9309
9658
|
// src/components/trend-indicator/trend-indicator.tsx
|
|
9310
|
-
import { jsx as
|
|
9659
|
+
import { jsx as _jsx32, jsxs as _jsxs15 } from "react/jsx-runtime";
|
|
9311
9660
|
var DIRECTION_LABELS = {
|
|
9312
9661
|
up: "Increase",
|
|
9313
9662
|
down: "Decrease",
|
|
@@ -9320,12 +9669,12 @@ var Icon2 = ({
|
|
|
9320
9669
|
return null;
|
|
9321
9670
|
}
|
|
9322
9671
|
const isUp = direction === "up";
|
|
9323
|
-
return /* @__PURE__ */
|
|
9672
|
+
return /* @__PURE__ */ _jsx32("svg", {
|
|
9324
9673
|
className: trend_indicator_module_default["trend-indicator__icon"],
|
|
9325
9674
|
viewBox: "0 0 16 16",
|
|
9326
9675
|
fill: "none",
|
|
9327
9676
|
"aria-hidden": "true",
|
|
9328
|
-
children: /* @__PURE__ */
|
|
9677
|
+
children: /* @__PURE__ */ _jsx32("path", {
|
|
9329
9678
|
d: isUp ? "M8 13V3M4 7l4-4 4 4" : "M8 3v10M4 9l4 4 4-4",
|
|
9330
9679
|
stroke: "currentColor",
|
|
9331
9680
|
strokeWidth: "1.5",
|
|
@@ -9342,13 +9691,13 @@ function TrendIndicator({
|
|
|
9342
9691
|
showIcon = true
|
|
9343
9692
|
}) {
|
|
9344
9693
|
const ariaLabel = `${DIRECTION_LABELS[direction]}: ${value}`;
|
|
9345
|
-
return /* @__PURE__ */
|
|
9694
|
+
return /* @__PURE__ */ _jsxs15("span", {
|
|
9346
9695
|
className: clsx13(trend_indicator_module_default["trend-indicator"], trend_indicator_module_default[`trend-indicator--${direction}`], className),
|
|
9347
9696
|
style,
|
|
9348
9697
|
"aria-label": ariaLabel,
|
|
9349
|
-
children: [showIcon && /* @__PURE__ */
|
|
9698
|
+
children: [showIcon && /* @__PURE__ */ _jsx32(Icon2, {
|
|
9350
9699
|
direction
|
|
9351
|
-
}), /* @__PURE__ */
|
|
9700
|
+
}), /* @__PURE__ */ _jsx32("span", {
|
|
9352
9701
|
className: trend_indicator_module_default["trend-indicator__value"],
|
|
9353
9702
|
children: value
|
|
9354
9703
|
})]
|