@automattic/charts 4.13.0 → 4.14.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 +24 -29
- package/TOKENS.md +3 -0
- package/dist/index.cjs +149 -1624
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +2 -1
- package/dist/index.d.cts +19 -8
- package/dist/index.d.ts +19 -8
- package/dist/index.js +150 -1292
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
- package/src/charts/leaderboard-chart/leaderboard-chart.module.scss +1 -1
- package/src/charts/leaderboard-chart/leaderboard-chart.tsx +26 -9
- package/src/charts/leaderboard-chart/private/resolve-leaderboard-entries.ts +53 -0
- package/src/charts/leaderboard-chart/test/leaderboard-chart.test.tsx +41 -0
- package/src/charts/leaderboard-chart/test/resolve-leaderboard-entries.test.ts +146 -0
- package/src/charts/leaderboard-chart/types.ts +6 -0
- package/src/components/legend/private/base-legend.tsx +13 -8
- package/src/components/legend/test/legend.test.tsx +125 -0
- package/src/components/legend/types.ts +9 -1
- package/src/styles/chart-scope.scss +1 -0
- package/src/types.ts +5 -7
package/dist/index.css
CHANGED
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
--a8c-charts-border-radius-leaderboard-bar: 9999px;
|
|
38
38
|
--a8c-charts-dimension-leaderboard-row-gap: var(--wpds-dimension-gap-md, 12px);
|
|
39
39
|
--a8c-charts-dimension-leaderboard-column-gap: var(--wpds-dimension-gap-xs, 4px);
|
|
40
|
+
--a8c-charts-dimension-leaderboard-label-inset: var(--wpds-dimension-padding-sm, 8px);
|
|
40
41
|
--a8c-charts-dimension-legend-column-gap: var(--wpds-dimension-gap-lg, 16px);
|
|
41
42
|
--a8c-charts-dimension-legend-row-gap: var(--wpds-dimension-gap-sm, 8px);
|
|
42
43
|
}
|
|
@@ -762,7 +763,7 @@
|
|
|
762
763
|
}
|
|
763
764
|
|
|
764
765
|
.a8ccharts-GovfoW-barWithLabelContainer.a8ccharts-GovfoW-is-overlay .a8ccharts-GovfoW-label {
|
|
765
|
-
padding-
|
|
766
|
+
padding-inline-start: var(--a8c-charts-dimension-leaderboard-label-inset);
|
|
766
767
|
}
|
|
767
768
|
|
|
768
769
|
.a8ccharts-GovfoW-barWithLabelContainer.a8ccharts-GovfoW-is-overlay .a8ccharts-GovfoW-barTrack {
|
package/dist/index.d.cts
CHANGED
|
@@ -163,18 +163,16 @@ type LeaderboardEntryFields = {
|
|
|
163
163
|
*/
|
|
164
164
|
previousValue?: number;
|
|
165
165
|
/**
|
|
166
|
-
* Width of current bar, as
|
|
167
|
-
* extends the bar from a shared zero point toward the inline start, for every row.
|
|
166
|
+
* Width of current bar, as %. Derived from the values when omitted; a passed value wins.
|
|
167
|
+
* A negative share extends the bar from a shared zero point toward the inline start, for every row.
|
|
168
168
|
*/
|
|
169
|
-
currentShare
|
|
169
|
+
currentShare?: number;
|
|
170
170
|
/**
|
|
171
|
-
* Width of previous bar, as
|
|
172
|
-
* row has no matching comparison-period value.
|
|
171
|
+
* Width of previous bar, as %. Derived from `previousValue` when omitted; a passed value wins.
|
|
173
172
|
*/
|
|
174
173
|
previousShare?: number;
|
|
175
174
|
/**
|
|
176
|
-
*
|
|
177
|
-
* as when the row has no comparison value or its previous value is zero.
|
|
175
|
+
* Percentage change. Derived from the values when omitted; a passed value wins.
|
|
178
176
|
*/
|
|
179
177
|
delta?: number;
|
|
180
178
|
/**
|
|
@@ -785,7 +783,15 @@ type BaseLegendItem = {
|
|
|
785
783
|
interactive?: boolean;
|
|
786
784
|
/** Label of the series this static item describes; the item is left out while it is hidden. */
|
|
787
785
|
describesSeries?: string;
|
|
788
|
-
}
|
|
786
|
+
} & ({
|
|
787
|
+
/** Pressed state of the toggle. */
|
|
788
|
+
pressed: boolean;
|
|
789
|
+
/** Makes an interactive legend item a toggle the consumer controls, instead of a series toggle. */
|
|
790
|
+
onToggle: () => void;
|
|
791
|
+
} | {
|
|
792
|
+
pressed?: never;
|
|
793
|
+
onToggle?: never;
|
|
794
|
+
});
|
|
789
795
|
export declare const Legend: import("react").ForwardRefExoticComponent<Omit<BaseLegendProps, "items"> & {
|
|
790
796
|
items?: BaseLegendItem[];
|
|
791
797
|
chartId?: string;
|
|
@@ -1603,6 +1609,11 @@ interface LeaderboardChartProps extends Pick<BaseChartProps<LeaderboardEntry>, '
|
|
|
1603
1609
|
* Whether to overlay the label on top of bar
|
|
1604
1610
|
*/
|
|
1605
1611
|
withOverlayLabel?: boolean;
|
|
1612
|
+
/**
|
|
1613
|
+
* How a negative value draws: `diverge` puts every row on a shared zero point, `clamp` draws it as an empty bar.
|
|
1614
|
+
* @default 'diverge'
|
|
1615
|
+
*/
|
|
1616
|
+
negativeBars?: 'diverge' | 'clamp';
|
|
1606
1617
|
/**
|
|
1607
1618
|
* Primary color for current period bars
|
|
1608
1619
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -163,18 +163,16 @@ type LeaderboardEntryFields = {
|
|
|
163
163
|
*/
|
|
164
164
|
previousValue?: number;
|
|
165
165
|
/**
|
|
166
|
-
* Width of current bar, as
|
|
167
|
-
* extends the bar from a shared zero point toward the inline start, for every row.
|
|
166
|
+
* Width of current bar, as %. Derived from the values when omitted; a passed value wins.
|
|
167
|
+
* A negative share extends the bar from a shared zero point toward the inline start, for every row.
|
|
168
168
|
*/
|
|
169
|
-
currentShare
|
|
169
|
+
currentShare?: number;
|
|
170
170
|
/**
|
|
171
|
-
* Width of previous bar, as
|
|
172
|
-
* row has no matching comparison-period value.
|
|
171
|
+
* Width of previous bar, as %. Derived from `previousValue` when omitted; a passed value wins.
|
|
173
172
|
*/
|
|
174
173
|
previousShare?: number;
|
|
175
174
|
/**
|
|
176
|
-
*
|
|
177
|
-
* as when the row has no comparison value or its previous value is zero.
|
|
175
|
+
* Percentage change. Derived from the values when omitted; a passed value wins.
|
|
178
176
|
*/
|
|
179
177
|
delta?: number;
|
|
180
178
|
/**
|
|
@@ -785,7 +783,15 @@ type BaseLegendItem = {
|
|
|
785
783
|
interactive?: boolean;
|
|
786
784
|
/** Label of the series this static item describes; the item is left out while it is hidden. */
|
|
787
785
|
describesSeries?: string;
|
|
788
|
-
}
|
|
786
|
+
} & ({
|
|
787
|
+
/** Pressed state of the toggle. */
|
|
788
|
+
pressed: boolean;
|
|
789
|
+
/** Makes an interactive legend item a toggle the consumer controls, instead of a series toggle. */
|
|
790
|
+
onToggle: () => void;
|
|
791
|
+
} | {
|
|
792
|
+
pressed?: never;
|
|
793
|
+
onToggle?: never;
|
|
794
|
+
});
|
|
789
795
|
export declare const Legend: import("react").ForwardRefExoticComponent<Omit<BaseLegendProps, "items"> & {
|
|
790
796
|
items?: BaseLegendItem[];
|
|
791
797
|
chartId?: string;
|
|
@@ -1603,6 +1609,11 @@ interface LeaderboardChartProps extends Pick<BaseChartProps<LeaderboardEntry>, '
|
|
|
1603
1609
|
* Whether to overlay the label on top of bar
|
|
1604
1610
|
*/
|
|
1605
1611
|
withOverlayLabel?: boolean;
|
|
1612
|
+
/**
|
|
1613
|
+
* How a negative value draws: `diverge` puts every row on a shared zero point, `clamp` draws it as an empty bar.
|
|
1614
|
+
* @default 'diverge'
|
|
1615
|
+
*/
|
|
1616
|
+
negativeBars?: 'diverge' | 'clamp';
|
|
1606
1617
|
/**
|
|
1607
1618
|
* Primary color for current period bars
|
|
1608
1619
|
*/
|