@redsift/charts 10.3.0-alpha.7 → 10.3.0-alpha.9

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.
Files changed (4) hide show
  1. package/index.d.ts +36 -27
  2. package/index.js +469 -112
  3. package/index.js.map +1 -1
  4. package/package.json +2 -2
package/index.js CHANGED
@@ -362,13 +362,17 @@ 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", "href", "id", "index", "isSelected", "labelDecorator", "onClick", "role", "tooltipDecorator", "tooltipVariant", "theme"];
365
+ const _excluded$q = ["as", "href"],
366
+ _excluded2$5 = ["anchorProps", "children", "className", "data", "id", "index", "isSelected", "labelDecorator", "onClick", "role", "tooltipDecorator", "tooltipVariant", "theme"];
366
367
  const DataPoint = /*#__PURE__*/forwardRef((props, ref) => {
367
368
  const {
369
+ anchorProps: {
370
+ as,
371
+ href
372
+ } = {},
368
373
  children,
369
374
  className,
370
375
  data,
371
- href,
372
376
  id: propsId,
373
377
  index,
374
378
  isSelected: propsIsSelected,
@@ -379,7 +383,8 @@ const DataPoint = /*#__PURE__*/forwardRef((props, ref) => {
379
383
  tooltipVariant,
380
384
  theme: propsTheme
381
385
  } = props,
382
- forwardedProps = _objectWithoutProperties(props, _excluded$q);
386
+ anchorProps = _objectWithoutProperties(props.anchorProps, _excluded$q),
387
+ forwardedProps = _objectWithoutProperties(props, _excluded2$5);
383
388
  const [_id] = useId();
384
389
  const id = propsId !== null && propsId !== void 0 ? propsId : _id;
385
390
  const theme = useTheme(propsTheme);
@@ -406,9 +411,12 @@ const DataPoint = /*#__PURE__*/forwardRef((props, ref) => {
406
411
  }
407
412
  }
408
413
  };
414
+ if (data.data.key === 'Line Chart') {
415
+ console.log(showTooltip, isEmpty, text);
416
+ }
409
417
  const DataPointComponent = /*#__PURE__*/React__default.createElement(StyledDataPoint, _extends({
410
418
  tabIndex: onClick ? 0 : undefined,
411
- "aria-label": showTooltip && !isEmpty ? text : undefined,
419
+ "aria-label": showTooltip && !isEmpty ? labelDecorator ? text : `${data.data.key}, ${data.data.value}` : undefined,
412
420
  "aria-labelledby": !showTooltip && !isEmpty ? `${id}-title` : undefined,
413
421
  "aria-selected": isSelected ? true : isDeselected ? false : undefined,
414
422
  onClick: onClick ? () => onClick(data) : undefined,
@@ -429,9 +437,9 @@ const DataPoint = /*#__PURE__*/forwardRef((props, ref) => {
429
437
  return /*#__PURE__*/React__default.createElement(Tooltip, {
430
438
  placement: "right",
431
439
  theme: theme
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, {
440
+ }, /*#__PURE__*/React__default.createElement(Tooltip.Trigger, null, href !== undefined ? /*#__PURE__*/React__default.createElement(as || 'a', _objectSpread2({
441
+ href
442
+ }, anchorProps), DataPointComponent) : DataPointComponent), /*#__PURE__*/React__default.createElement(Tooltip.Content, null, isTooltipCustom ? tooltipDecorator(data, {
435
443
  index,
436
444
  isSelected: propsIsSelected,
437
445
  color: props.color
@@ -1086,9 +1094,7 @@ const Bar = /*#__PURE__*/forwardRef((props, ref) => {
1086
1094
  t: 0
1087
1095
  }
1088
1096
  }));
1089
- return /*#__PURE__*/React__default.createElement(StyledBar, _extends({
1090
- "aria-hidden": "false"
1091
- }, forwardedProps, {
1097
+ return /*#__PURE__*/React__default.createElement(StyledBar, _extends({}, forwardedProps, {
1092
1098
  ref: ref,
1093
1099
  className: classNames(Bar.className, className),
1094
1100
  transform: isHorizontal ? `translate(0, ${scalePosition(data.data.key) + gap / 2})` : `translate(${scalePosition(data.data.key) + (isOrdinal ? width + gap / 2 : width / 2)}, ${maxHeight}), rotate(180)`,
@@ -1128,7 +1134,7 @@ const BarChartLegendVariant = {
1128
1134
  */
1129
1135
 
1130
1136
  var reset$1 = "Reset";
1131
- var enUS = {
1137
+ var enUS$4 = {
1132
1138
  "static-chart": "Static chart.",
1133
1139
  "interactive-chart": "Interactive chart.",
1134
1140
  "view-as-data-table": "View as data table",
@@ -1137,7 +1143,7 @@ var enUS = {
1137
1143
  };
1138
1144
 
1139
1145
  var reset = "Réinitialiser";
1140
- var frFR = {
1146
+ var frFR$4 = {
1141
1147
  "static-chart": "Graphique statique.",
1142
1148
  "interactive-chart": "Graphique intéractif.",
1143
1149
  "view-as-data-table": "Voir au format table de données",
@@ -1145,9 +1151,9 @@ var frFR = {
1145
1151
  reset: reset
1146
1152
  };
1147
1153
 
1148
- var intlMessages = {
1149
- 'en-US': enUS,
1150
- 'fr-FR': frFR
1154
+ var intlMessages$4 = {
1155
+ 'en-US': enUS$4,
1156
+ 'fr-FR': frFR$4
1151
1157
  };
1152
1158
 
1153
1159
  /**
@@ -1251,7 +1257,7 @@ const ChartContainer = /*#__PURE__*/forwardRef((props, ref) => {
1251
1257
  const theme = useTheme(propsTheme);
1252
1258
  const [viewAsDataTable, setViewAsDataTable] = useState(false);
1253
1259
  warnIfNoAccessibleLabelFound(props, [title]);
1254
- const format = useMessageFormatter(intlMessages);
1260
+ const format = useMessageFormatter(intlMessages$4);
1255
1261
  const ariaLabel = propsAriaLabel ? propsAriaLabel : propsAriaLabelledby || title ? undefined : undefined;
1256
1262
  const ariaLabelledby = propsAriaLabelledby ? propsAriaLabelledby : title ? `id${id}__title` : undefined;
1257
1263
  return /*#__PURE__*/React__default.createElement(ThemeProvider, {
@@ -1263,7 +1269,7 @@ const ChartContainer = /*#__PURE__*/forwardRef((props, ref) => {
1263
1269
  role: "region",
1264
1270
  "aria-hidden": "false"
1265
1271
  }, ariaLabel ? {
1266
- 'aria-label': `${ariaLabel}. ${format(`${mode}-chart`)}`
1272
+ 'aria-label': `${ariaLabel}. ${mode}`
1267
1273
  } : {}, ariaLabelledby ? {
1268
1274
  'aria-labelledby': `${ariaLabelledby} id${id}__interactive-or-not`
1269
1275
  } : {}, forwardedProps, {
@@ -1294,15 +1300,15 @@ const ChartContainer = /*#__PURE__*/forwardRef((props, ref) => {
1294
1300
  style: {
1295
1301
  display: 'none'
1296
1302
  }
1297
- }, format(`${mode}-chart`)), ariaLabel ? /*#__PURE__*/React__default.createElement("p", null, `${ariaLabel}. ${format(`${mode}-chart`)}`) : /*#__PURE__*/React__default.createElement("p", {
1303
+ }, mode), ariaLabel ? /*#__PURE__*/React__default.createElement("p", null, `${ariaLabel}. ${mode}`) : /*#__PURE__*/React__default.createElement("p", {
1298
1304
  "aria-labelledby": `${ariaLabelledby} id${id}__interactive-or-not`
1299
- }), /*#__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", {
1305
+ }), /*#__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), dataTableRepresentation ? /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("button", {
1300
1306
  tabIndex: -1,
1301
1307
  "aria-expanded": viewAsDataTable,
1302
1308
  onClick: () => setViewAsDataTable(!viewAsDataTable)
1303
1309
  }, format('view-as-data-table'), ', ', ariaLabel ? /*#__PURE__*/React__default.createElement("span", null, ariaLabel) : /*#__PURE__*/React__default.createElement("span", {
1304
1310
  "aria-labelledby": ariaLabelledby
1305
- }))), /*#__PURE__*/React__default.createElement("div", null, xAxisDefinition), /*#__PURE__*/React__default.createElement("div", null, yAxisDefinition))), title || onReset ? /*#__PURE__*/React__default.createElement(StyledChartContainerTitle, {
1311
+ }))) : null, /*#__PURE__*/React__default.createElement("div", null, xAxisDefinition), /*#__PURE__*/React__default.createElement("div", null, yAxisDefinition))), title || onReset ? /*#__PURE__*/React__default.createElement(StyledChartContainerTitle, {
1306
1312
  "aria-hidden": "true",
1307
1313
  $theme: theme,
1308
1314
  alignItems: "center",
@@ -1509,6 +1515,47 @@ const LoadingBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1509
1515
  }), "Loading...");
1510
1516
  });
1511
1517
 
1518
+ var interactive$7 = "interactive";
1519
+ var enUS$3 = {
1520
+ interactive: interactive$7,
1521
+ "static": "static",
1522
+ "interactive-chart": "Interactive Bar Chart",
1523
+ "static-chart": "Static Bar Chart",
1524
+ "definition-linear": "Linear Bar Chart with {barLength} bars.",
1525
+ "definition-linear-with-categories": "Linear Bar Chart with {categoryLength} categories and {barLength} bars.",
1526
+ "definition-ordinal": "Ordinal Bar Chart with {barLength} bars.",
1527
+ "x-axis-numbers-definition": "The chart has {numAxis, plural, =0 {0 X axis} =1 {1 X axis} other {# X axes}} displaying numbers from {start, number} to {end, number}.",
1528
+ "y-axis-numbers-definition": "The chart has {numAxis, plural, =0 {0 Y axis} =1 {1 Y axis} other {# Y axes}} displaying numbers from {start, number} to {end, number}.",
1529
+ "x-axis-dates-definition": "The chart has {numAxis, plural, =0 {0 X axis} =1 {1 X axis} other {# X axes}} displaying dates from {start, date, ::yyyyMMdd} to {end, date, ::yyyyMMdd}.",
1530
+ "y-axis-dates-definition": "The chart has {numAxis, plural, =0 {0 Y axis} =1 {1 Y axis} other {# Y axes}} displaying dates from {start, date, ::yyyyMMdd} to {end, date, ::yyyyMMdd}.",
1531
+ "x-axis-categories-definition": "The chart has {numAxis, plural, =0 {0 X axis} =1 {1 X axis} other {# X axes}} displaying categories.",
1532
+ "y-axis-categories-definition": "The chart has {numAxis, plural, =0 {0 Y axis} =1 {1 Y axis} other {# Y axes}} displaying categories.",
1533
+ "series-legend": "{category}, category {categoryIndex} of {categoryLength} with {barLength} bars"
1534
+ };
1535
+
1536
+ var interactive$6 = "interactif";
1537
+ var frFR$3 = {
1538
+ interactive: interactive$6,
1539
+ "static": "statique",
1540
+ "interactive-chart": "Diagrammes à bandes interactif",
1541
+ "static-chart": "Diagrammes à bandes statique",
1542
+ "definition-linear": "Diagrammes à bandes contenant {barLength} bandes réparties sur un axe linéraire.",
1543
+ "definition-linear-with-categories": "Diagrammes à bandes contenant {categoryLength} catégories et {barLength} bandes réparties sur un axe linéraire.",
1544
+ "definition-ordinal": "Diagrammes à bandes contenant {barLength} bandes.",
1545
+ "x-axis-numbers-definition": "Le graphique a {numAxis, plural, =0 {0 axe X} =1 {1 axe X} other {# axes X}} affichant des nombres allant de {start, number} à {end, number}.",
1546
+ "y-axis-numbers-definition": "Le graphique a {numAxis, plural, =0 {0 axe Y} =1 {1 axe Y} other {# axes Y}} affichant des nombres allant de {start, number} à {end, number}.",
1547
+ "x-axis-dates-definition": "Le graphique a {numAxis, plural, =0 {0 axe X} =1 {1 axe X} other {# axes X}} affichant des dates allant de {start, date, ::yyyyMMdd} à {end, date, ::yyyyMMdd}.",
1548
+ "y-axis-dates-definition": "Le graphique a {numAxis, plural, =0 {0 axe Y} =1 {1 axe Y} other {# axes Y}} affichant des dates allant de {start, date, ::yyyyMMdd} à {end, date, ::yyyyMMdd}.",
1549
+ "x-axis-categories-definition": "Le graphique a {numAxis, plural, =0 {0 axe X} =1 {1 axe X} other {# axes X}} affichant des categories.",
1550
+ "y-axis-categories-definition": "Le graphique a {numAxis, plural, =0 {0 axe Y} =1 {1 axe Y} other {# axes Y}} affichant des categories.",
1551
+ "series-legend": "{category}, catégorie {categoryIndex} sur {categoryLength} contenant {barLength} bandes"
1552
+ };
1553
+
1554
+ var intlMessages$3 = {
1555
+ 'en-US': enUS$3,
1556
+ 'fr-FR': frFR$3
1557
+ };
1558
+
1512
1559
  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"];
1513
1560
  const RenderedOrdinalBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1514
1561
  const {
@@ -1548,6 +1595,7 @@ const RenderedOrdinalBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1548
1595
  forwardedProps = _objectWithoutProperties(props, _excluded$i);
1549
1596
  const cache = useRef();
1550
1597
  const theme = useTheme();
1598
+ const format = useMessageFormatter(intlMessages$3);
1551
1599
  const {
1552
1600
  data,
1553
1601
  colorScale
@@ -1590,8 +1638,24 @@ const RenderedOrdinalBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1590
1638
  const scaleCategory = useMemo(() => scaleBand().domain(data.filter(datum => datum.value).map(datum => datum.key)).range([0, isHorizontal ? chartHeight : chartWidth]), [size]);
1591
1639
  const bars = data.filter(datum => datum.value);
1592
1640
  return /*#__PURE__*/React__default.createElement(StyledBarChart, _extends({
1593
- mode: typeof onBarClick === 'function' || typeof getBarAnchorProps === 'function' ? 'interactive' : 'static',
1594
- definition: `Bar Chart with ${bars.length} bars.`,
1641
+ mode: typeof onBarClick === 'function' || typeof getBarAnchorProps === 'function' ? format('interactive') : format('static'),
1642
+ definition: format('definition-ordinal', {
1643
+ barLength: bars.length
1644
+ }),
1645
+ xAxisDefinition: isHorizontal ? format('x-axis-numbers-definition', {
1646
+ numAxis: xAxisPlacement === 'both' ? 2 : 1,
1647
+ start: scale.domain()[0],
1648
+ end: scale.domain()[1]
1649
+ }) : format('x-axis-categories-definition', {
1650
+ numAxis: xAxisPlacement === 'both' ? 2 : 1
1651
+ }),
1652
+ yAxisDefinition: isHorizontal ? format('y-axis-categories-definition', {
1653
+ numAxis: yAxisPlacement === 'both' ? 2 : 1
1654
+ }) : format('y-axis-numbers-definition', {
1655
+ numAxis: yAxisPlacement === 'both' ? 2 : 1,
1656
+ start: scale.domain()[0],
1657
+ end: scale.domain()[1]
1658
+ }),
1595
1659
  dataTableRepresentation: {
1596
1660
  header: /*#__PURE__*/React__default.createElement("thead", null, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("th", {
1597
1661
  scope: "col"
@@ -1610,7 +1674,9 @@ const RenderedOrdinalBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1610
1674
  ref: ref
1611
1675
  }), /*#__PURE__*/React__default.createElement("svg", {
1612
1676
  width: width,
1613
- height: height
1677
+ height: height,
1678
+ "aria-label": typeof onBarClick === 'function' || typeof getBarAnchorProps === 'function' ? format('interactive-chart') : format('static-chart'),
1679
+ "aria-hidden": "false"
1614
1680
  }, /*#__PURE__*/React__default.createElement("g", {
1615
1681
  transform: `translate(${margins.left},${margins.top})`
1616
1682
  }, ['bottom', 'both'].includes(xAxisPlacement) ? /*#__PURE__*/React__default.createElement(Axis, {
@@ -1682,8 +1748,8 @@ const RenderedOrdinalBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1682
1748
  isSelected: Boolean(isBarSelected(to)),
1683
1749
  key: `bar _${index}`,
1684
1750
  labelDecorator: labelDecorator,
1685
- maxHeight: isHorizontal ? undefined : chartHeight
1686
- }, getBarAnchorProps ? getBarAnchorProps(to) : {}, {
1751
+ maxHeight: isHorizontal ? undefined : chartHeight,
1752
+ anchorProps: getBarAnchorProps ? getBarAnchorProps(to) : undefined,
1687
1753
  onClick: onBarClick,
1688
1754
  orientation: orientation,
1689
1755
  previousData: from,
@@ -1851,7 +1917,7 @@ LegendItem.className = CLASSNAME$7;
1851
1917
  LegendItem.displayName = COMPONENT_NAME$7;
1852
1918
 
1853
1919
  const _excluded$g = ["className", "data", "isLegendItemSelected", "labelDecorator", "legendDecorator", "legendItemRole", "onLegendItemClick", "variant", "width"],
1854
- _excluded2 = ["color"];
1920
+ _excluded2$4 = ["color"];
1855
1921
  const COMPONENT_NAME$6 = 'Legend';
1856
1922
  const CLASSNAME$6 = 'redsift-chart-legend';
1857
1923
  const Legend = /*#__PURE__*/forwardRef((props, ref) => {
@@ -1877,7 +1943,7 @@ const Legend = /*#__PURE__*/forwardRef((props, ref) => {
1877
1943
  let {
1878
1944
  color
1879
1945
  } = _ref,
1880
- datum = _objectWithoutProperties(_ref, _excluded2);
1946
+ datum = _objectWithoutProperties(_ref, _excluded2$4);
1881
1947
  return /*#__PURE__*/React__default.createElement(LegendItem, {
1882
1948
  data: {
1883
1949
  data: _objectSpread2(_objectSpread2({}, datum), {}, {
@@ -1901,7 +1967,8 @@ const Legend = /*#__PURE__*/forwardRef((props, ref) => {
1901
1967
  Legend.className = CLASSNAME$6;
1902
1968
  Legend.displayName = COMPONENT_NAME$6;
1903
1969
 
1904
- 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"];
1970
+ 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"],
1971
+ _excluded2$3 = ["extraLegendItems"];
1905
1972
  const getKey = datum => Array.isArray(datum.key) ? datum.key[0] : datum.key;
1906
1973
  const filterData = (hasCategory, data, filterFn) => {
1907
1974
  if (hasCategory) {
@@ -1961,6 +2028,7 @@ const RenderedLinearBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1961
2028
  forwardedProps = _objectWithoutProperties(props, _excluded$f);
1962
2029
  const cache = useRef();
1963
2030
  const theme = useTheme();
2031
+ const format = useMessageFormatter(intlMessages$3);
1964
2032
  const hasCategory = propsData[0] && Array.isArray(propsData[0].key) && propsData[0].key.length >= 2 && propsData[0].key[1] !== null && propsData[0].key[1] !== undefined;
1965
2033
  const xScaleType = propsXScaleType ? propsXScaleType : getKey(propsData[0]) instanceof Date ? 'Date' : typeof getKey(propsData[0]) === 'number' ? 'number' : typeof getKey(propsData[0]) === 'string' && isValidDate(getKey(propsData[0])) ? 'dateString' : undefined;
1966
2034
  const data = xScaleType === 'number' ? filterData(hasCategory, propsData, datum => typeof getKey(datum) === 'number' && !Number.isNaN(getKey(datum))) : xScaleType === 'dateString' ? filterData(hasCategory, propsData, datum => isValidDate(getKey(datum))) : xScaleType === 'Date' ? filterData(hasCategory, propsData, datum => getKey(datum) instanceof Date) : propsData;
@@ -2089,11 +2157,29 @@ const RenderedLinearBarChart = /*#__PURE__*/forwardRef((props, ref) => {
2089
2157
  entry[category] = value;
2090
2158
  return acc;
2091
2159
  }, []);
2160
+ const _ref9 = legendProps || {},
2161
+ {
2162
+ extraLegendItems
2163
+ } = _ref9,
2164
+ forwardedLegendProps = _objectWithoutProperties(_ref9, _excluded2$3);
2092
2165
  return /*#__PURE__*/React__default.createElement(StyledBarChart, _extends({
2093
- mode: typeof onBarClick === 'function' || typeof getBarAnchorProps === 'function' ? 'interactive' : 'static',
2094
- definition: `Bar Chart with ${bars.length} bars.`,
2095
- 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()}.`,
2096
- yAxisDefinition: `The chart has 1 Y axis displaying numbers from ${scaleY.domain()[0]} to ${scaleY.domain()[1]}.`,
2166
+ mode: typeof onBarClick === 'function' || typeof getBarAnchorProps === 'function' ? format('interactive') : format('static'),
2167
+ definition: hasCategory ? format('definition-linear-with-categories', {
2168
+ categoryLength: categories.length,
2169
+ barLength: bars.length
2170
+ }) : format('definition-linear', {
2171
+ barLength: bars.length
2172
+ }),
2173
+ xAxisDefinition: format(`x-axis-${xScaleType === 'number' ? 'numbers' : 'dates'}-definition`, {
2174
+ numAxis: xAxisPlacement === 'both' ? 2 : 1,
2175
+ start: scaleX.domain()[0],
2176
+ end: scaleX.domain()[1]
2177
+ }),
2178
+ yAxisDefinition: format('y-axis-numbers-definition', {
2179
+ numAxis: yAxisPlacement === 'both' ? 2 : 1,
2180
+ start: scaleY.domain()[0],
2181
+ end: scaleY.domain()[1]
2182
+ }),
2097
2183
  dataTableRepresentation: hasCategory ? {
2098
2184
  header: /*#__PURE__*/React__default.createElement("thead", null, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("th", {
2099
2185
  scope: "col"
@@ -2136,20 +2222,26 @@ const RenderedLinearBarChart = /*#__PURE__*/forwardRef((props, ref) => {
2136
2222
  ref: svgRef,
2137
2223
  width: width,
2138
2224
  height: height,
2139
- "aria-label": "Interactive Bar Chart",
2225
+ "aria-label": typeof onBarClick === 'function' || typeof getBarAnchorProps === 'function' ? format('interactive-chart') : format('static-chart'),
2140
2226
  "aria-hidden": "false"
2141
- }, categories.map((category, index) => {
2227
+ }, categories.map((category, categoryIndex) => {
2142
2228
  const filteredBars = bars.filter(bar => bar.category === category);
2143
2229
  return /*#__PURE__*/React__default.createElement("g", _extends({
2144
- key: category,
2230
+ key: `${id}-series-${category}`,
2145
2231
  transform: `translate(${margins.left},${margins.top})`,
2146
2232
  "aria-hidden": "false",
2147
2233
  role: "region"
2148
2234
  }, hasCategory ? {
2149
- 'aria-label': `${category}, category ${index + 1} of ${categories.length} with ${filteredBars.length} bars`
2235
+ 'aria-label': format('series-legend', {
2236
+ category,
2237
+ categoryIndex: categoryIndex + 1,
2238
+ categoryLength: categories.length,
2239
+ barLength: filteredBars.length
2240
+ })
2150
2241
  } : {}), filteredBars.map((bar, index) => {
2151
2242
  const to = {
2152
- data: bar
2243
+ data: bar,
2244
+ category
2153
2245
  };
2154
2246
  const from = cache.current ? {
2155
2247
  data: cache.current[index]
@@ -2158,13 +2250,13 @@ const RenderedLinearBarChart = /*#__PURE__*/forwardRef((props, ref) => {
2158
2250
  color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(to.data.category),
2159
2251
  data: to,
2160
2252
  gap: gap,
2161
- id: `id${id}__bar-${index}`,
2253
+ id: `id${id}__bar-${categoryIndex}.${index}`,
2162
2254
  index: index,
2163
2255
  isSelected: Boolean(isBarSelected(to)),
2164
- key: `bar _${index}`,
2256
+ key: `bar _${categoryIndex}.${index}`,
2165
2257
  labelDecorator: labelDecorator,
2166
- maxHeight: scaleY(bar.cumulativeValue - bar.value)
2167
- }, getBarAnchorProps ? getBarAnchorProps(to) : {}, {
2258
+ maxHeight: scaleY(bar.cumulativeValue - bar.value),
2259
+ anchorProps: getBarAnchorProps ? getBarAnchorProps(to) : undefined,
2168
2260
  onClick: onBarClick,
2169
2261
  orientation: BarOrientation.vertical,
2170
2262
  previousData: from,
@@ -2233,12 +2325,12 @@ const RenderedLinearBarChart = /*#__PURE__*/forwardRef((props, ref) => {
2233
2325
  tickRemodelling: yAxisTickRemodelling,
2234
2326
  variant: yAxisVariant
2235
2327
  }) : null))), hasCategory && legendVariant !== BarChartLegendVariant.none ? /*#__PURE__*/React__default.createElement(Legend, _extends({
2236
- data: statsByCategory.map(d => _objectSpread2(_objectSpread2({}, d), {}, {
2328
+ data: (extraLegendItems ? [...statsByCategory, ...extraLegendItems] : statsByCategory).map(d => _objectSpread2(_objectSpread2({}, d), {}, {
2237
2329
  color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(d.key)
2238
2330
  })),
2239
2331
  variant: legendVariant === BarChartLegendVariant.externalLabelValue ? LegendVariant.value : legendVariant === BarChartLegendVariant.externalLabelPercent ? LegendVariant.percent : legendVariant === BarChartLegendVariant.externalLabel ? LegendVariant.label : LegendVariant.custom,
2240
2332
  legendDecorator: legendDecorator ? (datum, props) => legendDecorator(datum, props) : undefined
2241
- }, legendProps)) : null);
2333
+ }, forwardedLegendProps)) : null);
2242
2334
  });
2243
2335
 
2244
2336
  const _excluded$e = ["barRole", "caping", "chartRef", "className", "colorTheme", "data", "dataType", "emptyComponent", "id", "isBarSelected", "labelDecorator", "legendDecorator", "legendVariant", "localeText", "onBarClick", "orientation", "others", "size", "sortingMethod", "theme", "tooltipDecorator", "tooltipVariant", "xAxisPlacement", "yAxisPlacement"];
@@ -2676,12 +2768,55 @@ const EmptyLineChart = /*#__PURE__*/forwardRef((props, ref) => {
2676
2768
  })))));
2677
2769
  });
2678
2770
 
2679
- const _excluded$9 = ["className", "data", "dotRole", "id", "isDotSelected", "labelDecorator", "legendDecorator", "legendVariant", "legendProps", "margins", "onDotClick", "size", "sortingMethod", "colorTheme", "tooltipDecorator", "tooltipVariant", "xAxisVariant", "xAxisPlacement", "xAxisTickFormat", "xAxisTickPadding", "xAxisTickRotation", "xAxisTickSize", "xAxisTickValues", "xAxisMinValue", "xAxisMaxValue", "xAxisTickRemodelling", "yAxisVariant", "yAxisPlacement", "yAxisTickFormat", "yAxisTickPadding", "yAxisTickRotation", "yAxisTickSize", "yAxisTickValues", "yAxisMinValue", "yAxisMaxValue", "yAxisTickRemodelling", "dateParser"];
2771
+ var interactive$5 = "interactive";
2772
+ var enUS$2 = {
2773
+ interactive: interactive$5,
2774
+ "static": "static",
2775
+ "interactive-chart": "Interactive Line Chart",
2776
+ "static-chart": "Static Line Chart",
2777
+ "definition-linear": "Linear Line Chart with {circleLength} circles.",
2778
+ "definition-linear-with-categories": "Linear Line Chart with {categoryLength} categories and {circleLength} circles.",
2779
+ "definition-ordinal": "Ordinal Line Chart with {circleLength} circles.",
2780
+ "x-axis-numbers-definition": "The chart has {numAxis, plural, =0 {0 X axis} =1 {1 X axis} other {# X axes}} displaying numbers from {start, number} to {end, number}.",
2781
+ "y-axis-numbers-definition": "The chart has {numAxis, plural, =0 {0 Y axis} =1 {1 Y axis} other {# Y axes}} displaying numbers from {start, number} to {end, number}.",
2782
+ "x-axis-dates-definition": "The chart has {numAxis, plural, =0 {0 X axis} =1 {1 X axis} other {# X axes}} displaying dates from {start, date, ::yyyyMMdd} to {end, date, ::yyyyMMdd}.",
2783
+ "y-axis-dates-definition": "The chart has {numAxis, plural, =0 {0 Y axis} =1 {1 Y axis} other {# Y axes}} displaying dates from {start, date, ::yyyyMMdd} to {end, date, ::yyyyMMdd}.",
2784
+ "x-axis-categories-definition": "The chart has {numAxis, plural, =0 {0 X axis} =1 {1 X axis} other {# X axes}} displaying categories.",
2785
+ "y-axis-categories-definition": "The chart has {numAxis, plural, =0 {0 Y axis} =1 {1 Y axis} other {# Y axes}} displaying categories.",
2786
+ "series-legend": "{category}, line {categoryIndex} of {categoryLength} with {circleLength} circles"
2787
+ };
2788
+
2789
+ var interactive$4 = "interactif";
2790
+ var frFR$2 = {
2791
+ interactive: interactive$4,
2792
+ "static": "statique",
2793
+ "interactive-chart": "Graphique en courbe interactif",
2794
+ "static-chart": "Graphique en courbe statique",
2795
+ "definition-linear": "Graphique en courbe contenant {circleLength} points répartis sur un axe linéraire.",
2796
+ "definition-linear-with-categories": "Graphique en courbe contenant {categoryLength} courbes et {circleLength} points répartis sur un axe linéraire.",
2797
+ "definition-ordinal": "Graphique en courbe contenant {circleLength} points.",
2798
+ "x-axis-numbers-definition": "Le graphique a {numAxis, plural, =0 {0 axe X} =1 {1 axe X} other {# axes X}} affichant des nombres allant de {start, number} à {end, number}.",
2799
+ "y-axis-numbers-definition": "Le graphique a {numAxis, plural, =0 {0 axe Y} =1 {1 axe Y} other {# axes Y}} affichant des nombres allant de {start, number} à {end, number}.",
2800
+ "x-axis-dates-definition": "Le graphique a {numAxis, plural, =0 {0 axe X} =1 {1 axe X} other {# axes X}} affichant des dates allant de {start, date, ::yyyyMMdd} à {end, date, ::yyyyMMdd}.",
2801
+ "y-axis-dates-definition": "Le graphique a {numAxis, plural, =0 {0 axe Y} =1 {1 axe Y} other {# axes Y}} affichant des dates allant de {start, date, ::yyyyMMdd} à {end, date, ::yyyyMMdd}.",
2802
+ "x-axis-categories-definition": "Le graphique a {numAxis, plural, =0 {0 axe X} =1 {1 axe X} other {# axes X}} affichant des categories.",
2803
+ "y-axis-categories-definition": "Le graphique a {numAxis, plural, =0 {0 axe Y} =1 {1 axe Y} other {# axes Y}} affichant des categories.",
2804
+ "series-legend": "{category}, courbe {categoryIndex} sur {categoryLength} contenant {circleLength} points"
2805
+ };
2806
+
2807
+ var intlMessages$2 = {
2808
+ 'en-US': enUS$2,
2809
+ 'fr-FR': frFR$2
2810
+ };
2811
+
2812
+ const _excluded$9 = ["className", "data", "dotRole", "getDotAnchorProps", "id", "isDotSelected", "labelDecorator", "legendDecorator", "legendVariant", "legendProps", "margins", "onDotClick", "size", "sortingMethod", "colorTheme", "tooltipDecorator", "tooltipVariant", "xAxisVariant", "xAxisPlacement", "xAxisTickFormat", "xAxisTickPadding", "xAxisTickRotation", "xAxisTickSize", "xAxisTickValues", "xAxisMinValue", "xAxisMaxValue", "xAxisTickRemodelling", "yAxisVariant", "yAxisPlacement", "yAxisTickFormat", "yAxisTickPadding", "yAxisTickRotation", "yAxisTickSize", "yAxisTickValues", "yAxisMinValue", "yAxisMaxValue", "yAxisTickRemodelling", "dateParser"],
2813
+ _excluded2$2 = ["extraLegendItems"];
2680
2814
  const RenderedLineChart = /*#__PURE__*/forwardRef((props, ref) => {
2681
2815
  const {
2682
2816
  className,
2683
2817
  data: propsData,
2684
2818
  dotRole,
2819
+ getDotAnchorProps,
2685
2820
  id,
2686
2821
  isDotSelected,
2687
2822
  labelDecorator,
@@ -2720,6 +2855,7 @@ const RenderedLineChart = /*#__PURE__*/forwardRef((props, ref) => {
2720
2855
  forwardedProps = _objectWithoutProperties(props, _excluded$9);
2721
2856
  const cache = useRef();
2722
2857
  const theme = useTheme();
2858
+ const format = useMessageFormatter(intlMessages$2);
2723
2859
  const xScaleType = propsData[0].key[0] instanceof Date ? 'Date' : typeof propsData[0].key[0] === 'number' ? 'number' : typeof propsData[0].key[0] === 'string' && isValidDate(propsData[0].key[0]) ? 'dateString' : typeof propsData[0].key[0] === 'string' ? 'string' : undefined;
2724
2860
  const data = xScaleType === 'number' ? propsData.filter(datum => typeof datum.key[0] === 'number' && !Number.isNaN(datum.key[0])) : xScaleType === 'dateString' ? propsData.filter(datum => isValidDate(datum.key[0])) : xScaleType === 'string' ? propsData.filter(datum => typeof datum.key[0] === 'string') : xScaleType === 'Date' ? propsData.filter(datum => datum.key[0] instanceof Date) : propsData;
2725
2861
  useEffect(() => {
@@ -2799,16 +2935,19 @@ const RenderedLineChart = /*#__PURE__*/forwardRef((props, ref) => {
2799
2935
  return 0;
2800
2936
  }
2801
2937
  return 0;
2802
- }).filter(d => d.value !== null).map(d => ({
2803
- category: d.key[1],
2804
- x: xScaleType === 'dateString' ? dateParser ? dateParser(d.key[0]) : new Date(Date.parse(d.key[0])) : d.key[0],
2805
- y: d.value,
2806
- data: {
2807
- key: d.key,
2808
- value: d.value
2809
- },
2810
- points: [d]
2811
- }));
2938
+ }).filter(d => d.value !== null).map(d => {
2939
+ var _d$key$;
2940
+ return {
2941
+ category: (_d$key$ = d.key[1]) !== null && _d$key$ !== void 0 ? _d$key$ : 'default',
2942
+ x: xScaleType === 'dateString' ? dateParser ? dateParser(d.key[0]) : new Date(Date.parse(d.key[0])) : d.key[0],
2943
+ y: d.value,
2944
+ data: {
2945
+ key: d.key,
2946
+ value: d.value
2947
+ },
2948
+ points: [d]
2949
+ };
2950
+ });
2812
2951
  const lines = hasCategory ? Object.values(circles.reduce((prev, curr) => {
2813
2952
  if (!prev[curr.category]) {
2814
2953
  prev[curr.category] = [];
@@ -2817,7 +2956,83 @@ const RenderedLineChart = /*#__PURE__*/forwardRef((props, ref) => {
2817
2956
  return prev;
2818
2957
  }, {})) : [circles];
2819
2958
  const createLine = line().x(d => scaleX(d.x)).y(d => scaleY(d.y));
2820
- return /*#__PURE__*/React__default.createElement(StyledLineChart, _extends({}, forwardedProps, {
2959
+ const categories = [];
2960
+ const pivotedTable = circles.reduce((acc, item) => {
2961
+ const {
2962
+ x,
2963
+ category,
2964
+ y
2965
+ } = item;
2966
+ if (!categories.includes(category)) {
2967
+ categories.push(category);
2968
+ }
2969
+ const formattedKey = xAxisTickFormat ? xAxisTickFormat(x) : x.toString();
2970
+ let entry = acc.find(e => e.key === formattedKey);
2971
+ if (!entry) {
2972
+ entry = {
2973
+ key: formattedKey
2974
+ };
2975
+ acc.push(entry);
2976
+ }
2977
+ entry[category] = y;
2978
+ return acc;
2979
+ }, []);
2980
+ const _ref11 = legendProps || {},
2981
+ {
2982
+ extraLegendItems
2983
+ } = _ref11,
2984
+ forwardedLegendProps = _objectWithoutProperties(_ref11, _excluded2$2);
2985
+ return /*#__PURE__*/React__default.createElement(StyledLineChart, _extends({
2986
+ mode: typeof onDotClick === 'function' || typeof getDotAnchorProps === 'function' ? format('interactive') : format('static'),
2987
+ definition: hasCategory ? format('definition-linear-with-categories', {
2988
+ categoryLength: categories.length,
2989
+ circleLength: circles.length
2990
+ }) : format('definition-linear', {
2991
+ circleLength: circles.length
2992
+ }),
2993
+ xAxisDefinition: xScaleType !== 'string' ? format(`x-axis-${xScaleType === 'number' ? 'numbers' : 'dates'}-definition`, {
2994
+ numAxis: xAxisPlacement === 'both' ? 2 : 1,
2995
+ start: scaleX.domain()[0],
2996
+ end: scaleX.domain()[1]
2997
+ }) : format('x-axis-categories-definition', {
2998
+ numAxis: xAxisPlacement === 'both' ? 2 : 1
2999
+ }),
3000
+ yAxisDefinition: format('y-axis-numbers-definition', {
3001
+ numAxis: yAxisPlacement === 'both' ? 2 : 1,
3002
+ start: scaleY.domain()[0],
3003
+ end: scaleY.domain()[1]
3004
+ }),
3005
+ dataTableRepresentation: hasCategory ? {
3006
+ header: /*#__PURE__*/React__default.createElement("thead", null, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("th", {
3007
+ scope: "col"
3008
+ }, xScaleType === 'Date' || xScaleType === 'dateString' ? 'Date' : 'Key'), categories.map(category => /*#__PURE__*/React__default.createElement("th", {
3009
+ key: category,
3010
+ scope: "col"
3011
+ }, category)))),
3012
+ body: /*#__PURE__*/React__default.createElement("tbody", null, pivotedTable.map(row => /*#__PURE__*/React__default.createElement("tr", {
3013
+ key: row.key
3014
+ }, /*#__PURE__*/React__default.createElement("th", {
3015
+ scope: "row"
3016
+ }, row.key), categories.map(category => /*#__PURE__*/React__default.createElement("th", {
3017
+ key: `${row.key}-${category}-${row[category]}`,
3018
+ scope: "col"
3019
+ }, row[category])))))
3020
+ } : {
3021
+ header: /*#__PURE__*/React__default.createElement("thead", null, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("th", {
3022
+ scope: "col"
3023
+ }, xScaleType === 'Date' || xScaleType === 'dateString' ? 'Date' : 'Key'), /*#__PURE__*/React__default.createElement("th", {
3024
+ scope: "col"
3025
+ }, "Value"))),
3026
+ body: /*#__PURE__*/React__default.createElement("tbody", null, circles.map(datum => {
3027
+ const key = xAxisTickFormat ? xAxisTickFormat(datum.x) : datum.x.toString();
3028
+ return /*#__PURE__*/React__default.createElement("tr", {
3029
+ key: key
3030
+ }, /*#__PURE__*/React__default.createElement("th", {
3031
+ scope: "row"
3032
+ }, key), /*#__PURE__*/React__default.createElement("td", null, datum.y));
3033
+ }))
3034
+ }
3035
+ }, forwardedProps, {
2821
3036
  id: id,
2822
3037
  className: className,
2823
3038
  ref: ref
@@ -2828,9 +3043,12 @@ const RenderedLineChart = /*#__PURE__*/forwardRef((props, ref) => {
2828
3043
  }, /*#__PURE__*/React__default.createElement("svg", {
2829
3044
  ref: svgRef,
2830
3045
  width: width,
2831
- height: height
3046
+ height: height,
3047
+ "aria-label": typeof onDotClick === 'function' || typeof getDotAnchorProps === 'function' ? format('interactive-chart') : format('static-chart'),
3048
+ "aria-hidden": "false"
2832
3049
  }, /*#__PURE__*/React__default.createElement("g", {
2833
- transform: `translate(${margins.left},${margins.top})`
3050
+ transform: `translate(${margins.left},${margins.top})`,
3051
+ "aria-hidden": "true"
2834
3052
  }, lines.map((line, index) => {
2835
3053
  return /*#__PURE__*/React__default.createElement(Line, {
2836
3054
  color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(line[0].category),
@@ -2838,32 +3056,42 @@ const RenderedLineChart = /*#__PURE__*/forwardRef((props, ref) => {
2838
3056
  createLine: createLine,
2839
3057
  key: `line _${index}`
2840
3058
  });
2841
- })), /*#__PURE__*/React__default.createElement("g", {
2842
- transform: `translate(${margins.left},${margins.top})`
2843
- }, circles.map((circle, index) => {
2844
- const scaleXDomain = scaleX.domain();
2845
- const scaleYDomain = scaleY.domain();
2846
- if (xScaleType === 'number' && (circle.x < scaleXDomain[0] || circle.x > scaleXDomain[1] || circle.y < scaleYDomain[0] || circle.y > scaleYDomain[1])) {
2847
- return null;
2848
- }
2849
- const to = _objectSpread2(_objectSpread2({}, circle), {}, {
2850
- r: 4
2851
- });
2852
- return /*#__PURE__*/React__default.createElement(Dot, {
2853
- color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(circle.category),
2854
- data: to,
2855
- isSelected: Boolean(isDotSelected === null || isDotSelected === void 0 ? void 0 : isDotSelected(to)),
2856
- key: `circle _${index}`,
2857
- labelDecorator: labelDecorator,
2858
- onClick: onDotClick,
2859
- role: dotRole,
2860
- scaleX: scaleX,
2861
- scaleY: scaleY,
2862
- tooltipDecorator: tooltipDecorator,
2863
- tooltipVariant: tooltipVariant,
2864
- variant: DotVariant.hollow
2865
- });
2866
- })), /*#__PURE__*/React__default.createElement("g", {
3059
+ })), categories.map((category, categoryIndex) => {
3060
+ const filteredCircles = circles.filter(circle => circle.category === category);
3061
+ return /*#__PURE__*/React__default.createElement("g", _extends({
3062
+ key: `${id}-series-${category}`,
3063
+ transform: `translate(${margins.left},${margins.top})`,
3064
+ "aria-hidden": "false",
3065
+ role: "region"
3066
+ }, hasCategory ? {
3067
+ 'aria-label': `${category}, category ${categoryIndex + 1} of ${categories.length} with ${filteredCircles.length} circles`
3068
+ } : {}), filteredCircles.map((circle, index) => {
3069
+ const scaleXDomain = scaleX.domain();
3070
+ const scaleYDomain = scaleY.domain();
3071
+ if (xScaleType === 'number' && (circle.x < scaleXDomain[0] || circle.x > scaleXDomain[1] || circle.y < scaleYDomain[0] || circle.y > scaleYDomain[1])) {
3072
+ return null;
3073
+ }
3074
+ const to = _objectSpread2(_objectSpread2({}, circle), {}, {
3075
+ r: 4
3076
+ });
3077
+ return /*#__PURE__*/React__default.createElement(Dot, {
3078
+ id: `id${id}__circle-${categoryIndex}.${index}`,
3079
+ color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(circle.category),
3080
+ data: to,
3081
+ isSelected: Boolean(isDotSelected === null || isDotSelected === void 0 ? void 0 : isDotSelected(to)),
3082
+ anchorProps: getDotAnchorProps ? getDotAnchorProps(to) : undefined,
3083
+ key: `circle _${categoryIndex}.${index}`,
3084
+ labelDecorator: labelDecorator,
3085
+ onClick: onDotClick,
3086
+ role: dotRole,
3087
+ scaleX: scaleX,
3088
+ scaleY: scaleY,
3089
+ tooltipDecorator: tooltipDecorator,
3090
+ tooltipVariant: tooltipVariant,
3091
+ variant: DotVariant.hollow
3092
+ });
3093
+ }));
3094
+ }), /*#__PURE__*/React__default.createElement("g", {
2867
3095
  transform: `translate(${margins.left},${margins.top})`
2868
3096
  }, ['bottom', 'both'].includes(xAxisPlacement) ? /*#__PURE__*/React__default.createElement(Axis, {
2869
3097
  position: "bottom",
@@ -2918,12 +3146,12 @@ const RenderedLineChart = /*#__PURE__*/forwardRef((props, ref) => {
2918
3146
  tickRemodelling: yAxisTickRemodelling,
2919
3147
  variant: yAxisVariant
2920
3148
  }) : null))), hasCategory && legendVariant !== LineChartLegendVariant.none ? /*#__PURE__*/React__default.createElement(Legend, _extends({
2921
- data: statsByCategory.map(d => _objectSpread2(_objectSpread2({}, d), {}, {
3149
+ data: (extraLegendItems ? [...statsByCategory, ...extraLegendItems] : statsByCategory).map(d => _objectSpread2(_objectSpread2({}, d), {}, {
2922
3150
  color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(d.key)
2923
3151
  })),
2924
3152
  variant: legendVariant === LineChartLegendVariant.externalLabelValue ? LegendVariant.value : legendVariant === LineChartLegendVariant.externalLabelPercent ? LegendVariant.percent : legendVariant === LineChartLegendVariant.externalLabel ? LegendVariant.label : LegendVariant.custom,
2925
3153
  legendDecorator: legendDecorator ? (datum, props) => legendDecorator(datum, props) : undefined
2926
- }, legendProps)) : null);
3154
+ }, forwardedLegendProps)) : null);
2927
3155
  });
2928
3156
 
2929
3157
  const _excluded$8 = ["className", "colorTheme", "data", "dotRole", "emptyComponent", "id", "isDotSelected", "labelDecorator", "legendDecorator", "legendVariant", "localeText", "onDotClick", "size", "sortingMethod", "tooltipDecorator", "tooltipVariant", "xAxisPlacement", "xAxisVariant", "yAxisPlacement", "yAxisVariant"];
@@ -3301,7 +3529,33 @@ const EmptyPieChart = /*#__PURE__*/forwardRef((props, ref) => {
3301
3529
  }))));
3302
3530
  });
3303
3531
 
3304
- 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"];
3532
+ var interactive$3 = "interactive";
3533
+ var definition$2 = "Pie Chart with {sliceLength} slices.";
3534
+ var enUS$1 = {
3535
+ interactive: interactive$3,
3536
+ "static": "static",
3537
+ "interactive-chart": "Interactive Line Chart",
3538
+ "static-chart": "Static Line Chart",
3539
+ definition: definition$2
3540
+ };
3541
+
3542
+ var interactive$2 = "interactif";
3543
+ var definition$1 = "Diagramme circulaire contenant {sliceLength} secteurs.";
3544
+ var frFR$1 = {
3545
+ interactive: interactive$2,
3546
+ "static": "statique",
3547
+ "interactive-chart": "Diagramme circulaire interactif",
3548
+ "static-chart": "Diagramme circulaire statique",
3549
+ definition: definition$1
3550
+ };
3551
+
3552
+ var intlMessages$1 = {
3553
+ 'en-US': enUS$1,
3554
+ 'fr-FR': frFR$1
3555
+ };
3556
+
3557
+ 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"],
3558
+ _excluded2$1 = ["extraLegendItems"];
3305
3559
  const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
3306
3560
  const {
3307
3561
  caping,
@@ -3331,6 +3585,7 @@ const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
3331
3585
  forwardedProps = _objectWithoutProperties(props, _excluded$5);
3332
3586
  const cache = useRef();
3333
3587
  const theme = useTheme();
3588
+ const format = useMessageFormatter(intlMessages$1);
3334
3589
  const isDonut = variant === PieChartVariant.donut || variant === PieChartVariant.spacedDonut;
3335
3590
  const isSpaced = variant === PieChartVariant.spaced || variant === PieChartVariant.spacedDonut;
3336
3591
  const {
@@ -3389,9 +3644,16 @@ const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
3389
3644
  });
3390
3645
  }), total) : propsMiddleText;
3391
3646
  const filteredPieData = pieData.filter(datum => datum.data.value);
3647
+ const _ref = legendProps || {},
3648
+ {
3649
+ extraLegendItems
3650
+ } = _ref,
3651
+ forwardedLegendProps = _objectWithoutProperties(_ref, _excluded2$1);
3392
3652
  return /*#__PURE__*/React__default.createElement(StyledPieChart, _extends({
3393
- mode: typeof onSliceClick === 'function' || typeof getSliceAnchorProps === 'function' ? 'interactive' : 'static',
3394
- definition: `Pie Chart with ${filteredPieData.length} slices.`,
3653
+ mode: typeof onSliceClick === 'function' || typeof getSliceAnchorProps === 'function' ? format('interactive') : format('static'),
3654
+ definition: format('definition', {
3655
+ sliceLength: filteredPieData.length
3656
+ }),
3395
3657
  dataTableRepresentation: {
3396
3658
  header: /*#__PURE__*/React__default.createElement("thead", null, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("th", {
3397
3659
  scope: "col"
@@ -3417,7 +3679,9 @@ const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
3417
3679
  $theme: theme
3418
3680
  }, subtext ? /*#__PURE__*/React__default.createElement("b", null, text) : /*#__PURE__*/React__default.createElement("span", null, text), middleText ? /*#__PURE__*/React__default.createElement("b", null, middleText) : null, /*#__PURE__*/React__default.createElement("span", null, subtext)) : null, /*#__PURE__*/React__default.createElement("svg", {
3419
3681
  width: width,
3420
- height: isHalf ? height + externalRadiusPadding : height
3682
+ height: isHalf ? height + externalRadiusPadding : height,
3683
+ "aria-label": typeof onSliceClick === 'function' || typeof getSliceAnchorProps === 'function' ? format('interactive-chart') : format('static-chart'),
3684
+ "aria-hidden": "false"
3421
3685
  }, /*#__PURE__*/React__default.createElement(Arcs, {
3422
3686
  arcs: filteredPieData.map((datum, index) => {
3423
3687
  const percent = datum.data.value / total;
@@ -3437,16 +3701,17 @@ const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
3437
3701
  percent
3438
3702
  })
3439
3703
  });
3440
- return _objectSpread2({
3704
+ return {
3441
3705
  color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(to.data.key),
3442
3706
  createArc,
3443
3707
  previousData: from,
3444
- id: `id${id}__bar-${index}`,
3708
+ id: `id${id}__arc-${index}`,
3445
3709
  index,
3446
3710
  isSelected: isSliceSelected(to),
3447
- key: `id${id}__bar-${index}`,
3448
- data: to
3449
- }, getSliceAnchorProps ? getSliceAnchorProps(to) : {});
3711
+ key: `id${id}__arc-${index}`,
3712
+ data: to,
3713
+ anchorProps: getSliceAnchorProps ? getSliceAnchorProps(to) : undefined
3714
+ };
3450
3715
  }),
3451
3716
  hasLabels: legendVariant === PieChartLegendVariant.internal,
3452
3717
  hasStroke: isSpaced,
@@ -3457,14 +3722,14 @@ const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
3457
3722
  tooltipVariant: tooltipVariant,
3458
3723
  transform: `translate(${width / 2} ${isHalf ? height : height / 2})`
3459
3724
  }))), legendVariant !== PieChartLegendVariant.none && legendVariant !== PieChartLegendVariant.internal ? /*#__PURE__*/React__default.createElement(Legend, _extends({
3460
- data: data.map(d => _objectSpread2(_objectSpread2({}, d), {}, {
3725
+ data: (extraLegendItems ? [...data, ...extraLegendItems] : data).map(d => _objectSpread2(_objectSpread2({}, d), {}, {
3461
3726
  color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(d.key)
3462
3727
  })),
3463
3728
  variant: legendVariant === PieChartLegendVariant.externalLabelValue ? LegendVariant.value : legendVariant === PieChartLegendVariant.externalLabelPercent ? LegendVariant.percent : legendVariant === PieChartLegendVariant.externalLabel ? LegendVariant.label : LegendVariant.custom,
3464
3729
  width: legendWidth.current,
3465
3730
  labelDecorator: labelDecorator ? (datum, props) => labelDecorator(datum, props) : undefined,
3466
3731
  legendDecorator: legendDecorator ? (datum, props) => legendDecorator(datum, props) : undefined
3467
- }, legendProps)) : null);
3732
+ }, forwardedLegendProps)) : null);
3468
3733
  });
3469
3734
 
3470
3735
  const _excluded$4 = ["caping", "chartRef", "className", "colorTheme", "data", "emptyComponent", "id", "isSliceSelected", "labelDecorator", "legendDecorator", "legendVariant", "localeText", "middleText", "onSliceClick", "others", "size", "sliceRole", "sortingMethod", "subtext", "text", "tooltipDecorator", "tooltipVariant", "variant"];
@@ -3746,18 +4011,56 @@ const EmptyScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
3746
4011
  })))));
3747
4012
  });
3748
4013
 
4014
+ var interactive$1 = "interactive";
4015
+ var definition = "Linear Scatter Plot with {circleLength} circles.";
4016
+ var enUS = {
4017
+ interactive: interactive$1,
4018
+ "static": "static",
4019
+ "interactive-chart": "Interactive Scatter Plot",
4020
+ "static-chart": "Static Scatter Plot",
4021
+ definition: definition,
4022
+ "definition-with-categories": "Linear Scatter Plot with {categoryLength} categories and {circleLength} circles.",
4023
+ "x-axis-definition": "The chart has {numAxis, plural, =0 {0 X axis} =1 {1 X axis} other {# X axes}} displaying numbers from {start, number} to {end, number}.",
4024
+ "y-axis-definition": "The chart has {numAxis, plural, =0 {0 Y axis} =1 {1 Y axis} other {# Y axes}} displaying numbers from {start, number} to {end, number}."
4025
+ };
4026
+
4027
+ var interactive = "interactif";
4028
+ var frFR = {
4029
+ interactive: interactive,
4030
+ "static": "statique",
4031
+ "interactive-chart": "Graphique en courbe interactif",
4032
+ "static-chart": "Graphique en courbe statique",
4033
+ "definition-linear": "Graphique en courbe contenant {circleLength} points répartis sur un axe linéraire.",
4034
+ "definition-linear-with-categories": "Graphique en courbe contenant {categoryLength} courbes et {circleLength} points répartis sur un axe linéraire.",
4035
+ "definition-ordinal": "Graphique en courbe contenant {circleLength} points.",
4036
+ "x-axis-numbers-definition": "Le graphique a {numAxis, plural, =0 {0 axe X} =1 {1 axe X} other {# axes X}} affichant des nombres allant de {start, number} à {end, number}.",
4037
+ "y-axis-numbers-definition": "Le graphique a {numAxis, plural, =0 {0 axe Y} =1 {1 axe Y} other {# axes Y}} affichant des nombres allant de {start, number} à {end, number}.",
4038
+ "x-axis-dates-definition": "Le graphique a {numAxis, plural, =0 {0 axe X} =1 {1 axe X} other {# axes X}} affichant des dates allant de {start, date, ::yyyyMMdd} à {end, date, ::yyyyMMdd}.",
4039
+ "y-axis-dates-definition": "Le graphique a {numAxis, plural, =0 {0 axe Y} =1 {1 axe Y} other {# axes Y}} affichant des dates allant de {start, date, ::yyyyMMdd} à {end, date, ::yyyyMMdd}.",
4040
+ "x-axis-categories-definition": "Le graphique a {numAxis, plural, =0 {0 axe X} =1 {1 axe X} other {# axes X}} affichant des categories.",
4041
+ "y-axis-categories-definition": "Le graphique a {numAxis, plural, =0 {0 axe Y} =1 {1 axe Y} other {# axes Y}} affichant des categories.",
4042
+ "series-legend": "{category}, courbe {categoryIndex} sur {categoryLength} contenant {circleLength} points"
4043
+ };
4044
+
4045
+ var intlMessages = {
4046
+ 'en-US': enUS,
4047
+ 'fr-FR': frFR
4048
+ };
4049
+
3749
4050
  // Material Design Icons v7.2.96
3750
4051
  var mdiChevronDown = "M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z";
3751
4052
  var mdiChevronRight = "M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z";
3752
4053
  var mdiMouse = "M11,1.07C7.05,1.56 4,4.92 4,9H11M4,15A8,8 0 0,0 12,23A8,8 0 0,0 20,15V11H4M13,1.07V9H20C20,4.92 16.94,1.56 13,1.07Z";
3753
4054
 
3754
- const _excluded$1 = ["isBrushable", "className", "data", "dotRole", "hideControlKeyPanel", "id", "isDotSelected", "labelDecorator", "legendDecorator", "legendVariant", "legendProps", "margins", "onBrush", "onBrushEnd", "onDotClick", "size", "sortingMethod", "colorTheme", "tooltipDecorator", "tooltipVariant", "xAxisVariant", "xAxisPlacement", "xAxisTickFormat", "xAxisTickPadding", "xAxisTickRotation", "xAxisTickSize", "xAxisTickValues", "yAxisVariant", "yAxisPlacement", "yAxisTickFormat", "yAxisTickPadding", "yAxisTickRotation", "yAxisTickSize", "yAxisTickValues", "variant"];
4055
+ const _excluded$1 = ["isBrushable", "className", "data", "dotRole", "getDotAnchorProps", "hideControlKeyPanel", "id", "isDotSelected", "labelDecorator", "legendDecorator", "legendVariant", "legendProps", "margins", "onBrush", "onBrushEnd", "onDotClick", "size", "sortingMethod", "colorTheme", "tooltipDecorator", "tooltipVariant", "xAxisVariant", "xAxisPlacement", "xAxisTickFormat", "xAxisTickPadding", "xAxisTickRotation", "xAxisTickSize", "xAxisTickValues", "yAxisVariant", "yAxisPlacement", "yAxisTickFormat", "yAxisTickPadding", "yAxisTickRotation", "yAxisTickSize", "yAxisTickValues", "variant"],
4056
+ _excluded2 = ["extraLegendItems"];
3755
4057
  const RenderedScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
3756
4058
  const {
3757
4059
  isBrushable,
3758
4060
  className,
3759
4061
  data: propsData,
3760
4062
  dotRole,
4063
+ getDotAnchorProps,
3761
4064
  hideControlKeyPanel,
3762
4065
  id,
3763
4066
  isDotSelected,
@@ -3793,6 +4096,7 @@ const RenderedScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
3793
4096
  forwardedProps = _objectWithoutProperties(props, _excluded$1);
3794
4097
  const cache = useRef();
3795
4098
  const theme = useTheme();
4099
+ const format = useMessageFormatter(intlMessages);
3796
4100
  const data = propsData.filter(datum => datum.value && typeof datum.key[0] === 'number' && !Number.isNaN(datum.key[0]) && typeof datum.key[1] === 'number' && !Number.isNaN(datum.key[1]));
3797
4101
  useEffect(() => {
3798
4102
  cache.current = data;
@@ -3861,23 +4165,76 @@ const RenderedScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
3861
4165
  onBrush,
3862
4166
  onBrushEnd
3863
4167
  });
3864
- const circles = variant === ScatterPlotVariant.gridded ? group(data, scaleX, scaleY).sort((a, b) => descending(a.points.length, b.points.length)) : data.map(d => ({
3865
- category: d.key[2],
3866
- x: d.key[0],
3867
- y: d.key[1],
3868
- data: {
3869
- key: d.key,
3870
- value: 1
3871
- },
3872
- points: [d]
3873
- }));
4168
+ const circles = variant === ScatterPlotVariant.gridded ? group(data, scaleX, scaleY).sort((a, b) => {
4169
+ if (a.y !== b.y) {
4170
+ return b.y - a.y;
4171
+ }
4172
+ if (a.x !== b.x) {
4173
+ return a.x - b.x;
4174
+ }
4175
+ return descending(a.points.length, b.points.length);
4176
+ }) : data.map(d => {
4177
+ var _d$key$;
4178
+ return {
4179
+ category: (_d$key$ = d.key[2]) !== null && _d$key$ !== void 0 ? _d$key$ : 'default',
4180
+ x: d.key[0],
4181
+ y: d.key[1],
4182
+ data: {
4183
+ key: d.key,
4184
+ value: 1
4185
+ },
4186
+ points: [d]
4187
+ };
4188
+ });
3874
4189
  const globalSize = variant === ScatterPlotVariant.gridded ? scaleSqrt().domain([1, Math.max(max(circles, d => d.points.length), 1)]).range([3, minSize / BASE_NUMBER_OF_TICKS / 2]) : undefined;
3875
4190
  const legendWidth = useRef();
3876
4191
  if (countsByCategory && !legendWidth.current) {
3877
4192
  legendWidth.current = `${Math.max(...countsByCategory.map(d => d.key.length + String(d.value).length)) * 8 + 32}px`;
3878
4193
  }
3879
4194
  const [isKeyPanelOpen, setIsKeyPanelOpen] = useState(false);
3880
- return /*#__PURE__*/React__default.createElement(StyledScatterPlot, _extends({}, forwardedProps, {
4195
+ const categories = [];
4196
+ // const pivotedTable = circles.reduce((acc, item) => {
4197
+ // const { x, category, y } = item;
4198
+ // if (!categories.includes(category)) {
4199
+ // categories.push(category);
4200
+ // }
4201
+ // const formattedKey = xAxisTickFormat ? xAxisTickFormat(x as any) : x.toString();
4202
+
4203
+ // let entry = acc.find((e) => e.key === formattedKey);
4204
+ // if (!entry) {
4205
+ // entry = { key: formattedKey };
4206
+ // acc.push(entry);
4207
+ // }
4208
+
4209
+ // entry[category] = y;
4210
+
4211
+ // return acc;
4212
+ // }, [] as Array<Record<string, string | number | null | undefined> & { key: string }>);
4213
+
4214
+ const _ref = legendProps || {},
4215
+ {
4216
+ extraLegendItems
4217
+ } = _ref,
4218
+ forwardedLegendProps = _objectWithoutProperties(_ref, _excluded2);
4219
+ return /*#__PURE__*/React__default.createElement(StyledScatterPlot, _extends({
4220
+ mode: typeof onDotClick === 'function' || typeof getDotAnchorProps === 'function' ? format('interactive') : format('static'),
4221
+ definition: hasCategory ? format('definition-with-categories', {
4222
+ categoryLength: categories.length,
4223
+ circleLength: circles.length
4224
+ }) : format('definition', {
4225
+ circleLength: circles.length
4226
+ }),
4227
+ xAxisDefinition: format('x-axis-definition', {
4228
+ numAxis: xAxisPlacement === 'both' ? 2 : 1,
4229
+ start: scaleX.domain()[0],
4230
+ end: scaleX.domain()[1]
4231
+ }),
4232
+ yAxisDefinition: format('y-axis-definition', {
4233
+ numAxis: yAxisPlacement === 'both' ? 2 : 1,
4234
+ start: scaleY.domain()[0],
4235
+ end: scaleY.domain()[1]
4236
+ })
4237
+ }, forwardedProps, {
3881
4238
  id: id,
3882
4239
  className: className,
3883
4240
  ref: ref
@@ -3937,10 +4294,10 @@ const RenderedScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
3937
4294
  }
3938
4295
  const to = _objectSpread2(_objectSpread2({}, circle), {}, {
3939
4296
  data: _objectSpread2(_objectSpread2({}, circle.data), {}, {
3940
- percent: circle.category ? circle.data.value / (countsByCategory === null || countsByCategory === void 0 ? void 0 : (_countsByCategory$fin = countsByCategory.find(_ref => {
4297
+ percent: circle.category ? circle.data.value / (countsByCategory === null || countsByCategory === void 0 ? void 0 : (_countsByCategory$fin = countsByCategory.find(_ref2 => {
3941
4298
  let {
3942
4299
  key
3943
- } = _ref;
4300
+ } = _ref2;
3944
4301
  return key === circle.category;
3945
4302
  })) === null || _countsByCategory$fin === void 0 ? void 0 : _countsByCategory$fin.value) : undefined
3946
4303
  }),
@@ -4010,13 +4367,13 @@ const RenderedScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
4010
4367
  tickFormat: yAxisTickFormat,
4011
4368
  variant: yAxisVariant
4012
4369
  }) : null))), hasCategory && legendVariant !== ScatterPlotLegendVariant.none ? /*#__PURE__*/React__default.createElement(Legend, _extends({
4013
- data: countsByCategory.map(d => _objectSpread2(_objectSpread2({}, d), {}, {
4370
+ data: (extraLegendItems ? [...countsByCategory, ...extraLegendItems] : countsByCategory).map(d => _objectSpread2(_objectSpread2({}, d), {}, {
4014
4371
  color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(d.key)
4015
4372
  })),
4016
4373
  variant: legendVariant === ScatterPlotLegendVariant.externalLabelValue ? LegendVariant.value : legendVariant === ScatterPlotLegendVariant.externalLabelPercent ? LegendVariant.percent : legendVariant === ScatterPlotLegendVariant.externalLabel ? LegendVariant.label : LegendVariant.custom,
4017
4374
  width: legendWidth.current,
4018
4375
  legendDecorator: legendDecorator ? (datum, props) => legendDecorator(datum, props) : undefined
4019
- }, legendProps)) : null);
4376
+ }, forwardedLegendProps)) : null);
4020
4377
  });
4021
4378
 
4022
4379
  const _excluded = ["className", "colorTheme", "data", "dotRole", "emptyComponent", "hideControlKeyPanel", "id", "isDotSelected", "labelDecorator", "legendDecorator", "legendVariant", "localeText", "onBrush", "onBrushEnd", "onDotClick", "size", "sortingMethod", "tooltipDecorator", "tooltipVariant", "variant", "xAxisPlacement", "xAxisVariant", "yAxisPlacement", "yAxisVariant"];