@redsift/charts 10.3.0-alpha.3 → 10.3.0-alpha.5

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/index.d.ts CHANGED
@@ -394,6 +394,8 @@ interface DataPointProps<T> extends Omit<ComponentProps<'g'>, 'onClick' | 'scale
394
394
  color?: string;
395
395
  /** Data. Also state to which the component should end the animation, if any. */
396
396
  data: T;
397
+ /** Href when the component is a navigation link. */
398
+ href?: string;
397
399
  /** Id. Used for accessibility. */
398
400
  id?: string;
399
401
  /** Position in the list of siblings. Used for placement and selection. */
@@ -542,6 +544,23 @@ interface ChartContainerProps extends Omit<ComponentProps<'div'>, 'title'>, Cont
542
544
  title?: string | ReactElement;
543
545
  /** Theme. */
544
546
  theme?: Theme;
547
+ /** Description that won't be visually displayed but will be used for assistive technology. If you want to display the description, use `description` instead. */
548
+ descriptionForAssistiveTechnology?: string;
549
+ /** Whether the chart is static or interactive. */
550
+ mode?: 'static' | 'interactive';
551
+ /** Small text explaining which kind of chart is presenting and what's its basic composition. */
552
+ definition?: string;
553
+ /** Small text explaining the basic composition of the x-axis, if any. */
554
+ xAxisDefinition?: string;
555
+ /** Small text explaining the basic composition of the y-axis, if any. */
556
+ yAxisDefinition?: string;
557
+ /** Small text explaining how the chart is interactive, if any. */
558
+ interactionExplanation?: string;
559
+ /** Table representation of the chart. */
560
+ dataTableRepresentation?: {
561
+ header: ReactElement;
562
+ body: ReactElement;
563
+ };
545
564
  }
