@fluentui/react-charts 9.2.0 → 9.2.2

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 (103) hide show
  1. package/CHANGELOG.md +38 -3
  2. package/dist/index.d.ts +84 -5
  3. package/lib/ChartTable.js +1 -0
  4. package/lib/ChartTable.js.map +1 -0
  5. package/lib/components/AreaChart/AreaChart.js.map +1 -1
  6. package/lib/components/ChartTable/ChartTable.js +57 -0
  7. package/lib/components/ChartTable/ChartTable.js.map +1 -0
  8. package/lib/components/ChartTable/ChartTable.types.js +1 -0
  9. package/lib/components/ChartTable/ChartTable.types.js.map +1 -0
  10. package/lib/components/ChartTable/index.js +3 -0
  11. package/lib/components/ChartTable/index.js.map +1 -0
  12. package/lib/components/ChartTable/useChartTableStyles.styles.js +93 -0
  13. package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
  14. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +55 -0
  15. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
  16. package/lib/components/CommonComponents/CartesianChart.js +110 -81
  17. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  18. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  19. package/lib/components/CommonComponents/ChartPopover.types.js.map +1 -1
  20. package/lib/components/DeclarativeChart/DeclarativeChart.js +20 -10
  21. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  22. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +95 -0
  23. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
  24. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +204 -87
  25. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  26. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  27. package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
  28. package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
  29. package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
  30. package/lib/components/GanttChart/GanttChart.js.map +1 -1
  31. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +161 -141
  32. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  33. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
  34. package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  35. package/lib/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
  36. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  37. package/lib/components/Legends/Legends.js.map +1 -1
  38. package/lib/components/Legends/OverflowMenu.js.map +1 -1
  39. package/lib/components/LineChart/LineChart.js.map +1 -1
  40. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  41. package/lib/components/VerticalBarChart/VerticalBarChart.js +12 -11
  42. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  43. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +57 -51
  44. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  45. package/lib/index.js +1 -0
  46. package/lib/index.js.map +1 -1
  47. package/lib/types/DataPoint.js.map +1 -1
  48. package/lib/utilities/FocusableTooltipText.js.map +1 -1
  49. package/lib/utilities/utilities.js +26 -37
  50. package/lib/utilities/utilities.js.map +1 -1
  51. package/lib/utilities/vbc-utils.js +24 -0
  52. package/lib/utilities/vbc-utils.js.map +1 -1
  53. package/lib-commonjs/ChartTable.js +6 -0
  54. package/lib-commonjs/ChartTable.js.map +1 -0
  55. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
  56. package/lib-commonjs/components/ChartTable/ChartTable.js +68 -0
  57. package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -0
  58. package/lib-commonjs/components/ChartTable/ChartTable.types.js +6 -0
  59. package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -0
  60. package/lib-commonjs/components/ChartTable/index.js +8 -0
  61. package/lib-commonjs/components/ChartTable/index.js.map +1 -0
  62. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +196 -0
  63. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
  64. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +69 -0
  65. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
  66. package/lib-commonjs/components/CommonComponents/CartesianChart.js +109 -80
  67. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  68. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  69. package/lib-commonjs/components/CommonComponents/ChartPopover.types.js.map +1 -1
  70. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +19 -9
  71. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  72. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +120 -0
  73. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
  74. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +204 -87
  75. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  76. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  77. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
  78. package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
  79. package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
  80. package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
  81. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +159 -139
  82. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  83. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
  84. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  85. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
  86. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  87. package/lib-commonjs/components/Legends/Legends.js.map +1 -1
  88. package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
  89. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  90. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  91. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +11 -10
  92. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  93. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +56 -50
  94. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  95. package/lib-commonjs/index.js +1 -0
  96. package/lib-commonjs/index.js.map +1 -1
  97. package/lib-commonjs/types/DataPoint.js.map +1 -1
  98. package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
  99. package/lib-commonjs/utilities/utilities.js +29 -37
  100. package/lib-commonjs/utilities/utilities.js.map +1 -1
  101. package/lib-commonjs/utilities/vbc-utils.js +27 -0
  102. package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
  103. package/package.json +9 -9
