@fluentui/react-charts 9.2.1 → 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.
- package/CHANGELOG.md +24 -2
- package/dist/index.d.ts +79 -5
- package/lib/ChartTable.js +1 -0
- package/lib/ChartTable.js.map +1 -0
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.js +57 -0
- package/lib/components/ChartTable/ChartTable.js.map +1 -0
- package/lib/components/ChartTable/ChartTable.types.js +1 -0
- package/lib/components/ChartTable/ChartTable.types.js.map +1 -0
- package/lib/components/ChartTable/index.js +3 -0
- package/lib/components/ChartTable/index.js.map +1 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.js +93 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +55 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
- package/lib/components/CommonComponents/CartesianChart.js +110 -81
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/ChartPopover.types.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +20 -10
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +95 -0
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +164 -77
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib/components/GanttChart/GanttChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +161 -141
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib/components/Legends/Legends.js.map +1 -1
- package/lib/components/Legends/OverflowMenu.js.map +1 -1
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +12 -11
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +57 -51
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/utilities/FocusableTooltipText.js.map +1 -1
- package/lib/utilities/utilities.js +26 -37
- package/lib/utilities/utilities.js.map +1 -1
- package/lib/utilities/vbc-utils.js +24 -0
- package/lib/utilities/vbc-utils.js.map +1 -1
- package/lib-commonjs/ChartTable.js +6 -0
- package/lib-commonjs/ChartTable.js.map +1 -0
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.js +68 -0
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -0
- package/lib-commonjs/components/ChartTable/ChartTable.types.js +6 -0
- package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -0
- package/lib-commonjs/components/ChartTable/index.js +8 -0
- package/lib-commonjs/components/ChartTable/index.js.map +1 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +196 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +69 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +109 -80
- package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/ChartPopover.types.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +19 -9
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +120 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +164 -77
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +159 -139
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.js.map +1 -1
- package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +11 -10
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +56 -50
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/index.js +1 -0
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +29 -37
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/lib-commonjs/utilities/vbc-utils.js +27 -0
- package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
- package/package.json +9 -9
|
@@ -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 @@
|
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
//
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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 -
|
|
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 -
|
|
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 -
|
|
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
|
-
|
|
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(
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
|
|
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
|
-
|
|
394
|
-
}
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
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 -
|
|
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 +
|
|
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 +
|
|
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,
|