@automattic/charts 1.10.1 → 1.10.3
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 +17 -0
- package/dist/index.cjs +248 -226
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +36 -7
- package/dist/index.d.cts +44 -5
- package/dist/index.d.ts +44 -5
- package/dist/index.js +236 -202
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/charts/heatmap-chart/heatmap-chart.module.scss +23 -0
- package/src/charts/heatmap-chart/heatmap-chart.tsx +78 -13
- package/src/charts/heatmap-chart/private/build-calendar-data.ts +22 -3
- package/src/charts/heatmap-chart/private/use-heatmap-colors.ts +6 -2
- package/src/charts/heatmap-chart/test/build-calendar-data.test.ts +34 -0
- package/src/charts/heatmap-chart/test/heatmap-chart.test.tsx +81 -0
- package/src/charts/heatmap-chart/test/use-heatmap-colors.test.ts +4 -0
- package/src/charts/heatmap-chart/types.ts +28 -0
- package/src/charts/leaderboard-chart/leaderboard-chart.module.scss +10 -10
- package/src/charts/leaderboard-chart/leaderboard-chart.tsx +6 -3
- package/src/charts/leaderboard-chart/test/leaderboard-chart.test.tsx +0 -6
- package/src/charts/pie-semi-circle-chart/test/pie-semi-circle-chart.test.tsx +0 -6
- package/src/charts/private/with-responsive/test/with-responsive.test.tsx +229 -18
- package/src/charts/private/with-responsive/with-responsive.module.scss +20 -1
- package/src/charts/private/with-responsive/with-responsive.tsx +114 -65
package/dist/index.css
CHANGED
|
@@ -82,6 +82,20 @@
|
|
|
82
82
|
color: var(--wpds-color-foreground-content-neutral-weak, #707070);
|
|
83
83
|
}
|
|
84
84
|
.a8ccharts-sP1gHa-container {
|
|
85
|
+
width: 100%;
|
|
86
|
+
min-width: 0;
|
|
87
|
+
height: 100%;
|
|
88
|
+
min-height: 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.a8ccharts-sP1gHa-isContained {
|
|
92
|
+
justify-content: center;
|
|
93
|
+
align-items: flex-start;
|
|
94
|
+
display: flex;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.a8ccharts-sP1gHa-content {
|
|
98
|
+
flex: none;
|
|
85
99
|
min-width: 0;
|
|
86
100
|
min-height: 0;
|
|
87
101
|
}
|
|
@@ -407,6 +421,10 @@
|
|
|
407
421
|
font-size: var(--wpds-typography-font-size-sm, 12px);
|
|
408
422
|
}
|
|
409
423
|
|
|
424
|
+
.a8ccharts-O3YMOW-heatmap-chart--height-capped {
|
|
425
|
+
height: max-content;
|
|
426
|
+
}
|
|
427
|
+
|
|
410
428
|
.a8ccharts-O3YMOW-heatmap-chart__empty {
|
|
411
429
|
padding: var(--wpds-dimension-padding-lg, 16px);
|
|
412
430
|
color: var(--wpds-color-foreground-content-neutral-weak, #707070);
|
|
@@ -433,6 +451,12 @@
|
|
|
433
451
|
min-height: 0;
|
|
434
452
|
}
|
|
435
453
|
|
|
454
|
+
.a8ccharts-O3YMOW-heatmap-chart__grid--height-capped {
|
|
455
|
+
flex: none;
|
|
456
|
+
height: max-content;
|
|
457
|
+
min-height: 0;
|
|
458
|
+
}
|
|
459
|
+
|
|
436
460
|
.a8ccharts-O3YMOW-heatmap-chart__row {
|
|
437
461
|
display: contents;
|
|
438
462
|
}
|
|
@@ -465,6 +489,11 @@
|
|
|
465
489
|
display: flex;
|
|
466
490
|
}
|
|
467
491
|
|
|
492
|
+
.a8ccharts-O3YMOW-heatmap-chart__cell--hidden {
|
|
493
|
+
visibility: hidden;
|
|
494
|
+
pointer-events: none;
|
|
495
|
+
}
|
|
496
|
+
|
|
468
497
|
.a8ccharts-O3YMOW-heatmap-chart__cell--filled {
|
|
469
498
|
background: color-mix(in sRGB, var(--heatmap-primary) calc((.15 + .85 * var(--intensity)) * 100%), var(--heatmap-bg, #fff));
|
|
470
499
|
}
|
|
@@ -578,23 +607,23 @@
|
|
|
578
607
|
font-style: italic;
|
|
579
608
|
}
|
|
580
609
|
|
|
581
|
-
.a8ccharts-GovfoW-
|
|
610
|
+
.a8ccharts-GovfoW-row {
|
|
582
611
|
--focus-ring-width: var(--wpds-border-width-focus, var(--wp-admin-border-width-focus, 2px));
|
|
583
612
|
grid-column: 1 / -1;
|
|
584
613
|
grid-template-columns: subgrid;
|
|
585
|
-
box-sizing: border-box;
|
|
586
|
-
appearance: none;
|
|
587
|
-
width: 100%;
|
|
588
614
|
padding: var(--focus-ring-width);
|
|
615
|
+
align-items: center;
|
|
616
|
+
display: grid;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
.a8ccharts-GovfoW-interactiveRow {
|
|
620
|
+
appearance: none;
|
|
589
621
|
color: inherit;
|
|
590
622
|
font: inherit;
|
|
591
623
|
text-align: inherit;
|
|
592
624
|
cursor: pointer;
|
|
593
625
|
background: none;
|
|
594
626
|
border: 0;
|
|
595
|
-
align-items: center;
|
|
596
|
-
margin: 0;
|
|
597
|
-
display: grid;
|
|
598
627
|
position: relative;
|
|
599
628
|
}
|
|
600
629
|
|
package/dist/index.d.cts
CHANGED
|
@@ -833,7 +833,11 @@ type ResponsiveConfig = {
|
|
|
833
833
|
maxWidth?: number;
|
|
834
834
|
/**
|
|
835
835
|
* The aspect ratio of the chart (height = width * aspectRatio).
|
|
836
|
-
* When provided,
|
|
836
|
+
* When provided, the chart keeps this ratio and is contained within the
|
|
837
|
+
* parent on both axes: it fills the available width and derives its height,
|
|
838
|
+
* but if the parent is shorter than that derived height it shrinks both axes
|
|
839
|
+
* to fit rather than overflowing. When it is narrower than the parent (the
|
|
840
|
+
* height-constrained case) it is centered horizontally.
|
|
837
841
|
* When omitted, the chart fills the parent container's height.
|
|
838
842
|
*/
|
|
839
843
|
aspectRatio?: number;
|
|
@@ -942,7 +946,7 @@ declare const BarListChartResponsive: ({
|
|
|
942
946
|
width,
|
|
943
947
|
height,
|
|
944
948
|
...chartProps
|
|
945
|
-
}: Omit<BarListChartProps, "
|
|
949
|
+
}: Omit<BarListChartProps, "width" | "height" | "size"> & {
|
|
946
950
|
width?: number;
|
|
947
951
|
height?: number;
|
|
948
952
|
size?: number;
|
|
@@ -1096,7 +1100,7 @@ declare const GeoChartResponsive: ({
|
|
|
1096
1100
|
width,
|
|
1097
1101
|
height,
|
|
1098
1102
|
...chartProps
|
|
1099
|
-
}: Omit<GeoChartProps, "
|
|
1103
|
+
}: Omit<GeoChartProps, "width" | "height" | "size"> & {
|
|
1100
1104
|
width?: number;
|
|
1101
1105
|
height?: number;
|
|
1102
1106
|
size?: number;
|
|
@@ -1107,6 +1111,13 @@ declare const GeoChartResponsive: ({
|
|
|
1107
1111
|
type HeatmapCell = {
|
|
1108
1112
|
/** Per-cell label used in the tooltip / accessible name. */label?: string;
|
|
1109
1113
|
value: number | null;
|
|
1114
|
+
/**
|
|
1115
|
+
* Leave the cell's grid slot empty: nothing is painted and the cell is
|
|
1116
|
+
* skipped by hover and keyboard navigation, while the slot keeps its
|
|
1117
|
+
* place so the rest of the grid doesn't shift. For calendar edges, where
|
|
1118
|
+
* days completing the first/last week fall outside the covered range.
|
|
1119
|
+
*/
|
|
1120
|
+
hidden?: boolean;
|
|
1110
1121
|
};
|
|
1111
1122
|
/** A heatmap column (rendered left→right); its cells render top→bottom. */
|
|
1112
1123
|
type HeatmapColumn = {
|
|
@@ -1128,6 +1139,27 @@ interface HeatmapChartProps extends Omit<BaseChartProps<HeatmapColumn[]>, 'showL
|
|
|
1128
1139
|
compact?: boolean;
|
|
1129
1140
|
/** Render the numeric value inside each cell. Default `! compact`. */
|
|
1130
1141
|
showValues?: boolean;
|
|
1142
|
+
/**
|
|
1143
|
+
* Cap a cell's width (px) in non-compact mode. Cells grow up to the cap
|
|
1144
|
+
* and stop instead of splitting the whole container width, so sparse
|
|
1145
|
+
* ranges don't produce oversized cells; narrow containers still shrink
|
|
1146
|
+
* them. Ignored in compact mode, which uses a fixed cell size.
|
|
1147
|
+
*/
|
|
1148
|
+
maxCellWidth?: number;
|
|
1149
|
+
/**
|
|
1150
|
+
* Cap a cell's height (px) in non-compact mode. Applying this cap
|
|
1151
|
+
* content-sizes the chart vertically so rows do not absorb unused height.
|
|
1152
|
+
* Ignored in compact mode, which uses a fixed cell size.
|
|
1153
|
+
*/
|
|
1154
|
+
maxCellHeight?: number;
|
|
1155
|
+
/**
|
|
1156
|
+
* Floor a cell's width (px) in non-compact mode. Below it the grid stops
|
|
1157
|
+
* shrinking and overflows its container instead, so a scrollable wrapper
|
|
1158
|
+
* can take over for long ranges. Default 0 (cells shrink freely).
|
|
1159
|
+
*/
|
|
1160
|
+
minCellWidth?: number;
|
|
1161
|
+
/** Floor a cell's height (px) in non-compact mode; see `minCellWidth`. */
|
|
1162
|
+
minCellHeight?: number;
|
|
1131
1163
|
/**
|
|
1132
1164
|
* Color the cell scale interpolates toward at the highest value
|
|
1133
1165
|
* (this prop > theme `heatmapChart.primaryColor` > palette `colors[0]`).
|
|
@@ -1144,6 +1176,13 @@ type CalendarHeatmapResult = {
|
|
|
1144
1176
|
};
|
|
1145
1177
|
declare const buildCalendarHeatmapData: (series: DataPointDate[], options?: {
|
|
1146
1178
|
weekStartsOn?: 0 | 1;
|
|
1179
|
+
/**
|
|
1180
|
+
* Mark the days completing the first/last week outside the series'
|
|
1181
|
+
* date span as hidden cells (empty grid slots) instead of blank
|
|
1182
|
+
* cells, giving the calendar ragged edges. Days inside the span stay
|
|
1183
|
+
* blank cells even when the series has no entry for them.
|
|
1184
|
+
*/
|
|
1185
|
+
hideOutOfRangeDays?: boolean;
|
|
1147
1186
|
}) => CalendarHeatmapResult;
|
|
1148
1187
|
//#endregion
|
|
1149
1188
|
//#region src/charts/heatmap-chart/private/heatmap-legend.d.ts
|
|
@@ -1232,7 +1271,7 @@ declare const LeaderboardChartResponsive: (({
|
|
|
1232
1271
|
width,
|
|
1233
1272
|
height,
|
|
1234
1273
|
...chartProps
|
|
1235
|
-
}: Omit<LeaderboardChartProps, "
|
|
1274
|
+
}: Omit<LeaderboardChartProps, "width" | "height" | "size"> & {
|
|
1236
1275
|
width?: number;
|
|
1237
1276
|
height?: number;
|
|
1238
1277
|
size?: number;
|
|
@@ -1765,7 +1804,7 @@ declare const Sparkline: ({
|
|
|
1765
1804
|
width,
|
|
1766
1805
|
height,
|
|
1767
1806
|
...chartProps
|
|
1768
|
-
}: Omit<SparklineProps, "
|
|
1807
|
+
}: Omit<SparklineProps, "width" | "height" | "size"> & {
|
|
1769
1808
|
width?: number;
|
|
1770
1809
|
height?: number;
|
|
1771
1810
|
size?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -833,7 +833,11 @@ type ResponsiveConfig = {
|
|
|
833
833
|
maxWidth?: number;
|
|
834
834
|
/**
|
|
835
835
|
* The aspect ratio of the chart (height = width * aspectRatio).
|
|
836
|
-
* When provided,
|
|
836
|
+
* When provided, the chart keeps this ratio and is contained within the
|
|
837
|
+
* parent on both axes: it fills the available width and derives its height,
|
|
838
|
+
* but if the parent is shorter than that derived height it shrinks both axes
|
|
839
|
+
* to fit rather than overflowing. When it is narrower than the parent (the
|
|
840
|
+
* height-constrained case) it is centered horizontally.
|
|
837
841
|
* When omitted, the chart fills the parent container's height.
|
|
838
842
|
*/
|
|
839
843
|
aspectRatio?: number;
|
|
@@ -942,7 +946,7 @@ declare const BarListChartResponsive: ({
|
|
|
942
946
|
width,
|
|
943
947
|
height,
|
|
944
948
|
...chartProps
|
|
945
|
-
}: Omit<BarListChartProps, "
|
|
949
|
+
}: Omit<BarListChartProps, "width" | "height" | "size"> & {
|
|
946
950
|
width?: number;
|
|
947
951
|
height?: number;
|
|
948
952
|
size?: number;
|
|
@@ -1096,7 +1100,7 @@ declare const GeoChartResponsive: ({
|
|
|
1096
1100
|
width,
|
|
1097
1101
|
height,
|
|
1098
1102
|
...chartProps
|
|
1099
|
-
}: Omit<GeoChartProps, "
|
|
1103
|
+
}: Omit<GeoChartProps, "width" | "height" | "size"> & {
|
|
1100
1104
|
width?: number;
|
|
1101
1105
|
height?: number;
|
|
1102
1106
|
size?: number;
|
|
@@ -1107,6 +1111,13 @@ declare const GeoChartResponsive: ({
|
|
|
1107
1111
|
type HeatmapCell = {
|
|
1108
1112
|
/** Per-cell label used in the tooltip / accessible name. */label?: string;
|
|
1109
1113
|
value: number | null;
|
|
1114
|
+
/**
|
|
1115
|
+
* Leave the cell's grid slot empty: nothing is painted and the cell is
|
|
1116
|
+
* skipped by hover and keyboard navigation, while the slot keeps its
|
|
1117
|
+
* place so the rest of the grid doesn't shift. For calendar edges, where
|
|
1118
|
+
* days completing the first/last week fall outside the covered range.
|
|
1119
|
+
*/
|
|
1120
|
+
hidden?: boolean;
|
|
1110
1121
|
};
|
|
1111
1122
|
/** A heatmap column (rendered left→right); its cells render top→bottom. */
|
|
1112
1123
|
type HeatmapColumn = {
|
|
@@ -1128,6 +1139,27 @@ interface HeatmapChartProps extends Omit<BaseChartProps<HeatmapColumn[]>, 'showL
|
|
|
1128
1139
|
compact?: boolean;
|
|
1129
1140
|
/** Render the numeric value inside each cell. Default `! compact`. */
|
|
1130
1141
|
showValues?: boolean;
|
|
1142
|
+
/**
|
|
1143
|
+
* Cap a cell's width (px) in non-compact mode. Cells grow up to the cap
|
|
1144
|
+
* and stop instead of splitting the whole container width, so sparse
|
|
1145
|
+
* ranges don't produce oversized cells; narrow containers still shrink
|
|
1146
|
+
* them. Ignored in compact mode, which uses a fixed cell size.
|
|
1147
|
+
*/
|
|
1148
|
+
maxCellWidth?: number;
|
|
1149
|
+
/**
|
|
1150
|
+
* Cap a cell's height (px) in non-compact mode. Applying this cap
|
|
1151
|
+
* content-sizes the chart vertically so rows do not absorb unused height.
|
|
1152
|
+
* Ignored in compact mode, which uses a fixed cell size.
|
|
1153
|
+
*/
|
|
1154
|
+
maxCellHeight?: number;
|
|
1155
|
+
/**
|
|
1156
|
+
* Floor a cell's width (px) in non-compact mode. Below it the grid stops
|
|
1157
|
+
* shrinking and overflows its container instead, so a scrollable wrapper
|
|
1158
|
+
* can take over for long ranges. Default 0 (cells shrink freely).
|
|
1159
|
+
*/
|
|
1160
|
+
minCellWidth?: number;
|
|
1161
|
+
/** Floor a cell's height (px) in non-compact mode; see `minCellWidth`. */
|
|
1162
|
+
minCellHeight?: number;
|
|
1131
1163
|
/**
|
|
1132
1164
|
* Color the cell scale interpolates toward at the highest value
|
|
1133
1165
|
* (this prop > theme `heatmapChart.primaryColor` > palette `colors[0]`).
|
|
@@ -1144,6 +1176,13 @@ type CalendarHeatmapResult = {
|
|
|
1144
1176
|
};
|
|
1145
1177
|
declare const buildCalendarHeatmapData: (series: DataPointDate[], options?: {
|
|
1146
1178
|
weekStartsOn?: 0 | 1;
|
|
1179
|
+
/**
|
|
1180
|
+
* Mark the days completing the first/last week outside the series'
|
|
1181
|
+
* date span as hidden cells (empty grid slots) instead of blank
|
|
1182
|
+
* cells, giving the calendar ragged edges. Days inside the span stay
|
|
1183
|
+
* blank cells even when the series has no entry for them.
|
|
1184
|
+
*/
|
|
1185
|
+
hideOutOfRangeDays?: boolean;
|
|
1147
1186
|
}) => CalendarHeatmapResult;
|
|
1148
1187
|
//#endregion
|
|
1149
1188
|
//#region src/charts/heatmap-chart/private/heatmap-legend.d.ts
|
|
@@ -1232,7 +1271,7 @@ declare const LeaderboardChartResponsive: (({
|
|
|
1232
1271
|
width,
|
|
1233
1272
|
height,
|
|
1234
1273
|
...chartProps
|
|
1235
|
-
}: Omit<LeaderboardChartProps, "
|
|
1274
|
+
}: Omit<LeaderboardChartProps, "width" | "height" | "size"> & {
|
|
1236
1275
|
width?: number;
|
|
1237
1276
|
height?: number;
|
|
1238
1277
|
size?: number;
|
|
@@ -1765,7 +1804,7 @@ declare const Sparkline: ({
|
|
|
1765
1804
|
width,
|
|
1766
1805
|
height,
|
|
1767
1806
|
...chartProps
|
|
1768
|
-
}: Omit<SparklineProps, "
|
|
1807
|
+
}: Omit<SparklineProps, "width" | "height" | "size"> & {
|
|
1769
1808
|
width?: number;
|
|
1770
1809
|
height?: number;
|
|
1771
1810
|
size?: number;
|