@automattic/charts 2.0.1 → 3.0.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 +16 -0
- package/TOKENS.md +107 -48
- package/dist/index.cjs +294 -110
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +97 -43
- package/dist/index.d.cts +40 -35
- package/dist/index.d.ts +40 -35
- package/dist/index.js +292 -111
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/charts/area-chart/area-chart.module.scss +8 -3
- package/src/charts/area-chart/area-chart.tsx +1 -1
- package/src/charts/bar-chart/bar-chart.module.scss +14 -6
- package/src/charts/conversion-funnel-chart/conversion-funnel-chart.module.scss +17 -12
- package/src/charts/conversion-funnel-chart/conversion-funnel-chart.tsx +107 -86
- package/src/charts/conversion-funnel-chart/test/chart-scope.test.tsx +36 -0
- package/src/charts/geo-chart/geo-chart.tsx +12 -4
- package/src/charts/heatmap-chart/heatmap-chart.module.scss +13 -9
- package/src/charts/heatmap-chart/heatmap-chart.tsx +12 -5
- package/src/charts/leaderboard-chart/leaderboard-chart.module.scss +13 -7
- package/src/charts/leaderboard-chart/types.ts +0 -2
- package/src/charts/line-chart/line-chart.module.scss +10 -5
- package/src/charts/line-chart/line-chart.tsx +1 -1
- package/src/charts/line-chart/private/line-chart-annotation.tsx +4 -4
- package/src/charts/pie-chart/pie-chart.tsx +4 -1
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.tsx +4 -1
- package/src/charts/private/svg-empty-state/svg-empty-state.module.scss +1 -1
- package/src/charts/private/with-responsive/test/with-responsive.test.tsx +16 -0
- package/src/charts/private/with-responsive/with-responsive.tsx +18 -11
- package/src/charts/private/x-zoom/x-zoom.module.scss +3 -3
- package/src/components/legend/private/base-legend.tsx +3 -1
- package/src/components/tooltip/accessible-tooltip.tsx +4 -2
- package/src/components/tooltip/base-tooltip.tsx +8 -1
- package/src/components/trend-indicator/test/trend-indicator.test.tsx +20 -0
- package/src/components/trend-indicator/trend-indicator.module.scss +3 -6
- package/src/components/trend-indicator/trend-indicator.tsx +3 -0
- package/src/hooks/test/use-xychart-theme-provider-override.test.tsx +28 -0
- package/src/hooks/test/use-xychart-theme-style-reads.test.tsx +19 -13
- package/src/hooks/test/use-xychart-theme.test.tsx +25 -0
- package/src/hooks/use-xychart-theme.ts +6 -4
- package/src/index.ts +9 -2
- package/src/providers/chart-context/global-charts-provider.tsx +35 -12
- package/src/providers/chart-context/private/theme-override-vars.ts +87 -0
- package/src/providers/chart-context/private/with-catalog-pointers.ts +50 -0
- package/src/providers/chart-context/test/chart-context.test.tsx +0 -40
- package/src/providers/chart-context/test/chart-scope-class.test.tsx +19 -0
- package/src/providers/chart-context/test/sparse-theme.test.ts +35 -0
- package/src/providers/chart-context/test/theme-override-vars-guard.test.tsx +29 -0
- package/src/providers/chart-context/test/theme-override-vars.test.ts +118 -0
- package/src/providers/chart-context/test/with-catalog-pointers.test.ts +47 -0
- package/src/providers/chart-context/themes.ts +18 -27
- package/src/providers/chart-context/types.ts +0 -3
- package/src/providers/chart-scope/chart-scope-context.ts +8 -0
- package/src/providers/chart-scope/index.ts +3 -0
- package/src/providers/chart-scope/test/chart-scope.test.tsx +24 -0
- package/src/providers/chart-scope/test/use-standalone-scope-class.test.tsx +20 -0
- package/src/providers/chart-scope/use-chart-scope-element.ts +9 -0
- package/src/providers/chart-scope/use-standalone-scope-class.ts +13 -0
- package/src/providers/index.ts +1 -0
- package/src/styles/chart-scope-class.ts +6 -0
- package/src/styles/chart-scope.scss +83 -0
- package/src/styles/test/chart-scope.test.ts +165 -0
- package/src/types.ts +0 -34
- package/src/charts/private/grid-control/grid-control.module.scss +0 -8
- package/src/charts/private/grid-control/grid-control.tsx +0 -26
- package/src/charts/private/grid-control/index.ts +0 -1
- package/src/charts/private/grid-control/test/grid-control.test.tsx +0 -56
package/dist/index.js
CHANGED
|
@@ -62,6 +62,14 @@ const useChartInstanceContext = () => {
|
|
|
62
62
|
};
|
|
63
63
|
const useSingleChartContext = useChartInstanceContext;
|
|
64
64
|
//#endregion
|
|
65
|
+
//#region src/styles/chart-scope-class.ts
|
|
66
|
+
/**
|
|
67
|
+
* Stable class that carries the `--a8c-charts-*` catalog. Applied to the `GlobalChartsProvider` wrapper, to portal-rendered surfaces (which sit outside the provider tree), and to standalone components when no provider is above them.
|
|
68
|
+
*
|
|
69
|
+
* Deliberately unhashed: consumers are documented as being able to target it to override a token on the provider element.
|
|
70
|
+
*/
|
|
71
|
+
const CHART_SCOPE_CLASS = "a8c-charts-scope";
|
|
72
|
+
//#endregion
|
|
65
73
|
//#region src/utils/create-composition.ts
|
|
66
74
|
/**
|
|
67
75
|
* Utility function to create chart components with composition API.
|
|
@@ -618,6 +626,14 @@ const resolveFontSize = (val) => {
|
|
|
618
626
|
}
|
|
619
627
|
};
|
|
620
628
|
//#endregion
|
|
629
|
+
//#region src/providers/chart-scope/chart-scope-context.ts
|
|
630
|
+
/**
|
|
631
|
+
* The nearest chart element, published so JS token resolution reads the same CSS cascade that paints the chart's own colours.
|
|
632
|
+
*
|
|
633
|
+
* All JS token resolution reads this element rather than `document.documentElement`, so a `getComputedStyle` call sees the same `--a8c-charts-*` values — including any override set inside the provider tree — that a CSS-painted sibling element does.
|
|
634
|
+
*/
|
|
635
|
+
const ChartScopeContext = createContext(null);
|
|
636
|
+
//#endregion
|
|
621
637
|
//#region src/providers/chart-context/private/get-chart-color.ts
|
|
622
638
|
/**
|
|
623
639
|
* Golden ratio for mathematically pleasing color distribution
|
|
@@ -747,12 +763,75 @@ const getChartColor = (index, colorCache) => {
|
|
|
747
763
|
return hsl(Math.round(fallbackHue), fallbackSaturation / 100, fallbackLightness / 100).formatHex();
|
|
748
764
|
};
|
|
749
765
|
//#endregion
|
|
766
|
+
//#region src/providers/chart-context/private/theme-override-vars.ts
|
|
767
|
+
const ROLE_FOR_FIELD = [
|
|
768
|
+
["--a8c-charts-color-background", (theme) => theme.backgroundColor],
|
|
769
|
+
["--a8c-charts-color-grid", (theme) => theme.gridStyles?.stroke],
|
|
770
|
+
["--a8c-charts-color-axis", (theme) => theme.xAxisLineStyles?.stroke],
|
|
771
|
+
["--a8c-charts-color-tick", (theme) => theme.xTickLineStyles?.stroke],
|
|
772
|
+
["--a8c-charts-color-label-axis", (theme) => theme.svgLabelSmall?.fill]
|
|
773
|
+
];
|
|
774
|
+
/**
|
|
775
|
+
* The variable a `theme` prop override is published as, one layer outside the role itself.
|
|
776
|
+
*
|
|
777
|
+
* `chart-scope.scss` declares each of these roles as `var(<role>-theme, <catalog default>)`, so an override that is invalid at computed-value time — a fallback-less `var()` naming a token the host never set — only invalidates this variable, and the role still resolves its mapped `--wpds-*` token. Published as the role directly, such a value took the role and every bare `var(<role>)` read site down with it.
|
|
778
|
+
*
|
|
779
|
+
* @param role - The catalog role being overridden.
|
|
780
|
+
* @return The custom property carrying the consumer's value.
|
|
781
|
+
*/
|
|
782
|
+
const themeLayerVar = (role) => `${role}-theme`;
|
|
783
|
+
ROLE_FOR_FIELD.map(([role]) => role);
|
|
784
|
+
/**
|
|
785
|
+
* Whether a value reads the role it is being published for, which would make the catalog entry depend on itself.
|
|
786
|
+
*
|
|
787
|
+
* The dependency runs `<role>: var(<role>-theme, …)`, so a value naming `<role>` closes a cycle through the catalog entry. CSS marks every custom property in a cycle invalid at computed-value time — the role's own fallback is *not* used, so the token resolves to nothing and every chart loses that colour. Verified in Chrome: `--role-theme: var(--role, blue); --role: var(--role-theme, green)` leaves `--role` empty, not `green`.
|
|
788
|
+
*
|
|
789
|
+
* Three things this has to get right, none of which a plain substring test gets:
|
|
790
|
+
*
|
|
791
|
+
* `var()` permits whitespace after the opening paren, so testing for `var(<role>` misses `var( --a8c-charts-color-grid, … )`.
|
|
792
|
+
*
|
|
793
|
+
* Several roles are prefixes of others (`--a8c-charts-color-label` of `--a8c-charts-color-label-secondary`), and every role is a prefix of its own theme layer. A prefix match would read a legitimate cross-role pointer as a self-reference and silently drop the override, so the role must be followed by something that cannot continue an identifier — `-` included. A value naming `<role>-theme` is therefore not treated as a self-reference: that cycle is confined to the theme layer, which leaves the role free to fall back to the catalog default.
|
|
794
|
+
*
|
|
795
|
+
* `resolveCssVariable` also accepts a bare custom-property name with no `var()` wrapper (`--a8c-charts-color-grid`), so that is legal `theme` input too. It forms no cycle — custom properties accept arbitrary token streams — so it survives as a literal string and drops silently at the use site instead of falling back to the catalog default.
|
|
796
|
+
*
|
|
797
|
+
* @param value - The consumer's value for the field.
|
|
798
|
+
* @param role - The catalog role this value would override.
|
|
799
|
+
* @return True when the value reads `role`, so it must not be published.
|
|
800
|
+
*/
|
|
801
|
+
const readsOwnRole = (value, role) => value.trim() === role || new RegExp(`var\\(\\s*${role.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\\w-])`).test(value);
|
|
802
|
+
/**
|
|
803
|
+
* Maps a sparse consumer theme onto the theme-layer variables its overridden catalog roles read, so CSS-painted and JS-resolved colours read one source.
|
|
804
|
+
*
|
|
805
|
+
* A value that reads the role it would override is left unpublished — that is the default theme's own pointer surviving `mergeThemes`, and publishing it would invalidate the role. The role is still reported in `roles`: `withCatalogPointers` restores its theme field to the catalog pointer either way, so CSS and visx agree on the catalog default rather than visx painting a literal CSS never sees.
|
|
806
|
+
*
|
|
807
|
+
* @param theme - The consumer's `theme` prop, before merging with the default theme.
|
|
808
|
+
* @return The wrapper's custom properties, and the roles the consumer overrode.
|
|
809
|
+
*/
|
|
810
|
+
const themeOverrideVars = (theme) => {
|
|
811
|
+
if (!theme) return {
|
|
812
|
+
vars: {},
|
|
813
|
+
roles: []
|
|
814
|
+
};
|
|
815
|
+
const vars = {};
|
|
816
|
+
const roles = [];
|
|
817
|
+
for (const [role, read] of ROLE_FOR_FIELD) {
|
|
818
|
+
const value = read(theme);
|
|
819
|
+
if (typeof value !== "string" || value === "") continue;
|
|
820
|
+
roles.push(role);
|
|
821
|
+
if (!readsOwnRole(value, role)) vars[themeLayerVar(role)] = value;
|
|
822
|
+
}
|
|
823
|
+
return {
|
|
824
|
+
vars,
|
|
825
|
+
roles
|
|
826
|
+
};
|
|
827
|
+
};
|
|
828
|
+
//#endregion
|
|
750
829
|
//#region src/providers/chart-context/themes.ts
|
|
751
830
|
/**
|
|
752
831
|
* Default theme configuration
|
|
753
832
|
*/
|
|
754
833
|
const defaultTheme = {
|
|
755
|
-
backgroundColor: "var(--a8c-charts-color-background,
|
|
834
|
+
backgroundColor: "var(--a8c-charts-color-background, #fff)",
|
|
756
835
|
labelBackgroundColor: "transparent",
|
|
757
836
|
labelTextColor: "var(--a8c-charts-color-label-on-fill, #FFFFFF)",
|
|
758
837
|
colors: [
|
|
@@ -763,59 +842,59 @@ const defaultTheme = {
|
|
|
763
842
|
"#FF8C8F"
|
|
764
843
|
],
|
|
765
844
|
gridStyles: {
|
|
766
|
-
stroke: "var(--a8c-charts-color-grid,
|
|
845
|
+
stroke: "var(--a8c-charts-color-grid, #dbdbdb)",
|
|
767
846
|
strokeWidth: 1
|
|
768
847
|
},
|
|
769
848
|
tickLength: 4,
|
|
770
849
|
gridColor: "",
|
|
771
850
|
gridColorDark: "",
|
|
772
851
|
xTickLineStyles: {
|
|
773
|
-
stroke: "var(--a8c-charts-color-tick,
|
|
852
|
+
stroke: "var(--a8c-charts-color-tick, #dbdbdb)",
|
|
774
853
|
strokeWidth: 1
|
|
775
854
|
},
|
|
776
855
|
xAxisLineStyles: {
|
|
777
|
-
stroke: "var(--a8c-charts-color-axis,
|
|
856
|
+
stroke: "var(--a8c-charts-color-axis, #dbdbdb)",
|
|
778
857
|
strokeWidth: 1
|
|
779
858
|
},
|
|
780
859
|
legend: {
|
|
781
|
-
labelStyles: { color: "var(--a8c-charts-color-label,
|
|
860
|
+
labelStyles: { color: "var(--a8c-charts-color-label, #1e1e1e)" },
|
|
782
861
|
containerStyles: {},
|
|
783
862
|
shapeStyles: []
|
|
784
863
|
},
|
|
785
864
|
seriesLineStyles: [],
|
|
786
865
|
glyphs: [],
|
|
787
866
|
svgLabelSmall: {
|
|
788
|
-
fill: "var(--a8c-charts-color-label
|
|
867
|
+
fill: "var(--a8c-charts-color-label-axis, #1e1e1e)",
|
|
789
868
|
fontFamily: "inherit"
|
|
790
869
|
},
|
|
791
870
|
svgLabelBig: { fontFamily: "inherit" },
|
|
792
871
|
annotationStyles: {
|
|
793
872
|
label: {
|
|
794
|
-
anchorLineStroke: "var(--a8c-charts-color-annotation,
|
|
795
|
-
backgroundFill: "var(--a8c-charts-color-
|
|
873
|
+
anchorLineStroke: "var(--a8c-charts-color-annotation, #1e1e1e)",
|
|
874
|
+
backgroundFill: "var(--a8c-charts-color-surface, #fff)"
|
|
796
875
|
},
|
|
797
|
-
connector: { stroke: "var(--a8c-charts-color-annotation,
|
|
876
|
+
connector: { stroke: "var(--a8c-charts-color-annotation, #1e1e1e)" },
|
|
798
877
|
circleSubject: {
|
|
799
878
|
stroke: "transparent",
|
|
800
|
-
fill: "var(--a8c-charts-color-annotation,
|
|
879
|
+
fill: "var(--a8c-charts-color-annotation, #1e1e1e)",
|
|
801
880
|
radius: 5
|
|
802
881
|
}
|
|
803
882
|
},
|
|
804
|
-
geoChart: { featureFillColor: "var(--a8c-charts-color-surface-secondary,
|
|
883
|
+
geoChart: { featureFillColor: "var(--a8c-charts-color-surface-secondary, #f4f4f4)" },
|
|
805
884
|
leaderboardChart: {
|
|
806
885
|
rowGap: 12,
|
|
807
886
|
columnGap: 4,
|
|
808
887
|
labelSpacing: "xs",
|
|
809
888
|
deltaColors: [
|
|
810
|
-
"var(--a8c-charts-color-trend-down,
|
|
811
|
-
"var(--a8c-charts-color-trend-neutral,
|
|
812
|
-
"var(--a8c-charts-color-trend-up,
|
|
889
|
+
"var(--a8c-charts-color-trend-down, #cc1818)",
|
|
890
|
+
"var(--a8c-charts-color-trend-neutral, #707070)",
|
|
891
|
+
"var(--a8c-charts-color-trend-up, #008030)"
|
|
813
892
|
]
|
|
814
893
|
},
|
|
815
894
|
conversionFunnelChart: {
|
|
816
|
-
backgroundColor: "var(--a8c-charts-color-surface-secondary,
|
|
817
|
-
positiveChangeColor: "var(--a8c-charts-color-trend-up,
|
|
818
|
-
negativeChangeColor: "var(--a8c-charts-color-trend-down,
|
|
895
|
+
backgroundColor: "var(--a8c-charts-color-surface-secondary, #f4f4f4)",
|
|
896
|
+
positiveChangeColor: "var(--a8c-charts-color-trend-up, #008030)",
|
|
897
|
+
negativeChangeColor: "var(--a8c-charts-color-trend-down, #cc1818)"
|
|
819
898
|
},
|
|
820
899
|
lineChart: { lineStyles: { comparison: {
|
|
821
900
|
strokeDasharray: "4 4",
|
|
@@ -840,15 +919,65 @@ const defaultTheme = {
|
|
|
840
919
|
}
|
|
841
920
|
};
|
|
842
921
|
//#endregion
|
|
922
|
+
//#region src/providers/chart-context/private/with-catalog-pointers.ts
|
|
923
|
+
const CATALOG_RESTORE_FOR_ROLE = {
|
|
924
|
+
"--a8c-charts-color-background": () => ({ backgroundColor: defaultTheme.backgroundColor }),
|
|
925
|
+
"--a8c-charts-color-grid": (theme) => ({ gridStyles: {
|
|
926
|
+
...theme.gridStyles,
|
|
927
|
+
stroke: defaultTheme.gridStyles.stroke
|
|
928
|
+
} }),
|
|
929
|
+
"--a8c-charts-color-axis": (theme) => ({ xAxisLineStyles: {
|
|
930
|
+
...theme.xAxisLineStyles,
|
|
931
|
+
stroke: defaultTheme.xAxisLineStyles.stroke
|
|
932
|
+
} }),
|
|
933
|
+
"--a8c-charts-color-tick": (theme) => ({ xTickLineStyles: {
|
|
934
|
+
...theme.xTickLineStyles,
|
|
935
|
+
stroke: defaultTheme.xTickLineStyles.stroke
|
|
936
|
+
} }),
|
|
937
|
+
"--a8c-charts-color-label-axis": (theme) => ({ svgLabelSmall: {
|
|
938
|
+
...theme.svgLabelSmall,
|
|
939
|
+
fill: defaultTheme.svgLabelSmall.fill
|
|
940
|
+
} })
|
|
941
|
+
};
|
|
942
|
+
/**
|
|
943
|
+
* Restores the mapped theme fields of `overriddenRoles` to their catalog pointer, so the theme-layer variable `themeOverrideVars` writes on the provider wrapper is the only carrier for an overridden role — CSS and the JS bridge (`useXYChartTheme`) then resolve it through the same cascade instead of visx reading a baked literal that can disagree with a closer CSS override.
|
|
944
|
+
*
|
|
945
|
+
* This covers roles `themeOverrideVars` deliberately left unpublished as well as the ones it published. A value that reads its own role is not publishable, but leaving visx the consumer's literal is what the whole mechanism exists to prevent: `theme={ { gridStyles: { stroke: 'var(--brand, var(--a8c-charts-color-grid, red))' } } }` would have CSS paint the catalog default while visx painted `--brand`.
|
|
946
|
+
*
|
|
947
|
+
* Every field outside the five mapped roles is left exactly as `merged` provided it: those aren't published as theme-layer vars, so rewriting them would erase a consumer's override with no replacement carrier.
|
|
948
|
+
*
|
|
949
|
+
* @param merged - The consumer theme merged onto `defaultTheme` (`mergeThemes` output).
|
|
950
|
+
* @param overriddenRoles - The catalog roles the consumer overrode, from `themeOverrideVars`.
|
|
951
|
+
* @return A new theme object; `merged` is not mutated.
|
|
952
|
+
*/
|
|
953
|
+
const withCatalogPointers = (merged, overriddenRoles) => {
|
|
954
|
+
let result = merged;
|
|
955
|
+
for (const role of overriddenRoles) {
|
|
956
|
+
const restore = CATALOG_RESTORE_FOR_ROLE[role];
|
|
957
|
+
if (restore) result = {
|
|
958
|
+
...result,
|
|
959
|
+
...restore(result)
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
return result;
|
|
963
|
+
};
|
|
964
|
+
//#endregion
|
|
843
965
|
//#region src/providers/chart-context/global-charts-provider.tsx
|
|
844
966
|
const GlobalChartsContext = createContext(null);
|
|
845
967
|
const GlobalChartsProvider = ({ children, theme }) => {
|
|
846
968
|
const [charts, setCharts] = useState(() => /* @__PURE__ */ new Map());
|
|
847
969
|
const [hiddenSeries, setHiddenSeries] = useState(() => /* @__PURE__ */ new Map());
|
|
848
970
|
const wrapperRef = useRef(null);
|
|
971
|
+
const [scopeNode, setScopeNode] = useState(null);
|
|
972
|
+
const setWrapperNode = useCallback((node) => {
|
|
973
|
+
wrapperRef.current = node;
|
|
974
|
+
setScopeNode(node);
|
|
975
|
+
}, []);
|
|
976
|
+
const { vars: overrideVars, roles: overriddenRoles } = useMemo(() => themeOverrideVars(theme), [theme]);
|
|
849
977
|
const providerTheme = useMemo(() => {
|
|
850
|
-
|
|
851
|
-
|
|
978
|
+
if (!theme) return defaultTheme;
|
|
979
|
+
return withCatalogPointers(mergeThemes(defaultTheme, theme), overriddenRoles);
|
|
980
|
+
}, [theme, overriddenRoles]);
|
|
852
981
|
const [colorCache, setColorCache] = useState(() => ({
|
|
853
982
|
colors: [],
|
|
854
983
|
hues: [],
|
|
@@ -925,7 +1054,6 @@ const GlobalChartsProvider = ({ children, theme }) => {
|
|
|
925
1054
|
}
|
|
926
1055
|
return getChartColor(index, colorCache);
|
|
927
1056
|
}, [colorCache, groupToColorMap]);
|
|
928
|
-
const resolveThemeColor = useCallback((value) => value ? normalizeColorToHex(value, wrapperRef.current, resolveCssVariable) : "", []);
|
|
929
1057
|
const getElementStyles = useCallback(({ data, index, overrideColor, legendShape }) => {
|
|
930
1058
|
const isSeriesData = data && typeof data === "object" && "data" in data && "options" in data;
|
|
931
1059
|
const isPointPercentageData = data && typeof data === "object" && "value" in data && typeof data.value === "number" && !("data" in data);
|
|
@@ -968,7 +1096,6 @@ const GlobalChartsProvider = ({ children, theme }) => {
|
|
|
968
1096
|
getChartData,
|
|
969
1097
|
theme: providerTheme,
|
|
970
1098
|
getElementStyles,
|
|
971
|
-
resolveThemeColor,
|
|
972
1099
|
toggleSeriesVisibility,
|
|
973
1100
|
isSeriesVisible,
|
|
974
1101
|
getHiddenSeries,
|
|
@@ -980,7 +1107,6 @@ const GlobalChartsProvider = ({ children, theme }) => {
|
|
|
980
1107
|
getChartData,
|
|
981
1108
|
providerTheme,
|
|
982
1109
|
getElementStyles,
|
|
983
|
-
resolveThemeColor,
|
|
984
1110
|
toggleSeriesVisibility,
|
|
985
1111
|
isSeriesVisible,
|
|
986
1112
|
getHiddenSeries,
|
|
@@ -989,9 +1115,16 @@ const GlobalChartsProvider = ({ children, theme }) => {
|
|
|
989
1115
|
return /* @__PURE__ */ jsx(GlobalChartsContext.Provider, {
|
|
990
1116
|
value,
|
|
991
1117
|
children: /* @__PURE__ */ jsx("div", {
|
|
992
|
-
ref:
|
|
993
|
-
|
|
994
|
-
|
|
1118
|
+
ref: setWrapperNode,
|
|
1119
|
+
className: CHART_SCOPE_CLASS,
|
|
1120
|
+
style: {
|
|
1121
|
+
display: "contents",
|
|
1122
|
+
...overrideVars
|
|
1123
|
+
},
|
|
1124
|
+
children: /* @__PURE__ */ jsx(ChartScopeContext.Provider, {
|
|
1125
|
+
value: scopeNode,
|
|
1126
|
+
children
|
|
1127
|
+
})
|
|
995
1128
|
})
|
|
996
1129
|
});
|
|
997
1130
|
};
|
|
@@ -1051,12 +1184,31 @@ const useDeepMemo = (value) => {
|
|
|
1051
1184
|
return ref.current;
|
|
1052
1185
|
};
|
|
1053
1186
|
//#endregion
|
|
1187
|
+
//#region src/providers/chart-scope/use-chart-scope-element.ts
|
|
1188
|
+
/**
|
|
1189
|
+
* Returns the nearest chart scope element, or `null` when rendered outside any scope (and during SSR, before the ref is attached).
|
|
1190
|
+
*
|
|
1191
|
+
* @return {HTMLElement | null} The nearest chart scope element, or `null`.
|
|
1192
|
+
*/
|
|
1193
|
+
const useChartScopeElement = () => useContext(ChartScopeContext);
|
|
1194
|
+
//#endregion
|
|
1195
|
+
//#region src/providers/chart-scope/use-standalone-scope-class.ts
|
|
1196
|
+
/**
|
|
1197
|
+
* Returns the catalog class when there is no `GlobalChartsProvider` above this component, and `undefined` when there is.
|
|
1198
|
+
*
|
|
1199
|
+
* Standalone components need the catalog to resolve at all, but inside a provider the tokens already inherit — re-declaring them there would shadow a consumer override set anywhere in the tree.
|
|
1200
|
+
*
|
|
1201
|
+
* @return The scope class name, or undefined when a provider is present.
|
|
1202
|
+
*/
|
|
1203
|
+
const useStandaloneScopeClass = () => useContext(GlobalChartsContext) ? void 0 : CHART_SCOPE_CLASS;
|
|
1204
|
+
//#endregion
|
|
1054
1205
|
//#region src/hooks/use-xychart-theme.ts
|
|
1055
1206
|
const useXYChartTheme = (data) => {
|
|
1056
1207
|
const theme = useGlobalChartsTheme();
|
|
1208
|
+
const scopeElement = useChartScopeElement();
|
|
1057
1209
|
const seriesColorKey = JSON.stringify((data ?? []).map((series) => series.options?.stroke).filter((color) => Boolean(color)));
|
|
1058
1210
|
return useMemo(() => {
|
|
1059
|
-
const resolve = createCssVariableResolver();
|
|
1211
|
+
const resolve = createCssVariableResolver(scopeElement);
|
|
1060
1212
|
const resolveColor = (value) => value ? resolve(value) ?? value : value;
|
|
1061
1213
|
const seriesColors = JSON.parse(seriesColorKey);
|
|
1062
1214
|
return buildChartTheme({
|
|
@@ -1080,7 +1232,11 @@ const useXYChartTheme = (data) => {
|
|
|
1080
1232
|
fill: resolveColor(theme.svgLabelSmall.fill)
|
|
1081
1233
|
}
|
|
1082
1234
|
});
|
|
1083
|
-
}, [
|
|
1235
|
+
}, [
|
|
1236
|
+
theme,
|
|
1237
|
+
seriesColorKey,
|
|
1238
|
+
scopeElement
|
|
1239
|
+
]);
|
|
1084
1240
|
};
|
|
1085
1241
|
//#endregion
|
|
1086
1242
|
//#region src/hooks/use-chart-data-transform.ts
|
|
@@ -1556,6 +1712,7 @@ const BaseLegend = forwardRef(({ items, className, orientation = "horizontal", a
|
|
|
1556
1712
|
const { width: shapeWidth = 16, height: shapeHeight = 16, margin: shapeMargin = "2px 4px 2px 0" } = shapeStyles ?? {};
|
|
1557
1713
|
const theme = useGlobalChartsTheme();
|
|
1558
1714
|
const context = useContext(GlobalChartsContext);
|
|
1715
|
+
const standaloneScopeClass = useStandaloneScopeClass();
|
|
1559
1716
|
const legendScale = scaleOrdinal({
|
|
1560
1717
|
domain: items.map((item) => item.label),
|
|
1561
1718
|
range: items.map((item) => item.color)
|
|
@@ -1608,7 +1765,7 @@ const BaseLegend = forwardRef(({ items, className, orientation = "horizontal", a
|
|
|
1608
1765
|
justify: orientation === "horizontal" ? flexAlignment : void 0,
|
|
1609
1766
|
wrap: orientation === "horizontal" ? "wrap" : void 0,
|
|
1610
1767
|
role: "list",
|
|
1611
|
-
className: clsx(base_legend_module_default.legend, className),
|
|
1768
|
+
className: clsx(standaloneScopeClass, base_legend_module_default.legend, className),
|
|
1612
1769
|
style: theme.legend?.containerStyles,
|
|
1613
1770
|
children: labels.map((label, i) => {
|
|
1614
1771
|
const matchedItem = items[i];
|
|
@@ -1895,9 +2052,10 @@ const BaseTooltip = ({ data, top, left, component: Component = DefaultTooltipCon
|
|
|
1895
2052
|
data,
|
|
1896
2053
|
className
|
|
1897
2054
|
});
|
|
2055
|
+
const standaloneScopeClass = useStandaloneScopeClass();
|
|
1898
2056
|
if (!renderContainer) return content;
|
|
1899
2057
|
return /* @__PURE__ */ jsx("div", {
|
|
1900
|
-
className: base_tooltip_module_default.tooltip,
|
|
2058
|
+
className: clsx(standaloneScopeClass, base_tooltip_module_default.tooltip),
|
|
1901
2059
|
style: {
|
|
1902
2060
|
top,
|
|
1903
2061
|
left,
|
|
@@ -1966,10 +2124,11 @@ const AccessibleTooltip = ({ renderTooltip, selectedIndex, tooltipRef, keyboardF
|
|
|
1966
2124
|
tabIndex: -1,
|
|
1967
2125
|
role: "tooltip",
|
|
1968
2126
|
"aria-atomic": "true",
|
|
1969
|
-
className: keyboardFocusedClassName,
|
|
2127
|
+
className: clsx(CHART_SCOPE_CLASS, keyboardFocusedClassName),
|
|
1970
2128
|
children: tooltipContent
|
|
1971
2129
|
}, `chart-tooltip-${selectedIndex}`);
|
|
1972
2130
|
return /* @__PURE__ */ jsx("div", {
|
|
2131
|
+
className: CHART_SCOPE_CLASS,
|
|
1973
2132
|
role: "tooltip",
|
|
1974
2133
|
"aria-live": "polite",
|
|
1975
2134
|
children: tooltipContent
|
|
@@ -2422,9 +2581,11 @@ function withResponsive(WrappedComponent) {
|
|
|
2422
2581
|
enableDebounceLeadingCall: true
|
|
2423
2582
|
});
|
|
2424
2583
|
const hasAspectRatio = aspectRatio !== void 0 && aspectRatio > 0;
|
|
2584
|
+
const [scopeNode, setScopeNode] = useState(null);
|
|
2425
2585
|
const wrapperRef = useRef(null);
|
|
2426
2586
|
const setWrapperRef = useCallback((node) => {
|
|
2427
2587
|
wrapperRef.current = node;
|
|
2588
|
+
setScopeNode(node);
|
|
2428
2589
|
if (typeof parentRef === "function") parentRef(node);
|
|
2429
2590
|
else if (parentRef) parentRef.current = node;
|
|
2430
2591
|
}, [parentRef]);
|
|
@@ -2470,14 +2631,17 @@ function withResponsive(WrappedComponent) {
|
|
|
2470
2631
|
...width !== void 0 ? { width } : null,
|
|
2471
2632
|
...height !== void 0 ? { height } : null
|
|
2472
2633
|
},
|
|
2473
|
-
children:
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2634
|
+
children: /* @__PURE__ */ jsx(ChartScopeContext.Provider, {
|
|
2635
|
+
value: scopeNode,
|
|
2636
|
+
children: hasAspectRatio ? /* @__PURE__ */ jsx("div", {
|
|
2637
|
+
className: with_responsive_module_default.content,
|
|
2638
|
+
style: {
|
|
2639
|
+
width: boxWidth,
|
|
2640
|
+
height: boxHeight
|
|
2641
|
+
},
|
|
2642
|
+
children: wrappedComponent
|
|
2643
|
+
}) : wrappedComponent
|
|
2644
|
+
})
|
|
2481
2645
|
});
|
|
2482
2646
|
};
|
|
2483
2647
|
}
|
|
@@ -2912,11 +3076,12 @@ const getVerticalAnchor = (subjectType, isFlippedVertically, y, yMax, height) =>
|
|
|
2912
3076
|
};
|
|
2913
3077
|
const LineChartAnnotation = ({ datum, title, subtitle, subjectType = "circle", styles: datumStyles, testId, renderLabel, renderLabelPopover }) => {
|
|
2914
3078
|
const providerTheme = useGlobalChartsTheme();
|
|
3079
|
+
const scopeElement = useChartScopeElement();
|
|
2915
3080
|
const { xScale, yScale } = useContext(DataContext) || {};
|
|
2916
3081
|
const labelRef = useRef(null);
|
|
2917
3082
|
const [height, setHeight] = useState(null);
|
|
2918
3083
|
const styles = deepmerge(providerTheme.annotationStyles ?? {}, datumStyles ?? {});
|
|
2919
|
-
const resolveColor = (value) => value ? resolveCssVariable(value) ?? value : value;
|
|
3084
|
+
const resolveColor = (value) => value ? resolveCssVariable(value, scopeElement) ?? value : value;
|
|
2920
3085
|
useEffect(() => {
|
|
2921
3086
|
if (labelRef.current?.getBBox) {
|
|
2922
3087
|
const bbox = labelRef.current.getBBox();
|
|
@@ -5067,12 +5232,22 @@ const ConversionFunnelChartInternal = ({ mainRate, changeIndicator, steps, loadi
|
|
|
5067
5232
|
const { getElementStyles, isColorPaletteResolved } = useGlobalChartsContext();
|
|
5068
5233
|
const chartRef = useRef(null);
|
|
5069
5234
|
const selectedBarRef = useRef(null);
|
|
5235
|
+
const [scopeNode, setScopeNode] = useState(null);
|
|
5070
5236
|
const { tooltipData, tooltipLeft, tooltipTop, tooltipOpen, showTooltip, hideTooltip } = useTooltip();
|
|
5071
5237
|
const { handleBarClick, handleBarKeyDown, clearSelection, getStepState } = useFunnelSelection(hideTooltip);
|
|
5072
5238
|
const { containerRef: portalContainerRef, TooltipInPortal, containerBounds } = useTooltipInPortal({
|
|
5073
5239
|
detectBounds: true,
|
|
5074
5240
|
scroll: true
|
|
5075
5241
|
});
|
|
5242
|
+
const portalContainerRefRef = useRef(portalContainerRef);
|
|
5243
|
+
useEffect(() => {
|
|
5244
|
+
portalContainerRefRef.current = portalContainerRef;
|
|
5245
|
+
}, [portalContainerRef]);
|
|
5246
|
+
const setChartRef = useCallback((node) => {
|
|
5247
|
+
portalContainerRefRef.current(node);
|
|
5248
|
+
chartRef.current = node;
|
|
5249
|
+
setScopeNode(node);
|
|
5250
|
+
}, []);
|
|
5076
5251
|
const clearSelectionAndRef = useCallback(() => {
|
|
5077
5252
|
clearSelection();
|
|
5078
5253
|
selectedBarRef.current = null;
|
|
@@ -5218,6 +5393,7 @@ const ConversionFunnelChartInternal = ({ mainRate, changeIndicator, steps, loadi
|
|
|
5218
5393
|
direction: "column",
|
|
5219
5394
|
align: "center",
|
|
5220
5395
|
justify: "center",
|
|
5396
|
+
ref: setScopeNode,
|
|
5221
5397
|
className: clsx(conversion_funnel_chart_module_default["conversion-funnel-chart"], loading && conversion_funnel_chart_module_default["conversion-funnel-chart--loading"], className),
|
|
5222
5398
|
style: {
|
|
5223
5399
|
...style,
|
|
@@ -5229,80 +5405,80 @@ const ConversionFunnelChartInternal = ({ mainRate, changeIndicator, steps, loadi
|
|
|
5229
5405
|
})
|
|
5230
5406
|
});
|
|
5231
5407
|
const maxRate = Math.max(...steps.map((step) => step.rate));
|
|
5232
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */
|
|
5408
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Stack, {
|
|
5233
5409
|
direction: "column",
|
|
5234
5410
|
gap: "xl",
|
|
5235
|
-
ref:
|
|
5236
|
-
portalContainerRef(node);
|
|
5237
|
-
chartRef.current = node;
|
|
5238
|
-
},
|
|
5411
|
+
ref: setChartRef,
|
|
5239
5412
|
className: clsx(conversion_funnel_chart_module_default["conversion-funnel-chart"], loading && conversion_funnel_chart_module_default["conversion-funnel-chart--loading"], className),
|
|
5240
5413
|
style: {
|
|
5241
5414
|
...style,
|
|
5242
5415
|
height: resolvedHeight
|
|
5243
5416
|
},
|
|
5244
|
-
children:
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
gap: "xl",
|
|
5267
|
-
children: [/* @__PURE__ */ jsxs(Stack, {
|
|
5417
|
+
children: /* @__PURE__ */ jsxs(ChartScopeContext.Provider, {
|
|
5418
|
+
value: scopeNode,
|
|
5419
|
+
children: [renderMainMetric ? renderMainMetric({
|
|
5420
|
+
mainRate,
|
|
5421
|
+
changeIndicator,
|
|
5422
|
+
className: conversion_funnel_chart_module_default["main-metric"],
|
|
5423
|
+
changeColor
|
|
5424
|
+
}) : /* @__PURE__ */ jsx(Stack, {
|
|
5425
|
+
direction: "row",
|
|
5426
|
+
align: "baseline",
|
|
5427
|
+
gap: "sm",
|
|
5428
|
+
className: conversion_funnel_chart_module_default["main-metric"],
|
|
5429
|
+
children: renderDefaultMainMetric()
|
|
5430
|
+
}), /* @__PURE__ */ jsx(Stack, {
|
|
5431
|
+
direction: "row",
|
|
5432
|
+
align: "flex-end",
|
|
5433
|
+
gap: "lg",
|
|
5434
|
+
className: conversion_funnel_chart_module_default["funnel-container"],
|
|
5435
|
+
children: steps.map((step, index) => {
|
|
5436
|
+
const barHeight = step.rate / maxRate * 100;
|
|
5437
|
+
const { isBlurred } = getStepState(step.id);
|
|
5438
|
+
return /* @__PURE__ */ jsxs(Stack, {
|
|
5268
5439
|
direction: "column",
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5440
|
+
className: clsx(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"]),
|
|
5441
|
+
gap: "xl",
|
|
5442
|
+
children: [/* @__PURE__ */ jsxs(Stack, {
|
|
5443
|
+
direction: "column",
|
|
5444
|
+
gap: "xs",
|
|
5445
|
+
children: [renderStepLabel ? renderStepLabel({
|
|
5446
|
+
step,
|
|
5447
|
+
index,
|
|
5448
|
+
className: conversion_funnel_chart_module_default["step-label"]
|
|
5449
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
5450
|
+
className: conversion_funnel_chart_module_default["step-label"],
|
|
5451
|
+
children: step.label
|
|
5452
|
+
}), renderStepRate ? renderStepRate({
|
|
5453
|
+
step,
|
|
5454
|
+
index,
|
|
5455
|
+
className: conversion_funnel_chart_module_default["step-rate"]
|
|
5456
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
5457
|
+
className: conversion_funnel_chart_module_default["step-rate"],
|
|
5458
|
+
children: formatPercentage(step.rate)
|
|
5459
|
+
})]
|
|
5460
|
+
}), /* @__PURE__ */ jsx(Stack, {
|
|
5461
|
+
direction: "column",
|
|
5462
|
+
justify: "flex-end",
|
|
5463
|
+
className: conversion_funnel_chart_module_default["bar-container"],
|
|
5464
|
+
onClick: stepHandlers.get(step.id)?.onClick,
|
|
5465
|
+
onKeyDown: stepHandlers.get(step.id)?.onKeyDown,
|
|
5466
|
+
role: "button",
|
|
5467
|
+
tabIndex: isBlurred ? -1 : 0,
|
|
5468
|
+
"aria-label": step.label,
|
|
5469
|
+
style: { backgroundColor: barBackgroundColor },
|
|
5470
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
5471
|
+
className: clsx(conversion_funnel_chart_module_default["funnel-bar"], { [conversion_funnel_chart_module_default["funnel-bar--animated"]]: animation && !loading && !prefersReducedMotion }),
|
|
5472
|
+
style: {
|
|
5473
|
+
height: `${barHeight}%`,
|
|
5474
|
+
backgroundColor: barColor
|
|
5475
|
+
}
|
|
5476
|
+
})
|
|
5284
5477
|
})]
|
|
5285
|
-
}
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
onClick: stepHandlers.get(step.id)?.onClick,
|
|
5290
|
-
onKeyDown: stepHandlers.get(step.id)?.onKeyDown,
|
|
5291
|
-
role: "button",
|
|
5292
|
-
tabIndex: isBlurred ? -1 : 0,
|
|
5293
|
-
"aria-label": step.label,
|
|
5294
|
-
style: { backgroundColor: barBackgroundColor },
|
|
5295
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
5296
|
-
className: clsx(conversion_funnel_chart_module_default["funnel-bar"], { [conversion_funnel_chart_module_default["funnel-bar--animated"]]: animation && !loading && !prefersReducedMotion }),
|
|
5297
|
-
style: {
|
|
5298
|
-
height: `${barHeight}%`,
|
|
5299
|
-
backgroundColor: barColor
|
|
5300
|
-
}
|
|
5301
|
-
})
|
|
5302
|
-
})]
|
|
5303
|
-
}, step.id);
|
|
5304
|
-
})
|
|
5305
|
-
})]
|
|
5478
|
+
}, step.id);
|
|
5479
|
+
})
|
|
5480
|
+
})]
|
|
5481
|
+
})
|
|
5306
5482
|
}), tooltipOpen && tooltipData && (() => {
|
|
5307
5483
|
const tooltipContent = renderTooltip ? renderTooltip({
|
|
5308
5484
|
step: tooltipData,
|
|
@@ -5315,7 +5491,7 @@ const ConversionFunnelChartInternal = ({ mainRate, changeIndicator, steps, loadi
|
|
|
5315
5491
|
return /* @__PURE__ */ jsx(TooltipInPortal, {
|
|
5316
5492
|
top: tooltipTop,
|
|
5317
5493
|
left: tooltipLeft,
|
|
5318
|
-
className: conversion_funnel_chart_module_default["tooltip-wrapper"],
|
|
5494
|
+
className: clsx("a8c-charts-scope", conversion_funnel_chart_module_default["tooltip-wrapper"]),
|
|
5319
5495
|
children: tooltipContent
|
|
5320
5496
|
}, Math.random());
|
|
5321
5497
|
})()] });
|
|
@@ -5465,6 +5641,7 @@ function normalizeGeoChartError(eventArgs) {
|
|
|
5465
5641
|
*/
|
|
5466
5642
|
const GeoChartInternal = ({ className, data, width, height, region = "world", resolution = "countries", onError, renderPlaceholder }) => {
|
|
5467
5643
|
const { getElementStyles, theme: { geoChart: { featureFillColor }, backgroundColor } } = useGlobalChartsContext();
|
|
5644
|
+
const scopeElement = useChartScopeElement();
|
|
5468
5645
|
const containerRef = useRef(null);
|
|
5469
5646
|
const reportedErrorIdsRef = useRef(/* @__PURE__ */ new Set());
|
|
5470
5647
|
useEffect(() => {
|
|
@@ -5497,8 +5674,8 @@ const GeoChartInternal = ({ className, data, width, height, region = "world", re
|
|
|
5497
5674
|
});
|
|
5498
5675
|
const fullColorHex = getElementStyles({ index: 0 }).color;
|
|
5499
5676
|
const lightColorHex = lightenHexColor(fullColorHex, .8);
|
|
5500
|
-
const backgroundColorHex = normalizeColorToHex(backgroundColor,
|
|
5501
|
-
const defaultFillColorHex = normalizeColorToHex(featureFillColor,
|
|
5677
|
+
const backgroundColorHex = normalizeColorToHex(backgroundColor, scopeElement, resolveCssVariable) || DEFAULT_BACKGROUND_COLOR;
|
|
5678
|
+
const defaultFillColorHex = normalizeColorToHex(featureFillColor, scopeElement, resolveCssVariable) || DEFAULT_FEATURE_FILL_COLOR;
|
|
5502
5679
|
const sanitizedData = useMemo(() => {
|
|
5503
5680
|
if (data.length === 0) return {
|
|
5504
5681
|
data,
|
|
@@ -5758,7 +5935,8 @@ const HeatmapLegend = ({ steps = 5, lessLabel, moreLabel }) => {
|
|
|
5758
5935
|
const CELL_MIX_FLOOR = .15;
|
|
5759
5936
|
const HeatmapChartInternal = ({ data, chartId: providedChartId, width = 0, height = 0, className, compact = false, showValues, maxCellWidth, maxCellHeight, minCellWidth, minCellHeight, rowLabels = [], primaryColor, gap = "md", withTooltips = false, renderTooltip, children }) => {
|
|
5760
5937
|
const chartId = useChartId(providedChartId);
|
|
5761
|
-
const { getElementStyles,
|
|
5938
|
+
const { getElementStyles, theme } = useGlobalChartsContext();
|
|
5939
|
+
const scopeElement = useChartScopeElement();
|
|
5762
5940
|
const { heatmapChart: heatmapChartSettings } = theme;
|
|
5763
5941
|
const { nonLegendChildren } = useChartChildren(children, "HeatmapChart");
|
|
5764
5942
|
const [selectedIndex, setSelectedIndex] = useState();
|
|
@@ -5773,7 +5951,7 @@ const HeatmapChartInternal = ({ data, chartId: providedChartId, width = 0, heigh
|
|
|
5773
5951
|
index: 0,
|
|
5774
5952
|
overrideColor: primaryColor || heatmapChartSettings.primaryColor
|
|
5775
5953
|
});
|
|
5776
|
-
const chartBackgroundHex =
|
|
5954
|
+
const chartBackgroundHex = normalizeColorToHex(theme.backgroundColor, scopeElement, resolveCssVariable);
|
|
5777
5955
|
const primaryHex = normalizeColorToHex(primaryColorHex);
|
|
5778
5956
|
const cellHasLightText = (intensity) => isValidHexColor(primaryHex) && isValidHexColor(chartBackgroundHex) && prefersLightText(mixHexColors(primaryHex, chartBackgroundHex, 1 - (CELL_MIX_FLOOR + (1 - CELL_MIX_FLOOR) * intensity)));
|
|
5779
5957
|
const extent = useMemo(() => getValueExtent(data), [data]);
|
|
@@ -6000,6 +6178,7 @@ const HeatmapChartInternal = ({ data, chartId: providedChartId, width = 0, heigh
|
|
|
6000
6178
|
top: tooltipTop,
|
|
6001
6179
|
left: tooltipLeft,
|
|
6002
6180
|
children: /* @__PURE__ */ jsx("div", {
|
|
6181
|
+
className: "a8c-charts-scope",
|
|
6003
6182
|
role: "tooltip",
|
|
6004
6183
|
tabIndex: -1,
|
|
6005
6184
|
children: (renderTooltip ?? defaultRenderTooltip)(tooltipData)
|
|
@@ -8970,6 +9149,7 @@ const PieChartInternal = ({ data, chartId: providedChartId, withTooltips = false
|
|
|
8970
9149
|
top: tooltipTop || 0,
|
|
8971
9150
|
left: tooltipLeft || 0,
|
|
8972
9151
|
children: /* @__PURE__ */ jsx("div", {
|
|
9152
|
+
className: "a8c-charts-scope",
|
|
8973
9153
|
role: "tooltip",
|
|
8974
9154
|
children: renderTooltip({ tooltipData })
|
|
8975
9155
|
})
|
|
@@ -9268,6 +9448,7 @@ const PieSemiCircleChartInternal = ({ data, chartId: providedChartId, width: pro
|
|
|
9268
9448
|
top: tooltipTop || 0,
|
|
9269
9449
|
left: tooltipLeft || 0,
|
|
9270
9450
|
children: /* @__PURE__ */ jsx("div", {
|
|
9451
|
+
className: "a8c-charts-scope",
|
|
9271
9452
|
role: "tooltip",
|
|
9272
9453
|
children: renderTooltip({ tooltipData })
|
|
9273
9454
|
})
|
|
@@ -9555,7 +9736,7 @@ const Icon$1 = ({ direction }) => {
|
|
|
9555
9736
|
function TrendIndicator({ direction, value, className, style, showIcon = true }) {
|
|
9556
9737
|
const ariaLabel = `${DIRECTION_LABELS[direction]}: ${value}`;
|
|
9557
9738
|
return /* @__PURE__ */ jsxs("span", {
|
|
9558
|
-
className: clsx(trend_indicator_module_default["trend-indicator"], trend_indicator_module_default[`trend-indicator--${direction}`], className),
|
|
9739
|
+
className: clsx(useStandaloneScopeClass(), trend_indicator_module_default["trend-indicator"], trend_indicator_module_default[`trend-indicator--${direction}`], className),
|
|
9559
9740
|
style,
|
|
9560
9741
|
"aria-label": ariaLabel,
|
|
9561
9742
|
children: [showIcon && /* @__PURE__ */ jsx(Icon$1, { direction }), /* @__PURE__ */ jsx("span", {
|
|
@@ -9565,6 +9746,6 @@ function TrendIndicator({ direction, value, className, style, showIcon = true })
|
|
|
9565
9746
|
});
|
|
9566
9747
|
}
|
|
9567
9748
|
//#endregion
|
|
9568
|
-
export { AccessibleTooltip, AreaChartResponsive as AreaChart, AreaChart as AreaChartUnresponsive, BarChartResponsive as BarChart, BarChart as BarChartUnresponsive, BarListChartResponsive as BarListChart, BarListChart as BarListChartUnresponsive, BaseTooltip, ConversionFunnelChartWithProvider as ConversionFunnelChart, GeoChartResponsive as GeoChart, GeoChartWithProvider as GeoChartUnresponsive, GlobalChartsContext, GlobalChartsProvider, GlobalChartsProvider as ThemeProvider, HeatmapChartResponsive as HeatmapChart, HeatmapChart as HeatmapChartUnresponsive, LeaderboardChartResponsive as LeaderboardChart, LeaderboardChart as LeaderboardChartUnresponsive, Legend, LineChartResponsive as LineChart, LineChart as LineChartUnresponsive, PieChartResponsive as PieChart, PieChart as PieChartUnresponsive, PieSemiCircleChartResponsive as PieSemiCircleChart, PieSemiCircleChart as PieSemiCircleChartUnresponsive, Sparkline, SparklineUnresponsive, TrendIndicator, buildCalendarHeatmapData, defaultTheme, formatMetricValue, formatPercentage, getColorDistance, hexToRgba, isValidHexColor, lightenHexColor, mergeThemes, mixHexColors, normalizeColorToHex, parseAsLocalDate, parseHslString, parseRgbString, prefersLightText, relativeLuminance, useChartLegendItems, useGlobalChartsContext, useGlobalChartsTheme, useLeaderboardLegendItems, validateHexColor };
|
|
9749
|
+
export { AccessibleTooltip, AreaChartResponsive as AreaChart, AreaChart as AreaChartUnresponsive, BarChartResponsive as BarChart, BarChart as BarChartUnresponsive, BarListChartResponsive as BarListChart, BarListChart as BarListChartUnresponsive, BaseTooltip, ConversionFunnelChartWithProvider as ConversionFunnelChart, GeoChartResponsive as GeoChart, GeoChartWithProvider as GeoChartUnresponsive, GlobalChartsContext, GlobalChartsProvider, GlobalChartsProvider as ThemeProvider, HeatmapChartResponsive as HeatmapChart, HeatmapChart as HeatmapChartUnresponsive, LeaderboardChartResponsive as LeaderboardChart, LeaderboardChart as LeaderboardChartUnresponsive, Legend, LineChartResponsive as LineChart, LineChart as LineChartUnresponsive, PieChartResponsive as PieChart, PieChart as PieChartUnresponsive, PieSemiCircleChartResponsive as PieSemiCircleChart, PieSemiCircleChart as PieSemiCircleChartUnresponsive, Sparkline, SparklineUnresponsive, TrendIndicator, buildCalendarHeatmapData, defaultTheme, formatMetricValue, formatPercentage, getColorDistance, hexToRgba, isValidHexColor, lightenHexColor, mergeThemes, mixHexColors, normalizeColorToHex, parseAsLocalDate, parseHslString, parseRgbString, prefersLightText, relativeLuminance, resolveCssVariable, useChartLegendItems, useChartRegistration, useChartScopeElement, useGlobalChartsContext, useGlobalChartsTheme, useLeaderboardLegendItems, validateHexColor };
|
|
9569
9750
|
|
|
9570
9751
|
//# sourceMappingURL=index.js.map
|