@@ -0,0 +1,57 @@
1
+ import * as React from 'react';
2
+ import { useChartTableStyles } from './useChartTableStyles.styles';
3
+ import { useRtl } from '../../utilities/utilities';
4
+ import { toImage } from '../../utilities/image-export-utils';
5
+ export const ChartTable = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
6
+ const { headers, rows, width, height } = props;
7
+ const _isRTL = useRtl();
8
+ const _rootElem = React.useRef(null);
9
+ const classes = useChartTableStyles(props);
10
+ React.useImperativeHandle(props.componentRef, ()=>({
11
+ chartContainer: _rootElem.current,
12
+ toImage: (opts)=>{
13
+ return toImage(_rootElem.current, undefined, _isRTL, opts);
14
+ }
15
+ }), []);
16
+ if (!headers || headers.length === 0) {
17
+ return /*#__PURE__*/ React.createElement("div", null, "No data available");
18
+ }
19
+ return /*#__PURE__*/ React.createElement("div", {
20
+ ref: (el)=>_rootElem.current = el,
21
+ className: classes.root,
22
+ style: {
23
+ height: height ? `${height}px` : '650px',
24
+ overflow: 'hidden'
25
+ }
26
+ }, /*#__PURE__*/ React.createElement("svg", {
27
+ width: width !== null && width !== void 0 ? width : '100%',
28
+ height: height !== null && height !== void 0 ? height : '650px'
29
+ }, /*#__PURE__*/ React.createElement("foreignObject", {
30
+ x: "0",
31
+ y: "0",
32
+ width: "100%",
33
+ height: "100%"
34
+ }, /*#__PURE__*/ React.createElement("div", {
35
+ style: {
36
+ maxHeight: height ? `${height}px` : '650px',
37
+ overflowY: 'auto',
38
+ overflowX: 'auto'
39
+ }
40
+ }, /*#__PURE__*/ React.createElement("table", {
41
+ className: classes.table,
42
+ style: {
43
+ width: width ? `${width}px` : '100%',
44
+ height: height ? `${height}px` : '650px'
45
+ }
46
+ }, /*#__PURE__*/ React.createElement("thead", null, /*#__PURE__*/ React.createElement("tr", null, headers.map((header, idx)=>/*#__PURE__*/ React.createElement("th", {
47
+ key: idx,
48
+ className: classes.headerCell
49
+ }, header.value)))), rows && rows.length > 0 && /*#__PURE__*/ React.createElement("tbody", null, rows.map((row, rowIdx)=>/*#__PURE__*/ React.createElement("tr", {
50
+ key: rowIdx
51
+ }, row.map((cell, colIdx)=>/*#__PURE__*/ React.createElement("td", {
52
+ key: colIdx,
53
+ className: classes.bodyCell,
54
+ style: cell.style
55
+ }, cell.value))))))))));
56
+ });
57
+ ChartTable.displayName = 'ChartTable';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/ChartTable/ChartTable.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ChartTableProps } from './ChartTable.types';\nimport { useChartTableStyles } from './useChartTableStyles.styles';\nimport { useRtl } from '../../utilities/utilities';\nimport { ImageExportOptions } from '../../types/index';\nimport { toImage } from '../../utilities/image-export-utils';\n\nexport const ChartTable: React.FunctionComponent<ChartTableProps> = React.forwardRef<HTMLDivElement, ChartTableProps>(\n (props, forwardedRef) => {\n const { headers, rows, width, height } = props;\n const _isRTL: boolean = useRtl();\n const _rootElem = React.useRef<HTMLDivElement | null>(null);\n const classes = useChartTableStyles(props);\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n chartContainer: _rootElem.current,\n toImage: (opts?: ImageExportOptions): Promise<string> => {\n return toImage(_rootElem.current, undefined, _isRTL, opts);\n },\n }),\n [],\n );\n\n if (!headers || headers.length === 0) {\n return <div>No data available</div>;\n }\n\n return (\n <div\n ref={el => (_rootElem.current = el)}\n className={classes.root as string}\n style={{ height: height ? `${height}px` : '650px', overflow: 'hidden' }}\n >\n <svg width={width ?? '100%'} height={height ?? '650px'}>\n <foreignObject x=\"0\" y=\"0\" width=\"100%\" height=\"100%\">\n <div\n style={{\n maxHeight: height ? `${height}px` : '650px',\n overflowY: 'auto',\n overflowX: 'auto',\n }}\n >\n <table\n className={classes.table}\n style={{\n width: width ? `${width}px` : '100%',\n height: height ? `${height}px` : '650px',\n }}\n >\n <thead>\n <tr>\n {headers.map((header, idx) => (\n <th key={idx} className={classes.headerCell}>\n {header.value}\n </th>\n ))}\n </tr>\n </thead>\n {rows && rows.length > 0 && (\n <tbody>\n {rows.map((row, rowIdx) => (\n <tr key={rowIdx}>\n {row.map((cell, colIdx) => (\n <td key={colIdx} className={classes.bodyCell} style={cell.style}>\n {cell.value}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n )}\n </table>\n </div>\n </foreignObject>\n </svg>\n </div>\n );\n },\n);\n\nChartTable.displayName = 'ChartTable';\n"],"names":["React","useChartTableStyles","useRtl","toImage","ChartTable","forwardRef","props","forwardedRef","headers","rows","width","height","_isRTL","_rootElem","useRef","classes","useImperativeHandle","componentRef","chartContainer","current","opts","undefined","length","div","ref","el","className","root","style","overflow","svg","foreignObject","x","y","maxHeight","overflowY","overflowX","table","thead","tr","map","header","idx","th","key","headerCell","value","tbody","row","rowIdx","cell","colIdx","td","bodyCell","displayName"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,mBAAmB,QAAQ,+BAA+B;AACnE,SAASC,MAAM,QAAQ,4BAA4B;AAEnD,SAASC,OAAO,QAAQ,qCAAqC;AAE7D,OAAO,MAAMC,2BAAuDJ,MAAMK,UAAU,CAClF,CAACC,OAAOC;IACN,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAEC,KAAK,EAAEC,MAAM,EAAE,GAAGL;IACzC,MAAMM,SAAkBV;IACxB,MAAMW,YAAYb,MAAMc,MAAM,CAAwB;IACtD,MAAMC,UAAUd,oBAAoBK;IAEpCN,MAAMgB,mBAAmB,CACvBV,MAAMW,YAAY,EAClB,IAAO,CAAA;YACLC,gBAAgBL,UAAUM,OAAO;YACjChB,SAAS,CAACiB;gBACR,OAAOjB,QAAQU,UAAUM,OAAO,EAAEE,WAAWT,QAAQQ;YACvD;QACF,CAAA,GACA,EAAE;IAGJ,IAAI,CAACZ,WAAWA,QAAQc,MAAM,KAAK,GAAG;QACpC,qBAAO,oBAACC,aAAI;IACd;IAEA,qBACE,oBAACA;QACCC,KAAKC,CAAAA,KAAOZ,UAAUM,OAAO,GAAGM;QAChCC,WAAWX,QAAQY,IAAI;QACvBC,OAAO;YAAEjB,QAAQA,SAAS,GAAGA,OAAO,EAAE,CAAC,GAAG;YAASkB,UAAU;QAAS;qBAEtE,oBAACC;QAAIpB,OAAOA,kBAAAA,mBAAAA,QAAS;QAAQC,QAAQA,mBAAAA,oBAAAA,SAAU;qBAC7C,oBAACoB;QAAcC,GAAE;QAAIC,GAAE;QAAIvB,OAAM;QAAOC,QAAO;qBAC7C,oBAACY;QACCK,OAAO;YACLM,WAAWvB,SAAS,GAAGA,OAAO,EAAE,CAAC,GAAG;YACpCwB,WAAW;YACXC,WAAW;QACb;qBAEA,oBAACC;QACCX,WAAWX,QAAQsB,KAAK;QACxBT,OAAO;YACLlB,OAAOA,QAAQ,GAAGA,MAAM,EAAE,CAAC,GAAG;YAC9BC,QAAQA,SAAS,GAAGA,OAAO,EAAE,CAAC,GAAG;QACnC;qBAEA,oBAAC2B,6BACC,oBAACC,YACE/B,QAAQgC,GAAG,CAAC,CAACC,QAAQC,oBACpB,oBAACC;YAAGC,KAAKF;YAAKhB,WAAWX,QAAQ8B,UAAU;WACxCJ,OAAOK,KAAK,MAKpBrC,QAAQA,KAAKa,MAAM,GAAG,mBACrB,oBAACyB,eACEtC,KAAK+B,GAAG,CAAC,CAACQ,KAAKC,uBACd,oBAACV;YAAGK,KAAKK;WACND,IAAIR,GAAG,CAAC,CAACU,MAAMC,uBACd,oBAACC;gBAAGR,KAAKO;gBAAQzB,WAAWX,QAAQsC,QAAQ;gBAAEzB,OAAOsB,KAAKtB,KAAK;eAC5DsB,KAAKJ,KAAK;AAarC,GACA;AAEF1C,WAAWkD,WAAW,GAAG"}
@@ -0,0 +1 @@
1
+ import * as React from 'react';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/ChartTable/ChartTable.types.ts"],"sourcesContent":["import * as React from 'react';\nimport { Chart } from './index';\n\n/**\n * Chart Table properties\n * {@docCategory ChartTable}\n */\nexport interface ChartTableProps {\n /**\n * 1d or 2d Array of header values.\n */\n headers: { value: string | number | boolean | null; style?: React.CSSProperties }[];\n\n /**\n * Array of rows. Each row corresponds to one data entry under each column.\n */\n rows: { value: string | number | boolean | null; style?: React.CSSProperties }[][];\n\n /**\n * Optional width for the table\n * @default '100%'\n */\n width?: string | number;\n\n /**\n * Optional height for the table\n * @default '650px'\n */\n height?: string | number;\n\n /**\n * Additional class name(s) to apply to the table chart\n */\n className?: string;\n\n /**\n * Call to provide customized styling that will layer on top of the variant rules.\n */\n styles?: ChartTableStyles;\n\n /**\n * Optional callback to access the Chart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: React.RefObject<Chart>;\n}\n\n/**\n * Table Chart styles\n * {@docCategory ChartTable}\n */\nexport interface ChartTableStyles {\n root?: string | React.CSSProperties;\n table?: string;\n headerCell?: string;\n bodyCell?: string;\n chart?: string;\n}\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
@@ -0,0 +1,3 @@
1
+ export * from './ChartTable';
2
+ export * from './ChartTable.types';
3
+ export * from '../../types/index';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/ChartTable/index.ts"],"sourcesContent":["export * from './ChartTable';\nexport * from './ChartTable.types';\nexport * from '../../types/index';\n"],"names":[],"mappings":"AAAA,cAAc,eAAe;AAC7B,cAAc,qBAAqB;AACnC,cAAc,oBAAoB"}
@@ -0,0 +1,93 @@
1
+ import { __styles, mergeClasses, shorthands } from '@griffel/react';
2
+ import { tokens, typographyStyles } from '@fluentui/react-theme';
3
+ /**
4
+ * @internal
5
+ */
6
+ export const chartTableClassNames = {
7
+ root: 'fui-ChartTable__root',
8
+ table: 'fui-ChartTable__table',
9
+ headerCell: 'fui-ChartTable__headerCell',
10
+ bodyCell: 'fui-ChartTable__bodyCell',
11
+ chart: 'fui-ChartTable__chart'
12
+ };
13
+ const useStyles = /*#__PURE__*/__styles({
14
+ root: {
15
+ a9b677: "fly5x3f",
16
+ B68tc82: "f1oy3dpc"
17
+ },
18
+ table: {
19
+ po53p8: "fgkb47j"
20
+ },
21
+ headerCell: {
22
+ Bahqtrf: "fk6fouc",
23
+ Be2twd7: "fy9rknc",
24
+ Bhrd7zp: "fl43uef",
25
+ Bg96gwp: "fwrc4pm",
26
+ De3pzq: "f16xq7d1",
27
+ sj55zd: "f19n0e5",
28
+ z8tnut: "f17mpqex",
29
+ z189sj: ["f1vdfbxk", "f1f5gg8d"],
30
+ Byoj8tv: "fdvome7",
31
+ uwmqm3: ["f1f5gg8d", "f1vdfbxk"],
32
+ fsow6f: ["f1o700av", "fes3tcz"],
33
+ B4j52fo: "f18zi460",
34
+ Bekrc4i: ["f1wpluaz", "fsfsuhs"],
35
+ Bn0qgzm: "fmklw6v",
36
+ ibv6hh: ["fsfsuhs", "f1wpluaz"],
37
+ icvyot: "fzkkow9",
38
+ vrafjx: ["fcdblym", "fjik90z"],
39
+ oivjwe: "fg706s2",
40
+ wvpqe5: ["fjik90z", "fcdblym"],
41
+ g2u3we: "f68mrw8",
42
+ h3c5rm: ["f7pw515", "fw35ms5"],
43
+ B9xav0g: "frpde29",
44
+ zhjwy3: ["fw35ms5", "f7pw515"],
45
+ Bsw6fvg: "f8pusc0",
46
+ Bbusuzp: "fqgauei"
47
+ },
48
+ bodyCell: {
49
+ Bahqtrf: "fk6fouc",
50
+ Be2twd7: "fy9rknc",
51
+ Bhrd7zp: "figsok6",
52
+ Bg96gwp: "fwrc4pm",
53
+ z8tnut: "f17mpqex",
54
+ z189sj: ["f1vdfbxk", "f1f5gg8d"],
55
+ Byoj8tv: "fdvome7",
56
+ uwmqm3: ["f1f5gg8d", "f1vdfbxk"],
57
+ B4j52fo: "f18zi460",
58
+ Bekrc4i: ["f1wpluaz", "fsfsuhs"],
59
+ Bn0qgzm: "fmklw6v",
60
+ ibv6hh: ["fsfsuhs", "f1wpluaz"],
61
+ icvyot: "fzkkow9",
62
+ vrafjx: ["fcdblym", "fjik90z"],
63
+ oivjwe: "fg706s2",
64
+ wvpqe5: ["fjik90z", "fcdblym"],
65
+ g2u3we: "f68mrw8",
66
+ h3c5rm: ["f7pw515", "fw35ms5"],
67
+ B9xav0g: "frpde29",
68
+ zhjwy3: ["fw35ms5", "f7pw515"],
69
+ sj55zd: "f19n0e5",
70
+ fsow6f: ["f1o700av", "fes3tcz"],
71
+ Bbusuzp: "fqgauei"
72
+ }
73
+ }, {
74
+ d: [".fly5x3f{width:100%;}", ".f1oy3dpc{overflow-x:auto;}", ".fgkb47j{border-collapse:collapse;}", ".fk6fouc{font-family:var(--fontFamilyBase);}", ".fy9rknc{font-size:var(--fontSizeBase200);}", ".fl43uef{font-weight:var(--fontWeightSemibold);}", ".fwrc4pm{line-height:var(--lineHeightBase200);}", ".f16xq7d1{background-color:var(--colorNeutralBackground3);}", ".f19n0e5{color:var(--colorNeutralForeground1);}", ".f17mpqex{padding-top:var(--spacingHorizontalS);}", ".f1vdfbxk{padding-right:var(--spacingHorizontalS);}", ".f1f5gg8d{padding-left:var(--spacingHorizontalS);}", ".fdvome7{padding-bottom:var(--spacingHorizontalS);}", ".f1o700av{text-align:left;}", ".fes3tcz{text-align:right;}", ".f18zi460{border-top-width:var(--strokeWidthThick);}", ".f1wpluaz{border-right-width:var(--strokeWidthThick);}", ".fsfsuhs{border-left-width:var(--strokeWidthThick);}", ".fmklw6v{border-bottom-width:var(--strokeWidthThick);}", ".fzkkow9{border-top-style:solid;}", ".fcdblym{border-right-style:solid;}", ".fjik90z{border-left-style:solid;}", ".fg706s2{border-bottom-style:solid;}", ".f68mrw8{border-top-color:var(--colorNeutralStroke2);}", ".f7pw515{border-right-color:var(--colorNeutralStroke2);}", ".fw35ms5{border-left-color:var(--colorNeutralStroke2);}", ".frpde29{border-bottom-color:var(--colorNeutralStroke2);}", ".figsok6{font-weight:var(--fontWeightRegular);}"],
75
+ m: [["@media (forced-colors: active){.f8pusc0{background-color:Window;}}", {
76
+ m: "(forced-colors: active)"
77
+ }], ["@media (forced-colors: active){.fqgauei{color:WindowText;}}", {
78
+ m: "(forced-colors: active)"
79
+ }]]
80
+ });
81
+ /**
82
+ * Apply styling to the ChartTable slots based on the state
83
+ */
84
+ export const useChartTableStyles = props => {
85
+ const baseStyles = useStyles();
86
+ return {
87
+ root: mergeClasses(chartTableClassNames.root, baseStyles.root /*props.styles?.root*/),
88
+ table: mergeClasses(chartTableClassNames.table, baseStyles.table /*props.styles?.table*/),
89
+ headerCell: mergeClasses(chartTableClassNames.headerCell, baseStyles.headerCell /*props.styles?.headerCell*/),
90
+ bodyCell: mergeClasses(chartTableClassNames.bodyCell, baseStyles.bodyCell /*props.styles?.bodyCell*/),
91
+ chart: mergeClasses(chartTableClassNames.chart /*props.styles?.chart*/)
92
+ };
93
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__styles","mergeClasses","shorthands","tokens","typographyStyles","chartTableClassNames","root","table","headerCell","bodyCell","chart","useStyles","a9b677","B68tc82","po53p8","Bahqtrf","Be2twd7","Bhrd7zp","Bg96gwp","De3pzq","sj55zd","z8tnut","z189sj","Byoj8tv","uwmqm3","fsow6f","B4j52fo","Bekrc4i","Bn0qgzm","ibv6hh","icvyot","vrafjx","oivjwe","wvpqe5","g2u3we","h3c5rm","B9xav0g","zhjwy3","Bsw6fvg","Bbusuzp","d","m","useChartTableStyles","props","baseStyles"],"sources":["useChartTableStyles.styles.js"],"sourcesContent":["import { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\n/**\n * @internal\n */ export const chartTableClassNames = {\n root: 'fui-ChartTable__root',\n table: 'fui-ChartTable__table',\n headerCell: 'fui-ChartTable__headerCell',\n bodyCell: 'fui-ChartTable__bodyCell',\n chart: 'fui-ChartTable__chart'\n};\nconst useStyles = makeStyles({\n root: {\n width: '100%',\n overflowX: 'auto'\n },\n table: {\n borderCollapse: 'collapse'\n },\n headerCell: {\n ...typographyStyles.caption1,\n fontWeight: tokens.fontWeightSemibold,\n backgroundColor: tokens.colorNeutralBackground3,\n color: tokens.colorNeutralForeground1,\n ...shorthands.padding(tokens.spacingHorizontalS),\n textAlign: 'left',\n ...shorthands.border(tokens.strokeWidthThick, 'solid', tokens.colorNeutralStroke2),\n '@media (forced-colors: active)': {\n backgroundColor: 'Window',\n color: 'WindowText'\n }\n },\n bodyCell: {\n ...typographyStyles.caption1,\n ...shorthands.padding(tokens.spacingHorizontalS),\n ...shorthands.border(tokens.strokeWidthThick, 'solid', tokens.colorNeutralStroke2),\n color: tokens.colorNeutralForeground1,\n textAlign: 'left',\n '@media (forced-colors: active)': {\n color: 'WindowText'\n }\n }\n});\n/**\n * Apply styling to the ChartTable slots based on the state\n */ export const useChartTableStyles = (props)=>{\n const baseStyles = useStyles();\n return {\n root: mergeClasses(chartTableClassNames.root, baseStyles.root /*props.styles?.root*/ ),\n table: mergeClasses(chartTableClassNames.table, baseStyles.table /*props.styles?.table*/ ),\n headerCell: mergeClasses(chartTableClassNames.headerCell, baseStyles.headerCell /*props.styles?.headerCell*/ ),\n bodyCell: mergeClasses(chartTableClassNames.bodyCell, baseStyles.bodyCell /*props.styles?.bodyCell*/ ),\n chart: mergeClasses(chartTableClassNames.chart /*props.styles?.chart*/ )\n };\n};\n"],"mappings":"AAAA,SAAAA,QAAA,EAAqBC,YAAY,EAAEC,UAAU,QAAQ,gBAAgB;AACrE,SAASC,MAAM,EAAEC,gBAAgB,QAAQ,uBAAuB;AAChE;AACA;AACA;AAAI,OAAO,MAAMC,oBAAoB,GAAG;EACpCC,IAAI,EAAE,sBAAsB;EAC5BC,KAAK,EAAE,uBAAuB;EAC9BC,UAAU,EAAE,4BAA4B;EACxCC,QAAQ,EAAE,0BAA0B;EACpCC,KAAK,EAAE;AACX,CAAC;AACD,MAAMC,SAAS,gBAAGX,QAAA;EAAAM,IAAA;IAAAM,MAAA;IAAAC,OAAA;EAAA;EAAAN,KAAA;IAAAO,MAAA;EAAA;EAAAN,UAAA;IAAAO,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;EAAA;EAAA9B,QAAA;IAAAM,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAG,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAE,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAjB,MAAA;IAAAK,MAAA;IAAAc,OAAA;EAAA;AAAA;EAAAC,CAAA;EAAAC,CAAA;IAAAA,CAAA;EAAA;IAAAA,CAAA;EAAA;AAAA,CA+BjB,CAAC;AACF;AACA;AACA;AAAI,OAAO,MAAMC,mBAAmB,GAAIC,KAAK,IAAG;EAC5C,MAAMC,UAAU,GAAGjC,SAAS,CAAC,CAAC;EAC9B,OAAO;IACHL,IAAI,EAAEL,YAAY,CAACI,oBAAoB,CAACC,IAAI,EAAEsC,UAAU,CAACtC,IAAI,CAAC,sBAAuB,CAAC;IACtFC,KAAK,EAAEN,YAAY,CAACI,oBAAoB,CAACE,KAAK,EAAEqC,UAAU,CAACrC,KAAK,CAAC,uBAAwB,CAAC;IAC1FC,UAAU,EAAEP,YAAY,CAACI,oBAAoB,CAACG,UAAU,EAAEoC,UAAU,CAACpC,UAAU,CAAC,4BAA6B,CAAC;IAC9GC,QAAQ,EAAER,YAAY,CAACI,oBAAoB,CAACI,QAAQ,EAAEmC,UAAU,CAACnC,QAAQ,CAAC,0BAA2B,CAAC;IACtGC,KAAK,EAAET,YAAY,CAACI,oBAAoB,CAACK,KAAK,CAAC,uBAAwB;EAC3E,CAAC;AACL,CAAC","ignoreList":[]}
@@ -0,0 +1,55 @@
1
+ import { makeStyles, mergeClasses, shorthands } from '@griffel/react';
2
+ import { tokens, typographyStyles } from '@fluentui/react-theme';
3
+ /**
4
+ * @internal
5
+ */ export const chartTableClassNames = {
6
+ root: 'fui-ChartTable__root',
7
+ table: 'fui-ChartTable__table',
8
+ headerCell: 'fui-ChartTable__headerCell',
9
+ bodyCell: 'fui-ChartTable__bodyCell',
10
+ chart: 'fui-ChartTable__chart'
11
+ };
12
+ const useStyles = makeStyles({
13
+ root: {
14
+ width: '100%',
15
+ overflowX: 'auto'
16
+ },
17
+ table: {
18
+ borderCollapse: 'collapse'
19
+ },
20
+ headerCell: {
21
+ ...typographyStyles.caption1,
22
+ fontWeight: tokens.fontWeightSemibold,
23
+ backgroundColor: tokens.colorNeutralBackground3,
24
+ color: tokens.colorNeutralForeground1,
25
+ ...shorthands.padding(tokens.spacingHorizontalS),
26
+ textAlign: 'left',
27
+ ...shorthands.border(tokens.strokeWidthThick, 'solid', tokens.colorNeutralStroke2),
28
+ '@media (forced-colors: active)': {
29
+ backgroundColor: 'Window',
30
+ color: 'WindowText'
31
+ }
32
+ },
33
+ bodyCell: {
34
+ ...typographyStyles.caption1,
35
+ ...shorthands.padding(tokens.spacingHorizontalS),
36
+ ...shorthands.border(tokens.strokeWidthThick, 'solid', tokens.colorNeutralStroke2),
37
+ color: tokens.colorNeutralForeground1,
38
+ textAlign: 'left',
39
+ '@media (forced-colors: active)': {
40
+ color: 'WindowText'
41
+ }
42
+ }
43
+ });
44
+ /**
45
+ * Apply styling to the ChartTable slots based on the state
46
+ */ export const useChartTableStyles = (props)=>{
47
+ const baseStyles = useStyles();
48
+ return {
49
+ root: mergeClasses(chartTableClassNames.root, baseStyles.root /*props.styles?.root*/ ),
50
+ table: mergeClasses(chartTableClassNames.table, baseStyles.table /*props.styles?.table*/ ),
51
+ headerCell: mergeClasses(chartTableClassNames.headerCell, baseStyles.headerCell /*props.styles?.headerCell*/ ),
52
+ bodyCell: mergeClasses(chartTableClassNames.bodyCell, baseStyles.bodyCell /*props.styles?.bodyCell*/ ),
53
+ chart: mergeClasses(chartTableClassNames.chart /*props.styles?.chart*/ )
54
+ };
55
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/ChartTable/useChartTableStyles.styles.ts"],"sourcesContent":["import { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { ChartTableProps, ChartTableStyles } from './ChartTable.types';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\n\n/**\n * @internal\n */\nexport const chartTableClassNames: SlotClassNames<ChartTableStyles> = {\n root: 'fui-ChartTable__root',\n table: 'fui-ChartTable__table',\n headerCell: 'fui-ChartTable__headerCell',\n bodyCell: 'fui-ChartTable__bodyCell',\n chart: 'fui-ChartTable__chart',\n};\n\nconst useStyles = makeStyles({\n root: {\n width: '100%',\n overflowX: 'auto',\n },\n table: {\n borderCollapse: 'collapse',\n },\n headerCell: {\n ...typographyStyles.caption1,\n fontWeight: tokens.fontWeightSemibold,\n backgroundColor: tokens.colorNeutralBackground3,\n color: tokens.colorNeutralForeground1,\n ...shorthands.padding(tokens.spacingHorizontalS),\n textAlign: 'left',\n ...shorthands.border(tokens.strokeWidthThick, 'solid', tokens.colorNeutralStroke2),\n '@media (forced-colors: active)': {\n backgroundColor: 'Window',\n color: 'WindowText',\n },\n },\n bodyCell: {\n ...typographyStyles.caption1,\n ...shorthands.padding(tokens.spacingHorizontalS),\n ...shorthands.border(tokens.strokeWidthThick, 'solid', tokens.colorNeutralStroke2),\n color: tokens.colorNeutralForeground1,\n textAlign: 'left',\n '@media (forced-colors: active)': {\n color: 'WindowText',\n },\n },\n});\n\n/**\n * Apply styling to the ChartTable slots based on the state\n */\nexport const useChartTableStyles = (props: ChartTableProps): ChartTableStyles => {\n const baseStyles = useStyles();\n\n return {\n root: mergeClasses(chartTableClassNames.root, baseStyles.root /*props.styles?.root*/),\n table: mergeClasses(chartTableClassNames.table, baseStyles.table /*props.styles?.table*/),\n headerCell: mergeClasses(chartTableClassNames.headerCell, baseStyles.headerCell /*props.styles?.headerCell*/),\n bodyCell: mergeClasses(chartTableClassNames.bodyCell, baseStyles.bodyCell /*props.styles?.bodyCell*/),\n chart: mergeClasses(chartTableClassNames.chart /*props.styles?.chart*/),\n };\n};\n"],"names":["makeStyles","mergeClasses","shorthands","tokens","typographyStyles","chartTableClassNames","root","table","headerCell","bodyCell","chart","useStyles","width","overflowX","borderCollapse","caption1","fontWeight","fontWeightSemibold","backgroundColor","colorNeutralBackground3","color","colorNeutralForeground1","padding","spacingHorizontalS","textAlign","border","strokeWidthThick","colorNeutralStroke2","useChartTableStyles","props","baseStyles"],"mappings":"AAAA,SAASA,UAAU,EAAEC,YAAY,EAAEC,UAAU,QAAQ,iBAAiB;AAGtE,SAASC,MAAM,EAAEC,gBAAgB,QAAQ,wBAAwB;AAEjE;;CAEC,GACD,OAAO,MAAMC,uBAAyD;IACpEC,MAAM;IACNC,OAAO;IACPC,YAAY;IACZC,UAAU;IACVC,OAAO;AACT,EAAE;AAEF,MAAMC,YAAYX,WAAW;IAC3BM,MAAM;QACJM,OAAO;QACPC,WAAW;IACb;IACAN,OAAO;QACLO,gBAAgB;IAClB;IACAN,YAAY;QACV,GAAGJ,iBAAiBW,QAAQ;QAC5BC,YAAYb,OAAOc,kBAAkB;QACrCC,iBAAiBf,OAAOgB,uBAAuB;QAC/CC,OAAOjB,OAAOkB,uBAAuB;QACrC,GAAGnB,WAAWoB,OAAO,CAACnB,OAAOoB,kBAAkB,CAAC;QAChDC,WAAW;QACX,GAAGtB,WAAWuB,MAAM,CAACtB,OAAOuB,gBAAgB,EAAE,SAASvB,OAAOwB,mBAAmB,CAAC;QAClF,kCAAkC;YAChCT,iBAAiB;YACjBE,OAAO;QACT;IACF;IACAX,UAAU;QACR,GAAGL,iBAAiBW,QAAQ;QAC5B,GAAGb,WAAWoB,OAAO,CAACnB,OAAOoB,kBAAkB,CAAC;QAChD,GAAGrB,WAAWuB,MAAM,CAACtB,OAAOuB,gBAAgB,EAAE,SAASvB,OAAOwB,mBAAmB,CAAC;QAClFP,OAAOjB,OAAOkB,uBAAuB;QACrCG,WAAW;QACX,kCAAkC;YAChCJ,OAAO;QACT;IACF;AACF;AAEA;;CAEC,GACD,OAAO,MAAMQ,sBAAsB,CAACC;IAClC,MAAMC,aAAanB;IAEnB,OAAO;QACLL,MAAML,aAAaI,qBAAqBC,IAAI,EAAEwB,WAAWxB,IAAI,CAAC,oBAAoB;QAClFC,OAAON,aAAaI,qBAAqBE,KAAK,EAAEuB,WAAWvB,KAAK,CAAC,qBAAqB;QACtFC,YAAYP,aAAaI,qBAAqBG,UAAU,EAAEsB,WAAWtB,UAAU,CAAC,0BAA0B;QAC1GC,UAAUR,aAAaI,qBAAqBI,QAAQ,EAAEqB,WAAWrB,QAAQ,CAAC,wBAAwB;QAClGC,OAAOT,aAAaI,qBAAqBK,KAAK,CAAC,qBAAqB;IACtE;AACF,EAAE"}
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { useCartesianChartStyles } from './useCartesianChartStyles.styles';
3
3
  import { select as d3Select } from 'd3-selection';
4
- import { createNumericXAxis, createStringXAxis, createDateXAxis, XAxisTypes, YAxisType, createWrapOfXLabels, rotateXAxisLabels, calculateLongestLabelWidth, createYAxisLabels, ChartTypes, wrapContent, useRtl, truncateString, tooltipOfAxislabels, getSecureProps } from '../../utilities/index';
4
+ import { createNumericXAxis, createStringXAxis, createDateXAxis, XAxisTypes, YAxisType, createWrapOfXLabels, rotateXAxisLabels, calculateLongestLabelWidth, createYAxisLabels, ChartTypes, wrapContent, useRtl, truncateString, tooltipOfAxislabels, getSecureProps, DEFAULT_WRAP_WIDTH } from '../../utilities/index';
5
5
  import { useId } from '@fluentui/react-utilities';
6
6
  import { SVGTooltipText } from '../../utilities/SVGTooltipText';
7
7
  import { ChartPopover } from './ChartPopover';
@@ -28,10 +28,14 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
28
28
  let _xScale;
29
29
  let isIntegralDataset = true;
30
30
  let _tooltipId = useId('tooltip_');
31
+ /* Used for when WrapXAxisLabels props appeared.
32
+ * To display the total word (space separated words), Need to have more space than usual.
33
+ * This height will get total height need to disaply total word.
34
+ * These value need to be removed from actual svg height/graph height.
35
+ * Defalut value is 0. And this values calculted when 'wrapXAxisLables' or 'showXAxisLablesTooltip' is true.
36
+ */ let _removalValueForTextTuncate = 0;
31
37
  const [containerWidth, setContainerWidth] = React.useState(0);
32
38
  const [containerHeight, setContainerHeight] = React.useState(0);
33
- const [isRemoveValCalculated, setIsRemoveValCalculated] = React.useState(true);
34
- const [removalValueForTextTuncate, setRemovalValueForTextTuncate] = React.useState(0);
35
39
  const [startFromX, setStartFromX] = React.useState(0);
36
40
  const [prevProps, setPrevProps] = React.useState(null);
37
41
  const chartTypesToCheck = [
@@ -114,19 +118,6 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
114
118
  props,
115
119
  prevProps
116
120
  ]);
117
- React.useEffect(()=>{
118
- if (!props.wrapXAxisLables && props.rotateXAxisLables && props.xAxisType === XAxisTypes.StringAxis) {
119
- const rotateLabelProps = {
120
- node: xAxisElement.current,
121
- xAxis: _xScale
122
- };
123
- const rotatedHeight = rotateXAxisLabels(rotateLabelProps);
124
- if (isRemoveValCalculated && removalValueForTextTuncate !== rotatedHeight + margins.bottom && rotatedHeight > 0) {
125
- setRemovalValueForTextTuncate(rotatedHeight + margins.bottom);
126
- setIsRemoveValCalculated(false);
127
- }
128
- }
129
- });
130
121
  React.useImperativeHandle(props.componentRef, ()=>{
131
122
  var _chartContainer_current;
132
123
  return {
@@ -182,7 +173,13 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
182
173
  const XAxisParams = {
183
174
  domainNRangeValues: props.getDomainNRangeValues(points, props.getDomainMargins ? props.getDomainMargins(containerWidth) : margins, containerWidth, chartType, _useRtl, props.xAxisType, props.barwidth, props.tickValues, // This is only used for Horizontal Bar Chart with Axis for y as string axis
184
175
  startFromX),
185
- containerHeight: containerHeight - removalValueForTextTuncate,
176
+ // FIXME: In XAxisParams, containerHeight is used by HBWA to generate vertical gridlines.
177
+ // Since the x-axis in HBWA is numeric, it typically doesn't require transformation.
178
+ // However, if transformation props are enabled, the updated _removalValueForTextTuncate
179
+ // will only be available in the next render, as it's set after the axis is created.
180
+ // Solution: Delay the creation of gridlines until after the transformation has been applied,
181
+ // or precompute the required height for transformed labels (_removalValueForTextTuncate).
182
+ containerHeight: containerHeight - _removalValueForTextTuncate,
186
183
  margins: margins,
187
184
  xAxisElement: xAxisElement.current,
188
185
  showRoundOffXTickValues: (_props_showRoundOffXTickValues = props.showRoundOffXTickValues) !== null && _props_showRoundOffXTickValues !== void 0 ? _props_showRoundOffXTickValues : true,
@@ -193,24 +190,8 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
193
190
  xAxisInnerPadding: props.xAxisInnerPadding,
194
191
  xAxisOuterPadding: props.xAxisOuterPadding,
195
192
  containerWidth: containerWidth,
196
- hideTickOverlap: props.hideTickOverlap && !props.rotateXAxisLables && !props.showXAxisLablesTooltip && !props.wrapXAxisLables
197
- };
198
- const YAxisParams = {
199
- margins: props.getYDomainMargins ? props.getYDomainMargins(containerHeight) : margins,
200
- containerWidth: containerWidth,
201
- containerHeight: containerHeight - removalValueForTextTuncate,
202
- yAxisElement: yAxisElement.current,
203
- yAxisTickFormat: props.yAxisTickFormat,
204
- yAxisTickCount: props.yAxisTickCount,
205
- yMinValue: props.yMinValue || 0,
206
- yMaxValue: props.yMaxValue || 0,
207
- tickPadding: props.showYAxisLablesTooltip ? 15 : 10,
208
- maxOfYVal: props.maxOfYVal,
209
- yMinMaxValues: props.getMinMaxOfYAxis(points, props.yAxisType),
210
- // please note these padding default values must be consistent in here
211
- // and the parent chart(HBWA/Vertical etc..) for more details refer example
212
- // http://using-d3js.com/04_07_ordinal_scales.html
213
- yAxisPadding: props.yAxisPadding || 0
193
+ hideTickOverlap: props.rotateXAxisLables ? false : props.hideTickOverlap,
194
+ calcMaxLabelWidth: _calcMaxLabelWidthWithTransform
214
195
  };
215
196
  /**
216
197
  * These scales used for 2 purposes.
@@ -235,25 +216,24 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
235
216
  }
236
217
  _xScale = xScale;
237
218
  _tickValues = tickValues;
238
- /*
239
- * To enable wrapping of x axis tick values or to display complete x axis tick values,
240
- * we need to calculate how much space it needed to render the text.
241
- * No need to re-calculate every time the chart renders and same time need to get an update. So using set
242
- * Required space will be calculated first time chart rendering and if any width/height of chart updated.
243
- * */ if (props.wrapXAxisLables || props.showXAxisLablesTooltip) {
244
- const wrapLabelProps = {
245
- node: xAxisElement.current,
246
- xAxis: xScale,
247
- showXAxisLablesTooltip: props.showXAxisLablesTooltip || false,
248
- noOfCharsToTruncate: props.noOfCharsToTruncate || 4
249
- };
250
- const temp = xScale && createWrapOfXLabels(wrapLabelProps);
251
- // this value need to be updated for draw graph updated. So instead of using private value, using set
252
- if (isRemoveValCalculated && removalValueForTextTuncate !== temp) {
253
- setRemovalValueForTextTuncate(temp);
254
- setIsRemoveValCalculated(false);
255
- }
256
- }
219
+ _transformXAxisLabels();
220
+ const YAxisParams = {
221
+ margins: props.getYDomainMargins ? props.getYDomainMargins(containerHeight) : margins,
222
+ containerWidth: containerWidth,
223
+ containerHeight: containerHeight - _removalValueForTextTuncate,
224
+ yAxisElement: yAxisElement.current,
225
+ yAxisTickFormat: props.yAxisTickFormat,
226
+ yAxisTickCount: props.yAxisTickCount,
227
+ yMinValue: props.yMinValue || 0,
228
+ yMaxValue: props.yMaxValue || 0,
229
+ tickPadding: 10,
230
+ maxOfYVal: props.maxOfYVal,
231
+ yMinMaxValues: props.getMinMaxOfYAxis(points, props.yAxisType),
232
+ // please note these padding default values must be consistent in here
233
+ // and the parent chart(HBWA/Vertical etc..) for more details refer example
234
+ // http://using-d3js.com/04_07_ordinal_scales.html
235
+ yAxisPadding: props.yAxisPadding || 0
236
+ };
257
237
  /**
258
238
  * These scales used for 2 purposes.
259
239
  * 1. To create x and y axis
@@ -280,7 +260,7 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
280
260
  const YAxisParamsSecondary = {
281
261
  margins: margins,
282
262
  containerWidth: containerWidth,
283
- containerHeight: containerHeight - removalValueForTextTuncate,
263
+ containerHeight: containerHeight - _removalValueForTextTuncate,
284
264
  yAxisElement: yAxisElementSecondary.current,
285
265
  yAxisTickFormat: props.yAxisTickFormat,
286
266
  yAxisTickCount: props.yAxisTickCount,
@@ -327,7 +307,7 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
327
307
  // Call back to the chart.
328
308
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
329
309
  const _getData = (xScale, yScalePrimary, yScaleSecondary)=>{
330
- props.getGraphData && props.getGraphData(xScale, yScalePrimary, containerHeight - removalValueForTextTuncate, containerWidth, xAxisElement.current, yAxisElement.current, yScaleSecondary);
310
+ props.getGraphData && props.getGraphData(xScale, yScalePrimary, containerHeight - _removalValueForTextTuncate, containerWidth, xAxisElement.current, yAxisElement.current, yScaleSecondary);
331
311
  };
332
312
  props.getAxisData && props.getAxisData(axisData);
333
313
  // Callback function for chart, returns axis
@@ -348,7 +328,7 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
348
328
  height: containerHeight
349
329
  };
350
330
  const xAxisTitleMaximumAllowedWidth = svgDimensions.width - margins.left - margins.right - startFromX;
351
- const yAxisTitleMaximumAllowedHeight = svgDimensions.height - margins.bottom - margins.top - removalValueForTextTuncate - titleMargin;
331
+ const yAxisTitleMaximumAllowedHeight = svgDimensions.height - margins.bottom - margins.top - _removalValueForTextTuncate - titleMargin;
352
332
  /**
353
333
  * When screen resizes, along with screen, chart also auto adjusted.
354
334
  * This method used to adjust height and width of the charts.
@@ -379,39 +359,88 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
379
359
  props.onChartMouseLeave && props.onChartMouseLeave();
380
360
  }
381
361
  function _calculateChartMinWidth() {
382
- let labelWidth = 10; // Total padding on the left and right sides of the label
362
+ // Adding 10px for padding on both sides
363
+ const labelWidth = _calcMaxLabelWidthWithTransform(_tickValues) + 10;
364
+ let minChartWidth = margins.left + margins.right + labelWidth * (_tickValues.length - 1);
365
+ if ([
366
+ ChartTypes.GroupedVerticalBarChart,
367
+ ChartTypes.VerticalBarChart,
368
+ ChartTypes.VerticalStackedBarChart
369
+ ].includes(props.chartType)) {
370
+ const minDomainMargin = 8;
371
+ minChartWidth += minDomainMargin * 2;
372
+ }
373
+ return minChartWidth;
374
+ }
375
+ function _calcMaxLabelWidthWithTransform(x) {
383
376
  // Case: rotated labels
384
377
  if (!props.wrapXAxisLables && props.rotateXAxisLables && props.xAxisType === XAxisTypes.StringAxis) {
385
- const longestLabelWidth = calculateLongestLabelWidth(_tickValues, `.${classes.xAxis} text`);
386
- labelWidth += Math.ceil(longestLabelWidth * Math.cos(Math.PI / 4));
387
- } else if (props.showXAxisLablesTooltip) {
388
- const tickValues = _tickValues.map((val)=>{
378
+ const longestLabelWidth = calculateLongestLabelWidth(x, `.${classes.xAxis} text`);
379
+ return Math.ceil(longestLabelWidth * Math.cos(Math.PI / 4));
380
+ }
381
+ // Case: truncated labels
382
+ if (props.showXAxisLablesTooltip) {
383
+ const tickValues = x.map((val)=>{
389
384
  const numChars = props.noOfCharsToTruncate || 4;
390
385
  return val.toString().length > numChars ? `${val.toString().slice(0, numChars)}...` : val;
391
386
  });
392
387
  const longestLabelWidth = calculateLongestLabelWidth(tickValues, `.${classes.xAxis} text`);
393
- labelWidth += Math.ceil(longestLabelWidth);
394
- } else if (props.wrapXAxisLables) {
388
+ return Math.ceil(longestLabelWidth);
389
+ }
390
+ // Case: wrapped labels
391
+ if (props.wrapXAxisLables) {
392
+ // FIXME: Calculate the max width of lines instead of words. This requires applying
393
+ // the wrapping transformation earlier to obtain the actual rendered lines.
395
394
  const words = [];
396
- _tickValues.forEach((val)=>{
395
+ x.forEach((val)=>{
397
396
  words.push(...val.toString().split(/\s+/));
398
397
  });
398
+ // This approach works well in most cases, since overflow typically occurs only when
399
+ // a single word exceeds the specified width — otherwise, the text will wrap as expected.
399
400
  const longestLabelWidth = calculateLongestLabelWidth(words, `.${classes.xAxis} text`);
400
- labelWidth += Math.max(Math.ceil(longestLabelWidth), 10);
401
- } else {
402
- const longestLabelWidth = calculateLongestLabelWidth(_tickValues, `.${classes.xAxis} text`);
403
- labelWidth += Math.ceil(longestLabelWidth);
401
+ return Math.max(Math.ceil(longestLabelWidth), DEFAULT_WRAP_WIDTH);
404
402
  }
405
- let minChartWidth = margins.left + margins.right + labelWidth * (_tickValues.length - 1);
406
- if ([
407
- ChartTypes.GroupedVerticalBarChart,
408
- ChartTypes.VerticalBarChart,
409
- ChartTypes.VerticalStackedBarChart
410
- ].includes(props.chartType)) {
411
- const minDomainMargin = 8;
412
- minChartWidth += minDomainMargin * 2;
403
+ // Default case
404
+ const longestLabelWidth = calculateLongestLabelWidth(x, `.${classes.xAxis} text`);
405
+ return Math.ceil(longestLabelWidth);
406
+ }
407
+ function _transformXAxisLabels() {
408
+ _removalValueForTextTuncate = 0;
409
+ /*
410
+ * To enable wrapping of x axis tick values or to display complete x axis tick values,
411
+ * we need to calculate how much space it needed to render the text.
412
+ * No need to re-calculate every time the chart renders and same time need to get an update. So using setState.
413
+ * Required space will be calculated first time chart rendering and if any width/height of chart updated.
414
+ * */ if (props.wrapXAxisLables || props.showXAxisLablesTooltip) {
415
+ let maxXAxisLabelWidth;
416
+ if (props.xAxisType === XAxisTypes.StringAxis) {
417
+ var _props_datasetForXAxisDomain;
418
+ if ((((_props_datasetForXAxisDomain = props.datasetForXAxisDomain) === null || _props_datasetForXAxisDomain === void 0 ? void 0 : _props_datasetForXAxisDomain.length) || 0) > 1) {
419
+ maxXAxisLabelWidth = _xScale.step();
420
+ } else {
421
+ maxXAxisLabelWidth = containerWidth;
422
+ }
423
+ }
424
+ const wrapLabelProps = {
425
+ node: xAxisElement.current,
426
+ xAxis: _xScale,
427
+ showXAxisLablesTooltip: props.showXAxisLablesTooltip || false,
428
+ noOfCharsToTruncate: props.noOfCharsToTruncate || 4,
429
+ width: maxXAxisLabelWidth
430
+ };
431
+ var _createWrapOfXLabels;
432
+ _removalValueForTextTuncate = (_createWrapOfXLabels = createWrapOfXLabels(wrapLabelProps)) !== null && _createWrapOfXLabels !== void 0 ? _createWrapOfXLabels : 0;
433
+ }
434
+ if (!props.wrapXAxisLables && props.rotateXAxisLables && props.xAxisType === XAxisTypes.StringAxis) {
435
+ const rotateLabelProps = {
436
+ node: xAxisElement.current,
437
+ xAxis: _xScale
438
+ };
439
+ var _rotateXAxisLabels;
440
+ const rotatedHeight = (_rotateXAxisLabels = rotateXAxisLabels(rotateLabelProps)) !== null && _rotateXAxisLabels !== void 0 ? _rotateXAxisLabels : 0;
441
+ // margins.bottom is used as padding here
442
+ _removalValueForTextTuncate = rotatedHeight + margins.bottom;
413
443
  }
414
- return minChartWidth;
415
444
  }
416
445
  /**
417
446
  * We have use the {@link defaultTabbableElement } to fix
@@ -456,7 +485,7 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
456
485
  },
457
486
  id: `xAxisGElement${idForGraph}`,
458
487
  // To add wrap of x axis lables feature, need to remove word height from svg height.
459
- transform: `translate(0, ${svgDimensions.height - margins.bottom - removalValueForTextTuncate})`,
488
+ transform: `translate(0, ${svgDimensions.height - margins.bottom - _removalValueForTextTuncate})`,
460
489
  className: classes.xAxis
461
490
  }), props.xAxisTitle !== undefined && props.xAxisTitle !== '' && /*#__PURE__*/ React.createElement(SVGTooltipText, {
462
491
  content: props.xAxisTitle,
@@ -487,7 +516,7 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
487
516
  }), props.secondaryYAxistitle !== undefined && props.secondaryYAxistitle !== '' && /*#__PURE__*/ React.createElement(SVGTooltipText, {
488
517
  content: props.secondaryYAxistitle,
489
518
  textProps: {
490
- x: (yAxisTitleMaximumAllowedHeight - margins.bottom) / 2 + removalValueForTextTuncate,
519
+ x: (yAxisTitleMaximumAllowedHeight - margins.bottom) / 2 + _removalValueForTextTuncate,
491
520
  y: _useRtl ? startFromX - titleMargin : svgDimensions.width - margins.right,
492
521
  textAnchor: 'middle',
493
522
  transform: `translate(${_useRtl ? margins.right / 2 - titleMargin : margins.right / 2 + titleMargin},
@@ -501,7 +530,7 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
501
530
  })), children, props.yAxisTitle !== undefined && props.yAxisTitle !== '' && /*#__PURE__*/ React.createElement(SVGTooltipText, {
502
531
  content: props.yAxisTitle,
503
532
  textProps: {
504
- x: (yAxisTitleMaximumAllowedHeight - margins.bottom) / 2 + removalValueForTextTuncate,
533
+ x: (yAxisTitleMaximumAllowedHeight - margins.bottom) / 2 + _removalValueForTextTuncate,
505
534
  y: _useRtl ? svgDimensions.width - margins.right / 2 + titleMargin : margins.left / 2 - titleMargin,
506
535
  textAnchor: 'middle',
507
536
  transform: `translate(0,