546
565
  type StyledChartContainerProps = Omit<ChartContainerProps, 'theme'> & {
547
566
  $theme: Theme;
@@ -643,7 +662,7 @@ interface BarChartProps extends ChartContainerProps, ChartAxesProps {
643
662
  /** @deprecated: Use xAxisTickRotation instead. Whether the x axis labels are rotated or not. */
644
663
  areXLabelsRotated?: boolean;
645
664
  /** Native HTML props to forward to each bar. */
646
- barProps?: Omit<ComponentProps<'g'>, 'onClick' | 'orientation' | 'ref' | 'scale' | 'width'>;
665
+ barProps?: Omit<ComponentProps<'g'>, 'onClick' | 'orientation' | 'ref' | 'scale'>;
647
666
  /** Number of categories to use, the rest being put into a new category called "Others". */
648
667
  caping?: number;
649
668
  /** Dataset to use to generate the chart, should be a list of objects containing a key and a value. */
@@ -652,6 +671,11 @@ interface BarChartProps extends ChartContainerProps, ChartAxesProps {
652
671
  dataType?: 'TwoCategoryData' | 'LinearData' | 'CategoryData';
653
672
  /** Component to use if the chart is empty (replacing the default one). */
654
673
  emptyComponent?: ReactNode;
674
+ /** Method used to define the href on a bar used as a navigation link. */
675
+ getBarAnchorProps?: (datum: BarDatum) => {
676
+ href: string;
677
+ target?: string;
678
+ };
655
679
  /** Method to determine whether a slice is selected or not. */
656
680
  isBarSelected?: (datum: BarDatum) => void;
657
681
  /** Method to override the data labels. */
@@ -674,7 +698,7 @@ interface BarChartProps extends ChartContainerProps, ChartAxesProps {
674
698
  localeText?: LocaleText$3;
675
699
  /** Custom margins, used to give more space for axes labels and legend for instance. */
676
700
  margins?: MarginProps;
677
- /** Method to be called on a click on a bar. */
701
+ /** Method to be called on a click on a bar. For a navigation link, please use `getBarAnchorProps` instead. */
678
702
  onBarClick?: (datum: BarDatum) => void;
679
703
  /** Orientation of the bar. */
680
704
  orientation?: BarOrientation;
@@ -895,6 +919,11 @@ interface PieChartProps extends ChartContainerProps {
895
919
  data?: CategoryData;
896
920
  /** Component to use if the chart is empty (replacing the default one). */
897
921
  emptyComponent?: ReactNode;
922
+ /** Method used to define the href on a bar used as a navigation link. */
923
+ getSliceAnchorProps?: (datum: ArcDatum) => {
924
+ href: string;
925
+ target?: string;
926
+ };
898
927
  /** Whether the pie or donut is cut in half or not. */
899
928
  isHalf?: boolean;
900
929
  /** Method to determine whether a slice is selected or not. */
@@ -917,7 +946,7 @@ interface PieChartProps extends ChartContainerProps {
917
946
  legendProps?: Omit<LegendProps, 'data' | 'ref' | 'variant'>;
918
947
  /** Labels and texts. */
919
948
  localeText?: LocaleText$1;
920
- /** Method to be called on a click on a slice. */
949
+ /** Method to be called on a click on a slice. For a navigation link, please use `getSliceAnchorProps` instead. */
921
950
  onSliceClick?: (datum: ArcDatum) => void;
922
951
  /** Whether a category should be displayed for categories that has been removed by the caping option. Optionaly, this prop can be used to change the label of this category. */
923
952
  others?: boolean | string;
package/index.js CHANGED
@@ -362,12 +362,13 @@ var k=/^--/;function I(t,e){return e==null||typeof e=="boolean"||e===""?"":typeo
362
362
  */
363
363
  const StyledDataPoint = styled(it.g)``;
364
364
 
365
- const _excluded$q = ["children", "className", "data", "id", "index", "isSelected", "labelDecorator", "onClick", "role", "tooltipDecorator", "tooltipVariant", "theme"];
365
+ const _excluded$q = ["children", "className", "data", "href", "id", "index", "isSelected", "labelDecorator", "onClick", "role", "tooltipDecorator", "tooltipVariant", "theme"];
366
366
  const DataPoint = /*#__PURE__*/forwardRef((props, ref) => {
367
367
  const {
368
368
  children,
369
369
  className,
370
370
  data,
371
+ href,
371
372
  id: propsId,
372
373
  index,
373
374
  isSelected: propsIsSelected,
@@ -428,7 +429,9 @@ const DataPoint = /*#__PURE__*/forwardRef((props, ref) => {
428
429
  return /*#__PURE__*/React__default.createElement(Tooltip, {
429
430
  placement: "right",
430
431
  theme: theme
431
- }, /*#__PURE__*/React__default.createElement(Tooltip.Trigger, null, DataPointComponent), /*#__PURE__*/React__default.createElement(Tooltip.Content, null, isTooltipCustom ? tooltipDecorator(data, {
432
+ }, /*#__PURE__*/React__default.createElement(Tooltip.Trigger, null, href !== undefined ? /*#__PURE__*/React__default.createElement("a", {
433
+ href: href
434
+ }, DataPointComponent) : DataPointComponent), /*#__PURE__*/React__default.createElement(Tooltip.Content, null, isTooltipCustom ? tooltipDecorator(data, {
432
435
  index,
433
436
  isSelected: propsIsSelected,
434
437
  color: props.color
@@ -938,6 +941,7 @@ const Axis = /*#__PURE__*/forwardRef((props, ref) => {
938
941
  }
939
942
  }));
940
943
  return /*#__PURE__*/React__default.createElement(StyledAxis, _extends({
944
+ "aria-hidden": "true",
941
945
  className: classNames(Axis.className, className),
942
946
  $theme: theme
943
947
  }, forwardedProps, {
@@ -1112,7 +1116,9 @@ const Bar = /*#__PURE__*/forwardRef((props, ref) => {
1112
1116
  t: 0
1113
1117
  }
1114
1118
  }));
1115
- return /*#__PURE__*/React__default.createElement(StyledBar, _extends({}, forwardedProps, {
1119
+ return /*#__PURE__*/React__default.createElement(StyledBar, _extends({
1120
+ "aria-hidden": "false"
1121
+ }, forwardedProps, {
1116
1122
  ref: ref,
1117
1123
  className: classNames(Bar.className, className),
1118
1124
  transform: isHorizontal ? `translate(0, ${scalePosition(data.data.key) + gap / 2})` : `translate(${scalePosition(data.data.key) + (isOrdinal ? width + gap / 2 : width / 2)}, ${maxHeight}), rotate(180)`,
@@ -1154,11 +1160,19 @@ const BarChartLegendVariant = {
1154
1160
 
1155
1161
  var reset$1 = "Reset";
1156
1162
  var enUS = {
1163
+ "static-chart": "Static chart.",
1164
+ "interactive-chart": "Interactive chart.",
1165
+ "view-as-data-table": "View as data table",
1166
+ "table-summary": "Table representation of chart.",
1157
1167
  reset: reset$1
1158
1168
  };
1159
1169
 
1160
1170
  var reset = "Réinitialiser";
1161
1171
  var frFR = {
1172
+ "static-chart": "Graphique statique.",
1173
+ "interactive-chart": "Graphique intéractif.",
1174
+ "view-as-data-table": "Voir au format table de données",
1175
+ "table-summary": "Représentation du graphique sous forme de table de données.",
1162
1176
  reset: reset
1163
1177
  };
1164
1178
 
@@ -1189,6 +1203,7 @@ const StyledChartContainer = styled.div`
1189
1203
 
1190
1204
  svg {
1191
1205
  display: block;
1206
+ user-select: none;
1192
1207
  }
1193
1208
 
1194
1209
  text {
@@ -1201,6 +1216,32 @@ const StyledChartContainer = styled.div`
1201
1216
  `;
1202
1217
  }}
1203
1218
  }
1219
+
1220
+ table {
1221
+ border-collapse: collapse;
1222
+ border: 1px solid #ebebeb;
1223
+ margin: 10px auto;
1224
+ text-align: center;
1225
+ width: 100%;
1226
+ max-width: 500px;
1227
+
1228
+ td, th, caption {
1229
+ padding: 0.5em;
1230
+ }
1231
+
1232
+ caption {
1233
+ padding: 1em 0;
1234
+ font-size: 1.2em;
1235
+ color: #555;
1236
+ }
1237
+
1238
+ thead tr, tr:nth-child(even) {
1239
+ background: #f8f8f8;
1240
+ }
1241
+
1242
+ th {
1243
+ font-weight: 600;
1244
+ }
1204
1245
  `;
1205
1246
  const StyledChartContainerTitle = styled(Flexbox)``;
1206
1247
  const StyledChartContainerCaption = styled.p`
@@ -1211,7 +1252,7 @@ const StyledChartContainerCaption = styled.p`
1211
1252
  margin: 8px;
1212
1253
  `;
1213
1254
 
1214
- const _excluded$l = ["aria-label", "aria-labelledby", "description", "chartProps", "chartRef", "children", "className", "id", "title", "onReset", "theme"];
1255
+ const _excluded$l = ["aria-label", "aria-labelledby", "description", "chartProps", "chartRef", "children", "className", "id", "title", "onReset", "theme", "mode", "definition", "interactionExplanation", "descriptionForAssistiveTechnology", "dataTableRepresentation", "xAxisDefinition", "yAxisDefinition"];
1215
1256
  const COMPONENT_NAME$8 = 'ChartContainer';
1216
1257
  const CLASSNAME$8 = 'redsift-chart-container';
1217
1258
  const DEFAULT_PROPS$8 = {};
@@ -1227,12 +1268,20 @@ const ChartContainer = /*#__PURE__*/forwardRef((props, ref) => {
1227
1268
  id: propsId,
1228
1269
  title,
1229
1270
  onReset,
1230
- theme: propsTheme
1271
+ theme: propsTheme,
1272
+ mode = 'static',
1273
+ definition,
1274
+ interactionExplanation,
1275
+ descriptionForAssistiveTechnology,
1276
+ dataTableRepresentation,
1277
+ xAxisDefinition,
1278
+ yAxisDefinition
1231
1279
  } = props,
1232
1280
  forwardedProps = _objectWithoutProperties(props, _excluded$l);
1233
1281
  const [_id] = useId();
1234
1282
  const id = propsId !== null && propsId !== void 0 ? propsId : _id;
1235
1283
  const theme = useTheme(propsTheme);
1284
+ const [viewAsDataTable, setViewAsDataTable] = useState(false);
1236
1285
  warnIfNoAccessibleLabelFound(props, [title]);
1237
1286
  const format = useMessageFormatter(intlMessages);
1238
1287
  const ariaLabel = propsAriaLabel ? propsAriaLabel : propsAriaLabelledby || title ? undefined : undefined;
@@ -1241,13 +1290,53 @@ const ChartContainer = /*#__PURE__*/forwardRef((props, ref) => {
1241
1290
  value: {
1242
1291
  theme
1243
1292
  }
1244
- }, /*#__PURE__*/React__default.createElement(StyledChartContainer, _extends({
1245
- $theme: theme
1246
- }, forwardedProps, {
1293
+ }, /*#__PURE__*/React__default.createElement("figure", null, /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(StyledChartContainer, _extends({
1294
+ $theme: theme,
1295
+ role: "region",
1296
+ "aria-hidden": "false"
1297
+ }, ariaLabel ? {
1298
+ 'aria-label': `${ariaLabel}. ${format(`${mode}-chart`)}`
1299
+ } : {}, ariaLabelledby ? {
1300
+ 'aria-labelledby': `${ariaLabelledby} id${id}__interactive-or-not`
1301
+ } : {}, forwardedProps, {
1247
1302
  ref: ref,
1248
1303
  className: classNames(ChartContainer.className, className),
1249
1304
  id: id
1250
- }), title || onReset ? /*#__PURE__*/React__default.createElement(StyledChartContainerTitle, {
1305
+ }), /*#__PURE__*/React__default.createElement("div", {
1306
+ id: `id${id}__screen-reader-region-before`,
1307
+ "aria-hidden": "false",
1308
+ style: {
1309
+ position: 'relative'
1310
+ }
1311
+ }, /*#__PURE__*/React__default.createElement("div", {
1312
+ "aria-hidden": "false",
1313
+ style: {
1314
+ position: 'absolute',
1315
+ width: '1px',
1316
+ height: '1px',
1317
+ overflow: 'hidden',
1318
+ whiteSpace: 'nowrap',
1319
+ clip: 'rect(1px, 1px, 1px, 1px)',
1320
+ marginTop: '-3px',
1321
+ opacity: '0.01'
1322
+ }
1323
+ }, /*#__PURE__*/React__default.createElement("p", {
1324
+ id: `id${id}__interactive-or-not`,
1325
+ "aria-hidden": "true",
1326
+ style: {
1327
+ display: 'none'
1328
+ }
1329
+ }, format(`${mode}-chart`)), ariaLabel ? /*#__PURE__*/React__default.createElement("p", null, `${ariaLabel}. ${format(`${mode}-chart`)}`) : /*#__PURE__*/React__default.createElement("p", {
1330
+ "aria-labelledby": `${ariaLabelledby} id${id}__interactive-or-not`
1331
+ }), /*#__PURE__*/React__default.createElement("div", null, definition), /*#__PURE__*/React__default.createElement("div", null, interactionExplanation), /*#__PURE__*/React__default.createElement("div", null, descriptionForAssistiveTechnology !== null && descriptionForAssistiveTechnology !== void 0 ? descriptionForAssistiveTechnology : description), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("button", {
1332
+ id: "hc-linkto-highcharts-data-table-0",
1333
+ tabIndex: -1,
1334
+ "aria-expanded": viewAsDataTable,
1335
+ onClick: () => setViewAsDataTable(!viewAsDataTable)
1336
+ }, format('view-as-data-table'), ', ', ariaLabel ? /*#__PURE__*/React__default.createElement("span", null, ariaLabel) : /*#__PURE__*/React__default.createElement("span", {
1337
+ "aria-labelledby": ariaLabelledby
1338
+ }))), /*#__PURE__*/React__default.createElement("div", null, xAxisDefinition), /*#__PURE__*/React__default.createElement("div", null, yAxisDefinition))), title || onReset ? /*#__PURE__*/React__default.createElement(StyledChartContainerTitle, {
1339
+ "aria-hidden": "true",
1251
1340
  $theme: theme,
1252
1341
  alignItems: "center",
1253
1342
  justifyContent: "space-between",
@@ -1262,15 +1351,22 @@ const ChartContainer = /*#__PURE__*/forwardRef((props, ref) => {
1262
1351
  onClick: onReset
1263
1352
  }, format('reset')) : null) : null, /*#__PURE__*/React__default.createElement(Flexbox, {
1264
1353
  flexDirection: "column"
1265
- }, children ? /*#__PURE__*/React__default.createElement("div", _extends({}, chartProps, {
1354
+ }, children ? /*#__PURE__*/React__default.createElement("div", _extends({
1355
+ "aria-hidden": "false",
1356
+ dir: "ltr"
1357
+ }, chartProps, {
1266
1358
  ref: chartRef,
1267
- className: `${ChartContainer.className}__content`,
1268
- "aria-label": ariaLabel,
1269
- "aria-labelledby": ariaLabelledby
1359
+ className: `${ChartContainer.className}__content`
1270
1360
  }), children) : null, description ? /*#__PURE__*/React__default.createElement(StyledChartContainerCaption, {
1361
+ "aria-hidden": "true",
1271
1362
  $theme: theme,
1272
1363
  className: `${ChartContainer.className}__description`
1273
- }, description) : null)));
1364
+ }, description) : null, viewAsDataTable && dataTableRepresentation ? /*#__PURE__*/React__default.createElement("table", {
1365
+ tabIndex: -1,
1366
+ summary: format('table-summary')
1367
+ }, ariaLabel ? /*#__PURE__*/React__default.createElement("caption", null, ariaLabel) : /*#__PURE__*/React__default.createElement("caption", {
1368
+ "aria-labelledby": ariaLabelledby
1369
+ }), dataTableRepresentation.header, dataTableRepresentation.body) : null)))));
1274
1370
  });
1275
1371
  ChartContainer.className = CLASSNAME$8;
1276
1372
  ChartContainer.defaultProps = DEFAULT_PROPS$8;
@@ -1447,7 +1543,7 @@ const LoadingBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1447
1543
  }), "Loading...");
1448
1544
  });
1449
1545
 
1450
- const _excluded$i = ["areXLabelsRotated", "barProps", "caping", "className", "data", "id", "isBarSelected", "labelDecorator", "margins", "onBarClick", "orientation", "others", "size", "sortingMethod", "barRole", "colorTheme", "tooltipVariant", "xAxisVariant", "xAxisPlacement", "xAxisTickFormat", "xAxisTickPadding", "xAxisTickRotation", "xAxisTickSize", "xAxisTickValues", "yAxisVariant", "yAxisPlacement", "yAxisTickFormat", "yAxisTickPadding", "yAxisTickRotation", "yAxisTickSize", "yAxisTickValues"];
1546
+ const _excluded$i = ["areXLabelsRotated", "barProps", "caping", "className", "data", "id", "isBarSelected", "getBarAnchorProps", "labelDecorator", "margins", "onBarClick", "orientation", "others", "size", "sortingMethod", "barRole", "colorTheme", "tooltipVariant", "xAxisVariant", "xAxisPlacement", "xAxisTickFormat", "xAxisTickPadding", "xAxisTickRotation", "xAxisTickSize", "xAxisTickValues", "yAxisVariant", "yAxisPlacement", "yAxisTickFormat", "yAxisTickPadding", "yAxisTickRotation", "yAxisTickSize", "yAxisTickValues"];
1451
1547
  const RenderedOrdinalBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1452
1548
  const {
1453
1549
  areXLabelsRotated,
@@ -1457,6 +1553,7 @@ const RenderedOrdinalBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1457
1553
  data: propsData,
1458
1554
  id,
1459
1555
  isBarSelected,
1556
+ getBarAnchorProps,
1460
1557
  labelDecorator,
1461
1558
  margins: propsMargins,
1462
1559
  onBarClick,
@@ -1525,7 +1622,23 @@ const RenderedOrdinalBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1525
1622
  return value;
1526
1623
  }))]).range(isHorizontal ? [0, chartWidth] : [chartHeight, 0]), [size]);
1527
1624
  const scaleCategory = useMemo(() => scaleBand().domain(data.filter(datum => datum.value).map(datum => datum.key)).range([0, isHorizontal ? chartHeight : chartWidth]), [size]);
1528
- return /*#__PURE__*/React__default.createElement(StyledBarChart, _extends({}, forwardedProps, {
1625
+ const bars = data.filter(datum => datum.value);
1626
+ return /*#__PURE__*/React__default.createElement(StyledBarChart, _extends({
1627
+ mode: typeof onBarClick === 'function' || typeof getBarAnchorProps === 'function' ? 'interactive' : 'static',
1628
+ definition: `Bar Chart with ${bars.length} bars.`,
1629
+ dataTableRepresentation: {
1630
+ header: /*#__PURE__*/React__default.createElement("thead", null, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("th", {
1631
+ scope: "col"
1632
+ }, "Key"), /*#__PURE__*/React__default.createElement("th", {
1633
+ scope: "col"
1634
+ }, "Value"))),
1635
+ body: /*#__PURE__*/React__default.createElement("tbody", null, bars.map(datum => /*#__PURE__*/React__default.createElement("tr", {
1636
+ key: datum.key
1637
+ }, /*#__PURE__*/React__default.createElement("th", {
1638
+ scope: "row"
1639
+ }, datum.key), /*#__PURE__*/React__default.createElement("td", null, datum.value))))
1640
+ }
1641
+ }, forwardedProps, {
1529
1642
  id: id,
1530
1643
  className: className,
1531
1644
  ref: ref
@@ -1584,7 +1697,7 @@ const RenderedOrdinalBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1584
1697
  variant: yAxisVariant
1585
1698
  }) : null), /*#__PURE__*/React__default.createElement("g", {
1586
1699
  transform: `translate(${margins.left},${margins.top})`
1587
- }, data.filter(datum => datum.value).map((datum, index) => {
1700
+ }, bars.map((datum, index) => {
1588
1701
  const percent = datum.value / total;
1589
1702
  const to = {
1590
1703
  data: _objectSpread2(_objectSpread2({}, datum), {}, {
@@ -1594,25 +1707,27 @@ const RenderedOrdinalBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1594
1707
  const from = cache.current ? {
1595
1708
  data: cache.current[index]
1596
1709
  } : undefined;
1597
- return /*#__PURE__*/React__default.createElement(Bar, _extends({}, barProps, {
1710
+ return /*#__PURE__*/React__default.createElement(Bar, _extends({
1598
1711
  color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(to.data.key),
1599
1712
  data: to,
1600
1713
  gap: gap,
1601
- height: isHorizontal ? barHeight : undefined,
1602
1714
  id: `id${id}__bar-${index}`,
1603
1715
  index: index,
1604
1716
  isSelected: Boolean(isBarSelected(to)),
1605
1717
  key: `bar _${index}`,
1606
1718
  labelDecorator: labelDecorator,
1607
- maxHeight: isHorizontal ? undefined : chartHeight,
1719
+ maxHeight: isHorizontal ? undefined : chartHeight
1720
+ }, getBarAnchorProps ? getBarAnchorProps(to) : {}, {
1608
1721
  onClick: onBarClick,
1609
1722
  orientation: orientation,
1610
1723
  previousData: from,
1611
- role: barRole,
1612
1724
  scale: scale,
1613
1725
  scalePosition: scaleCategory,
1614
- tooltipVariant: tooltipVariant,
1615
- width: isHorizontal ? undefined : barWidth
1726
+ tooltipVariant: tooltipVariant
1727
+ }, barProps, {
1728
+ width: isHorizontal ? undefined : barProps !== null && barProps !== void 0 && barProps.width && typeof barProps.width === 'number' ? barProps.width : barWidth,
1729
+ height: isHorizontal ? barProps !== null && barProps !== void 0 && barProps.height && typeof barProps.height === 'number' ? barProps.height : barHeight : undefined,
1730
+ role: barRole
1616
1731
  }));
1617
1732
  }))));
1618
1733
  });
@@ -1830,7 +1945,7 @@ Legend.className = CLASSNAME$6;
1830
1945
  Legend.defaultProps = DEFAULT_PROPS$6;
1831
1946
  Legend.displayName = COMPONENT_NAME$6;
1832
1947
 
1833
- const _excluded$f = ["barProps", "className", "data", "id", "isBarSelected", "labelDecorator", "legendDecorator", "legendVariant", "legendProps", "margins", "onBarClick", "size", "sortingMethod", "barRole", "colorTheme", "tooltipVariant", "xAxisVariant", "xAxisPlacement", "xAxisTickFormat", "xAxisTickPadding", "xAxisTickRotation", "xAxisTickSize", "xAxisTickValues", "xAxisMinValue", "xAxisMaxValue", "xAxisTickRemodelling", "yAxisVariant", "yAxisPlacement", "yAxisTickFormat", "yAxisTickPadding", "yAxisTickRotation", "yAxisTickSize", "yAxisTickValues", "yAxisMinValue", "yAxisMaxValue", "yAxisTickRemodelling", "xScaleType", "dateParser"];
1948
+ const _excluded$f = ["barProps", "className", "data", "id", "getBarAnchorProps", "isBarSelected", "labelDecorator", "legendDecorator", "legendVariant", "legendProps", "margins", "onBarClick", "size", "sortingMethod", "barRole", "colorTheme", "tooltipVariant", "xAxisVariant", "xAxisPlacement", "xAxisTickFormat", "xAxisTickPadding", "xAxisTickRotation", "xAxisTickSize", "xAxisTickValues", "xAxisMinValue", "xAxisMaxValue", "xAxisTickRemodelling", "yAxisVariant", "yAxisPlacement", "yAxisTickFormat", "yAxisTickPadding", "yAxisTickRotation", "yAxisTickSize", "yAxisTickValues", "yAxisMinValue", "yAxisMaxValue", "yAxisTickRemodelling", "xScaleType", "dateParser"];
1834
1949
  const getKey = datum => Array.isArray(datum.key) ? datum.key[0] : datum.key;
1835
1950
  const filterData = (hasCategory, data, filterFn) => {
1836
1951
  if (hasCategory) {
@@ -1851,6 +1966,7 @@ const RenderedLinearBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1851
1966
  className,
1852
1967
  data: propsData,
1853
1968
  id,
1969
+ getBarAnchorProps,
1854
1970
  isBarSelected,
1855
1971
  labelDecorator,
1856
1972
  legendDecorator,
@@ -1909,9 +2025,9 @@ const RenderedLinearBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1909
2025
  }, propsMargins);
1910
2026
  const chartHeight = height - margins.top - margins.bottom;
1911
2027
  const chartWidth = width - margins.left - margins.right;
1912
- const numberOfRows = filterData(hasCategory, data, datum => datum.value).length;
2028
+ const numberOfBars = filterData(hasCategory, data, datum => datum.value).length;
1913
2029
  const gap = 5;
1914
- let barWidth = chartWidth / (numberOfRows * 2) - gap;
2030
+ let barWidth = chartWidth / (numberOfBars * 2) - gap;
1915
2031
  const scaleX = (() => {
1916
2032
  if (xScaleType === 'number') {
1917
2033
  var _ref, _ref2;
@@ -1928,7 +2044,7 @@ const RenderedLinearBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1928
2044
  domain[0] = (_ref3 = xAxisMinValue) !== null && _ref3 !== void 0 ? _ref3 : domain[0];
1929
2045
  domain[1] = (_ref4 = xAxisMaxValue) !== null && _ref4 !== void 0 ? _ref4 : domain[1];
1930
2046
  const startDate = xAxisTickValues && typeof xAxisTickValues === 'function' && typeof xAxisTickValues.offset === 'function' ? xAxisTickValues.offset(new Date(domain[0]), -1) : new Date(domain[0]);
1931
- const endDate = xAxisTickValues && typeof xAxisTickValues === 'function' && typeof xAxisTickValues.offset === 'function' ? xAxisTickValues.offset(new Date(domain[1]), 0) : new Date(domain[1]);
2047
+ const endDate = xAxisTickValues && typeof xAxisTickValues === 'function' && typeof xAxisTickValues.offset === 'function' ? xAxisTickValues.offset(new Date(domain[1]), 1) : new Date(domain[1]);
1932
2048
  return scaleTime().domain([startDate, endDate]).range([0, chartWidth]).nice();
1933
2049
  } else {
1934
2050
  var _ref5, _ref6;
@@ -1996,7 +2112,63 @@ const RenderedLinearBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1996
2112
  const minimalGap = Math.min(...bars.map((bar, i) => i > 0 ? Math.abs(bar.key - bars[i - 1].key) : undefined).filter(k => k)) * 0.9;
1997
2113
  barWidth = Math.min(barWidth, chartWidth / ((scaleX.domain()[1] - scaleX.domain()[0]) / minimalGap), chartWidth / (xAxisTickValues && typeof xAxisTickValues !== 'string' ? typeof xAxisTickValues === 'number' ? xAxisTickValues : Array.isArray(xAxisTickValues) ? xAxisTickValues.length : xAxisTickValues.range(scaleX.domain()[0], scaleX.domain()[1]).length : 1));
1998
2114
  }
1999
- return /*#__PURE__*/React__default.createElement(StyledBarChart, _extends({}, forwardedProps, {
2115
+ const categories = [];
2116
+ const pivotedTable = bars.reduce((acc, item) => {
2117
+ const {
2118
+ key,
2119
+ category,
2120
+ value
2121
+ } = item;
2122
+ if (!categories.includes(category)) {
2123
+ categories.push(category);
2124
+ }
2125
+ const formattedKey = xAxisTickFormat ? xAxisTickFormat(key) : key.toString();
2126
+ let entry = acc.find(e => e.key === formattedKey);
2127
+ if (!entry) {
2128
+ entry = {
2129
+ key: formattedKey
2130
+ };
2131
+ acc.push(entry);
2132
+ }
2133
+ entry[category] = value;
2134
+ return acc;
2135
+ }, []);
2136
+ return /*#__PURE__*/React__default.createElement(StyledBarChart, _extends({
2137
+ mode: typeof onBarClick === 'function' || typeof getBarAnchorProps === 'function' ? 'interactive' : 'static',
2138
+ definition: `Bar Chart with ${bars.length} bars.`,
2139
+ xAxisDefinition: `The chart has 1 X axis displaying ${xScaleType === 'number' ? 'Numbers' : 'Dates'} from ${xScaleType === 'number' ? scaleX.domain()[0] : xAxisTickFormat ? xAxisTickFormat(scaleX.domain()[0]) : scaleX.domain()[0].toString()} to ${xScaleType === 'number' ? scaleX.domain()[1] : xAxisTickFormat ? xAxisTickFormat(scaleX.domain()[1]) : scaleX.domain()[1].toString()}.`,
2140
+ yAxisDefinition: `The chart has 1 Y axis displaying numbers from ${scaleY.domain()[0]} to ${scaleY.domain()[1]}.`,
2141
+ dataTableRepresentation: hasCategory ? {
2142
+ header: /*#__PURE__*/React__default.createElement("thead", null, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("th", {
2143
+ scope: "col"
2144
+ }, xScaleType === 'Date' || xScaleType === 'dateString' ? 'Date' : 'Key'), categories.map(category => /*#__PURE__*/React__default.createElement("th", {
2145
+ key: category,
2146
+ scope: "col"
2147
+ }, category)))),
2148
+ body: /*#__PURE__*/React__default.createElement("tbody", null, pivotedTable.map(row => /*#__PURE__*/React__default.createElement("tr", {
2149
+ key: row.key
2150
+ }, /*#__PURE__*/React__default.createElement("th", {
2151
+ scope: "row"
2152
+ }, row.key), categories.map(category => /*#__PURE__*/React__default.createElement("th", {
2153
+ key: `${row.key}-${category}-${row[category]}`,
2154
+ scope: "col"
2155
+ }, row[category])))))
2156
+ } : {
2157
+ header: /*#__PURE__*/React__default.createElement("thead", null, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("th", {
2158
+ scope: "col"
2159
+ }, xScaleType === 'Date' || xScaleType === 'dateString' ? 'Date' : 'Key'), /*#__PURE__*/React__default.createElement("th", {
2160
+ scope: "col"
2161
+ }, "Value"))),
2162
+ body: /*#__PURE__*/React__default.createElement("tbody", null, bars.map(datum => {
2163
+ const key = xAxisTickFormat ? xAxisTickFormat(datum.key) : datum.key.toString();
2164
+ return /*#__PURE__*/React__default.createElement("tr", {
2165
+ key: key
2166
+ }, /*#__PURE__*/React__default.createElement("th", {
2167
+ scope: "row"
2168
+ }, key), /*#__PURE__*/React__default.createElement("td", null, datum.value));
2169
+ }))
2170
+ }
2171
+ }, forwardedProps, {
2000
2172
  id: id,
2001
2173
  className: className,
2002
2174
  ref: ref
@@ -2007,9 +2179,12 @@ const RenderedLinearBarChart = /*#__PURE__*/forwardRef((props, ref) => {
2007
2179
  }, /*#__PURE__*/React__default.createElement("svg", {
2008
2180
  ref: svgRef,
2009
2181
  width: width,
2010
- height: height
2182
+ height: height,
2183
+ "aria-label": "Interactive Bar Chart",
2184
+ "aria-hidden": "false"
2011
2185
  }, /*#__PURE__*/React__default.createElement("g", {
2012
- transform: `translate(${margins.left},${margins.top})`
2186
+ transform: `translate(${margins.left},${margins.top})`,
2187
+ "aria-hidden": "false"
2013
2188
  }, bars.map((bar, index) => {
2014
2189
  const to = {
2015
2190
  data: bar
@@ -2017,25 +2192,27 @@ const RenderedLinearBarChart = /*#__PURE__*/forwardRef((props, ref) => {
2017
2192
  const from = cache.current ? {
2018
2193
  data: cache.current[index]
2019
2194
  } : undefined;
2020
- return /*#__PURE__*/React__default.createElement(Bar, _extends({}, barProps, {
2195
+ return /*#__PURE__*/React__default.createElement(Bar, _extends({
2021
2196
  color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(to.data.category),
2022
2197
  data: to,
2023
2198
  gap: gap,
2024
- height: undefined,
2025
2199
  id: `id${id}__bar-${index}`,
2026
2200
  index: index,
2027
2201
  isSelected: Boolean(isBarSelected(to)),
2028
2202
  key: `bar _${index}`,
2029
2203
  labelDecorator: labelDecorator,
2030
- maxHeight: scaleY(bar.cumulativeValue - bar.value),
2204
+ maxHeight: scaleY(bar.cumulativeValue - bar.value)
2205
+ }, getBarAnchorProps ? getBarAnchorProps(to) : {}, {
2031
2206
  onClick: onBarClick,
2032
2207
  orientation: BarOrientation.vertical,
2033
2208
  previousData: from,
2034
- role: barRole,
2035
2209
  scale: scaleY,
2036
2210
  scalePosition: scaleX,
2037
- tooltipVariant: tooltipVariant,
2038
- width: barWidth
2211
+ tooltipVariant: tooltipVariant
2212
+ }, barProps, {
2213
+ width: barProps !== null && barProps !== void 0 && barProps.width && typeof barProps.width === 'number' ? barProps.width : barWidth,
2214
+ height: undefined,
2215
+ role: barRole
2039
2216
  }));
2040
2217
  }), ['bottom', 'both'].includes(xAxisPlacement) ? /*#__PURE__*/React__default.createElement(Axis, {
2041
2218
  position: "bottom",
@@ -3168,12 +3345,13 @@ const EmptyPieChart = /*#__PURE__*/forwardRef((props, ref) => {
3168
3345
  }))));
3169
3346
  });
3170
3347
 
3171
- const _excluded$5 = ["caping", "className", "data", "id", "isHalf", "isSliceSelected", "labelDecorator", "legendDecorator", "legendVariant", "legendProps", "middleText", "onSliceClick", "others", "size", "sliceProps", "sliceRole", "sortingMethod", "subtext", "text", "colorTheme", "tooltipVariant", "variant"];
3348
+ const _excluded$5 = ["caping", "className", "data", "getSliceAnchorProps", "id", "isHalf", "isSliceSelected", "labelDecorator", "legendDecorator", "legendVariant", "legendProps", "middleText", "onSliceClick", "others", "size", "sliceProps", "sliceRole", "sortingMethod", "subtext", "text", "colorTheme", "tooltipVariant", "variant"];
3172
3349
  const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
3173
3350
  const {
3174
3351
  caping,
3175
3352
  className,
3176
3353
  data: propsData,
3354
+ getSliceAnchorProps,
3177
3355
  id,
3178
3356
  isHalf,
3179
3357
  isSliceSelected,
@@ -3254,7 +3432,23 @@ const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
3254
3432
  })
3255
3433
  });
3256
3434
  }), total) : propsMiddleText;
3257
- return /*#__PURE__*/React__default.createElement(StyledPieChart, _extends({}, forwardedProps, {
3435
+ const filteredPieData = pieData.filter(datum => datum.data.value);
3436
+ return /*#__PURE__*/React__default.createElement(StyledPieChart, _extends({
3437
+ mode: typeof onSliceClick === 'function' || typeof getSliceAnchorProps === 'function' ? 'interactive' : 'static',
3438
+ definition: `Pie Chart with ${filteredPieData.length} slices.`,
3439
+ dataTableRepresentation: {
3440
+ header: /*#__PURE__*/React__default.createElement("thead", null, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("th", {
3441
+ scope: "col"
3442
+ }, "Key"), /*#__PURE__*/React__default.createElement("th", {
3443
+ scope: "col"
3444
+ }, "Value"))),
3445
+ body: /*#__PURE__*/React__default.createElement("tbody", null, filteredPieData.map(datum => /*#__PURE__*/React__default.createElement("tr", {
3446
+ key: datum.data.key
3447
+ }, /*#__PURE__*/React__default.createElement("th", {
3448
+ scope: "row"
3449
+ }, datum.data.key), /*#__PURE__*/React__default.createElement("td", null, datum.data.value))))
3450
+ }
3451
+ }, forwardedProps, {
3258
3452
  className: className,
3259
3453
  id: id,
3260
3454
  ref: ref
@@ -3269,7 +3463,7 @@ const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
3269
3463
  width: width,
3270
3464
  height: isHalf ? height + externalRadiusPadding : height
3271
3465
  }, /*#__PURE__*/React__default.createElement(Arcs, {
3272
- arcs: pieData.filter(datum => datum.data.value).map((datum, index) => {
3466
+ arcs: filteredPieData.map((datum, index) => {
3273
3467
  const percent = datum.data.value / total;
3274
3468
  const from = previousPieData ? previousPieData[index] : {
3275
3469
  data: {
@@ -3287,7 +3481,7 @@ const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
3287
3481
  percent
3288
3482
  })
3289
3483
  });
3290
- return {
3484
+ return _objectSpread2({
3291
3485
  color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(to.data.key),
3292
3486
  createArc,
3293
3487
  previousData: from,
@@ -3296,7 +3490,7 @@ const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
3296
3490
  isSelected: isSliceSelected(to),
3297
3491
  key: `id${id}__bar-${index}`,
3298
3492
  data: to
3299
- };
3493
+ }, getSliceAnchorProps ? getSliceAnchorProps(to) : {});
3300
3494
  }),
3301
3495
  hasLabels: legendVariant === PieChartLegendVariant.internal,
3302
3496
  hasStroke: isSpaced,