@automattic/charts 1.4.2 → 1.5.0
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 +14 -0
- package/SECURITY.md +0 -1
- package/dist/index.cjs +449 -137
- 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 +747 -435
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/charts/area-chart/area-chart.tsx +24 -10
- package/src/charts/area-chart/test/area-chart.test.tsx +73 -3
- package/src/charts/area-chart/types.ts +15 -0
- package/src/charts/line-chart/line-chart.tsx +16 -5
- 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 +162 -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,126 @@ 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, 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 ZoomResetButton({
|
|
3315
|
+
onClick
|
|
3316
|
+
}) {
|
|
3317
|
+
const label = __("Reset zoom", "jetpack-charts");
|
|
3318
|
+
return /* @__PURE__ */ _jsx12("button", {
|
|
3319
|
+
type: "button",
|
|
3320
|
+
className: x_zoom_module_default["x-zoom__reset"],
|
|
3321
|
+
onClick,
|
|
3322
|
+
"aria-label": label,
|
|
3323
|
+
title: label,
|
|
3324
|
+
children: /* @__PURE__ */ _jsxs4("svg", {
|
|
3325
|
+
className: x_zoom_module_default["x-zoom__reset-icon"],
|
|
3326
|
+
viewBox: "0 0 24 24",
|
|
3327
|
+
fill: "none",
|
|
3328
|
+
stroke: "currentColor",
|
|
3329
|
+
strokeWidth: "2",
|
|
3330
|
+
strokeLinecap: "round",
|
|
3331
|
+
strokeLinejoin: "round",
|
|
3332
|
+
"aria-hidden": "true",
|
|
3333
|
+
focusable: "false",
|
|
3334
|
+
children: [/* @__PURE__ */ _jsx12("circle", {
|
|
3335
|
+
cx: "10",
|
|
3336
|
+
cy: "10",
|
|
3337
|
+
r: "6"
|
|
3338
|
+
}), /* @__PURE__ */ _jsx12("line", {
|
|
3339
|
+
x1: "15",
|
|
3340
|
+
y1: "15",
|
|
3341
|
+
x2: "20",
|
|
3342
|
+
y2: "20"
|
|
3343
|
+
}), /* @__PURE__ */ _jsx12("line", {
|
|
3344
|
+
x1: "7",
|
|
3345
|
+
y1: "10",
|
|
3346
|
+
x2: "13",
|
|
3347
|
+
y2: "10"
|
|
3348
|
+
})]
|
|
3349
|
+
})
|
|
3350
|
+
});
|
|
3351
|
+
}
|
|
3352
|
+
|
|
3082
3353
|
// src/charts/line-chart/line-chart.module.scss
|
|
3083
3354
|
var line_chart_module_default = {
|
|
3084
3355
|
"line-chart": "a8ccharts-v-oO8E",
|
|
@@ -3099,11 +3370,11 @@ var line_chart_module_default = {
|
|
|
3099
3370
|
};
|
|
3100
3371
|
|
|
3101
3372
|
// src/charts/line-chart/private/line-chart-annotation-label-popover.tsx
|
|
3102
|
-
import { __ } from "@wordpress/i18n";
|
|
3373
|
+
import { __ as __2 } from "@wordpress/i18n";
|
|
3103
3374
|
import { Icon, close } from "@wordpress/icons";
|
|
3104
3375
|
import clsx3 from "clsx";
|
|
3105
|
-
import { useEffect as useEffect7, useId as useId3, useRef as useRef7, useState as
|
|
3106
|
-
import { jsx as
|
|
3376
|
+
import { useEffect as useEffect7, useId as useId3, useRef as useRef7, useState as useState7 } from "react";
|
|
3377
|
+
import { jsx as _jsx13, jsxs as _jsxs5 } from "react/jsx-runtime";
|
|
3107
3378
|
var POPOVER_BUTTON_SIZE = 44;
|
|
3108
3379
|
var LineChartAnnotationLabelWithPopover = ({
|
|
3109
3380
|
title,
|
|
@@ -3114,7 +3385,7 @@ var LineChartAnnotationLabelWithPopover = ({
|
|
|
3114
3385
|
const popoverId = useId3();
|
|
3115
3386
|
const buttonRef = useRef7(null);
|
|
3116
3387
|
const popoverRef = useRef7(null);
|
|
3117
|
-
const [isPositioned, setIsPositioned] =
|
|
3388
|
+
const [isPositioned, setIsPositioned] = useState7(false);
|
|
3118
3389
|
const isBrowserSafari = isSafari();
|
|
3119
3390
|
useEffect7(() => {
|
|
3120
3391
|
const button = buttonRef.current;
|
|
@@ -3140,9 +3411,9 @@ var LineChartAnnotationLabelWithPopover = ({
|
|
|
3140
3411
|
} catch {
|
|
3141
3412
|
}
|
|
3142
3413
|
}, [isBrowserSafari]);
|
|
3143
|
-
return /* @__PURE__ */
|
|
3414
|
+
return /* @__PURE__ */ _jsxs5("div", {
|
|
3144
3415
|
className: line_chart_module_default["line-chart__annotation-label"],
|
|
3145
|
-
children: [/* @__PURE__ */
|
|
3416
|
+
children: [/* @__PURE__ */ _jsx13("button", {
|
|
3146
3417
|
ref: buttonRef,
|
|
3147
3418
|
popovertarget: popoverId,
|
|
3148
3419
|
className: line_chart_module_default["line-chart__annotation-label-trigger-button"],
|
|
@@ -3151,32 +3422,32 @@ var LineChartAnnotationLabelWithPopover = ({
|
|
|
3151
3422
|
height: `${POPOVER_BUTTON_SIZE}px`,
|
|
3152
3423
|
transform: `translate(${POPOVER_BUTTON_SIZE / 2}px, 0)`
|
|
3153
3424
|
},
|
|
3154
|
-
"aria-label": title ||
|
|
3425
|
+
"aria-label": title || __2("View details", "jetpack-charts"),
|
|
3155
3426
|
children: renderLabel({
|
|
3156
3427
|
title,
|
|
3157
3428
|
subtitle
|
|
3158
3429
|
})
|
|
3159
|
-
}), /* @__PURE__ */
|
|
3430
|
+
}), /* @__PURE__ */ _jsx13("div", {
|
|
3160
3431
|
ref: popoverRef,
|
|
3161
3432
|
id: popoverId,
|
|
3162
3433
|
popover: "auto",
|
|
3163
3434
|
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__ */
|
|
3435
|
+
children: /* @__PURE__ */ _jsxs5(Stack, {
|
|
3165
3436
|
direction: "row",
|
|
3166
3437
|
align: "flex-start",
|
|
3167
3438
|
justify: "space-between",
|
|
3168
|
-
children: [/* @__PURE__ */
|
|
3439
|
+
children: [/* @__PURE__ */ _jsx13("div", {
|
|
3169
3440
|
className: line_chart_module_default["line-chart__annotation-label-popover-content"],
|
|
3170
3441
|
children: renderLabelPopover({
|
|
3171
3442
|
title,
|
|
3172
3443
|
subtitle
|
|
3173
3444
|
})
|
|
3174
|
-
}), /* @__PURE__ */
|
|
3445
|
+
}), /* @__PURE__ */ _jsx13("button", {
|
|
3175
3446
|
popovertarget: popoverId,
|
|
3176
3447
|
popovertargetaction: "hide",
|
|
3177
3448
|
className: line_chart_module_default["line-chart__annotation-label-popover-close-button"],
|
|
3178
|
-
"aria-label":
|
|
3179
|
-
children: /* @__PURE__ */
|
|
3449
|
+
"aria-label": __2("Close", "jetpack-charts"),
|
|
3450
|
+
children: /* @__PURE__ */ _jsx13(Icon, {
|
|
3180
3451
|
icon: close,
|
|
3181
3452
|
size: 16
|
|
3182
3453
|
})
|
|
@@ -3188,9 +3459,9 @@ var LineChartAnnotationLabelWithPopover = ({
|
|
|
3188
3459
|
var line_chart_annotation_label_popover_default = LineChartAnnotationLabelWithPopover;
|
|
3189
3460
|
|
|
3190
3461
|
// 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
|
|
3462
|
+
import { DataContext as DataContext3 } from "@visx/xychart";
|
|
3463
|
+
import { useEffect as useEffect8, useState as useState8, useCallback as useCallback8 } from "react";
|
|
3464
|
+
import { jsx as _jsx14 } from "react/jsx-runtime";
|
|
3194
3465
|
var LineChartAnnotationsOverlay = ({
|
|
3195
3466
|
children
|
|
3196
3467
|
}) => {
|
|
@@ -3199,16 +3470,16 @@ var LineChartAnnotationsOverlay = ({
|
|
|
3199
3470
|
chartWidth,
|
|
3200
3471
|
chartHeight
|
|
3201
3472
|
} = useSingleChartContext();
|
|
3202
|
-
const [scales, setScales] =
|
|
3203
|
-
const [scalesStable, setScalesStable] =
|
|
3204
|
-
const createScaleSignature =
|
|
3473
|
+
const [scales, setScales] = useState8(null);
|
|
3474
|
+
const [scalesStable, setScalesStable] = useState8(false);
|
|
3475
|
+
const createScaleSignature = useCallback8((scaleData) => {
|
|
3205
3476
|
const xDomain = scaleData.xScale.domain();
|
|
3206
3477
|
const yDomain = scaleData.yScale.domain();
|
|
3207
3478
|
const xRange = scaleData.xScale.range();
|
|
3208
3479
|
const yRange = scaleData.yScale.range();
|
|
3209
3480
|
return `${xDomain.join(",")}-${yDomain.join(",")}-${xRange.join(",")}-${yRange.join(",")}`;
|
|
3210
3481
|
}, []);
|
|
3211
|
-
const getScalesData =
|
|
3482
|
+
const getScalesData = useCallback8(() => {
|
|
3212
3483
|
if (chartRef?.current) {
|
|
3213
3484
|
const scaleData = chartRef.current.getScales();
|
|
3214
3485
|
if (scaleData) {
|
|
@@ -3272,9 +3543,9 @@ var LineChartAnnotationsOverlay = ({
|
|
|
3272
3543
|
width: chartWidth,
|
|
3273
3544
|
height: chartHeight
|
|
3274
3545
|
};
|
|
3275
|
-
return /* @__PURE__ */
|
|
3546
|
+
return /* @__PURE__ */ _jsx14(DataContext3.Provider, {
|
|
3276
3547
|
value: dataContextValue,
|
|
3277
|
-
children: /* @__PURE__ */
|
|
3548
|
+
children: /* @__PURE__ */ _jsx14("svg", {
|
|
3278
3549
|
width: chartWidth,
|
|
3279
3550
|
height: chartHeight,
|
|
3280
3551
|
className: line_chart_module_default["line-chart__annotations-overlay"],
|
|
@@ -3286,10 +3557,10 @@ var line_chart_annotations_overlay_default = LineChartAnnotationsOverlay;
|
|
|
3286
3557
|
|
|
3287
3558
|
// src/charts/line-chart/private/line-chart-annotation.tsx
|
|
3288
3559
|
import { Annotation, CircleSubject, Connector, HtmlLabel, Label, LineSubject } from "@visx/annotation";
|
|
3289
|
-
import { DataContext as
|
|
3560
|
+
import { DataContext as DataContext4 } from "@visx/xychart";
|
|
3290
3561
|
import merge from "deepmerge";
|
|
3291
|
-
import { useContext as
|
|
3292
|
-
import { jsx as
|
|
3562
|
+
import { useContext as useContext10, useRef as useRef8, useEffect as useEffect9, useState as useState9, useMemo as useMemo15 } from "react";
|
|
3563
|
+
import { jsx as _jsx15, jsxs as _jsxs6 } from "react/jsx-runtime";
|
|
3293
3564
|
var ANNOTATION_MAX_WIDTH = 125;
|
|
3294
3565
|
var ANNOTATION_INIT_HEIGHT = 100;
|
|
3295
3566
|
var getLabelPosition = ({
|
|
@@ -3381,9 +3652,9 @@ var LineChartAnnotation = ({
|
|
|
3381
3652
|
const {
|
|
3382
3653
|
xScale,
|
|
3383
3654
|
yScale
|
|
3384
|
-
} =
|
|
3655
|
+
} = useContext10(DataContext4) || {};
|
|
3385
3656
|
const labelRef = useRef8(null);
|
|
3386
|
-
const [height, setHeight] =
|
|
3657
|
+
const [height, setHeight] = useState9(null);
|
|
3387
3658
|
const styles = merge(providerTheme.annotationStyles ?? {}, datumStyles ?? {});
|
|
3388
3659
|
useEffect9(() => {
|
|
3389
3660
|
if (labelRef.current?.getBBox) {
|
|
@@ -3391,7 +3662,7 @@ var LineChartAnnotation = ({
|
|
|
3391
3662
|
setHeight(bbox.height);
|
|
3392
3663
|
}
|
|
3393
3664
|
}, []);
|
|
3394
|
-
const positionData =
|
|
3665
|
+
const positionData = useMemo15(() => {
|
|
3395
3666
|
if (!datum || !datum.date || datum.value == null || !xScale || !yScale) return null;
|
|
3396
3667
|
const x2 = xScale(datum.date);
|
|
3397
3668
|
const y2 = yScale(datum.value);
|
|
@@ -3470,32 +3741,32 @@ var LineChartAnnotation = ({
|
|
|
3470
3741
|
height: labelHeight
|
|
3471
3742
|
} : void 0;
|
|
3472
3743
|
};
|
|
3473
|
-
return /* @__PURE__ */
|
|
3474
|
-
children: /* @__PURE__ */
|
|
3744
|
+
return /* @__PURE__ */ _jsx15("g", {
|
|
3745
|
+
children: /* @__PURE__ */ _jsxs6(Annotation, {
|
|
3475
3746
|
x,
|
|
3476
3747
|
y,
|
|
3477
3748
|
dx,
|
|
3478
3749
|
dy,
|
|
3479
|
-
children: [/* @__PURE__ */
|
|
3750
|
+
children: [/* @__PURE__ */ _jsx15(Connector, {
|
|
3480
3751
|
...styles?.connector
|
|
3481
|
-
}), subjectType === "circle" && /* @__PURE__ */
|
|
3752
|
+
}), subjectType === "circle" && /* @__PURE__ */ _jsx15(CircleSubject, {
|
|
3482
3753
|
...styles?.circleSubject
|
|
3483
|
-
}), subjectType === "line-vertical" && /* @__PURE__ */
|
|
3754
|
+
}), subjectType === "line-vertical" && /* @__PURE__ */ _jsx15(LineSubject, {
|
|
3484
3755
|
min: yMax,
|
|
3485
3756
|
max: yMin,
|
|
3486
3757
|
...styles?.lineSubject,
|
|
3487
3758
|
orientation: "vertical"
|
|
3488
|
-
}), subjectType === "line-horizontal" && /* @__PURE__ */
|
|
3759
|
+
}), subjectType === "line-horizontal" && /* @__PURE__ */ _jsx15(LineSubject, {
|
|
3489
3760
|
min: xMin,
|
|
3490
3761
|
max: xMax,
|
|
3491
3762
|
...styles?.lineSubject,
|
|
3492
3763
|
orientation: "horizontal"
|
|
3493
|
-
}), renderLabel ? /* @__PURE__ */
|
|
3764
|
+
}), renderLabel ? /* @__PURE__ */ _jsx15(HtmlLabel, {
|
|
3494
3765
|
...styles?.label,
|
|
3495
3766
|
...labelPosition,
|
|
3496
|
-
children: /* @__PURE__ */
|
|
3767
|
+
children: /* @__PURE__ */ _jsx15("div", {
|
|
3497
3768
|
style: getSafariHTMLLabelPosition(),
|
|
3498
|
-
children: renderLabelPopover ? /* @__PURE__ */
|
|
3769
|
+
children: renderLabelPopover ? /* @__PURE__ */ _jsx15(line_chart_annotation_label_popover_default, {
|
|
3499
3770
|
title,
|
|
3500
3771
|
subtitle,
|
|
3501
3772
|
renderLabel,
|
|
@@ -3505,9 +3776,9 @@ var LineChartAnnotation = ({
|
|
|
3505
3776
|
subtitle
|
|
3506
3777
|
})
|
|
3507
3778
|
})
|
|
3508
|
-
}) : /* @__PURE__ */
|
|
3779
|
+
}) : /* @__PURE__ */ _jsx15("g", {
|
|
3509
3780
|
ref: labelRef,
|
|
3510
|
-
children: /* @__PURE__ */
|
|
3781
|
+
children: /* @__PURE__ */ _jsx15(Label, {
|
|
3511
3782
|
title,
|
|
3512
3783
|
subtitle,
|
|
3513
3784
|
...styles?.label,
|
|
@@ -3522,8 +3793,8 @@ var LineChartAnnotation = ({
|
|
|
3522
3793
|
var line_chart_annotation_default = LineChartAnnotation;
|
|
3523
3794
|
|
|
3524
3795
|
// src/charts/line-chart/private/line-chart-glyph.tsx
|
|
3525
|
-
import { DataContext as
|
|
3526
|
-
import { useContext as
|
|
3796
|
+
import { DataContext as DataContext5 } from "@visx/xychart";
|
|
3797
|
+
import { useContext as useContext11 } from "react";
|
|
3527
3798
|
var toNumber = (val) => {
|
|
3528
3799
|
const num = typeof val === "number" ? val : parseFloat(val);
|
|
3529
3800
|
return isNaN(num) ? void 0 : num;
|
|
@@ -3540,7 +3811,7 @@ var LineChartGlyph = ({
|
|
|
3540
3811
|
const {
|
|
3541
3812
|
xScale,
|
|
3542
3813
|
yScale
|
|
3543
|
-
} =
|
|
3814
|
+
} = useContext11(DataContext5) || {};
|
|
3544
3815
|
if (!xScale || !yScale) return null;
|
|
3545
3816
|
if (data.data.length === 0) return null;
|
|
3546
3817
|
const point = position2 === "start" ? data.data[0] : data.data[data.data.length - 1];
|
|
@@ -3563,7 +3834,7 @@ var LineChartGlyph = ({
|
|
|
3563
3834
|
var line_chart_glyph_default = LineChartGlyph;
|
|
3564
3835
|
|
|
3565
3836
|
// src/charts/line-chart/line-chart.tsx
|
|
3566
|
-
import { jsx as
|
|
3837
|
+
import { jsx as _jsx16, jsxs as _jsxs7 } from "react/jsx-runtime";
|
|
3567
3838
|
var defaultRenderGlyph = (props) => {
|
|
3568
3839
|
return /* @__PURE__ */ _createElement2(DefaultGlyph, {
|
|
3569
3840
|
...props,
|
|
@@ -3586,20 +3857,20 @@ var renderDefaultTooltip = (params) => {
|
|
|
3586
3857
|
key,
|
|
3587
3858
|
value: datum.value
|
|
3588
3859
|
})).sort((a, b) => b.value - a.value);
|
|
3589
|
-
return /* @__PURE__ */
|
|
3860
|
+
return /* @__PURE__ */ _jsxs7("div", {
|
|
3590
3861
|
className: line_chart_module_default["line-chart__tooltip"],
|
|
3591
|
-
children: [/* @__PURE__ */
|
|
3862
|
+
children: [/* @__PURE__ */ _jsx16("div", {
|
|
3592
3863
|
className: line_chart_module_default["line-chart__tooltip-date"],
|
|
3593
3864
|
children: nearestDatum.date?.toLocaleDateString()
|
|
3594
|
-
}), tooltipPoints.map((point) => /* @__PURE__ */
|
|
3865
|
+
}), tooltipPoints.map((point) => /* @__PURE__ */ _jsxs7(Stack, {
|
|
3595
3866
|
direction: "row",
|
|
3596
3867
|
align: "center",
|
|
3597
3868
|
justify: "space-between",
|
|
3598
3869
|
className: line_chart_module_default["line-chart__tooltip-row"],
|
|
3599
|
-
children: [/* @__PURE__ */
|
|
3870
|
+
children: [/* @__PURE__ */ _jsxs7("span", {
|
|
3600
3871
|
className: line_chart_module_default["line-chart__tooltip-label"],
|
|
3601
3872
|
children: [point.key, ":"]
|
|
3602
|
-
}), /* @__PURE__ */
|
|
3873
|
+
}), /* @__PURE__ */ _jsx16("span", {
|
|
3603
3874
|
className: line_chart_module_default["line-chart__tooltip-value"],
|
|
3604
3875
|
children: formatNumber5(point.value)
|
|
3605
3876
|
})]
|
|
@@ -3618,7 +3889,7 @@ var LineChartScalesRef = ({
|
|
|
3618
3889
|
height,
|
|
3619
3890
|
margin
|
|
3620
3891
|
}) => {
|
|
3621
|
-
const context =
|
|
3892
|
+
const context = useContext12(DataContext6);
|
|
3622
3893
|
useImperativeHandle2(chartRef, () => ({
|
|
3623
3894
|
getScales: () => {
|
|
3624
3895
|
if (!context?.xScale || !context?.yScale) {
|
|
@@ -3663,6 +3934,7 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3663
3934
|
onPointerUp = void 0,
|
|
3664
3935
|
onPointerMove = void 0,
|
|
3665
3936
|
onPointerOut = void 0,
|
|
3937
|
+
zoomable = false,
|
|
3666
3938
|
children,
|
|
3667
3939
|
gridVisibility,
|
|
3668
3940
|
gap = "md"
|
|
@@ -3674,15 +3946,24 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3674
3946
|
const theme = useXYChartTheme(data);
|
|
3675
3947
|
const chartId = useChartId(providedChartId);
|
|
3676
3948
|
const chartRef = useRef9(null);
|
|
3677
|
-
const [selectedIndex, setSelectedIndex] =
|
|
3678
|
-
const [isNavigating, setIsNavigating] =
|
|
3949
|
+
const [selectedIndex, setSelectedIndex] = useState10(void 0);
|
|
3950
|
+
const [isNavigating, setIsNavigating] = useState10(false);
|
|
3679
3951
|
const internalChartRef = useRef9(null);
|
|
3952
|
+
const zoom = useXZoom({
|
|
3953
|
+
enabled: zoomable,
|
|
3954
|
+
chartRef: internalChartRef,
|
|
3955
|
+
userHandlers: {
|
|
3956
|
+
onPointerDown,
|
|
3957
|
+
onPointerMove,
|
|
3958
|
+
onPointerUp
|
|
3959
|
+
}
|
|
3960
|
+
});
|
|
3680
3961
|
const {
|
|
3681
3962
|
legendChildren,
|
|
3682
3963
|
nonLegendChildren
|
|
3683
3964
|
} = useChartChildren(children, "LineChart");
|
|
3684
|
-
const [measuredChartHeight, setMeasuredChartHeight] =
|
|
3685
|
-
const handleContentHeightChange =
|
|
3965
|
+
const [measuredChartHeight, setMeasuredChartHeight] = useState10();
|
|
3966
|
+
const handleContentHeightChange = useCallback9((contentHeight) => {
|
|
3686
3967
|
const chartHeight = contentHeight > 0 ? contentHeight : height;
|
|
3687
3968
|
setMeasuredChartHeight(chartHeight);
|
|
3688
3969
|
}, [height]);
|
|
@@ -3699,7 +3980,7 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3699
3980
|
getElementStyles,
|
|
3700
3981
|
isSeriesVisible
|
|
3701
3982
|
} = useGlobalChartsContext();
|
|
3702
|
-
const seriesWithVisibility =
|
|
3983
|
+
const seriesWithVisibility = useMemo16(() => {
|
|
3703
3984
|
if (!chartId || !legendInteractive) {
|
|
3704
3985
|
return dataSorted.map((series, index) => ({
|
|
3705
3986
|
series,
|
|
@@ -3713,7 +3994,7 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3713
3994
|
isVisible: isSeriesVisible(chartId, series.label)
|
|
3714
3995
|
}));
|
|
3715
3996
|
}, [dataSorted, chartId, isSeriesVisible, legendInteractive]);
|
|
3716
|
-
const allSeriesHidden =
|
|
3997
|
+
const allSeriesHidden = useMemo16(() => {
|
|
3717
3998
|
return seriesWithVisibility.every(({
|
|
3718
3999
|
isVisible
|
|
3719
4000
|
}) => !isVisible);
|
|
@@ -3731,7 +4012,7 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3731
4012
|
chartRef,
|
|
3732
4013
|
totalPoints: dataSorted[0]?.data.length || 0
|
|
3733
4014
|
});
|
|
3734
|
-
const chartOptions =
|
|
4015
|
+
const chartOptions = useMemo16(() => {
|
|
3735
4016
|
const formatter = options?.axis?.x?.tickFormat || getFormatter(dataSorted);
|
|
3736
4017
|
return {
|
|
3737
4018
|
axis: {
|
|
@@ -3752,7 +4033,10 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3752
4033
|
},
|
|
3753
4034
|
xScale: {
|
|
3754
4035
|
type: "time",
|
|
3755
|
-
...options?.xScale
|
|
4036
|
+
...options?.xScale,
|
|
4037
|
+
...zoom.domain ? {
|
|
4038
|
+
domain: zoom.domain
|
|
4039
|
+
} : {}
|
|
3756
4040
|
},
|
|
3757
4041
|
yScale: {
|
|
3758
4042
|
type: "linear",
|
|
@@ -3761,8 +4045,8 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3761
4045
|
...options?.yScale
|
|
3762
4046
|
}
|
|
3763
4047
|
};
|
|
3764
|
-
}, [options, dataSorted, width]);
|
|
3765
|
-
const tooltipRenderGlyph =
|
|
4048
|
+
}, [options, dataSorted, width, zoom.domain]);
|
|
4049
|
+
const tooltipRenderGlyph = useMemo16(() => {
|
|
3766
4050
|
return (props) => {
|
|
3767
4051
|
const seriesIndex = dataSorted.findIndex((series) => series.label === props.key || series.data.includes(props.datum));
|
|
3768
4052
|
const seriesData = dataSorted[seriesIndex];
|
|
@@ -3783,13 +4067,13 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3783
4067
|
const defaultMargin = useChartMargin(height, chartOptions, dataSorted, theme);
|
|
3784
4068
|
const error = validateData(dataSorted);
|
|
3785
4069
|
const isDataValid = !error;
|
|
3786
|
-
const legendOptions =
|
|
4070
|
+
const legendOptions = useMemo16(() => ({
|
|
3787
4071
|
withGlyph: withLegendGlyph,
|
|
3788
4072
|
glyphSize: Math.max(0, toNumber2(glyphStyle?.radius) ?? 4),
|
|
3789
4073
|
renderGlyph
|
|
3790
4074
|
}), [withLegendGlyph, glyphStyle?.radius, renderGlyph]);
|
|
3791
4075
|
const legendItems = useChartLegendItems(dataSorted, legendOptions, legendShape);
|
|
3792
|
-
const chartMetadata =
|
|
4076
|
+
const chartMetadata = useMemo16(() => ({
|
|
3793
4077
|
withGradientFill,
|
|
3794
4078
|
smoothing,
|
|
3795
4079
|
curveType,
|
|
@@ -3810,12 +4094,12 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3810
4094
|
yAccessor: (d) => d?.value
|
|
3811
4095
|
};
|
|
3812
4096
|
if (error) {
|
|
3813
|
-
return /* @__PURE__ */
|
|
4097
|
+
return /* @__PURE__ */ _jsx16("div", {
|
|
3814
4098
|
className: clsx4("line-chart", line_chart_module_default["line-chart"]),
|
|
3815
4099
|
children: error
|
|
3816
4100
|
});
|
|
3817
4101
|
}
|
|
3818
|
-
const legendElement = showLegend && /* @__PURE__ */
|
|
4102
|
+
const legendElement = showLegend && /* @__PURE__ */ _jsx16(Legend, {
|
|
3819
4103
|
orientation: legend.orientation ?? "horizontal",
|
|
3820
4104
|
alignment: legend.alignment ?? "center",
|
|
3821
4105
|
position: legendPosition,
|
|
@@ -3828,14 +4112,14 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3828
4112
|
chartId,
|
|
3829
4113
|
interactive: legendInteractive
|
|
3830
4114
|
});
|
|
3831
|
-
return /* @__PURE__ */
|
|
4115
|
+
return /* @__PURE__ */ _jsx16(SingleChartContext.Provider, {
|
|
3832
4116
|
value: {
|
|
3833
4117
|
chartId,
|
|
3834
4118
|
chartRef: internalChartRef,
|
|
3835
4119
|
chartWidth: width,
|
|
3836
4120
|
chartHeight: measuredChartHeight || 0
|
|
3837
4121
|
},
|
|
3838
|
-
children: /* @__PURE__ */
|
|
4122
|
+
children: /* @__PURE__ */ _jsx16(ChartLayout, {
|
|
3839
4123
|
legendPosition,
|
|
3840
4124
|
legendElement,
|
|
3841
4125
|
legendChildren,
|
|
@@ -3853,16 +4137,21 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3853
4137
|
contentHeight
|
|
3854
4138
|
}) => {
|
|
3855
4139
|
const chartHeight = contentHeight > 0 ? contentHeight : height;
|
|
3856
|
-
return /* @__PURE__ */
|
|
4140
|
+
return /* @__PURE__ */ _jsx16("div", {
|
|
3857
4141
|
role: "grid",
|
|
3858
|
-
"aria-label":
|
|
4142
|
+
"aria-label": __3("Line chart", "jetpack-charts"),
|
|
3859
4143
|
tabIndex: 0,
|
|
3860
4144
|
onKeyDown: onChartKeyDown,
|
|
3861
4145
|
onFocus: onChartFocus,
|
|
3862
4146
|
onBlur: onChartBlur,
|
|
3863
|
-
children: chartHeight > 0 && /* @__PURE__ */
|
|
4147
|
+
children: chartHeight > 0 && /* @__PURE__ */ _jsxs7("div", {
|
|
3864
4148
|
ref: chartRef,
|
|
3865
|
-
|
|
4149
|
+
style: {
|
|
4150
|
+
position: "relative"
|
|
4151
|
+
},
|
|
4152
|
+
children: [zoomable && zoom.domain && /* @__PURE__ */ _jsx16(ZoomResetButton, {
|
|
4153
|
+
onClick: zoom.reset
|
|
4154
|
+
}), /* @__PURE__ */ _jsxs7(XYChart, {
|
|
3866
4155
|
theme,
|
|
3867
4156
|
width,
|
|
3868
4157
|
height: chartHeight,
|
|
@@ -3872,24 +4161,24 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3872
4161
|
},
|
|
3873
4162
|
xScale: chartOptions.xScale,
|
|
3874
4163
|
yScale: chartOptions.yScale,
|
|
3875
|
-
onPointerDown,
|
|
3876
|
-
onPointerUp,
|
|
3877
|
-
onPointerMove,
|
|
4164
|
+
onPointerDown: zoom.handlers.onPointerDown,
|
|
4165
|
+
onPointerUp: zoom.handlers.onPointerUp,
|
|
4166
|
+
onPointerMove: zoom.handlers.onPointerMove,
|
|
3878
4167
|
onPointerOut,
|
|
3879
4168
|
pointerEventsDataKey: "nearest",
|
|
3880
|
-
children: [gridVisibility !== "none" && /* @__PURE__ */
|
|
4169
|
+
children: [gridVisibility !== "none" && /* @__PURE__ */ _jsx16(Grid, {
|
|
3881
4170
|
columns: false,
|
|
3882
4171
|
numTicks: 4
|
|
3883
|
-
}), chartOptions.axis.x.display && /* @__PURE__ */
|
|
4172
|
+
}), chartOptions.axis.x.display && /* @__PURE__ */ _jsx16(Axis, {
|
|
3884
4173
|
...chartOptions.axis.x
|
|
3885
|
-
}), chartOptions.axis.y.display && /* @__PURE__ */
|
|
4174
|
+
}), chartOptions.axis.y.display && /* @__PURE__ */ _jsx16(Axis, {
|
|
3886
4175
|
...chartOptions.axis.y
|
|
3887
|
-
}), allSeriesHidden ? /* @__PURE__ */
|
|
4176
|
+
}), allSeriesHidden ? /* @__PURE__ */ _jsx16(SvgEmptyState, {
|
|
3888
4177
|
x: width / 2,
|
|
3889
4178
|
y: chartHeight / 2,
|
|
3890
4179
|
width,
|
|
3891
4180
|
height: chartHeight,
|
|
3892
|
-
children:
|
|
4181
|
+
children: __3("All series are hidden. Click legend items to show data.", "jetpack-charts")
|
|
3893
4182
|
}) : null, seriesWithVisibility.map(({
|
|
3894
4183
|
series: seriesData,
|
|
3895
4184
|
index,
|
|
@@ -3910,20 +4199,20 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3910
4199
|
stroke: color,
|
|
3911
4200
|
...lineStyles
|
|
3912
4201
|
};
|
|
3913
|
-
return /* @__PURE__ */
|
|
3914
|
-
children: [withGradientFill && /* @__PURE__ */
|
|
4202
|
+
return /* @__PURE__ */ _jsxs7("g", {
|
|
4203
|
+
children: [withGradientFill && /* @__PURE__ */ _jsx16(LinearGradient, {
|
|
3915
4204
|
id: `area-gradient-${chartId}-${index + 1}`,
|
|
3916
4205
|
from: color,
|
|
3917
4206
|
fromOpacity: 0.4,
|
|
3918
4207
|
toOpacity: 0.1,
|
|
3919
4208
|
to: providerTheme.backgroundColor,
|
|
3920
4209
|
...seriesData.options?.gradient,
|
|
3921
|
-
children: seriesData.options?.gradient?.stops?.map((stop, stopIndex) => /* @__PURE__ */
|
|
4210
|
+
children: seriesData.options?.gradient?.stops?.map((stop, stopIndex) => /* @__PURE__ */ _jsx16("stop", {
|
|
3922
4211
|
offset: stop.offset,
|
|
3923
4212
|
stopColor: stop.color || color,
|
|
3924
4213
|
stopOpacity: stop.opacity ?? 1
|
|
3925
4214
|
}, `${stop.offset}-${stop.color || color}`))
|
|
3926
|
-
}), /* @__PURE__ */
|
|
4215
|
+
}), /* @__PURE__ */ _jsx16(AreaSeries, {
|
|
3927
4216
|
dataKey: seriesData?.label,
|
|
3928
4217
|
data: seriesData.data,
|
|
3929
4218
|
...accessors,
|
|
@@ -3931,7 +4220,7 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3931
4220
|
renderLine: true,
|
|
3932
4221
|
curve: getCurveType(curveType, smoothing),
|
|
3933
4222
|
lineProps
|
|
3934
|
-
}, seriesData?.label), withStartGlyphs && /* @__PURE__ */
|
|
4223
|
+
}, seriesData?.label), withStartGlyphs && /* @__PURE__ */ _jsx16(line_chart_glyph_default, {
|
|
3935
4224
|
index,
|
|
3936
4225
|
data: seriesData,
|
|
3937
4226
|
color,
|
|
@@ -3939,7 +4228,7 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3939
4228
|
accessors,
|
|
3940
4229
|
glyphStyle,
|
|
3941
4230
|
position: "start"
|
|
3942
|
-
}), withEndGlyphs && /* @__PURE__ */
|
|
4231
|
+
}), withEndGlyphs && /* @__PURE__ */ _jsx16(line_chart_glyph_default, {
|
|
3943
4232
|
index,
|
|
3944
4233
|
data: seriesData,
|
|
3945
4234
|
color,
|
|
@@ -3949,7 +4238,7 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3949
4238
|
position: "end"
|
|
3950
4239
|
})]
|
|
3951
4240
|
}, seriesData?.label || index);
|
|
3952
|
-
}), withTooltips && /* @__PURE__ */
|
|
4241
|
+
}), withTooltips && /* @__PURE__ */ _jsx16(AccessibleTooltip, {
|
|
3953
4242
|
detectBounds: true,
|
|
3954
4243
|
snapTooltipToDatumX: true,
|
|
3955
4244
|
snapTooltipToDatumY: true,
|
|
@@ -3963,13 +4252,15 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3963
4252
|
tooltipRef,
|
|
3964
4253
|
keyboardFocusedClassName: line_chart_module_default["line-chart__tooltip--keyboard-focused"],
|
|
3965
4254
|
series: dataSorted
|
|
3966
|
-
}), /* @__PURE__ */
|
|
4255
|
+
}), /* @__PURE__ */ _jsx16(LineChartScalesRef, {
|
|
3967
4256
|
chartRef: internalChartRef,
|
|
3968
4257
|
width,
|
|
3969
4258
|
height,
|
|
3970
4259
|
margin
|
|
4260
|
+
}), zoomable && /* @__PURE__ */ _jsx16(ZoomSelectionRect, {
|
|
4261
|
+
drag: zoom.drag
|
|
3971
4262
|
})]
|
|
3972
|
-
})
|
|
4263
|
+
})]
|
|
3973
4264
|
})
|
|
3974
4265
|
});
|
|
3975
4266
|
}
|
|
@@ -3977,15 +4268,15 @@ var LineChartInternal = /* @__PURE__ */ forwardRef4(({
|
|
|
3977
4268
|
});
|
|
3978
4269
|
});
|
|
3979
4270
|
var LineChartWithProvider = /* @__PURE__ */ forwardRef4((props, ref) => {
|
|
3980
|
-
const existingContext =
|
|
4271
|
+
const existingContext = useContext12(GlobalChartsContext);
|
|
3981
4272
|
if (existingContext) {
|
|
3982
|
-
return /* @__PURE__ */
|
|
4273
|
+
return /* @__PURE__ */ _jsx16(LineChartInternal, {
|
|
3983
4274
|
...props,
|
|
3984
4275
|
ref
|
|
3985
4276
|
});
|
|
3986
4277
|
}
|
|
3987
|
-
return /* @__PURE__ */
|
|
3988
|
-
children: /* @__PURE__ */
|
|
4278
|
+
return /* @__PURE__ */ _jsx16(GlobalChartsProvider, {
|
|
4279
|
+
children: /* @__PURE__ */ _jsx16(LineChartInternal, {
|
|
3989
4280
|
...props,
|
|
3990
4281
|
ref
|
|
3991
4282
|
})
|
|
@@ -4011,31 +4302,31 @@ var area_chart_module_default = {
|
|
|
4011
4302
|
};
|
|
4012
4303
|
|
|
4013
4304
|
// src/charts/area-chart/private/validate-data.ts
|
|
4014
|
-
import { __ as
|
|
4305
|
+
import { __ as __4 } from "@wordpress/i18n";
|
|
4015
4306
|
var validateData2 = (data) => {
|
|
4016
|
-
if (!data?.length) return
|
|
4307
|
+
if (!data?.length) return __4("No data available", "jetpack-charts");
|
|
4017
4308
|
const hasEmptySeries = data.some((series) => !series.data?.length);
|
|
4018
|
-
if (hasEmptySeries) return
|
|
4309
|
+
if (hasEmptySeries) return __4("No data available", "jetpack-charts");
|
|
4019
4310
|
const hasInvalidData = data.some(
|
|
4020
4311
|
(series) => series.data.some(
|
|
4021
4312
|
(point) => isNaN(point.value) || point.value === null || point.value === void 0 || "date" in point && point.date && isNaN(point.date.getTime())
|
|
4022
4313
|
)
|
|
4023
4314
|
);
|
|
4024
|
-
if (hasInvalidData) return
|
|
4315
|
+
if (hasInvalidData) return __4("Invalid data", "jetpack-charts");
|
|
4025
4316
|
return null;
|
|
4026
4317
|
};
|
|
4027
4318
|
|
|
4028
4319
|
// src/charts/area-chart/private/overlays.tsx
|
|
4029
|
-
import { DataContext as
|
|
4030
|
-
import { useContext as
|
|
4031
|
-
import { jsx as
|
|
4320
|
+
import { DataContext as DataContext7, TooltipContext as TooltipContext2 } from "@visx/xychart";
|
|
4321
|
+
import { useContext as useContext13, useImperativeHandle as useImperativeHandle3 } from "react";
|
|
4322
|
+
import { jsx as _jsx17 } from "react/jsx-runtime";
|
|
4032
4323
|
var AreaChartScalesRef = ({
|
|
4033
4324
|
chartRef,
|
|
4034
4325
|
width,
|
|
4035
4326
|
height,
|
|
4036
4327
|
margin
|
|
4037
4328
|
}) => {
|
|
4038
|
-
const context =
|
|
4329
|
+
const context = useContext13(DataContext7);
|
|
4039
4330
|
useImperativeHandle3(chartRef, () => ({
|
|
4040
4331
|
getScales: () => {
|
|
4041
4332
|
if (!context?.xScale || !context?.yScale) return null;
|
|
@@ -4059,8 +4350,8 @@ var HoverGlyphs = ({
|
|
|
4059
4350
|
getElementStyles,
|
|
4060
4351
|
strokeColor
|
|
4061
4352
|
}) => {
|
|
4062
|
-
const dataContext =
|
|
4063
|
-
const tooltipContext =
|
|
4353
|
+
const dataContext = useContext13(DataContext7);
|
|
4354
|
+
const tooltipContext = useContext13(TooltipContext2);
|
|
4064
4355
|
const xScale = dataContext?.xScale;
|
|
4065
4356
|
const yScale = dataContext?.yScale;
|
|
4066
4357
|
const tooltipOpen = tooltipContext?.tooltipOpen;
|
|
@@ -4093,7 +4384,7 @@ var HoverGlyphs = ({
|
|
|
4093
4384
|
data: series,
|
|
4094
4385
|
index
|
|
4095
4386
|
});
|
|
4096
|
-
circles.push(/* @__PURE__ */
|
|
4387
|
+
circles.push(/* @__PURE__ */ _jsx17("circle", {
|
|
4097
4388
|
cx: xPx,
|
|
4098
4389
|
cy: yPx,
|
|
4099
4390
|
r: 4,
|
|
@@ -4104,7 +4395,7 @@ var HoverGlyphs = ({
|
|
|
4104
4395
|
}, series.label || index));
|
|
4105
4396
|
}
|
|
4106
4397
|
if (circles.length === 0) return null;
|
|
4107
|
-
return /* @__PURE__ */
|
|
4398
|
+
return /* @__PURE__ */ _jsx17("g", {
|
|
4108
4399
|
pointerEvents: "none",
|
|
4109
4400
|
className: "area-chart__hover-glyphs",
|
|
4110
4401
|
children: circles
|
|
@@ -4112,7 +4403,7 @@ var HoverGlyphs = ({
|
|
|
4112
4403
|
};
|
|
4113
4404
|
|
|
4114
4405
|
// src/charts/area-chart/area-chart.tsx
|
|
4115
|
-
import { jsx as
|
|
4406
|
+
import { jsx as _jsx18, Fragment as _Fragment4, jsxs as _jsxs8 } from "react/jsx-runtime";
|
|
4116
4407
|
var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
4117
4408
|
data,
|
|
4118
4409
|
chartId: providedChartId,
|
|
@@ -4137,6 +4428,8 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4137
4428
|
onPointerUp,
|
|
4138
4429
|
onPointerMove,
|
|
4139
4430
|
onPointerOut,
|
|
4431
|
+
zoomable = false,
|
|
4432
|
+
rescaleYOnLegendToggle = true,
|
|
4140
4433
|
children,
|
|
4141
4434
|
gridVisibility,
|
|
4142
4435
|
gap = "md"
|
|
@@ -4148,15 +4441,24 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4148
4441
|
const theme = useXYChartTheme(data);
|
|
4149
4442
|
const chartId = useChartId(providedChartId);
|
|
4150
4443
|
const chartRef = useRef10(null);
|
|
4151
|
-
const [selectedIndex, setSelectedIndex] =
|
|
4152
|
-
const [isNavigating, setIsNavigating] =
|
|
4444
|
+
const [selectedIndex, setSelectedIndex] = useState11(void 0);
|
|
4445
|
+
const [isNavigating, setIsNavigating] = useState11(false);
|
|
4153
4446
|
const internalChartRef = useRef10(null);
|
|
4447
|
+
const zoom = useXZoom({
|
|
4448
|
+
enabled: zoomable,
|
|
4449
|
+
chartRef: internalChartRef,
|
|
4450
|
+
userHandlers: {
|
|
4451
|
+
onPointerDown,
|
|
4452
|
+
onPointerMove,
|
|
4453
|
+
onPointerUp
|
|
4454
|
+
}
|
|
4455
|
+
});
|
|
4154
4456
|
const {
|
|
4155
4457
|
legendChildren,
|
|
4156
4458
|
nonLegendChildren
|
|
4157
4459
|
} = useChartChildren(children, "AreaChart");
|
|
4158
|
-
const [measuredChartHeight, setMeasuredChartHeight] =
|
|
4159
|
-
const handleContentHeightChange =
|
|
4460
|
+
const [measuredChartHeight, setMeasuredChartHeight] = useState11();
|
|
4461
|
+
const handleContentHeightChange = useCallback10((contentHeight) => {
|
|
4160
4462
|
const chartHeight = contentHeight > 0 ? contentHeight : height;
|
|
4161
4463
|
setMeasuredChartHeight(chartHeight);
|
|
4162
4464
|
}, [height]);
|
|
@@ -4173,7 +4475,7 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4173
4475
|
getElementStyles,
|
|
4174
4476
|
isSeriesVisible
|
|
4175
4477
|
} = useGlobalChartsContext();
|
|
4176
|
-
const seriesWithVisibility =
|
|
4478
|
+
const seriesWithVisibility = useMemo17(() => {
|
|
4177
4479
|
if (!chartId || !legendInteractive) {
|
|
4178
4480
|
return dataSorted.map((series, index) => ({
|
|
4179
4481
|
series,
|
|
@@ -4187,7 +4489,7 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4187
4489
|
isVisible: isSeriesVisible(chartId, series.label)
|
|
4188
4490
|
}));
|
|
4189
4491
|
}, [dataSorted, chartId, isSeriesVisible, legendInteractive]);
|
|
4190
|
-
const allSeriesHidden =
|
|
4492
|
+
const allSeriesHidden = useMemo17(() => seriesWithVisibility.every(({
|
|
4191
4493
|
isVisible
|
|
4192
4494
|
}) => !isVisible), [seriesWithVisibility]);
|
|
4193
4495
|
const {
|
|
@@ -4203,8 +4505,8 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4203
4505
|
chartRef,
|
|
4204
4506
|
totalPoints: dataSorted[0]?.data.length || 0
|
|
4205
4507
|
});
|
|
4206
|
-
const fixedYDomain =
|
|
4207
|
-
if (!legendInteractive || !dataSorted.length || !dataSorted[0].data.length || stacked && stackOffset !== "none") {
|
|
4508
|
+
const fixedYDomain = useMemo17(() => {
|
|
4509
|
+
if (rescaleYOnLegendToggle || !legendInteractive || !dataSorted.length || !dataSorted[0].data.length || stacked && stackOffset !== "none") {
|
|
4208
4510
|
return void 0;
|
|
4209
4511
|
}
|
|
4210
4512
|
if (stacked) {
|
|
@@ -4238,8 +4540,8 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4238
4540
|
}
|
|
4239
4541
|
if (max === -Infinity) return void 0;
|
|
4240
4542
|
return [Math.min(0, min), max];
|
|
4241
|
-
}, [dataSorted, stacked, stackOffset, legendInteractive]);
|
|
4242
|
-
const chartOptions =
|
|
4543
|
+
}, [dataSorted, stacked, stackOffset, legendInteractive, rescaleYOnLegendToggle]);
|
|
4544
|
+
const chartOptions = useMemo17(() => {
|
|
4243
4545
|
const formatter = options?.axis?.x?.tickFormat || getFormatter(dataSorted);
|
|
4244
4546
|
return {
|
|
4245
4547
|
axis: {
|
|
@@ -4260,7 +4562,10 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4260
4562
|
},
|
|
4261
4563
|
xScale: {
|
|
4262
4564
|
type: "time",
|
|
4263
|
-
...options?.xScale
|
|
4565
|
+
...options?.xScale,
|
|
4566
|
+
...zoom.domain ? {
|
|
4567
|
+
domain: zoom.domain
|
|
4568
|
+
} : {}
|
|
4264
4569
|
},
|
|
4265
4570
|
yScale: {
|
|
4266
4571
|
type: "linear",
|
|
@@ -4273,16 +4578,16 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4273
4578
|
...options?.yScale
|
|
4274
4579
|
}
|
|
4275
4580
|
};
|
|
4276
|
-
}, [options, dataSorted, width, stacked, fixedYDomain]);
|
|
4581
|
+
}, [options, dataSorted, width, stacked, fixedYDomain, zoom.domain]);
|
|
4277
4582
|
const defaultMargin = useChartMargin(height, chartOptions, dataSorted, theme);
|
|
4278
4583
|
const error = validateData2(dataSorted);
|
|
4279
4584
|
const isDataValid = !error;
|
|
4280
|
-
const legendOptions =
|
|
4585
|
+
const legendOptions = useMemo17(() => ({
|
|
4281
4586
|
withGlyph: false,
|
|
4282
4587
|
glyphSize: 0
|
|
4283
4588
|
}), []);
|
|
4284
4589
|
const legendItems = useChartLegendItems(dataSorted, legendOptions, legendShape);
|
|
4285
|
-
const chartMetadata =
|
|
4590
|
+
const chartMetadata = useMemo17(() => ({
|
|
4286
4591
|
stacked,
|
|
4287
4592
|
stackOffset,
|
|
4288
4593
|
smoothing,
|
|
@@ -4301,9 +4606,9 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4301
4606
|
xAccessor: (d) => d?.date,
|
|
4302
4607
|
yAccessor: (d) => d?.value
|
|
4303
4608
|
};
|
|
4304
|
-
const zeroYAccessor =
|
|
4305
|
-
const visibleLabels =
|
|
4306
|
-
const filteredRenderTooltip =
|
|
4609
|
+
const zeroYAccessor = useCallback10(() => 0, []);
|
|
4610
|
+
const visibleLabels = useMemo17(() => new Set(seriesWithVisibility.filter((s) => s.isVisible).map((s) => s.series.label)), [seriesWithVisibility]);
|
|
4611
|
+
const filteredRenderTooltip = useCallback10((params) => {
|
|
4307
4612
|
if (!legendInteractive) return renderTooltip(params);
|
|
4308
4613
|
const datumByKey = params?.tooltipData?.datumByKey;
|
|
4309
4614
|
if (!datumByKey) return renderTooltip(params);
|
|
@@ -4326,12 +4631,12 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4326
4631
|
const resolvedFillOpacity = fillOpacity ?? (stacked ? 0.85 : 0.4);
|
|
4327
4632
|
const resolvedWithStroke = withStroke ?? !stacked;
|
|
4328
4633
|
if (error) {
|
|
4329
|
-
return /* @__PURE__ */
|
|
4634
|
+
return /* @__PURE__ */ _jsx18("div", {
|
|
4330
4635
|
className: clsx5("area-chart", area_chart_module_default["area-chart"]),
|
|
4331
4636
|
children: error
|
|
4332
4637
|
});
|
|
4333
4638
|
}
|
|
4334
|
-
const legendElement = showLegend && /* @__PURE__ */
|
|
4639
|
+
const legendElement = showLegend && /* @__PURE__ */ _jsx18(Legend, {
|
|
4335
4640
|
orientation: legend.orientation ?? "horizontal",
|
|
4336
4641
|
alignment: legend.alignment ?? "center",
|
|
4337
4642
|
position: legendPosition,
|
|
@@ -4360,7 +4665,7 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4360
4665
|
data: seriesData,
|
|
4361
4666
|
index
|
|
4362
4667
|
});
|
|
4363
|
-
return /* @__PURE__ */
|
|
4668
|
+
return /* @__PURE__ */ _jsx18(AnimatedAreaSeries, {
|
|
4364
4669
|
dataKey: seriesData?.label,
|
|
4365
4670
|
data: seriesData.data,
|
|
4366
4671
|
xAccessor: accessors.xAccessor,
|
|
@@ -4377,14 +4682,14 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4377
4682
|
}
|
|
4378
4683
|
}, seriesData?.label || index);
|
|
4379
4684
|
};
|
|
4380
|
-
return /* @__PURE__ */
|
|
4685
|
+
return /* @__PURE__ */ _jsx18(SingleChartContext.Provider, {
|
|
4381
4686
|
value: {
|
|
4382
4687
|
chartId,
|
|
4383
4688
|
chartRef: internalChartRef,
|
|
4384
4689
|
chartWidth: width,
|
|
4385
4690
|
chartHeight: measuredChartHeight || 0
|
|
4386
4691
|
},
|
|
4387
|
-
children: /* @__PURE__ */
|
|
4692
|
+
children: /* @__PURE__ */ _jsx18(ChartLayout, {
|
|
4388
4693
|
legendPosition,
|
|
4389
4694
|
legendElement,
|
|
4390
4695
|
legendChildren,
|
|
@@ -4402,16 +4707,21 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4402
4707
|
contentHeight
|
|
4403
4708
|
}) => {
|
|
4404
4709
|
const chartHeight = contentHeight > 0 ? contentHeight : height;
|
|
4405
|
-
return /* @__PURE__ */
|
|
4710
|
+
return /* @__PURE__ */ _jsx18("div", {
|
|
4406
4711
|
role: "grid",
|
|
4407
|
-
"aria-label":
|
|
4712
|
+
"aria-label": __5("Area chart", "jetpack-charts"),
|
|
4408
4713
|
tabIndex: 0,
|
|
4409
4714
|
onKeyDown: onChartKeyDown,
|
|
4410
4715
|
onFocus: onChartFocus,
|
|
4411
4716
|
onBlur: onChartBlur,
|
|
4412
|
-
children: chartHeight > 0 && /* @__PURE__ */
|
|
4717
|
+
children: chartHeight > 0 && /* @__PURE__ */ _jsxs8("div", {
|
|
4413
4718
|
ref: chartRef,
|
|
4414
|
-
|
|
4719
|
+
style: {
|
|
4720
|
+
position: "relative"
|
|
4721
|
+
},
|
|
4722
|
+
children: [zoomable && zoom.domain && /* @__PURE__ */ _jsx18(ZoomResetButton, {
|
|
4723
|
+
onClick: zoom.reset
|
|
4724
|
+
}), /* @__PURE__ */ _jsxs8(XYChart2, {
|
|
4415
4725
|
theme,
|
|
4416
4726
|
width,
|
|
4417
4727
|
height: chartHeight,
|
|
@@ -4421,31 +4731,31 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4421
4731
|
},
|
|
4422
4732
|
xScale: chartOptions.xScale,
|
|
4423
4733
|
yScale: chartOptions.yScale,
|
|
4424
|
-
onPointerDown,
|
|
4425
|
-
onPointerUp,
|
|
4426
|
-
onPointerMove,
|
|
4734
|
+
onPointerDown: zoom.handlers.onPointerDown,
|
|
4735
|
+
onPointerUp: zoom.handlers.onPointerUp,
|
|
4736
|
+
onPointerMove: zoom.handlers.onPointerMove,
|
|
4427
4737
|
onPointerOut,
|
|
4428
4738
|
pointerEventsDataKey: "nearest",
|
|
4429
|
-
children: [gridVisibility !== "none" && /* @__PURE__ */
|
|
4739
|
+
children: [gridVisibility !== "none" && /* @__PURE__ */ _jsx18(Grid2, {
|
|
4430
4740
|
columns: false,
|
|
4431
4741
|
numTicks: 4
|
|
4432
|
-
}), chartOptions.axis.x.display && /* @__PURE__ */
|
|
4742
|
+
}), chartOptions.axis.x.display && /* @__PURE__ */ _jsx18(Axis2, {
|
|
4433
4743
|
...chartOptions.axis.x
|
|
4434
|
-
}), chartOptions.axis.y.display && /* @__PURE__ */
|
|
4744
|
+
}), chartOptions.axis.y.display && /* @__PURE__ */ _jsx18(Axis2, {
|
|
4435
4745
|
...chartOptions.axis.y
|
|
4436
|
-
}), allSeriesHidden ? /* @__PURE__ */
|
|
4746
|
+
}), allSeriesHidden ? /* @__PURE__ */ _jsx18(SvgEmptyState, {
|
|
4437
4747
|
x: width / 2,
|
|
4438
4748
|
y: chartHeight / 2,
|
|
4439
4749
|
width,
|
|
4440
4750
|
height: chartHeight,
|
|
4441
|
-
children:
|
|
4442
|
-
}) : null, !allSeriesHidden && stacked && /* @__PURE__ */
|
|
4751
|
+
children: __5("All series are hidden. Click legend items to show data.", "jetpack-charts")
|
|
4752
|
+
}) : null, !allSeriesHidden && stacked && /* @__PURE__ */ _jsx18(AnimatedAreaStack, {
|
|
4443
4753
|
curve,
|
|
4444
4754
|
offset: stackOffset,
|
|
4445
4755
|
renderLine: resolvedWithStroke,
|
|
4446
4756
|
children: seriesWithVisibility.map(renderSeries)
|
|
4447
|
-
}), !allSeriesHidden && !stacked && seriesWithVisibility.map(renderSeries), withTooltips && /* @__PURE__ */
|
|
4448
|
-
children: [/* @__PURE__ */
|
|
4757
|
+
}), !allSeriesHidden && !stacked && seriesWithVisibility.map(renderSeries), withTooltips && /* @__PURE__ */ _jsxs8(_Fragment4, {
|
|
4758
|
+
children: [/* @__PURE__ */ _jsx18(AccessibleTooltip, {
|
|
4449
4759
|
detectBounds: true,
|
|
4450
4760
|
snapTooltipToDatumX: true,
|
|
4451
4761
|
snapTooltipToDatumY: !stacked,
|
|
@@ -4456,20 +4766,22 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4456
4766
|
tooltipRef,
|
|
4457
4767
|
keyboardFocusedClassName: area_chart_module_default["area-chart__tooltip--keyboard-focused"],
|
|
4458
4768
|
series: dataSorted
|
|
4459
|
-
}), /* @__PURE__ */
|
|
4769
|
+
}), /* @__PURE__ */ _jsx18(HoverGlyphs, {
|
|
4460
4770
|
visibleSeries,
|
|
4461
4771
|
stacked,
|
|
4462
4772
|
stackOffset,
|
|
4463
4773
|
getElementStyles,
|
|
4464
4774
|
strokeColor: providerTheme.backgroundColor
|
|
4465
4775
|
})]
|
|
4466
|
-
}), /* @__PURE__ */
|
|
4776
|
+
}), /* @__PURE__ */ _jsx18(AreaChartScalesRef, {
|
|
4467
4777
|
chartRef: internalChartRef,
|
|
4468
4778
|
width,
|
|
4469
4779
|
height: height || chartHeight,
|
|
4470
4780
|
margin
|
|
4781
|
+
}), zoomable && /* @__PURE__ */ _jsx18(ZoomSelectionRect, {
|
|
4782
|
+
drag: zoom.drag
|
|
4471
4783
|
})]
|
|
4472
|
-
})
|
|
4784
|
+
})]
|
|
4473
4785
|
})
|
|
4474
4786
|
});
|
|
4475
4787
|
}
|
|
@@ -4477,15 +4789,15 @@ var AreaChartInternal = /* @__PURE__ */ forwardRef5(({
|
|
|
4477
4789
|
});
|
|
4478
4790
|
});
|
|
4479
4791
|
var AreaChartWithProvider = /* @__PURE__ */ forwardRef5((props, ref) => {
|
|
4480
|
-
const existingContext =
|
|
4792
|
+
const existingContext = useContext14(GlobalChartsContext);
|
|
4481
4793
|
if (existingContext) {
|
|
4482
|
-
return /* @__PURE__ */
|
|
4794
|
+
return /* @__PURE__ */ _jsx18(AreaChartInternal, {
|
|
4483
4795
|
...props,
|
|
4484
4796
|
ref
|
|
4485
4797
|
});
|
|
4486
4798
|
}
|
|
4487
|
-
return /* @__PURE__ */
|
|
4488
|
-
children: /* @__PURE__ */
|
|
4799
|
+
return /* @__PURE__ */ _jsx18(GlobalChartsProvider, {
|
|
4800
|
+
children: /* @__PURE__ */ _jsx18(AreaChartInternal, {
|
|
4489
4801
|
...props,
|
|
4490
4802
|
ref
|
|
4491
4803
|
})
|
|
@@ -4503,9 +4815,9 @@ var AreaChartResponsive = attachSubComponents(withResponsive(AreaChartWithProvid
|
|
|
4503
4815
|
import { formatNumber as formatNumber6 } from "@automattic/number-formatters";
|
|
4504
4816
|
import { PatternLines, PatternCircles, PatternWaves, PatternHexagons } from "@visx/pattern";
|
|
4505
4817
|
import { Axis as Axis3, BarSeries, BarGroup, Grid as Grid3, XYChart as XYChart3 } from "@visx/xychart";
|
|
4506
|
-
import { __ as
|
|
4818
|
+
import { __ as __6 } from "@wordpress/i18n";
|
|
4507
4819
|
import clsx6 from "clsx";
|
|
4508
|
-
import { useCallback as
|
|
4820
|
+
import { useCallback as useCallback11, useContext as useContext16, useState as useState12, useRef as useRef11, useMemo as useMemo19 } from "react";
|
|
4509
4821
|
|
|
4510
4822
|
// src/charts/bar-chart/bar-chart.module.scss
|
|
4511
4823
|
var bar_chart_module_default = {
|
|
@@ -4518,12 +4830,12 @@ var bar_chart_module_default = {
|
|
|
4518
4830
|
|
|
4519
4831
|
// src/charts/bar-chart/private/use-bar-chart-options.ts
|
|
4520
4832
|
import { formatNumberCompact as formatNumberCompact4 } from "@automattic/number-formatters";
|
|
4521
|
-
import { useMemo as
|
|
4833
|
+
import { useMemo as useMemo18 } from "react";
|
|
4522
4834
|
|
|
4523
4835
|
// src/charts/bar-chart/private/truncated-tick-component.tsx
|
|
4524
|
-
import { DataContext as
|
|
4525
|
-
import { useContext as
|
|
4526
|
-
import { jsx as
|
|
4836
|
+
import { DataContext as DataContext8 } from "@visx/xychart";
|
|
4837
|
+
import { useContext as useContext15 } from "react";
|
|
4838
|
+
import { jsx as _jsx19 } from "react/jsx-runtime";
|
|
4527
4839
|
var getScaleBandwidth = (scale) => {
|
|
4528
4840
|
return scale && "bandwidth" in scale ? scale.bandwidth() ?? 0 : 0;
|
|
4529
4841
|
};
|
|
@@ -4541,7 +4853,7 @@ var TruncatedTickComponent = ({
|
|
|
4541
4853
|
const {
|
|
4542
4854
|
xScale,
|
|
4543
4855
|
yScale
|
|
4544
|
-
} =
|
|
4856
|
+
} = useContext15(DataContext8) || {};
|
|
4545
4857
|
const scale = axis === "x" ? xScale : yScale;
|
|
4546
4858
|
const bandwidth = getScaleBandwidth(scale);
|
|
4547
4859
|
const maxWidth = Math.max(bandwidth, MIN_TICK_LABEL_WIDTH);
|
|
@@ -4597,13 +4909,13 @@ var TruncatedTickComponent = ({
|
|
|
4597
4909
|
cursor: "default",
|
|
4598
4910
|
pointerEvents: "auto"
|
|
4599
4911
|
};
|
|
4600
|
-
return /* @__PURE__ */
|
|
4912
|
+
return /* @__PURE__ */ _jsx19("foreignObject", {
|
|
4601
4913
|
x: x + xOffset,
|
|
4602
4914
|
y,
|
|
4603
4915
|
width: maxWidth,
|
|
4604
4916
|
height: 0,
|
|
4605
4917
|
overflow: "visible",
|
|
4606
|
-
children: /* @__PURE__ */
|
|
4918
|
+
children: /* @__PURE__ */ _jsx19("div", {
|
|
4607
4919
|
style: textStyles,
|
|
4608
4920
|
title: formattedValue,
|
|
4609
4921
|
children: formattedValue
|
|
@@ -4611,7 +4923,7 @@ var TruncatedTickComponent = ({
|
|
|
4611
4923
|
});
|
|
4612
4924
|
};
|
|
4613
4925
|
var createTruncatedTickComponent = (axis) => (props) => {
|
|
4614
|
-
return /* @__PURE__ */
|
|
4926
|
+
return /* @__PURE__ */ _jsx19(TruncatedTickComponent, {
|
|
4615
4927
|
...props,
|
|
4616
4928
|
axis
|
|
4617
4929
|
});
|
|
@@ -4631,7 +4943,7 @@ var getGroupPadding = (scale) => {
|
|
|
4631
4943
|
return typeof scale.paddingInner === "number" ? scale.paddingInner : 0;
|
|
4632
4944
|
};
|
|
4633
4945
|
function useBarChartOptions(data, horizontal, options = {}) {
|
|
4634
|
-
const defaultOptions =
|
|
4946
|
+
const defaultOptions = useMemo18(() => {
|
|
4635
4947
|
const bandScale = {
|
|
4636
4948
|
type: "band",
|
|
4637
4949
|
padding: 0.2,
|
|
@@ -4672,7 +4984,7 @@ function useBarChartOptions(data, horizontal, options = {}) {
|
|
|
4672
4984
|
}
|
|
4673
4985
|
};
|
|
4674
4986
|
}, [data]);
|
|
4675
|
-
return
|
|
4987
|
+
return useMemo18(() => {
|
|
4676
4988
|
const orientationKey = horizontal ? "horizontal" : "vertical";
|
|
4677
4989
|
const {
|
|
4678
4990
|
xTickFormat,
|
|
@@ -4724,7 +5036,7 @@ function useBarChartOptions(data, horizontal, options = {}) {
|
|
|
4724
5036
|
}
|
|
4725
5037
|
|
|
4726
5038
|
// src/charts/bar-chart/bar-chart.tsx
|
|
4727
|
-
import { jsx as
|
|
5039
|
+
import { jsx as _jsx20, jsxs as _jsxs9, Fragment as _Fragment5 } from "react/jsx-runtime";
|
|
4728
5040
|
var validateData3 = (data) => {
|
|
4729
5041
|
if (!data?.length) return "No data available";
|
|
4730
5042
|
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 +5081,13 @@ var BarChartInternal = ({
|
|
|
4769
5081
|
legendChildren,
|
|
4770
5082
|
nonLegendChildren
|
|
4771
5083
|
} = useChartChildren(children, "BarChart");
|
|
4772
|
-
const [measuredChartHeight, setMeasuredChartHeight] =
|
|
4773
|
-
const handleContentHeightChange =
|
|
5084
|
+
const [measuredChartHeight, setMeasuredChartHeight] = useState12();
|
|
5085
|
+
const handleContentHeightChange = useCallback11((contentHeight) => {
|
|
4774
5086
|
const chartHeight = contentHeight > 0 ? contentHeight : height;
|
|
4775
5087
|
setMeasuredChartHeight(chartHeight);
|
|
4776
5088
|
}, [height]);
|
|
4777
|
-
const [selectedIndex, setSelectedIndex] =
|
|
4778
|
-
const [isNavigating, setIsNavigating] =
|
|
5089
|
+
const [selectedIndex, setSelectedIndex] = useState12(void 0);
|
|
5090
|
+
const [isNavigating, setIsNavigating] = useState12(false);
|
|
4779
5091
|
const totalPoints = Math.max(0, ...data.map((series) => series.data?.length || 0)) * data.length;
|
|
4780
5092
|
const {
|
|
4781
5093
|
tooltipRef,
|
|
@@ -4794,7 +5106,7 @@ var BarChartInternal = ({
|
|
|
4794
5106
|
getElementStyles,
|
|
4795
5107
|
isSeriesVisible
|
|
4796
5108
|
} = useGlobalChartsContext();
|
|
4797
|
-
const seriesWithVisibility =
|
|
5109
|
+
const seriesWithVisibility = useMemo19(() => {
|
|
4798
5110
|
if (!chartId || !legendInteractive) {
|
|
4799
5111
|
return dataWithVisibleZeros.map((series, index) => ({
|
|
4800
5112
|
series,
|
|
@@ -4808,38 +5120,38 @@ var BarChartInternal = ({
|
|
|
4808
5120
|
isVisible: isSeriesVisible(chartId, series.label)
|
|
4809
5121
|
}));
|
|
4810
5122
|
}, [dataWithVisibleZeros, chartId, isSeriesVisible, legendInteractive]);
|
|
4811
|
-
const allSeriesHidden =
|
|
5123
|
+
const allSeriesHidden = useMemo19(() => {
|
|
4812
5124
|
return seriesWithVisibility.every(({
|
|
4813
5125
|
isVisible
|
|
4814
5126
|
}) => !isVisible);
|
|
4815
5127
|
}, [seriesWithVisibility]);
|
|
4816
|
-
const getBarBackground =
|
|
5128
|
+
const getBarBackground = useCallback11((index) => () => withPatterns ? `url(#${getPatternId(chartId, index)})` : getElementStyles({
|
|
4817
5129
|
data: dataSorted[index],
|
|
4818
5130
|
index
|
|
4819
5131
|
}).color, [withPatterns, getElementStyles, dataSorted, chartId]);
|
|
4820
|
-
const renderDefaultTooltip2 =
|
|
5132
|
+
const renderDefaultTooltip2 = useCallback11(({
|
|
4821
5133
|
tooltipData
|
|
4822
5134
|
}) => {
|
|
4823
5135
|
const nearestDatum = tooltipData?.nearestDatum?.datum;
|
|
4824
5136
|
if (!nearestDatum) return null;
|
|
4825
|
-
return /* @__PURE__ */
|
|
5137
|
+
return /* @__PURE__ */ _jsxs9("div", {
|
|
4826
5138
|
className: bar_chart_module_default["bar-chart__tooltip"],
|
|
4827
|
-
children: [/* @__PURE__ */
|
|
5139
|
+
children: [/* @__PURE__ */ _jsx20("div", {
|
|
4828
5140
|
className: bar_chart_module_default["bar-chart__tooltip-header"],
|
|
4829
5141
|
children: tooltipData?.nearestDatum?.key
|
|
4830
|
-
}), /* @__PURE__ */
|
|
5142
|
+
}), /* @__PURE__ */ _jsxs9("div", {
|
|
4831
5143
|
className: bar_chart_module_default["bar-chart__tooltip-row"],
|
|
4832
|
-
children: [/* @__PURE__ */
|
|
5144
|
+
children: [/* @__PURE__ */ _jsxs9("span", {
|
|
4833
5145
|
className: bar_chart_module_default["bar-chart__tooltip-label"],
|
|
4834
5146
|
children: [chartOptions.tooltip.labelFormatter(nearestDatum.label || (nearestDatum.date ? nearestDatum.date.getTime() : 0), 0, []), ":"]
|
|
4835
|
-
}), /* @__PURE__ */
|
|
5147
|
+
}), /* @__PURE__ */ _jsx20("span", {
|
|
4836
5148
|
className: bar_chart_module_default["bar-chart__tooltip-value"],
|
|
4837
5149
|
children: formatNumber6(nearestDatum.value)
|
|
4838
5150
|
})]
|
|
4839
5151
|
})]
|
|
4840
5152
|
});
|
|
4841
5153
|
}, [chartOptions.tooltip]);
|
|
4842
|
-
const renderPattern =
|
|
5154
|
+
const renderPattern = useCallback11((index, color) => {
|
|
4843
5155
|
const patternType = index % 4;
|
|
4844
5156
|
const id = getPatternId(chartId, index);
|
|
4845
5157
|
const commonProps = {
|
|
@@ -4851,34 +5163,34 @@ var BarChartInternal = ({
|
|
|
4851
5163
|
switch (patternType) {
|
|
4852
5164
|
case 0:
|
|
4853
5165
|
default:
|
|
4854
|
-
return /* @__PURE__ */
|
|
5166
|
+
return /* @__PURE__ */ _jsx20(PatternLines, {
|
|
4855
5167
|
...commonProps,
|
|
4856
5168
|
width: 5,
|
|
4857
5169
|
height: 5,
|
|
4858
5170
|
orientation: ["diagonal"]
|
|
4859
5171
|
}, id);
|
|
4860
5172
|
case 1:
|
|
4861
|
-
return /* @__PURE__ */
|
|
5173
|
+
return /* @__PURE__ */ _jsx20(PatternCircles, {
|
|
4862
5174
|
...commonProps,
|
|
4863
5175
|
width: 6,
|
|
4864
5176
|
height: 6,
|
|
4865
5177
|
fill: "white"
|
|
4866
5178
|
}, id);
|
|
4867
5179
|
case 2:
|
|
4868
|
-
return /* @__PURE__ */
|
|
5180
|
+
return /* @__PURE__ */ _jsx20(PatternWaves, {
|
|
4869
5181
|
...commonProps,
|
|
4870
5182
|
width: 4,
|
|
4871
5183
|
height: 4
|
|
4872
5184
|
}, id);
|
|
4873
5185
|
case 3:
|
|
4874
|
-
return /* @__PURE__ */
|
|
5186
|
+
return /* @__PURE__ */ _jsx20(PatternHexagons, {
|
|
4875
5187
|
...commonProps,
|
|
4876
5188
|
size: 8,
|
|
4877
5189
|
height: 3
|
|
4878
5190
|
}, id);
|
|
4879
5191
|
}
|
|
4880
5192
|
}, [chartId]);
|
|
4881
|
-
const createPatternBorderStyle =
|
|
5193
|
+
const createPatternBorderStyle = useCallback11((index, color) => {
|
|
4882
5194
|
const patternId = getPatternId(chartId, index);
|
|
4883
5195
|
return `
|
|
4884
5196
|
.visx-bar[fill="url(#${patternId})"] {
|
|
@@ -4887,7 +5199,7 @@ var BarChartInternal = ({
|
|
|
4887
5199
|
}
|
|
4888
5200
|
`;
|
|
4889
5201
|
}, [chartId]);
|
|
4890
|
-
const createKeyboardHighlightStyle =
|
|
5202
|
+
const createKeyboardHighlightStyle = useCallback11(() => {
|
|
4891
5203
|
if (selectedIndex === void 0) return "";
|
|
4892
5204
|
const maxDataPoints = Math.max(...data.map((s) => s.data.length));
|
|
4893
5205
|
const dataPointIndex = Math.floor(selectedIndex / data.length);
|
|
@@ -4910,7 +5222,7 @@ var BarChartInternal = ({
|
|
|
4910
5222
|
}, [selectedIndex, data, chartId]);
|
|
4911
5223
|
const error = validateData3(dataSorted);
|
|
4912
5224
|
const isDataValid = !error;
|
|
4913
|
-
const chartMetadata =
|
|
5225
|
+
const chartMetadata = useMemo19(() => ({
|
|
4914
5226
|
orientation,
|
|
4915
5227
|
withPatterns
|
|
4916
5228
|
}), [orientation, withPatterns]);
|
|
@@ -4923,7 +5235,7 @@ var BarChartInternal = ({
|
|
|
4923
5235
|
});
|
|
4924
5236
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
4925
5237
|
if (error) {
|
|
4926
|
-
return /* @__PURE__ */
|
|
5238
|
+
return /* @__PURE__ */ _jsx20("div", {
|
|
4927
5239
|
className: clsx6("bar-chart", bar_chart_module_default["bar-chart"]),
|
|
4928
5240
|
children: error
|
|
4929
5241
|
});
|
|
@@ -4931,7 +5243,7 @@ var BarChartInternal = ({
|
|
|
4931
5243
|
const gridVisibility = gridVisibilityProp ?? chartOptions.gridVisibility;
|
|
4932
5244
|
const highlightedBarStyle = createKeyboardHighlightStyle();
|
|
4933
5245
|
const legendPosition = legend.position ?? "bottom";
|
|
4934
|
-
const legendElement = showLegend && /* @__PURE__ */
|
|
5246
|
+
const legendElement = showLegend && /* @__PURE__ */ _jsx20(Legend, {
|
|
4935
5247
|
orientation: legend.orientation ?? "horizontal",
|
|
4936
5248
|
position: legendPosition,
|
|
4937
5249
|
alignment: legend.alignment ?? "center",
|
|
@@ -4944,13 +5256,13 @@ var BarChartInternal = ({
|
|
|
4944
5256
|
chartId,
|
|
4945
5257
|
interactive: legendInteractive
|
|
4946
5258
|
});
|
|
4947
|
-
return /* @__PURE__ */
|
|
5259
|
+
return /* @__PURE__ */ _jsx20(SingleChartContext.Provider, {
|
|
4948
5260
|
value: {
|
|
4949
5261
|
chartId,
|
|
4950
5262
|
chartWidth: width,
|
|
4951
5263
|
chartHeight: measuredChartHeight || 0
|
|
4952
5264
|
},
|
|
4953
|
-
children: /* @__PURE__ */
|
|
5265
|
+
children: /* @__PURE__ */ _jsx20(ChartLayout, {
|
|
4954
5266
|
legendPosition,
|
|
4955
5267
|
legendElement,
|
|
4956
5268
|
legendChildren,
|
|
@@ -4969,16 +5281,16 @@ var BarChartInternal = ({
|
|
|
4969
5281
|
contentHeight
|
|
4970
5282
|
}) => {
|
|
4971
5283
|
const chartHeight = contentHeight > 0 ? contentHeight : height;
|
|
4972
|
-
return /* @__PURE__ */
|
|
5284
|
+
return /* @__PURE__ */ _jsx20("div", {
|
|
4973
5285
|
role: "grid",
|
|
4974
|
-
"aria-label":
|
|
5286
|
+
"aria-label": __6("Bar chart", "jetpack-charts"),
|
|
4975
5287
|
tabIndex: 0,
|
|
4976
5288
|
onKeyDown: onChartKeyDown,
|
|
4977
5289
|
onFocus: onChartFocus,
|
|
4978
5290
|
onBlur: onChartBlur,
|
|
4979
|
-
children: chartHeight > 0 && /* @__PURE__ */
|
|
5291
|
+
children: chartHeight > 0 && /* @__PURE__ */ _jsx20("div", {
|
|
4980
5292
|
ref: chartRef,
|
|
4981
|
-
children: /* @__PURE__ */
|
|
5293
|
+
children: /* @__PURE__ */ _jsxs9(XYChart3, {
|
|
4982
5294
|
theme,
|
|
4983
5295
|
width,
|
|
4984
5296
|
height: chartHeight,
|
|
@@ -4990,31 +5302,31 @@ var BarChartInternal = ({
|
|
|
4990
5302
|
yScale: chartOptions.yScale,
|
|
4991
5303
|
horizontal,
|
|
4992
5304
|
pointerEventsDataKey: "nearest",
|
|
4993
|
-
children: [/* @__PURE__ */
|
|
5305
|
+
children: [/* @__PURE__ */ _jsx20(Grid3, {
|
|
4994
5306
|
columns: gridVisibility.includes("y"),
|
|
4995
5307
|
rows: gridVisibility.includes("x"),
|
|
4996
5308
|
numTicks: 4
|
|
4997
|
-
}), withPatterns && /* @__PURE__ */
|
|
4998
|
-
children: [/* @__PURE__ */
|
|
5309
|
+
}), withPatterns && /* @__PURE__ */ _jsxs9(_Fragment5, {
|
|
5310
|
+
children: [/* @__PURE__ */ _jsx20("defs", {
|
|
4999
5311
|
children: dataSorted.map((seriesData, index) => renderPattern(index, getElementStyles({
|
|
5000
5312
|
data: seriesData,
|
|
5001
5313
|
index
|
|
5002
5314
|
}).color))
|
|
5003
|
-
}), /* @__PURE__ */
|
|
5315
|
+
}), /* @__PURE__ */ _jsx20("style", {
|
|
5004
5316
|
children: dataSorted.map((seriesData, index) => createPatternBorderStyle(index, getElementStyles({
|
|
5005
5317
|
data: seriesData,
|
|
5006
5318
|
index
|
|
5007
5319
|
}).color))
|
|
5008
5320
|
})]
|
|
5009
|
-
}), highlightedBarStyle && /* @__PURE__ */
|
|
5321
|
+
}), highlightedBarStyle && /* @__PURE__ */ _jsx20("style", {
|
|
5010
5322
|
children: highlightedBarStyle
|
|
5011
|
-
}), allSeriesHidden ? /* @__PURE__ */
|
|
5323
|
+
}), allSeriesHidden ? /* @__PURE__ */ _jsx20(SvgEmptyState, {
|
|
5012
5324
|
x: width / 2,
|
|
5013
5325
|
y: chartHeight / 2,
|
|
5014
5326
|
width,
|
|
5015
5327
|
height: chartHeight,
|
|
5016
|
-
children:
|
|
5017
|
-
}) : null, /* @__PURE__ */
|
|
5328
|
+
children: __6("All series are hidden. Click legend items to show data.", "jetpack-charts")
|
|
5329
|
+
}) : null, /* @__PURE__ */ _jsx20(BarGroup, {
|
|
5018
5330
|
padding: chartOptions.barGroup.padding,
|
|
5019
5331
|
children: seriesWithVisibility.map(({
|
|
5020
5332
|
series: seriesData,
|
|
@@ -5024,7 +5336,7 @@ var BarChartInternal = ({
|
|
|
5024
5336
|
if (!isVisible) {
|
|
5025
5337
|
return null;
|
|
5026
5338
|
}
|
|
5027
|
-
return /* @__PURE__ */
|
|
5339
|
+
return /* @__PURE__ */ _jsx20(BarSeries, {
|
|
5028
5340
|
dataKey: seriesData?.label,
|
|
5029
5341
|
data: seriesData.data,
|
|
5030
5342
|
yAccessor: chartOptions.accessors.yAccessor,
|
|
@@ -5032,11 +5344,11 @@ var BarChartInternal = ({
|
|
|
5032
5344
|
colorAccessor: getBarBackground(index)
|
|
5033
5345
|
}, seriesData?.label);
|
|
5034
5346
|
})
|
|
5035
|
-
}), /* @__PURE__ */
|
|
5347
|
+
}), /* @__PURE__ */ _jsx20(Axis3, {
|
|
5036
5348
|
...chartOptions.axis.x
|
|
5037
|
-
}), /* @__PURE__ */
|
|
5349
|
+
}), /* @__PURE__ */ _jsx20(Axis3, {
|
|
5038
5350
|
...chartOptions.axis.y
|
|
5039
|
-
}), withTooltips && /* @__PURE__ */
|
|
5351
|
+
}), withTooltips && /* @__PURE__ */ _jsx20(AccessibleTooltip, {
|
|
5040
5352
|
detectBounds: true,
|
|
5041
5353
|
snapTooltipToDatumX: true,
|
|
5042
5354
|
snapTooltipToDatumY: true,
|
|
@@ -5055,14 +5367,14 @@ var BarChartInternal = ({
|
|
|
5055
5367
|
});
|
|
5056
5368
|
};
|
|
5057
5369
|
var BarChartWithProvider = (props) => {
|
|
5058
|
-
const existingContext =
|
|
5370
|
+
const existingContext = useContext16(GlobalChartsContext);
|
|
5059
5371
|
if (existingContext) {
|
|
5060
|
-
return /* @__PURE__ */
|
|
5372
|
+
return /* @__PURE__ */ _jsx20(BarChartInternal, {
|
|
5061
5373
|
...props
|
|
5062
5374
|
});
|
|
5063
5375
|
}
|
|
5064
|
-
return /* @__PURE__ */
|
|
5065
|
-
children: /* @__PURE__ */
|
|
5376
|
+
return /* @__PURE__ */ _jsx20(GlobalChartsProvider, {
|
|
5377
|
+
children: /* @__PURE__ */ _jsx20(BarChartInternal, {
|
|
5066
5378
|
...props
|
|
5067
5379
|
})
|
|
5068
5380
|
});
|
|
@@ -5080,8 +5392,8 @@ import { formatNumberCompact as formatNumberCompact5 } from "@automattic/number-
|
|
|
5080
5392
|
import { Group as Group3 } from "@visx/group";
|
|
5081
5393
|
import { createScale as createScale2, scaleBand } from "@visx/scale";
|
|
5082
5394
|
import { Text as Text3 } from "@visx/text";
|
|
5083
|
-
import { useContext as
|
|
5084
|
-
import { jsx as
|
|
5395
|
+
import { useContext as useContext17, useMemo as useMemo20 } from "react";
|
|
5396
|
+
import { jsx as _jsx21, jsxs as _jsxs10 } from "react/jsx-runtime";
|
|
5085
5397
|
var getScaleBandwidth2 = (scale) => {
|
|
5086
5398
|
const s = scale;
|
|
5087
5399
|
return s && "bandwidth" in s ? s?.bandwidth() ?? 0 : 0;
|
|
@@ -5093,7 +5405,7 @@ var DefaultLabelComponent = ({
|
|
|
5093
5405
|
label,
|
|
5094
5406
|
formatter
|
|
5095
5407
|
}) => {
|
|
5096
|
-
return /* @__PURE__ */
|
|
5408
|
+
return /* @__PURE__ */ _jsx21(Text3, {
|
|
5097
5409
|
...textProps,
|
|
5098
5410
|
textAnchor: "start",
|
|
5099
5411
|
x,
|
|
@@ -5108,7 +5420,7 @@ var DefaultValueComponent = ({
|
|
|
5108
5420
|
value,
|
|
5109
5421
|
formatter
|
|
5110
5422
|
}) => {
|
|
5111
|
-
return /* @__PURE__ */
|
|
5423
|
+
return /* @__PURE__ */ _jsx21(Text3, {
|
|
5112
5424
|
...textProps,
|
|
5113
5425
|
textAnchor: "end",
|
|
5114
5426
|
x,
|
|
@@ -5147,14 +5459,14 @@ var AxisRenderer = ({
|
|
|
5147
5459
|
data: seriesData
|
|
5148
5460
|
}) => acc + (seriesData[index]?.value ?? 0), 0);
|
|
5149
5461
|
const y = from2.y + yOffset;
|
|
5150
|
-
return /* @__PURE__ */
|
|
5151
|
-
children: [/* @__PURE__ */
|
|
5462
|
+
return /* @__PURE__ */ _jsxs10(Group3, {
|
|
5463
|
+
children: [/* @__PURE__ */ _jsx21(LabelComponent, {
|
|
5152
5464
|
textProps,
|
|
5153
5465
|
x: labelPosition,
|
|
5154
5466
|
y,
|
|
5155
5467
|
label: formattedValue,
|
|
5156
5468
|
formatter: labelFormatter
|
|
5157
|
-
}), /* @__PURE__ */
|
|
5469
|
+
}), /* @__PURE__ */ _jsx21(ValueComponent, {
|
|
5158
5470
|
textProps,
|
|
5159
5471
|
x: valuePosition,
|
|
5160
5472
|
y,
|
|
@@ -5201,7 +5513,7 @@ var BarListChartInternal = ({
|
|
|
5201
5513
|
},
|
|
5202
5514
|
...rest
|
|
5203
5515
|
}) => {
|
|
5204
|
-
const chartOptions =
|
|
5516
|
+
const chartOptions = useMemo20(() => {
|
|
5205
5517
|
const isMultiSeries = data.length > 1;
|
|
5206
5518
|
const defaultYScale = {
|
|
5207
5519
|
// For multi series, set default padding larger to look better.
|
|
@@ -5230,7 +5542,7 @@ var BarListChartInternal = ({
|
|
|
5230
5542
|
yOffset: options.yOffset ?? getDefaultYOffset(data, yScale, height, isMultiSeries)
|
|
5231
5543
|
};
|
|
5232
5544
|
}, [options, width, data, height]);
|
|
5233
|
-
return /* @__PURE__ */
|
|
5545
|
+
return /* @__PURE__ */ _jsx21(BarChart, {
|
|
5234
5546
|
orientation: "horizontal",
|
|
5235
5547
|
gridVisibility: "none",
|
|
5236
5548
|
data,
|
|
@@ -5240,7 +5552,7 @@ var BarListChartInternal = ({
|
|
|
5240
5552
|
options: {
|
|
5241
5553
|
axis: {
|
|
5242
5554
|
y: {
|
|
5243
|
-
children: (renderProps) => /* @__PURE__ */
|
|
5555
|
+
children: (renderProps) => /* @__PURE__ */ _jsx21(AxisRenderer, {
|
|
5244
5556
|
...renderProps,
|
|
5245
5557
|
data,
|
|
5246
5558
|
yOffset: chartOptions.yOffset,
|
|
@@ -5263,14 +5575,14 @@ var BarListChartInternal = ({
|
|
|
5263
5575
|
});
|
|
5264
5576
|
};
|
|
5265
5577
|
var BarListChart = (props) => {
|
|
5266
|
-
const existingContext =
|
|
5578
|
+
const existingContext = useContext17(GlobalChartsContext);
|
|
5267
5579
|
if (existingContext) {
|
|
5268
|
-
return /* @__PURE__ */
|
|
5580
|
+
return /* @__PURE__ */ _jsx21(BarListChartInternal, {
|
|
5269
5581
|
...props
|
|
5270
5582
|
});
|
|
5271
5583
|
}
|
|
5272
|
-
return /* @__PURE__ */
|
|
5273
|
-
children: /* @__PURE__ */
|
|
5584
|
+
return /* @__PURE__ */ _jsx21(GlobalChartsProvider, {
|
|
5585
|
+
children: /* @__PURE__ */ _jsx21(BarListChartInternal, {
|
|
5274
5586
|
...props
|
|
5275
5587
|
})
|
|
5276
5588
|
});
|
|
@@ -5281,7 +5593,7 @@ var BarListChartResponsive = withResponsive(BarListChart);
|
|
|
5281
5593
|
// src/charts/conversion-funnel-chart/conversion-funnel-chart.tsx
|
|
5282
5594
|
import { useTooltip, useTooltipInPortal } from "@visx/tooltip";
|
|
5283
5595
|
import clsx7 from "clsx";
|
|
5284
|
-
import { useRef as useRef12, useMemo as
|
|
5596
|
+
import { useRef as useRef12, useMemo as useMemo21, useEffect as useEffect10, useCallback as useCallback13, useContext as useContext18 } from "react";
|
|
5285
5597
|
|
|
5286
5598
|
// src/charts/conversion-funnel-chart/conversion-funnel-chart.module.scss
|
|
5287
5599
|
var conversion_funnel_chart_module_default = {
|
|
@@ -5306,10 +5618,10 @@ var conversion_funnel_chart_module_default = {
|
|
|
5306
5618
|
};
|
|
5307
5619
|
|
|
5308
5620
|
// src/charts/conversion-funnel-chart/private/use-funnel-selection.ts
|
|
5309
|
-
import { useCallback as
|
|
5621
|
+
import { useCallback as useCallback12, useState as useState13 } from "react";
|
|
5310
5622
|
var useFunnelSelection = (hideTooltip) => {
|
|
5311
|
-
const [clickedStep, setClickedStep] =
|
|
5312
|
-
const handleBarClick =
|
|
5623
|
+
const [clickedStep, setClickedStep] = useState13(null);
|
|
5624
|
+
const handleBarClick = useCallback12(
|
|
5313
5625
|
(stepId) => {
|
|
5314
5626
|
if (clickedStep === stepId) {
|
|
5315
5627
|
setClickedStep(null);
|
|
@@ -5320,7 +5632,7 @@ var useFunnelSelection = (hideTooltip) => {
|
|
|
5320
5632
|
},
|
|
5321
5633
|
[clickedStep, hideTooltip]
|
|
5322
5634
|
);
|
|
5323
|
-
const handleBarKeyDown =
|
|
5635
|
+
const handleBarKeyDown = useCallback12(
|
|
5324
5636
|
(stepId, event) => {
|
|
5325
5637
|
if (event.key === "Enter" || event.key === " ") {
|
|
5326
5638
|
event.preventDefault();
|
|
@@ -5338,11 +5650,11 @@ var useFunnelSelection = (hideTooltip) => {
|
|
|
5338
5650
|
},
|
|
5339
5651
|
[clickedStep, hideTooltip]
|
|
5340
5652
|
);
|
|
5341
|
-
const clearSelection =
|
|
5653
|
+
const clearSelection = useCallback12(() => {
|
|
5342
5654
|
setClickedStep(null);
|
|
5343
5655
|
hideTooltip?.();
|
|
5344
5656
|
}, [hideTooltip]);
|
|
5345
|
-
const getStepState =
|
|
5657
|
+
const getStepState = useCallback12(
|
|
5346
5658
|
(stepId) => ({
|
|
5347
5659
|
isClicked: clickedStep === stepId,
|
|
5348
5660
|
isBlurred: clickedStep !== null && clickedStep !== stepId
|
|
@@ -5359,7 +5671,7 @@ var useFunnelSelection = (hideTooltip) => {
|
|
|
5359
5671
|
};
|
|
5360
5672
|
|
|
5361
5673
|
// src/charts/conversion-funnel-chart/conversion-funnel-chart.tsx
|
|
5362
|
-
import { jsx as
|
|
5674
|
+
import { jsx as _jsx22, Fragment as _Fragment6, jsxs as _jsxs11 } from "react/jsx-runtime";
|
|
5363
5675
|
var ConversionFunnelChartInternal = ({
|
|
5364
5676
|
mainRate,
|
|
5365
5677
|
changeIndicator,
|
|
@@ -5409,19 +5721,19 @@ var ConversionFunnelChartInternal = ({
|
|
|
5409
5721
|
// when tooltip containers are scrolled, this will correctly update the Tooltip position
|
|
5410
5722
|
scroll: true
|
|
5411
5723
|
});
|
|
5412
|
-
const clearSelectionAndRef =
|
|
5724
|
+
const clearSelectionAndRef = useCallback13(() => {
|
|
5413
5725
|
clearSelection();
|
|
5414
5726
|
selectedBarRef.current = null;
|
|
5415
5727
|
hideTooltip();
|
|
5416
5728
|
}, [clearSelection, hideTooltip]);
|
|
5417
|
-
const showTooltipAt =
|
|
5729
|
+
const showTooltipAt = useCallback13((step, x, y) => {
|
|
5418
5730
|
showTooltip({
|
|
5419
5731
|
tooltipData: step,
|
|
5420
5732
|
tooltipLeft: x,
|
|
5421
5733
|
tooltipTop: y - 10
|
|
5422
5734
|
});
|
|
5423
5735
|
}, [showTooltip]);
|
|
5424
|
-
const getMouseTooltipCoords =
|
|
5736
|
+
const getMouseTooltipCoords = useCallback13((event) => {
|
|
5425
5737
|
if (containerBounds.width === 0 || containerBounds.height === 0) {
|
|
5426
5738
|
return null;
|
|
5427
5739
|
}
|
|
@@ -5430,7 +5742,7 @@ var ConversionFunnelChartInternal = ({
|
|
|
5430
5742
|
y: event.clientY - containerBounds.top
|
|
5431
5743
|
};
|
|
5432
5744
|
}, [containerBounds.width, containerBounds.height, containerBounds.left, containerBounds.top]);
|
|
5433
|
-
const getKeyboardTooltipCoords =
|
|
5745
|
+
const getKeyboardTooltipCoords = useCallback13((event) => {
|
|
5434
5746
|
if (containerBounds.width === 0 || containerBounds.height === 0) {
|
|
5435
5747
|
return null;
|
|
5436
5748
|
}
|
|
@@ -5442,7 +5754,7 @@ var ConversionFunnelChartInternal = ({
|
|
|
5442
5754
|
y
|
|
5443
5755
|
};
|
|
5444
5756
|
}, [containerBounds.width, containerBounds.height, containerBounds.left, containerBounds.top]);
|
|
5445
|
-
const handleStepInteraction =
|
|
5757
|
+
const handleStepInteraction = useCallback13((step, event, interactionType) => {
|
|
5446
5758
|
selectedBarRef.current = event.currentTarget;
|
|
5447
5759
|
const {
|
|
5448
5760
|
isClicked
|
|
@@ -5469,7 +5781,7 @@ var ConversionFunnelChartInternal = ({
|
|
|
5469
5781
|
}
|
|
5470
5782
|
}
|
|
5471
5783
|
}, [getStepState, handleBarClick, handleBarKeyDown, showTooltipAt, getMouseTooltipCoords, getKeyboardTooltipCoords]);
|
|
5472
|
-
const stepHandlers =
|
|
5784
|
+
const stepHandlers = useMemo21(() => {
|
|
5473
5785
|
const handlers = /* @__PURE__ */ new Map();
|
|
5474
5786
|
steps.forEach((step) => {
|
|
5475
5787
|
const onClick = (event) => {
|
|
@@ -5520,11 +5832,11 @@ var ConversionFunnelChartInternal = ({
|
|
|
5520
5832
|
const isPositiveChange = changeIndicator?.startsWith("+");
|
|
5521
5833
|
const changeColor = isPositiveChange ? positiveChangeColor : negativeChangeColor;
|
|
5522
5834
|
const barBackgroundColor = backgroundColor || hexToRgba(barColor, 0.08) || "rgba(0, 0, 0, 0.08)";
|
|
5523
|
-
const renderDefaultMainMetric = () => /* @__PURE__ */
|
|
5524
|
-
children: [/* @__PURE__ */
|
|
5835
|
+
const renderDefaultMainMetric = () => /* @__PURE__ */ _jsxs11(_Fragment6, {
|
|
5836
|
+
children: [/* @__PURE__ */ _jsx22("span", {
|
|
5525
5837
|
className: conversion_funnel_chart_module_default["main-rate"],
|
|
5526
5838
|
children: formatPercentage(mainRate)
|
|
5527
|
-
}), changeIndicator && /* @__PURE__ */
|
|
5839
|
+
}), changeIndicator && /* @__PURE__ */ _jsx22("span", {
|
|
5528
5840
|
className: conversion_funnel_chart_module_default["change-indicator"],
|
|
5529
5841
|
style: {
|
|
5530
5842
|
color: changeColor
|
|
@@ -5532,20 +5844,20 @@ var ConversionFunnelChartInternal = ({
|
|
|
5532
5844
|
children: changeIndicator
|
|
5533
5845
|
})]
|
|
5534
5846
|
});
|
|
5535
|
-
const renderDefaultTooltip2 = (step) => /* @__PURE__ */
|
|
5847
|
+
const renderDefaultTooltip2 = (step) => /* @__PURE__ */ _jsxs11(Stack, {
|
|
5536
5848
|
direction: "column",
|
|
5537
5849
|
align: "flex-start",
|
|
5538
5850
|
gap: "xs",
|
|
5539
|
-
children: [/* @__PURE__ */
|
|
5851
|
+
children: [/* @__PURE__ */ _jsx22("div", {
|
|
5540
5852
|
className: conversion_funnel_chart_module_default["tooltip-title"],
|
|
5541
5853
|
children: step.label
|
|
5542
|
-
}), /* @__PURE__ */
|
|
5854
|
+
}), /* @__PURE__ */ _jsxs11("div", {
|
|
5543
5855
|
className: conversion_funnel_chart_module_default["tooltip-content"],
|
|
5544
5856
|
children: [formatPercentage(step.rate), ` \u2022 ${step.count ?? "no"} items`]
|
|
5545
5857
|
})]
|
|
5546
5858
|
});
|
|
5547
5859
|
const isDataValid = Boolean(steps && steps.length > 0);
|
|
5548
|
-
const chartMetadata =
|
|
5860
|
+
const chartMetadata = useMemo21(() => ({
|
|
5549
5861
|
mainRate,
|
|
5550
5862
|
changeIndicator,
|
|
5551
5863
|
stepsCount: steps?.length || 0
|
|
@@ -5559,7 +5871,7 @@ var ConversionFunnelChartInternal = ({
|
|
|
5559
5871
|
});
|
|
5560
5872
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
5561
5873
|
if (!isDataValid) {
|
|
5562
|
-
return /* @__PURE__ */
|
|
5874
|
+
return /* @__PURE__ */ _jsx22(Stack, {
|
|
5563
5875
|
direction: "column",
|
|
5564
5876
|
align: "center",
|
|
5565
5877
|
justify: "center",
|
|
@@ -5568,15 +5880,15 @@ var ConversionFunnelChartInternal = ({
|
|
|
5568
5880
|
...style,
|
|
5569
5881
|
height: resolvedHeight
|
|
5570
5882
|
},
|
|
5571
|
-
children: /* @__PURE__ */
|
|
5883
|
+
children: /* @__PURE__ */ _jsx22("div", {
|
|
5572
5884
|
className: conversion_funnel_chart_module_default["empty-state"],
|
|
5573
5885
|
children: loading ? "Loading..." : "No data available"
|
|
5574
5886
|
})
|
|
5575
5887
|
});
|
|
5576
5888
|
}
|
|
5577
5889
|
const maxRate = Math.max(...steps.map((step) => step.rate));
|
|
5578
|
-
return /* @__PURE__ */
|
|
5579
|
-
children: [/* @__PURE__ */
|
|
5890
|
+
return /* @__PURE__ */ _jsxs11(_Fragment6, {
|
|
5891
|
+
children: [/* @__PURE__ */ _jsxs11(Stack, {
|
|
5580
5892
|
direction: "column",
|
|
5581
5893
|
gap: "xl",
|
|
5582
5894
|
ref: (node2) => {
|
|
@@ -5593,13 +5905,13 @@ var ConversionFunnelChartInternal = ({
|
|
|
5593
5905
|
changeIndicator,
|
|
5594
5906
|
className: conversion_funnel_chart_module_default["main-metric"],
|
|
5595
5907
|
changeColor
|
|
5596
|
-
}) : /* @__PURE__ */
|
|
5908
|
+
}) : /* @__PURE__ */ _jsx22(Stack, {
|
|
5597
5909
|
direction: "row",
|
|
5598
5910
|
align: "baseline",
|
|
5599
5911
|
gap: "sm",
|
|
5600
5912
|
className: conversion_funnel_chart_module_default["main-metric"],
|
|
5601
5913
|
children: renderDefaultMainMetric()
|
|
5602
|
-
}), /* @__PURE__ */
|
|
5914
|
+
}), /* @__PURE__ */ _jsx22(Stack, {
|
|
5603
5915
|
direction: "row",
|
|
5604
5916
|
align: "flex-end",
|
|
5605
5917
|
gap: "lg",
|
|
@@ -5609,29 +5921,29 @@ var ConversionFunnelChartInternal = ({
|
|
|
5609
5921
|
const {
|
|
5610
5922
|
isBlurred
|
|
5611
5923
|
} = getStepState(step.id);
|
|
5612
|
-
return /* @__PURE__ */
|
|
5924
|
+
return /* @__PURE__ */ _jsxs11(Stack, {
|
|
5613
5925
|
direction: "column",
|
|
5614
5926
|
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
5927
|
gap: "xl",
|
|
5616
|
-
children: [/* @__PURE__ */
|
|
5928
|
+
children: [/* @__PURE__ */ _jsxs11(Stack, {
|
|
5617
5929
|
direction: "column",
|
|
5618
5930
|
gap: "xs",
|
|
5619
5931
|
children: [renderStepLabel ? renderStepLabel({
|
|
5620
5932
|
step,
|
|
5621
5933
|
index,
|
|
5622
5934
|
className: conversion_funnel_chart_module_default["step-label"]
|
|
5623
|
-
}) : /* @__PURE__ */
|
|
5935
|
+
}) : /* @__PURE__ */ _jsx22("span", {
|
|
5624
5936
|
className: conversion_funnel_chart_module_default["step-label"],
|
|
5625
5937
|
children: step.label
|
|
5626
5938
|
}), renderStepRate ? renderStepRate({
|
|
5627
5939
|
step,
|
|
5628
5940
|
index,
|
|
5629
5941
|
className: conversion_funnel_chart_module_default["step-rate"]
|
|
5630
|
-
}) : /* @__PURE__ */
|
|
5942
|
+
}) : /* @__PURE__ */ _jsx22("span", {
|
|
5631
5943
|
className: conversion_funnel_chart_module_default["step-rate"],
|
|
5632
5944
|
children: formatPercentage(step.rate)
|
|
5633
5945
|
})]
|
|
5634
|
-
}), /* @__PURE__ */
|
|
5946
|
+
}), /* @__PURE__ */ _jsx22(Stack, {
|
|
5635
5947
|
direction: "column",
|
|
5636
5948
|
justify: "flex-end",
|
|
5637
5949
|
className: conversion_funnel_chart_module_default["bar-container"],
|
|
@@ -5643,7 +5955,7 @@ var ConversionFunnelChartInternal = ({
|
|
|
5643
5955
|
style: {
|
|
5644
5956
|
backgroundColor: barBackgroundColor
|
|
5645
5957
|
},
|
|
5646
|
-
children: /* @__PURE__ */
|
|
5958
|
+
children: /* @__PURE__ */ _jsx22("div", {
|
|
5647
5959
|
className: clsx7(conversion_funnel_chart_module_default["funnel-bar"], {
|
|
5648
5960
|
[conversion_funnel_chart_module_default["funnel-bar--animated"]]: animation && !loading && !prefersReducedMotion
|
|
5649
5961
|
}),
|
|
@@ -5665,7 +5977,7 @@ var ConversionFunnelChartInternal = ({
|
|
|
5665
5977
|
className: conversion_funnel_chart_module_default["tooltip-wrapper"]
|
|
5666
5978
|
}) : renderDefaultTooltip2(tooltipData);
|
|
5667
5979
|
if (!tooltipContent) return null;
|
|
5668
|
-
return /* @__PURE__ */
|
|
5980
|
+
return /* @__PURE__ */ _jsx22(
|
|
5669
5981
|
TooltipInPortal,
|
|
5670
5982
|
{
|
|
5671
5983
|
top: tooltipTop,
|
|
@@ -5679,14 +5991,14 @@ var ConversionFunnelChartInternal = ({
|
|
|
5679
5991
|
});
|
|
5680
5992
|
};
|
|
5681
5993
|
var ConversionFunnelChartWithProvider = (props) => {
|
|
5682
|
-
const existingContext =
|
|
5994
|
+
const existingContext = useContext18(GlobalChartsContext);
|
|
5683
5995
|
if (existingContext) {
|
|
5684
|
-
return /* @__PURE__ */
|
|
5996
|
+
return /* @__PURE__ */ _jsx22(ConversionFunnelChartInternal, {
|
|
5685
5997
|
...props
|
|
5686
5998
|
});
|
|
5687
5999
|
}
|
|
5688
|
-
return /* @__PURE__ */
|
|
5689
|
-
children: /* @__PURE__ */
|
|
6000
|
+
return /* @__PURE__ */ _jsx22(GlobalChartsProvider, {
|
|
6001
|
+
children: /* @__PURE__ */ _jsx22(ConversionFunnelChartInternal, {
|
|
5690
6002
|
...props
|
|
5691
6003
|
})
|
|
5692
6004
|
});
|
|
@@ -5694,9 +6006,9 @@ var ConversionFunnelChartWithProvider = (props) => {
|
|
|
5694
6006
|
ConversionFunnelChartWithProvider.displayName = "ConversionFunnelChart";
|
|
5695
6007
|
|
|
5696
6008
|
// src/charts/geo-chart/geo-chart.tsx
|
|
5697
|
-
import { __ as
|
|
6009
|
+
import { __ as __7 } from "@wordpress/i18n";
|
|
5698
6010
|
import clsx8 from "clsx";
|
|
5699
|
-
import { useContext as
|
|
6011
|
+
import { useContext as useContext19, useMemo as useMemo22 } from "react";
|
|
5700
6012
|
import { Chart } from "react-google-charts";
|
|
5701
6013
|
|
|
5702
6014
|
// src/utils/sanitize-html.ts
|
|
@@ -5742,7 +6054,7 @@ var geo_chart_module_default = {
|
|
|
5742
6054
|
};
|
|
5743
6055
|
|
|
5744
6056
|
// src/charts/geo-chart/geo-chart.tsx
|
|
5745
|
-
import { jsx as
|
|
6057
|
+
import { jsx as _jsx23 } from "react/jsx-runtime";
|
|
5746
6058
|
var DEFAULT_FEATURE_FILL_COLOR = "#ffffff";
|
|
5747
6059
|
var DEFAULT_BACKGROUND_COLOR = "#ffffff";
|
|
5748
6060
|
var GeoChartInternal = ({
|
|
@@ -5763,7 +6075,7 @@ var GeoChartInternal = ({
|
|
|
5763
6075
|
backgroundColor
|
|
5764
6076
|
}
|
|
5765
6077
|
} = useGlobalChartsContext();
|
|
5766
|
-
const loadingPlaceholder = /* @__PURE__ */
|
|
6078
|
+
const loadingPlaceholder = /* @__PURE__ */ _jsx23(Stack, {
|
|
5767
6079
|
align: "center",
|
|
5768
6080
|
justify: "center",
|
|
5769
6081
|
className: clsx8("geo-chart", geo_chart_module_default.container, className),
|
|
@@ -5771,7 +6083,7 @@ var GeoChartInternal = ({
|
|
|
5771
6083
|
width,
|
|
5772
6084
|
height
|
|
5773
6085
|
},
|
|
5774
|
-
children: renderPlaceholder ? renderPlaceholder() :
|
|
6086
|
+
children: renderPlaceholder ? renderPlaceholder() : __7("Loading map", "jetpack-charts")
|
|
5775
6087
|
});
|
|
5776
6088
|
const fullColorHex = getElementStyles({
|
|
5777
6089
|
index: 0
|
|
@@ -5779,7 +6091,7 @@ var GeoChartInternal = ({
|
|
|
5779
6091
|
const lightColorHex = lightenHexColor(fullColorHex, 0.8);
|
|
5780
6092
|
const backgroundColorHex = normalizeColorToHex(backgroundColor, null, resolveCssVariable) || DEFAULT_BACKGROUND_COLOR;
|
|
5781
6093
|
const defaultFillColorHex = normalizeColorToHex(featureFillColor, null, resolveCssVariable) || DEFAULT_FEATURE_FILL_COLOR;
|
|
5782
|
-
const sanitizedData =
|
|
6094
|
+
const sanitizedData = useMemo22(() => {
|
|
5783
6095
|
if (data.length === 0) {
|
|
5784
6096
|
return {
|
|
5785
6097
|
data,
|
|
@@ -5813,7 +6125,7 @@ var GeoChartInternal = ({
|
|
|
5813
6125
|
hasHtmlTooltips: true
|
|
5814
6126
|
};
|
|
5815
6127
|
}, [data]);
|
|
5816
|
-
const options =
|
|
6128
|
+
const options = useMemo22(() => ({
|
|
5817
6129
|
...region !== "world" && {
|
|
5818
6130
|
region
|
|
5819
6131
|
},
|
|
@@ -5833,7 +6145,7 @@ var GeoChartInternal = ({
|
|
|
5833
6145
|
legend: "none",
|
|
5834
6146
|
keepAspectRatio: true
|
|
5835
6147
|
}), [region, resolution, lightColorHex, fullColorHex, backgroundColorHex, defaultFillColorHex, sanitizedData.hasHtmlTooltips]);
|
|
5836
|
-
return /* @__PURE__ */
|
|
6148
|
+
return /* @__PURE__ */ _jsx23(Stack, {
|
|
5837
6149
|
align: "center",
|
|
5838
6150
|
justify: "center",
|
|
5839
6151
|
className: clsx8("geo-chart", geo_chart_module_default.container, className),
|
|
@@ -5842,7 +6154,7 @@ var GeoChartInternal = ({
|
|
|
5842
6154
|
height,
|
|
5843
6155
|
backgroundColor
|
|
5844
6156
|
},
|
|
5845
|
-
children: /* @__PURE__ */
|
|
6157
|
+
children: /* @__PURE__ */ _jsx23(Chart, {
|
|
5846
6158
|
chartType: "GeoChart",
|
|
5847
6159
|
width,
|
|
5848
6160
|
height,
|
|
@@ -5853,14 +6165,14 @@ var GeoChartInternal = ({
|
|
|
5853
6165
|
});
|
|
5854
6166
|
};
|
|
5855
6167
|
var GeoChartWithProvider = (props) => {
|
|
5856
|
-
const existingContext =
|
|
6168
|
+
const existingContext = useContext19(GlobalChartsContext);
|
|
5857
6169
|
if (existingContext) {
|
|
5858
|
-
return /* @__PURE__ */
|
|
6170
|
+
return /* @__PURE__ */ _jsx23(GeoChartInternal, {
|
|
5859
6171
|
...props
|
|
5860
6172
|
});
|
|
5861
6173
|
}
|
|
5862
|
-
return /* @__PURE__ */
|
|
5863
|
-
children: /* @__PURE__ */
|
|
6174
|
+
return /* @__PURE__ */ _jsx23(GlobalChartsProvider, {
|
|
6175
|
+
children: /* @__PURE__ */ _jsx23(GeoChartInternal, {
|
|
5864
6176
|
...props
|
|
5865
6177
|
})
|
|
5866
6178
|
});
|
|
@@ -5886,7 +6198,7 @@ var use_update_effect_default = useUpdateEffect;
|
|
|
5886
6198
|
|
|
5887
6199
|
// ../../../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
6200
|
import * as React6 from "react";
|
|
5889
|
-
import { useContext as
|
|
6201
|
+
import { useContext as useContext21, forwardRef as forwardRef7 } from "react";
|
|
5890
6202
|
|
|
5891
6203
|
// ../../../node_modules/.pnpm/@emotion+sheet@1.4.0/node_modules/@emotion/sheet/dist/emotion-sheet.esm.js
|
|
5892
6204
|
var isDevelopment = false;
|
|
@@ -7077,18 +7389,18 @@ var EmotionCacheContext = /* @__PURE__ */ React6.createContext(
|
|
|
7077
7389
|
);
|
|
7078
7390
|
var CacheProvider = EmotionCacheContext.Provider;
|
|
7079
7391
|
var __unsafe_useEmotionCache = function useEmotionCache() {
|
|
7080
|
-
return
|
|
7392
|
+
return useContext21(EmotionCacheContext);
|
|
7081
7393
|
};
|
|
7082
7394
|
var withEmotionCache = function withEmotionCache2(func) {
|
|
7083
7395
|
return /* @__PURE__ */ forwardRef7(function(props, ref) {
|
|
7084
|
-
var cache2 =
|
|
7396
|
+
var cache2 = useContext21(EmotionCacheContext);
|
|
7085
7397
|
return func(props, cache2, ref);
|
|
7086
7398
|
});
|
|
7087
7399
|
};
|
|
7088
7400
|
if (!isBrowser4) {
|
|
7089
7401
|
withEmotionCache = function withEmotionCache3(func) {
|
|
7090
7402
|
return function(props) {
|
|
7091
|
-
var cache2 =
|
|
7403
|
+
var cache2 = useContext21(EmotionCacheContext);
|
|
7092
7404
|
if (cache2 === null) {
|
|
7093
7405
|
cache2 = createCache({
|
|
7094
7406
|
key: "css"
|
|
@@ -7186,10 +7498,10 @@ var jsx = function jsx2(type, props) {
|
|
|
7186
7498
|
}
|
|
7187
7499
|
return React7.createElement.apply(null, createElementArgArray);
|
|
7188
7500
|
};
|
|
7189
|
-
(function(
|
|
7501
|
+
(function(_jsx33) {
|
|
7190
7502
|
var JSX;
|
|
7191
7503
|
/* @__PURE__ */ (function(_JSX) {
|
|
7192
|
-
})(JSX || (JSX =
|
|
7504
|
+
})(JSX || (JSX = _jsx33.JSX || (_jsx33.JSX = {})));
|
|
7193
7505
|
})(jsx || (jsx = {}));
|
|
7194
7506
|
function css() {
|
|
7195
7507
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -7588,7 +7900,7 @@ function warning(message) {
|
|
|
7588
7900
|
}
|
|
7589
7901
|
|
|
7590
7902
|
// ../../../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
|
|
7903
|
+
import { jsx as _jsx24 } from "react/jsx-runtime";
|
|
7592
7904
|
var ComponentsContext = createContext3(
|
|
7593
7905
|
/** @type {Record<string, any>} */
|
|
7594
7906
|
{}
|
|
@@ -7623,7 +7935,7 @@ var BaseContextSystemProvider = ({
|
|
|
7623
7935
|
const contextValue = useContextSystemBridge({
|
|
7624
7936
|
value
|
|
7625
7937
|
});
|
|
7626
|
-
return /* @__PURE__ */
|
|
7938
|
+
return /* @__PURE__ */ _jsx24(ComponentsContext.Provider, {
|
|
7627
7939
|
value: contextValue,
|
|
7628
7940
|
children
|
|
7629
7941
|
});
|
|
@@ -7864,7 +8176,7 @@ var createStyled = function createStyled2(tag, options) {
|
|
|
7864
8176
|
};
|
|
7865
8177
|
|
|
7866
8178
|
// ../../../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
|
|
8179
|
+
import { jsx as _jsx25 } from "react/jsx-runtime";
|
|
7868
8180
|
var PolymorphicDiv = /* @__PURE__ */ createStyled("div", process.env.NODE_ENV === "production" ? {
|
|
7869
8181
|
target: "e19lxcc00"
|
|
7870
8182
|
} : {
|
|
@@ -7875,7 +8187,7 @@ function UnforwardedView({
|
|
|
7875
8187
|
as,
|
|
7876
8188
|
...restProps
|
|
7877
8189
|
}, ref) {
|
|
7878
|
-
return /* @__PURE__ */
|
|
8190
|
+
return /* @__PURE__ */ _jsx25(PolymorphicDiv, {
|
|
7879
8191
|
as,
|
|
7880
8192
|
ref,
|
|
7881
8193
|
...restProps
|
|
@@ -8027,10 +8339,10 @@ function useGrid(props) {
|
|
|
8027
8339
|
}
|
|
8028
8340
|
|
|
8029
8341
|
// ../../../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
|
|
8342
|
+
import { jsx as _jsx26 } from "react/jsx-runtime";
|
|
8031
8343
|
function UnconnectedGrid(props, forwardedRef) {
|
|
8032
8344
|
const gridProps = useGrid(props);
|
|
8033
|
-
return /* @__PURE__ */
|
|
8345
|
+
return /* @__PURE__ */ _jsx26(component_default, {
|
|
8034
8346
|
...gridProps,
|
|
8035
8347
|
ref: forwardedRef
|
|
8036
8348
|
});
|
|
@@ -8039,13 +8351,13 @@ var Grid4 = contextConnect(UnconnectedGrid, "Grid");
|
|
|
8039
8351
|
var component_default2 = Grid4;
|
|
8040
8352
|
|
|
8041
8353
|
// src/charts/leaderboard-chart/leaderboard-chart.tsx
|
|
8042
|
-
import { __ as
|
|
8354
|
+
import { __ as __9 } from "@wordpress/i18n";
|
|
8043
8355
|
import clsx9 from "clsx";
|
|
8044
|
-
import { useContext as
|
|
8356
|
+
import { useContext as useContext24, useMemo as useMemo24 } from "react";
|
|
8045
8357
|
|
|
8046
8358
|
// src/charts/leaderboard-chart/hooks/use-leaderboard-legend-items.ts
|
|
8047
|
-
import { __ as
|
|
8048
|
-
import { useMemo as
|
|
8359
|
+
import { __ as __8 } from "@wordpress/i18n";
|
|
8360
|
+
import { useMemo as useMemo23 } from "react";
|
|
8049
8361
|
function useLeaderboardLegendItems({
|
|
8050
8362
|
data,
|
|
8051
8363
|
primaryColor,
|
|
@@ -8056,7 +8368,7 @@ function useLeaderboardLegendItems({
|
|
|
8056
8368
|
}) {
|
|
8057
8369
|
const { leaderboardChart: leaderboardChartSettings } = useGlobalChartsTheme();
|
|
8058
8370
|
const { getElementStyles } = useGlobalChartsContext();
|
|
8059
|
-
return
|
|
8371
|
+
return useMemo23(() => {
|
|
8060
8372
|
if (!data || data.length === 0) {
|
|
8061
8373
|
return [];
|
|
8062
8374
|
}
|
|
@@ -8066,7 +8378,7 @@ function useLeaderboardLegendItems({
|
|
|
8066
8378
|
overrideColor: primaryColor || leaderboardChartSettings.primaryColor
|
|
8067
8379
|
});
|
|
8068
8380
|
items.push({
|
|
8069
|
-
label: legendLabels?.primary ||
|
|
8381
|
+
label: legendLabels?.primary || __8("Current period", "jetpack-charts"),
|
|
8070
8382
|
color: resolvedPrimaryColor
|
|
8071
8383
|
});
|
|
8072
8384
|
if (withComparison && !withOverlayLabel) {
|
|
@@ -8075,7 +8387,7 @@ function useLeaderboardLegendItems({
|
|
|
8075
8387
|
overrideColor: secondaryColor || leaderboardChartSettings.secondaryColor
|
|
8076
8388
|
});
|
|
8077
8389
|
items.push({
|
|
8078
|
-
label: legendLabels?.comparison ||
|
|
8390
|
+
label: legendLabels?.comparison || __8("Previous period", "jetpack-charts"),
|
|
8079
8391
|
color: resolvedSecondaryColor
|
|
8080
8392
|
});
|
|
8081
8393
|
}
|
|
@@ -8110,7 +8422,7 @@ var leaderboard_chart_module_default = {
|
|
|
8110
8422
|
};
|
|
8111
8423
|
|
|
8112
8424
|
// src/charts/leaderboard-chart/leaderboard-chart.tsx
|
|
8113
|
-
import { jsx as
|
|
8425
|
+
import { jsx as _jsx27, Fragment as _Fragment7, jsxs as _jsxs12 } from "react/jsx-runtime";
|
|
8114
8426
|
var defaultValueFormatter = (value) => {
|
|
8115
8427
|
return formatMetricValue(value, "number", {
|
|
8116
8428
|
useMultipliers: true,
|
|
@@ -8125,8 +8437,8 @@ var defaultDeltaFormatter = (value) => {
|
|
|
8125
8437
|
};
|
|
8126
8438
|
var BarLabel = ({
|
|
8127
8439
|
label
|
|
8128
|
-
}) => /* @__PURE__ */
|
|
8129
|
-
children: typeof label === "string" ? /* @__PURE__ */
|
|
8440
|
+
}) => /* @__PURE__ */ _jsx27(_Fragment7, {
|
|
8441
|
+
children: typeof label === "string" ? /* @__PURE__ */ _jsx27(Text, {
|
|
8130
8442
|
className: leaderboard_chart_module_default.label,
|
|
8131
8443
|
children: label
|
|
8132
8444
|
}) : label
|
|
@@ -8140,13 +8452,13 @@ var BarWithLabel = ({
|
|
|
8140
8452
|
animation,
|
|
8141
8453
|
isPrimaryVisible = true,
|
|
8142
8454
|
isComparisonVisible = true
|
|
8143
|
-
}) => /* @__PURE__ */
|
|
8455
|
+
}) => /* @__PURE__ */ _jsxs12("div", {
|
|
8144
8456
|
className: clsx9(leaderboard_chart_module_default.barWithLabelContainer, {
|
|
8145
8457
|
[leaderboard_chart_module_default["is-overlay"]]: withOverlayLabel
|
|
8146
8458
|
}),
|
|
8147
|
-
children: [/* @__PURE__ */
|
|
8459
|
+
children: [/* @__PURE__ */ _jsx27(BarLabel, {
|
|
8148
8460
|
label: entry.label
|
|
8149
|
-
}), isPrimaryVisible && /* @__PURE__ */
|
|
8461
|
+
}), isPrimaryVisible && /* @__PURE__ */ _jsx27("div", {
|
|
8150
8462
|
className: clsx9(leaderboard_chart_module_default.bar, {
|
|
8151
8463
|
[leaderboard_chart_module_default["bar--animated"]]: animation
|
|
8152
8464
|
}),
|
|
@@ -8154,7 +8466,7 @@ var BarWithLabel = ({
|
|
|
8154
8466
|
width: entry.currentShare + "%",
|
|
8155
8467
|
backgroundColor: primaryColor
|
|
8156
8468
|
}
|
|
8157
|
-
}), withComparison && !withOverlayLabel && isComparisonVisible && /* @__PURE__ */
|
|
8469
|
+
}), withComparison && !withOverlayLabel && isComparisonVisible && /* @__PURE__ */ _jsx27("div", {
|
|
8158
8470
|
className: clsx9(leaderboard_chart_module_default.bar, {
|
|
8159
8471
|
[leaderboard_chart_module_default["bar--animated"]]: animation
|
|
8160
8472
|
}),
|
|
@@ -8232,19 +8544,19 @@ var LeaderboardChartInternal = ({
|
|
|
8232
8544
|
withOverlayLabel,
|
|
8233
8545
|
legendLabels
|
|
8234
8546
|
});
|
|
8235
|
-
const isPrimaryVisible =
|
|
8547
|
+
const isPrimaryVisible = useMemo24(() => {
|
|
8236
8548
|
if (!chartId || !legendInteractive || legendItems.length === 0) {
|
|
8237
8549
|
return true;
|
|
8238
8550
|
}
|
|
8239
8551
|
return isSeriesVisible(chartId, legendItems[0].label);
|
|
8240
8552
|
}, [chartId, legendInteractive, legendItems, isSeriesVisible]);
|
|
8241
|
-
const isComparisonVisible =
|
|
8553
|
+
const isComparisonVisible = useMemo24(() => {
|
|
8242
8554
|
if (!chartId || !legendInteractive || legendItems.length < 2) {
|
|
8243
8555
|
return true;
|
|
8244
8556
|
}
|
|
8245
8557
|
return isSeriesVisible(chartId, legendItems[1].label);
|
|
8246
8558
|
}, [chartId, legendInteractive, legendItems, isSeriesVisible]);
|
|
8247
|
-
const allSeriesHidden =
|
|
8559
|
+
const allSeriesHidden = useMemo24(() => {
|
|
8248
8560
|
if (!legendInteractive) return false;
|
|
8249
8561
|
if (withComparison && !withOverlayLabel) {
|
|
8250
8562
|
return !isPrimaryVisible && !isComparisonVisible;
|
|
@@ -8252,7 +8564,7 @@ var LeaderboardChartInternal = ({
|
|
|
8252
8564
|
return !isPrimaryVisible;
|
|
8253
8565
|
}, [legendInteractive, isPrimaryVisible, isComparisonVisible, withComparison, withOverlayLabel]);
|
|
8254
8566
|
const isDataValid = Boolean(data && data.length > 0);
|
|
8255
|
-
const chartMetadata =
|
|
8567
|
+
const chartMetadata = useMemo24(() => ({
|
|
8256
8568
|
withComparison,
|
|
8257
8569
|
withOverlayLabel
|
|
8258
8570
|
}), [withComparison, withOverlayLabel]);
|
|
@@ -8265,11 +8577,11 @@ var LeaderboardChartInternal = ({
|
|
|
8265
8577
|
});
|
|
8266
8578
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
8267
8579
|
if (!data || data.length === 0) {
|
|
8268
|
-
return /* @__PURE__ */
|
|
8580
|
+
return /* @__PURE__ */ _jsx27(SingleChartContext.Provider, {
|
|
8269
8581
|
value: {
|
|
8270
8582
|
chartId
|
|
8271
8583
|
},
|
|
8272
|
-
children: /* @__PURE__ */
|
|
8584
|
+
children: /* @__PURE__ */ _jsx27(ChartLayout, {
|
|
8273
8585
|
legendPosition,
|
|
8274
8586
|
legendElement: false,
|
|
8275
8587
|
legendChildren,
|
|
@@ -8284,14 +8596,14 @@ var LeaderboardChartInternal = ({
|
|
|
8284
8596
|
height: propHeight || void 0
|
|
8285
8597
|
},
|
|
8286
8598
|
trailingContent: nonLegendChildren,
|
|
8287
|
-
children: /* @__PURE__ */
|
|
8599
|
+
children: /* @__PURE__ */ _jsx27("div", {
|
|
8288
8600
|
className: leaderboard_chart_module_default.emptyState,
|
|
8289
|
-
children: loading ?
|
|
8601
|
+
children: loading ? __9("Loading\u2026", "jetpack-charts") : __9("No data available", "jetpack-charts")
|
|
8290
8602
|
})
|
|
8291
8603
|
})
|
|
8292
8604
|
});
|
|
8293
8605
|
}
|
|
8294
|
-
const legendElement = showLegend && /* @__PURE__ */
|
|
8606
|
+
const legendElement = showLegend && /* @__PURE__ */ _jsx27(Legend, {
|
|
8295
8607
|
orientation: legend.orientation ?? "horizontal",
|
|
8296
8608
|
position: legendPosition,
|
|
8297
8609
|
alignment: legend.alignment ?? "center",
|
|
@@ -8303,11 +8615,11 @@ var LeaderboardChartInternal = ({
|
|
|
8303
8615
|
chartId,
|
|
8304
8616
|
interactive: legendInteractive
|
|
8305
8617
|
});
|
|
8306
|
-
return /* @__PURE__ */
|
|
8618
|
+
return /* @__PURE__ */ _jsx27(SingleChartContext.Provider, {
|
|
8307
8619
|
value: {
|
|
8308
8620
|
chartId
|
|
8309
8621
|
},
|
|
8310
|
-
children: /* @__PURE__ */
|
|
8622
|
+
children: /* @__PURE__ */ _jsx27(ChartLayout, {
|
|
8311
8623
|
legendPosition,
|
|
8312
8624
|
legendElement,
|
|
8313
8625
|
legendChildren,
|
|
@@ -8322,23 +8634,23 @@ var LeaderboardChartInternal = ({
|
|
|
8322
8634
|
height: propHeight || void 0
|
|
8323
8635
|
},
|
|
8324
8636
|
trailingContent: nonLegendChildren,
|
|
8325
|
-
children: /* @__PURE__ */
|
|
8637
|
+
children: /* @__PURE__ */ _jsx27("div", {
|
|
8326
8638
|
className: leaderboard_chart_module_default.leaderboardChart__content,
|
|
8327
|
-
children: allSeriesHidden ? /* @__PURE__ */
|
|
8639
|
+
children: allSeriesHidden ? /* @__PURE__ */ _jsx27("div", {
|
|
8328
8640
|
className: leaderboard_chart_module_default.emptyState,
|
|
8329
|
-
children:
|
|
8330
|
-
}) : /* @__PURE__ */
|
|
8641
|
+
children: __9("All series are hidden. Click legend items to show data.", "jetpack-charts")
|
|
8642
|
+
}) : /* @__PURE__ */ _jsx27(component_default2, {
|
|
8331
8643
|
templateColumns: "minmax(0, 1fr) auto",
|
|
8332
8644
|
rowGap,
|
|
8333
8645
|
columnGap,
|
|
8334
8646
|
children: data.map((entry) => {
|
|
8335
8647
|
const colorIndex = Math.sign(entry.delta) + 1;
|
|
8336
8648
|
const deltaColor = deltaColors[colorIndex];
|
|
8337
|
-
return /* @__PURE__ */
|
|
8338
|
-
children: [/* @__PURE__ */
|
|
8649
|
+
return /* @__PURE__ */ _jsxs12(Fragment, {
|
|
8650
|
+
children: [/* @__PURE__ */ _jsx27(Stack, {
|
|
8339
8651
|
direction: "column",
|
|
8340
8652
|
gap: labelSpacing,
|
|
8341
|
-
children: /* @__PURE__ */
|
|
8653
|
+
children: /* @__PURE__ */ _jsx27(BarWithLabel, {
|
|
8342
8654
|
entry,
|
|
8343
8655
|
withComparison,
|
|
8344
8656
|
withOverlayLabel,
|
|
@@ -8348,15 +8660,15 @@ var LeaderboardChartInternal = ({
|
|
|
8348
8660
|
isComparisonVisible,
|
|
8349
8661
|
animation: animation && !loading && !prefersReducedMotion
|
|
8350
8662
|
})
|
|
8351
|
-
}), /* @__PURE__ */
|
|
8663
|
+
}), /* @__PURE__ */ _jsxs12(Stack, {
|
|
8352
8664
|
direction: "row",
|
|
8353
8665
|
gap: "xs",
|
|
8354
8666
|
className: clsx9(leaderboard_chart_module_default.valueContainer, {
|
|
8355
8667
|
[leaderboard_chart_module_default.overlayLabel]: withOverlayLabel
|
|
8356
8668
|
}),
|
|
8357
|
-
children: [isPrimaryVisible && /* @__PURE__ */
|
|
8669
|
+
children: [isPrimaryVisible && /* @__PURE__ */ _jsx27(Text, {
|
|
8358
8670
|
children: valueFormatter(entry.currentValue)
|
|
8359
|
-
}), withComparison && isComparisonVisible && /* @__PURE__ */
|
|
8671
|
+
}), withComparison && isComparisonVisible && /* @__PURE__ */ _jsx27(Text, {
|
|
8360
8672
|
style: {
|
|
8361
8673
|
color: deltaColor
|
|
8362
8674
|
},
|
|
@@ -8371,14 +8683,14 @@ var LeaderboardChartInternal = ({
|
|
|
8371
8683
|
});
|
|
8372
8684
|
};
|
|
8373
8685
|
var LeaderboardChartWithProvider = (props) => {
|
|
8374
|
-
const existingContext =
|
|
8686
|
+
const existingContext = useContext24(GlobalChartsContext);
|
|
8375
8687
|
if (existingContext) {
|
|
8376
|
-
return /* @__PURE__ */
|
|
8688
|
+
return /* @__PURE__ */ _jsx27(LeaderboardChartInternal, {
|
|
8377
8689
|
...props
|
|
8378
8690
|
});
|
|
8379
8691
|
}
|
|
8380
|
-
return /* @__PURE__ */
|
|
8381
|
-
children: /* @__PURE__ */
|
|
8692
|
+
return /* @__PURE__ */ _jsx27(GlobalChartsProvider, {
|
|
8693
|
+
children: /* @__PURE__ */ _jsx27(LeaderboardChartInternal, {
|
|
8382
8694
|
...props
|
|
8383
8695
|
})
|
|
8384
8696
|
});
|
|
@@ -8395,12 +8707,12 @@ var LeaderboardChartResponsive = attachSubComponents(withResponsive(LeaderboardC
|
|
|
8395
8707
|
import { Group as Group4 } from "@visx/group";
|
|
8396
8708
|
import { Pie } from "@visx/shape";
|
|
8397
8709
|
import { useTooltip as useTooltip2, useTooltipInPortal as useTooltipInPortal2 } from "@visx/tooltip";
|
|
8398
|
-
import { __ as
|
|
8710
|
+
import { __ as __10 } from "@wordpress/i18n";
|
|
8399
8711
|
import clsx10 from "clsx";
|
|
8400
|
-
import { useCallback as
|
|
8712
|
+
import { useCallback as useCallback14, useContext as useContext25, useMemo as useMemo25 } from "react";
|
|
8401
8713
|
|
|
8402
8714
|
// src/charts/private/radial-wipe-animation/radial-wipe-animation.tsx
|
|
8403
|
-
import { jsx as
|
|
8715
|
+
import { jsx as _jsx28 } from "react/jsx-runtime";
|
|
8404
8716
|
function RadialWipeAnimation({
|
|
8405
8717
|
id,
|
|
8406
8718
|
radius,
|
|
@@ -8416,9 +8728,9 @@ function RadialWipeAnimation({
|
|
|
8416
8728
|
const isValidWipePercentage = 0 < wipePercentage && wipePercentage <= 100;
|
|
8417
8729
|
const animationDuration = `${// If wipePercentage is invalid, set animation duration to 0 to disable animation.
|
|
8418
8730
|
isValidWipePercentage ? durationMs * (100 / wipePercentage) : 0}ms`;
|
|
8419
|
-
return /* @__PURE__ */
|
|
8731
|
+
return /* @__PURE__ */ _jsx28("mask", {
|
|
8420
8732
|
id,
|
|
8421
|
-
children: /* @__PURE__ */
|
|
8733
|
+
children: /* @__PURE__ */ _jsx28("circle", {
|
|
8422
8734
|
cx: 0,
|
|
8423
8735
|
cy: 0,
|
|
8424
8736
|
r: radius,
|
|
@@ -8431,7 +8743,7 @@ function RadialWipeAnimation({
|
|
|
8431
8743
|
style: {
|
|
8432
8744
|
transform: `rotate(${startAngle}) scaleY(${scaleY})`
|
|
8433
8745
|
},
|
|
8434
|
-
children: /* @__PURE__ */
|
|
8746
|
+
children: /* @__PURE__ */ _jsx28("animate", {
|
|
8435
8747
|
attributeName: "stroke-dashoffset",
|
|
8436
8748
|
from: "0",
|
|
8437
8749
|
to: "100.1",
|
|
@@ -8454,11 +8766,11 @@ var pie_chart_module_default = {
|
|
|
8454
8766
|
};
|
|
8455
8767
|
|
|
8456
8768
|
// src/charts/pie-chart/pie-chart.tsx
|
|
8457
|
-
import { jsx as
|
|
8769
|
+
import { jsx as _jsx29, Fragment as _Fragment8, jsxs as _jsxs13 } from "react/jsx-runtime";
|
|
8458
8770
|
var renderDefaultPieTooltip = ({
|
|
8459
8771
|
tooltipData
|
|
8460
8772
|
}) => {
|
|
8461
|
-
return /* @__PURE__ */
|
|
8773
|
+
return /* @__PURE__ */ _jsx29(BaseTooltip, {
|
|
8462
8774
|
data: tooltipData,
|
|
8463
8775
|
top: 0,
|
|
8464
8776
|
left: 0,
|
|
@@ -8535,7 +8847,7 @@ var PieChartInternal = ({
|
|
|
8535
8847
|
scroll: true,
|
|
8536
8848
|
debounce: 0
|
|
8537
8849
|
});
|
|
8538
|
-
const onMouseLeave =
|
|
8850
|
+
const onMouseLeave = useCallback14(() => {
|
|
8539
8851
|
if (!withTooltips) {
|
|
8540
8852
|
return;
|
|
8541
8853
|
}
|
|
@@ -8556,7 +8868,7 @@ var PieChartInternal = ({
|
|
|
8556
8868
|
legendInteractive,
|
|
8557
8869
|
isSeriesVisible
|
|
8558
8870
|
});
|
|
8559
|
-
const legendOptions =
|
|
8871
|
+
const legendOptions = useMemo25(() => ({
|
|
8560
8872
|
showValues: true,
|
|
8561
8873
|
legendValueDisplay
|
|
8562
8874
|
}), [legendValueDisplay]);
|
|
@@ -8571,7 +8883,7 @@ var PieChartInternal = ({
|
|
|
8571
8883
|
legendChildren,
|
|
8572
8884
|
otherChildren
|
|
8573
8885
|
} = useChartChildren(children, "PieChart");
|
|
8574
|
-
const chartMetadata =
|
|
8886
|
+
const chartMetadata = useMemo25(() => ({
|
|
8575
8887
|
thickness,
|
|
8576
8888
|
gapScale,
|
|
8577
8889
|
cornerScale
|
|
@@ -8585,9 +8897,9 @@ var PieChartInternal = ({
|
|
|
8585
8897
|
});
|
|
8586
8898
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
8587
8899
|
if (!isValid2) {
|
|
8588
|
-
return /* @__PURE__ */
|
|
8900
|
+
return /* @__PURE__ */ _jsx29("div", {
|
|
8589
8901
|
className: clsx10("pie-chart", pie_chart_module_default["pie-chart"], className),
|
|
8590
|
-
children: /* @__PURE__ */
|
|
8902
|
+
children: /* @__PURE__ */ _jsx29("div", {
|
|
8591
8903
|
className: pie_chart_module_default["error-message"],
|
|
8592
8904
|
children: message
|
|
8593
8905
|
})
|
|
@@ -8610,7 +8922,7 @@ var PieChartInternal = ({
|
|
|
8610
8922
|
}).color;
|
|
8611
8923
|
}
|
|
8612
8924
|
};
|
|
8613
|
-
const legendElement = showLegend && /* @__PURE__ */
|
|
8925
|
+
const legendElement = showLegend && /* @__PURE__ */ _jsx29(Legend, {
|
|
8614
8926
|
orientation: legend.orientation ?? "horizontal",
|
|
8615
8927
|
position: legendPosition,
|
|
8616
8928
|
alignment: legend.alignment ?? "center",
|
|
@@ -8622,11 +8934,11 @@ var PieChartInternal = ({
|
|
|
8622
8934
|
chartId,
|
|
8623
8935
|
interactive: legendInteractive
|
|
8624
8936
|
});
|
|
8625
|
-
return /* @__PURE__ */
|
|
8937
|
+
return /* @__PURE__ */ _jsx29(SingleChartContext.Provider, {
|
|
8626
8938
|
value: {
|
|
8627
8939
|
chartId
|
|
8628
8940
|
},
|
|
8629
|
-
children: /* @__PURE__ */
|
|
8941
|
+
children: /* @__PURE__ */ _jsx29(ChartLayout, {
|
|
8630
8942
|
legendPosition,
|
|
8631
8943
|
legendElement,
|
|
8632
8944
|
legendChildren,
|
|
@@ -8644,11 +8956,11 @@ var PieChartInternal = ({
|
|
|
8644
8956
|
width: propWidth || void 0,
|
|
8645
8957
|
height: propHeight || void 0
|
|
8646
8958
|
},
|
|
8647
|
-
trailingContent: /* @__PURE__ */
|
|
8648
|
-
children: [withTooltips && tooltipOpen && tooltipData && /* @__PURE__ */
|
|
8959
|
+
trailingContent: /* @__PURE__ */ _jsxs13(_Fragment8, {
|
|
8960
|
+
children: [withTooltips && tooltipOpen && tooltipData && /* @__PURE__ */ _jsx29(TooltipInPortal, {
|
|
8649
8961
|
top: tooltipTop || 0,
|
|
8650
8962
|
left: tooltipLeft || 0,
|
|
8651
|
-
children: /* @__PURE__ */
|
|
8963
|
+
children: /* @__PURE__ */ _jsx29("div", {
|
|
8652
8964
|
role: "tooltip",
|
|
8653
8965
|
children: renderTooltip({
|
|
8654
8966
|
tooltipData
|
|
@@ -8673,33 +8985,33 @@ var PieChartInternal = ({
|
|
|
8673
8985
|
const innerRadius = thickness === 0 ? 0 : outerRadius * (1 - thickness);
|
|
8674
8986
|
const maxCornerRadius = (outerRadius - innerRadius) / 2;
|
|
8675
8987
|
const cornerRadius = cornerScale ? Math.min(cornerScale * outerRadius, maxCornerRadius) : 0;
|
|
8676
|
-
return /* @__PURE__ */
|
|
8988
|
+
return /* @__PURE__ */ _jsx29(Stack, {
|
|
8677
8989
|
ref: containerRef,
|
|
8678
8990
|
align: "center",
|
|
8679
8991
|
justify: "center",
|
|
8680
8992
|
className: pie_chart_module_default["pie-chart__centering"],
|
|
8681
|
-
children: /* @__PURE__ */
|
|
8993
|
+
children: /* @__PURE__ */ _jsxs13("svg", {
|
|
8682
8994
|
viewBox: `0 0 ${width} ${height}`,
|
|
8683
8995
|
preserveAspectRatio: "xMidYMid meet",
|
|
8684
8996
|
width,
|
|
8685
8997
|
height,
|
|
8686
|
-
children: [/* @__PURE__ */
|
|
8687
|
-
children: /* @__PURE__ */
|
|
8998
|
+
children: [/* @__PURE__ */ _jsx29("defs", {
|
|
8999
|
+
children: /* @__PURE__ */ _jsx29(radial_wipe_animation_default, {
|
|
8688
9000
|
id: `radial-wipe-${chartId}`,
|
|
8689
9001
|
radius: outerRadius,
|
|
8690
9002
|
innerRadius
|
|
8691
9003
|
})
|
|
8692
|
-
}), /* @__PURE__ */
|
|
9004
|
+
}), /* @__PURE__ */ _jsxs13(Group4, {
|
|
8693
9005
|
top: centerY,
|
|
8694
9006
|
left: centerX,
|
|
8695
9007
|
mask: animation && !prefersReducedMotion ? `url(#radial-wipe-${chartId})` : null,
|
|
8696
|
-
children: [allSegmentsHidden ? /* @__PURE__ */
|
|
9008
|
+
children: [allSegmentsHidden ? /* @__PURE__ */ _jsx29(SvgEmptyState, {
|
|
8697
9009
|
x: 0,
|
|
8698
9010
|
y: 0,
|
|
8699
9011
|
width,
|
|
8700
9012
|
height,
|
|
8701
|
-
children:
|
|
8702
|
-
}) : /* @__PURE__ */
|
|
9013
|
+
children: __10("All segments are hidden. Click legend items to show data.", "jetpack-charts")
|
|
9014
|
+
}) : /* @__PURE__ */ _jsx29(Pie, {
|
|
8703
9015
|
data: dataWithIndex,
|
|
8704
9016
|
pieValue: accessors.value,
|
|
8705
9017
|
outerRadius,
|
|
@@ -8743,12 +9055,12 @@ var PieChartInternal = ({
|
|
|
8743
9055
|
const labelPadding = 6;
|
|
8744
9056
|
const backgroundWidth = estimatedTextWidth + labelPadding * 2;
|
|
8745
9057
|
const backgroundHeight = fontSize + labelPadding * 2;
|
|
8746
|
-
return /* @__PURE__ */
|
|
9058
|
+
return /* @__PURE__ */ _jsxs13("g", {
|
|
8747
9059
|
...groupProps,
|
|
8748
|
-
children: [/* @__PURE__ */
|
|
9060
|
+
children: [/* @__PURE__ */ _jsx29("path", {
|
|
8749
9061
|
...pathProps
|
|
8750
|
-
}), showLabels && hasSpaceForLabel && /* @__PURE__ */
|
|
8751
|
-
children: [providerTheme.labelBackgroundColor && /* @__PURE__ */
|
|
9062
|
+
}), showLabels && hasSpaceForLabel && /* @__PURE__ */ _jsxs13("g", {
|
|
9063
|
+
children: [providerTheme.labelBackgroundColor && /* @__PURE__ */ _jsx29("rect", {
|
|
8752
9064
|
x: centroidX - backgroundWidth / 2,
|
|
8753
9065
|
y: centroidY - backgroundHeight / 2,
|
|
8754
9066
|
width: backgroundWidth,
|
|
@@ -8757,7 +9069,7 @@ var PieChartInternal = ({
|
|
|
8757
9069
|
rx: 4,
|
|
8758
9070
|
ry: 4,
|
|
8759
9071
|
pointerEvents: "none"
|
|
8760
|
-
}), /* @__PURE__ */
|
|
9072
|
+
}), /* @__PURE__ */ _jsx29("text", {
|
|
8761
9073
|
x: centroidX,
|
|
8762
9074
|
y: centroidY,
|
|
8763
9075
|
dy: ".33em",
|
|
@@ -8780,14 +9092,14 @@ var PieChartInternal = ({
|
|
|
8780
9092
|
});
|
|
8781
9093
|
};
|
|
8782
9094
|
var PieChartWithProvider = (props) => {
|
|
8783
|
-
const existingContext =
|
|
9095
|
+
const existingContext = useContext25(GlobalChartsContext);
|
|
8784
9096
|
if (existingContext) {
|
|
8785
|
-
return /* @__PURE__ */
|
|
9097
|
+
return /* @__PURE__ */ _jsx29(PieChartInternal, {
|
|
8786
9098
|
...props
|
|
8787
9099
|
});
|
|
8788
9100
|
}
|
|
8789
|
-
return /* @__PURE__ */
|
|
8790
|
-
children: /* @__PURE__ */
|
|
9101
|
+
return /* @__PURE__ */ _jsx29(GlobalChartsProvider, {
|
|
9102
|
+
children: /* @__PURE__ */ _jsx29(PieChartInternal, {
|
|
8791
9103
|
...props
|
|
8792
9104
|
})
|
|
8793
9105
|
});
|
|
@@ -8809,9 +9121,9 @@ import { Group as Group5 } from "@visx/group";
|
|
|
8809
9121
|
import { Pie as Pie2 } from "@visx/shape";
|
|
8810
9122
|
import { Text as Text4 } from "@visx/text";
|
|
8811
9123
|
import { useTooltip as useTooltip3, useTooltipInPortal as useTooltipInPortal3 } from "@visx/tooltip";
|
|
8812
|
-
import { __ as
|
|
9124
|
+
import { __ as __11 } from "@wordpress/i18n";
|
|
8813
9125
|
import clsx11 from "clsx";
|
|
8814
|
-
import { useCallback as
|
|
9126
|
+
import { useCallback as useCallback15, useContext as useContext26, useMemo as useMemo26 } from "react";
|
|
8815
9127
|
|
|
8816
9128
|
// src/charts/pie-semi-circle-chart/pie-semi-circle-chart.module.scss
|
|
8817
9129
|
var pie_semi_circle_chart_module_default = {
|
|
@@ -8823,11 +9135,11 @@ var pie_semi_circle_chart_module_default = {
|
|
|
8823
9135
|
};
|
|
8824
9136
|
|
|
8825
9137
|
// src/charts/pie-semi-circle-chart/pie-semi-circle-chart.tsx
|
|
8826
|
-
import { jsx as
|
|
9138
|
+
import { jsx as _jsx30, Fragment as _Fragment9, jsxs as _jsxs14 } from "react/jsx-runtime";
|
|
8827
9139
|
var renderDefaultPieSemiCircleTooltip = ({
|
|
8828
9140
|
tooltipData
|
|
8829
9141
|
}) => {
|
|
8830
|
-
return /* @__PURE__ */
|
|
9142
|
+
return /* @__PURE__ */ _jsx30(BaseTooltip, {
|
|
8831
9143
|
data: tooltipData,
|
|
8832
9144
|
top: 0,
|
|
8833
9145
|
left: 0,
|
|
@@ -8903,7 +9215,7 @@ var PieSemiCircleChartInternal = ({
|
|
|
8903
9215
|
scroll: true,
|
|
8904
9216
|
debounce: 0
|
|
8905
9217
|
});
|
|
8906
|
-
const handleMouseMove =
|
|
9218
|
+
const handleMouseMove = useCallback15((event, arc) => {
|
|
8907
9219
|
if (containerBounds.width === 0 || containerBounds.height === 0) {
|
|
8908
9220
|
return;
|
|
8909
9221
|
}
|
|
@@ -8913,10 +9225,10 @@ var PieSemiCircleChartInternal = ({
|
|
|
8913
9225
|
tooltipTop: event.clientY - containerBounds.top + tooltipOffsetY
|
|
8914
9226
|
});
|
|
8915
9227
|
}, [containerBounds.width, containerBounds.height, containerBounds.left, containerBounds.top, showTooltip, tooltipOffsetX, tooltipOffsetY]);
|
|
8916
|
-
const handleMouseLeave =
|
|
9228
|
+
const handleMouseLeave = useCallback15(() => {
|
|
8917
9229
|
hideTooltip();
|
|
8918
9230
|
}, [hideTooltip]);
|
|
8919
|
-
const handleArcMouseMove =
|
|
9231
|
+
const handleArcMouseMove = useCallback15((arc) => (event) => {
|
|
8920
9232
|
handleMouseMove(event, arc);
|
|
8921
9233
|
}, [handleMouseMove]);
|
|
8922
9234
|
const {
|
|
@@ -8938,7 +9250,7 @@ var PieSemiCircleChartInternal = ({
|
|
|
8938
9250
|
legendInteractive,
|
|
8939
9251
|
isSeriesVisible
|
|
8940
9252
|
});
|
|
8941
|
-
const accessors =
|
|
9253
|
+
const accessors = useMemo26(() => ({
|
|
8942
9254
|
value: (d) => d.value,
|
|
8943
9255
|
sort: (a, b) => b.value - a.value,
|
|
8944
9256
|
fill: (d) => getElementStyles({
|
|
@@ -8946,7 +9258,7 @@ var PieSemiCircleChartInternal = ({
|
|
|
8946
9258
|
index: d.index
|
|
8947
9259
|
}).color
|
|
8948
9260
|
}), [getElementStyles]);
|
|
8949
|
-
const legendOptions =
|
|
9261
|
+
const legendOptions = useMemo26(() => ({
|
|
8950
9262
|
showValues: true,
|
|
8951
9263
|
legendValueDisplay
|
|
8952
9264
|
}), [legendValueDisplay]);
|
|
@@ -8957,7 +9269,7 @@ var PieSemiCircleChartInternal = ({
|
|
|
8957
9269
|
legendChildren,
|
|
8958
9270
|
otherChildren
|
|
8959
9271
|
} = useChartChildren(children, "PieSemiCircleChart");
|
|
8960
|
-
const chartMetadata =
|
|
9272
|
+
const chartMetadata = useMemo26(() => ({
|
|
8961
9273
|
thickness,
|
|
8962
9274
|
clockwise
|
|
8963
9275
|
}), [thickness, clockwise]);
|
|
@@ -8973,12 +9285,12 @@ var PieSemiCircleChartInternal = ({
|
|
|
8973
9285
|
if (!isValid2) {
|
|
8974
9286
|
const errorWidth = propHeight ? Math.min(propWidth || propHeight * 2, propHeight * 2) : effectiveWidth;
|
|
8975
9287
|
const errorHeight = errorWidth / 2;
|
|
8976
|
-
return /* @__PURE__ */
|
|
9288
|
+
return /* @__PURE__ */ _jsx30("div", {
|
|
8977
9289
|
className: pie_semi_circle_chart_module_default["pie-semi-circle-chart"],
|
|
8978
|
-
children: /* @__PURE__ */
|
|
9290
|
+
children: /* @__PURE__ */ _jsx30("svg", {
|
|
8979
9291
|
width: errorWidth,
|
|
8980
9292
|
height: errorHeight,
|
|
8981
|
-
children: /* @__PURE__ */
|
|
9293
|
+
children: /* @__PURE__ */ _jsx30("text", {
|
|
8982
9294
|
x: "50%",
|
|
8983
9295
|
y: "50%",
|
|
8984
9296
|
textAnchor: "middle",
|
|
@@ -8997,7 +9309,7 @@ var PieSemiCircleChartInternal = ({
|
|
|
8997
9309
|
});
|
|
8998
9310
|
const startAngle = clockwise ? -Math.PI / 2 : Math.PI / 2;
|
|
8999
9311
|
const endAngle = clockwise ? Math.PI / 2 : -Math.PI / 2;
|
|
9000
|
-
const legendElement = showLegend && /* @__PURE__ */
|
|
9312
|
+
const legendElement = showLegend && /* @__PURE__ */ _jsx30(Legend, {
|
|
9001
9313
|
orientation: legend.orientation ?? "horizontal",
|
|
9002
9314
|
position: legendPosition,
|
|
9003
9315
|
alignment: legend.alignment ?? "center",
|
|
@@ -9009,11 +9321,11 @@ var PieSemiCircleChartInternal = ({
|
|
|
9009
9321
|
chartId,
|
|
9010
9322
|
interactive: legendInteractive
|
|
9011
9323
|
});
|
|
9012
|
-
return /* @__PURE__ */
|
|
9324
|
+
return /* @__PURE__ */ _jsx30(SingleChartContext.Provider, {
|
|
9013
9325
|
value: {
|
|
9014
9326
|
chartId
|
|
9015
9327
|
},
|
|
9016
|
-
children: /* @__PURE__ */
|
|
9328
|
+
children: /* @__PURE__ */ _jsx30(ChartLayout, {
|
|
9017
9329
|
legendPosition,
|
|
9018
9330
|
legendElement,
|
|
9019
9331
|
legendChildren,
|
|
@@ -9025,11 +9337,11 @@ var PieSemiCircleChartInternal = ({
|
|
|
9025
9337
|
width: propWidth || void 0,
|
|
9026
9338
|
height: propHeight || void 0
|
|
9027
9339
|
},
|
|
9028
|
-
trailingContent: /* @__PURE__ */
|
|
9029
|
-
children: [withTooltips && tooltipOpen && tooltipData && /* @__PURE__ */
|
|
9340
|
+
trailingContent: /* @__PURE__ */ _jsxs14(_Fragment9, {
|
|
9341
|
+
children: [withTooltips && tooltipOpen && tooltipData && /* @__PURE__ */ _jsx30(TooltipInPortal, {
|
|
9030
9342
|
top: tooltipTop || 0,
|
|
9031
9343
|
left: tooltipLeft || 0,
|
|
9032
|
-
children: /* @__PURE__ */
|
|
9344
|
+
children: /* @__PURE__ */ _jsx30("div", {
|
|
9033
9345
|
role: "tooltip",
|
|
9034
9346
|
children: renderTooltip({
|
|
9035
9347
|
tooltipData
|
|
@@ -9047,35 +9359,35 @@ var PieSemiCircleChartInternal = ({
|
|
|
9047
9359
|
const height = width / 2;
|
|
9048
9360
|
const radius = height;
|
|
9049
9361
|
const innerRadius = radius * (1 - thickness);
|
|
9050
|
-
return /* @__PURE__ */
|
|
9362
|
+
return /* @__PURE__ */ _jsx30(Stack, {
|
|
9051
9363
|
ref: containerRef,
|
|
9052
9364
|
align: "center",
|
|
9053
9365
|
justify: "center",
|
|
9054
9366
|
className: pie_semi_circle_chart_module_default["pie-semi-circle-chart__centering"],
|
|
9055
|
-
children: /* @__PURE__ */
|
|
9367
|
+
children: /* @__PURE__ */ _jsxs14("svg", {
|
|
9056
9368
|
width,
|
|
9057
9369
|
height,
|
|
9058
9370
|
viewBox: `0 0 ${width} ${height}`,
|
|
9059
|
-
children: [/* @__PURE__ */
|
|
9060
|
-
children: /* @__PURE__ */
|
|
9371
|
+
children: [/* @__PURE__ */ _jsx30("defs", {
|
|
9372
|
+
children: /* @__PURE__ */ _jsx30(radial_wipe_animation_default, {
|
|
9061
9373
|
id: `radial-wipe-${chartId}`,
|
|
9062
9374
|
radius,
|
|
9063
9375
|
innerRadius,
|
|
9064
9376
|
startAngle: "-180deg",
|
|
9065
9377
|
wipePercentage: 50
|
|
9066
9378
|
})
|
|
9067
|
-
}), /* @__PURE__ */
|
|
9379
|
+
}), /* @__PURE__ */ _jsx30(Group5, {
|
|
9068
9380
|
top: height,
|
|
9069
9381
|
left: width / 2,
|
|
9070
9382
|
mask: animation && !prefersReducedMotion ? `url(#radial-wipe-${chartId})` : null,
|
|
9071
|
-
children: allSegmentsHidden ? /* @__PURE__ */
|
|
9383
|
+
children: allSegmentsHidden ? /* @__PURE__ */ _jsx30(SvgEmptyState, {
|
|
9072
9384
|
x: 0,
|
|
9073
9385
|
y: -radius / 2,
|
|
9074
9386
|
width,
|
|
9075
9387
|
height,
|
|
9076
|
-
children:
|
|
9077
|
-
}) : /* @__PURE__ */
|
|
9078
|
-
children: [/* @__PURE__ */
|
|
9388
|
+
children: __11("All segments are hidden. Click legend items to show data.", "jetpack-charts")
|
|
9389
|
+
}) : /* @__PURE__ */ _jsxs14(_Fragment9, {
|
|
9390
|
+
children: [/* @__PURE__ */ _jsx30(Pie2, {
|
|
9079
9391
|
data: dataWithIndex,
|
|
9080
9392
|
pieValue: accessors.value,
|
|
9081
9393
|
outerRadius: radius,
|
|
@@ -9086,23 +9398,23 @@ var PieSemiCircleChartInternal = ({
|
|
|
9086
9398
|
endAngle,
|
|
9087
9399
|
pieSort: accessors.sort,
|
|
9088
9400
|
children: (pie) => {
|
|
9089
|
-
return pie.arcs.map((arc) => /* @__PURE__ */
|
|
9401
|
+
return pie.arcs.map((arc) => /* @__PURE__ */ _jsx30("g", {
|
|
9090
9402
|
onMouseMove: withTooltips ? handleArcMouseMove(arc) : void 0,
|
|
9091
9403
|
onMouseLeave: withTooltips ? handleMouseLeave : void 0,
|
|
9092
|
-
children: /* @__PURE__ */
|
|
9404
|
+
children: /* @__PURE__ */ _jsx30("path", {
|
|
9093
9405
|
d: pie.path(arc) || "",
|
|
9094
9406
|
fill: accessors.fill(arc.data)
|
|
9095
9407
|
})
|
|
9096
9408
|
}, arc.data.label));
|
|
9097
9409
|
}
|
|
9098
|
-
}), /* @__PURE__ */
|
|
9099
|
-
children: [/* @__PURE__ */
|
|
9410
|
+
}), /* @__PURE__ */ _jsxs14(Group5, {
|
|
9411
|
+
children: [/* @__PURE__ */ _jsx30(Text4, {
|
|
9100
9412
|
textAnchor: "middle",
|
|
9101
9413
|
verticalAnchor: "start",
|
|
9102
9414
|
y: -40,
|
|
9103
9415
|
className: pie_semi_circle_chart_module_default.label,
|
|
9104
9416
|
children: label
|
|
9105
|
-
}), /* @__PURE__ */
|
|
9417
|
+
}), /* @__PURE__ */ _jsx30(Text4, {
|
|
9106
9418
|
textAnchor: "middle",
|
|
9107
9419
|
verticalAnchor: "start",
|
|
9108
9420
|
y: -20,
|
|
@@ -9119,14 +9431,14 @@ var PieSemiCircleChartInternal = ({
|
|
|
9119
9431
|
});
|
|
9120
9432
|
};
|
|
9121
9433
|
var PieSemiCircleChartWithProvider = (props) => {
|
|
9122
|
-
const existingContext =
|
|
9434
|
+
const existingContext = useContext26(GlobalChartsContext);
|
|
9123
9435
|
if (existingContext) {
|
|
9124
|
-
return /* @__PURE__ */
|
|
9436
|
+
return /* @__PURE__ */ _jsx30(PieSemiCircleChartInternal, {
|
|
9125
9437
|
...props
|
|
9126
9438
|
});
|
|
9127
9439
|
}
|
|
9128
|
-
return /* @__PURE__ */
|
|
9129
|
-
children: /* @__PURE__ */
|
|
9440
|
+
return /* @__PURE__ */ _jsx30(GlobalChartsProvider, {
|
|
9441
|
+
children: /* @__PURE__ */ _jsx30(PieSemiCircleChartInternal, {
|
|
9130
9442
|
...props
|
|
9131
9443
|
})
|
|
9132
9444
|
});
|
|
@@ -9145,7 +9457,7 @@ var PieSemiCircleChartResponsive = attachSubComponents(withResponsive(PieSemiCir
|
|
|
9145
9457
|
|
|
9146
9458
|
// src/charts/sparkline/sparkline.tsx
|
|
9147
9459
|
import clsx12 from "clsx";
|
|
9148
|
-
import { useMemo as
|
|
9460
|
+
import { useMemo as useMemo27, forwardRef as forwardRef8 } from "react";
|
|
9149
9461
|
|
|
9150
9462
|
// src/charts/sparkline/sparkline.module.scss
|
|
9151
9463
|
var sparkline_module_default = {
|
|
@@ -9154,7 +9466,7 @@ var sparkline_module_default = {
|
|
|
9154
9466
|
};
|
|
9155
9467
|
|
|
9156
9468
|
// src/charts/sparkline/sparkline.tsx
|
|
9157
|
-
import { jsx as
|
|
9469
|
+
import { jsx as _jsx31 } from "react/jsx-runtime";
|
|
9158
9470
|
var DEFAULT_WIDTH2 = 100;
|
|
9159
9471
|
var DEFAULT_HEIGHT = 40;
|
|
9160
9472
|
var transformToSeriesData = (data, color, strokeWidth) => {
|
|
@@ -9190,13 +9502,13 @@ var SparklineComponent = /* @__PURE__ */ forwardRef8(({
|
|
|
9190
9502
|
const theme = useGlobalChartsTheme();
|
|
9191
9503
|
const themeStrokeWidth = theme.sparkline?.strokeWidth ?? 1.5;
|
|
9192
9504
|
const strokeWidth = strokeWidthProp ?? themeStrokeWidth;
|
|
9193
|
-
const seriesData =
|
|
9505
|
+
const seriesData = useMemo27(() => {
|
|
9194
9506
|
if (!data || data.length === 0) {
|
|
9195
9507
|
return [];
|
|
9196
9508
|
}
|
|
9197
9509
|
return transformToSeriesData(data, color, strokeWidth);
|
|
9198
9510
|
}, [data, color, strokeWidth]);
|
|
9199
|
-
const finalMargin =
|
|
9511
|
+
const finalMargin = useMemo27(() => {
|
|
9200
9512
|
const themeMargin = theme.sparkline?.margin ?? {
|
|
9201
9513
|
top: 2,
|
|
9202
9514
|
right: 2,
|
|
@@ -9209,7 +9521,7 @@ var SparklineComponent = /* @__PURE__ */ forwardRef8(({
|
|
|
9209
9521
|
...margin
|
|
9210
9522
|
};
|
|
9211
9523
|
}, [marginProp, theme.sparkline?.margin]);
|
|
9212
|
-
const seriesWithGradient =
|
|
9524
|
+
const seriesWithGradient = useMemo27(() => {
|
|
9213
9525
|
if (!gradient || seriesData.length === 0) {
|
|
9214
9526
|
return seriesData;
|
|
9215
9527
|
}
|
|
@@ -9227,7 +9539,7 @@ var SparklineComponent = /* @__PURE__ */ forwardRef8(({
|
|
|
9227
9539
|
}));
|
|
9228
9540
|
}, [seriesData, gradient, color]);
|
|
9229
9541
|
if (!data || data.length === 0) {
|
|
9230
|
-
return /* @__PURE__ */
|
|
9542
|
+
return /* @__PURE__ */ _jsx31("div", {
|
|
9231
9543
|
ref,
|
|
9232
9544
|
className: clsx12("sparkline", sparkline_module_default.sparkline, sparkline_module_default["sparkline--empty"], className),
|
|
9233
9545
|
style: {
|
|
@@ -9240,18 +9552,18 @@ var SparklineComponent = /* @__PURE__ */ forwardRef8(({
|
|
|
9240
9552
|
const cx2 = width / 2;
|
|
9241
9553
|
const cy = height / 2;
|
|
9242
9554
|
const resolvedColor = color || "#000000";
|
|
9243
|
-
return /* @__PURE__ */
|
|
9555
|
+
return /* @__PURE__ */ _jsx31("div", {
|
|
9244
9556
|
ref,
|
|
9245
9557
|
className: clsx12("sparkline", sparkline_module_default.sparkline, sparkline_module_default["sparkline--single-point"], className),
|
|
9246
9558
|
style: {
|
|
9247
9559
|
width,
|
|
9248
9560
|
height
|
|
9249
9561
|
},
|
|
9250
|
-
children: /* @__PURE__ */
|
|
9562
|
+
children: /* @__PURE__ */ _jsx31("svg", {
|
|
9251
9563
|
width,
|
|
9252
9564
|
height,
|
|
9253
9565
|
"aria-hidden": "true",
|
|
9254
|
-
children: /* @__PURE__ */
|
|
9566
|
+
children: /* @__PURE__ */ _jsx31("circle", {
|
|
9255
9567
|
cx: cx2,
|
|
9256
9568
|
cy,
|
|
9257
9569
|
r: strokeWidth * 1.5,
|
|
@@ -9260,10 +9572,10 @@ var SparklineComponent = /* @__PURE__ */ forwardRef8(({
|
|
|
9260
9572
|
})
|
|
9261
9573
|
});
|
|
9262
9574
|
}
|
|
9263
|
-
return /* @__PURE__ */
|
|
9575
|
+
return /* @__PURE__ */ _jsx31("div", {
|
|
9264
9576
|
ref,
|
|
9265
9577
|
className: clsx12("sparkline", sparkline_module_default.sparkline, className),
|
|
9266
|
-
children: /* @__PURE__ */
|
|
9578
|
+
children: /* @__PURE__ */ _jsx31(LineChart, {
|
|
9267
9579
|
data: seriesWithGradient,
|
|
9268
9580
|
width,
|
|
9269
9581
|
height,
|
|
@@ -9307,7 +9619,7 @@ var trend_indicator_module_default = {
|
|
|
9307
9619
|
};
|
|
9308
9620
|
|
|
9309
9621
|
// src/components/trend-indicator/trend-indicator.tsx
|
|
9310
|
-
import { jsx as
|
|
9622
|
+
import { jsx as _jsx32, jsxs as _jsxs15 } from "react/jsx-runtime";
|
|
9311
9623
|
var DIRECTION_LABELS = {
|
|
9312
9624
|
up: "Increase",
|
|
9313
9625
|
down: "Decrease",
|
|
@@ -9320,12 +9632,12 @@ var Icon2 = ({
|
|
|
9320
9632
|
return null;
|
|
9321
9633
|
}
|
|
9322
9634
|
const isUp = direction === "up";
|
|
9323
|
-
return /* @__PURE__ */
|
|
9635
|
+
return /* @__PURE__ */ _jsx32("svg", {
|
|
9324
9636
|
className: trend_indicator_module_default["trend-indicator__icon"],
|
|
9325
9637
|
viewBox: "0 0 16 16",
|
|
9326
9638
|
fill: "none",
|
|
9327
9639
|
"aria-hidden": "true",
|
|
9328
|
-
children: /* @__PURE__ */
|
|
9640
|
+
children: /* @__PURE__ */ _jsx32("path", {
|
|
9329
9641
|
d: isUp ? "M8 13V3M4 7l4-4 4 4" : "M8 3v10M4 9l4 4 4-4",
|
|
9330
9642
|
stroke: "currentColor",
|
|
9331
9643
|
strokeWidth: "1.5",
|
|
@@ -9342,13 +9654,13 @@ function TrendIndicator({
|
|
|
9342
9654
|
showIcon = true
|
|
9343
9655
|
}) {
|
|
9344
9656
|
const ariaLabel = `${DIRECTION_LABELS[direction]}: ${value}`;
|
|
9345
|
-
return /* @__PURE__ */
|
|
9657
|
+
return /* @__PURE__ */ _jsxs15("span", {
|
|
9346
9658
|
className: clsx13(trend_indicator_module_default["trend-indicator"], trend_indicator_module_default[`trend-indicator--${direction}`], className),
|
|
9347
9659
|
style,
|
|
9348
9660
|
"aria-label": ariaLabel,
|
|
9349
|
-
children: [showIcon && /* @__PURE__ */
|
|
9661
|
+
children: [showIcon && /* @__PURE__ */ _jsx32(Icon2, {
|
|
9350
9662
|
direction
|
|
9351
|
-
}), /* @__PURE__ */
|
|
9663
|
+
}), /* @__PURE__ */ _jsx32("span", {
|
|
9352
9664
|
className: trend_indicator_module_default["trend-indicator__value"],
|
|
9353
9665
|
children: value
|
|
9354
9666
|
})]
|