@fluentui/react-charting 5.24.15 → 5.24.17

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 (55) hide show
  1. package/CHANGELOG.json +49 -1
  2. package/CHANGELOG.md +23 -2
  3. package/dist/react-charting.d.ts +1 -1
  4. package/dist/react-charting.js +1 -1
  5. package/dist/react-charting.min.js +1 -1
  6. package/etc/react-charting.api.md +1 -1
  7. package/lib/components/ChartTable/ChartTable.base.js +83 -4
  8. package/lib/components/ChartTable/ChartTable.base.js.map +1 -1
  9. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +72 -25
  10. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  11. package/lib/components/FunnelChart/FunnelChart.base.js +44 -15
  12. package/lib/components/FunnelChart/FunnelChart.base.js.map +1 -1
  13. package/lib/components/FunnelChart/funnelGeometry.d.ts +8 -8
  14. package/lib/components/FunnelChart/funnelGeometry.js +4 -4
  15. package/lib/components/FunnelChart/funnelGeometry.js.map +1 -1
  16. package/lib/components/ScatterChart/ScatterChart.base.js +15 -9
  17. package/lib/components/ScatterChart/ScatterChart.base.js.map +1 -1
  18. package/lib/types/IDataPoint.d.ts +1 -1
  19. package/lib/types/IDataPoint.js.map +1 -1
  20. package/lib/utilities/utilities.d.ts +6 -0
  21. package/lib/utilities/utilities.js +10 -0
  22. package/lib/utilities/utilities.js.map +1 -1
  23. package/lib-amd/components/ChartTable/ChartTable.base.js +81 -4
  24. package/lib-amd/components/ChartTable/ChartTable.base.js.map +1 -1
  25. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +72 -25
  26. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  27. package/lib-amd/components/FunnelChart/FunnelChart.base.js +44 -15
  28. package/lib-amd/components/FunnelChart/FunnelChart.base.js.map +1 -1
  29. package/lib-amd/components/FunnelChart/funnelGeometry.d.ts +8 -8
  30. package/lib-amd/components/FunnelChart/funnelGeometry.js +9 -9
  31. package/lib-amd/components/FunnelChart/funnelGeometry.js.map +1 -1
  32. package/lib-amd/components/ScatterChart/ScatterChart.base.js +14 -8
  33. package/lib-amd/components/ScatterChart/ScatterChart.base.js.map +1 -1
  34. package/lib-amd/types/IDataPoint.d.ts +1 -1
  35. package/lib-amd/types/IDataPoint.js.map +1 -1
  36. package/lib-amd/utilities/utilities.d.ts +6 -0
  37. package/lib-amd/utilities/utilities.js +12 -1
  38. package/lib-amd/utilities/utilities.js.map +1 -1
  39. package/lib-commonjs/components/ChartTable/ChartTable.base.js +82 -3
  40. package/lib-commonjs/components/ChartTable/ChartTable.base.js.map +1 -1
  41. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +72 -25
  42. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  43. package/lib-commonjs/components/FunnelChart/FunnelChart.base.js +44 -15
  44. package/lib-commonjs/components/FunnelChart/FunnelChart.base.js.map +1 -1
  45. package/lib-commonjs/components/FunnelChart/funnelGeometry.d.ts +8 -8
  46. package/lib-commonjs/components/FunnelChart/funnelGeometry.js +9 -9
  47. package/lib-commonjs/components/FunnelChart/funnelGeometry.js.map +1 -1
  48. package/lib-commonjs/components/ScatterChart/ScatterChart.base.js +14 -8
  49. package/lib-commonjs/components/ScatterChart/ScatterChart.base.js.map +1 -1
  50. package/lib-commonjs/types/IDataPoint.d.ts +1 -1
  51. package/lib-commonjs/types/IDataPoint.js.map +1 -1
  52. package/lib-commonjs/utilities/utilities.d.ts +6 -0
  53. package/lib-commonjs/utilities/utilities.js +12 -1
  54. package/lib-commonjs/utilities/utilities.js.map +1 -1
  55. package/package.json +2 -2
@@ -36,6 +36,12 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
36
36
  setIsCalloutVisible(true);
37
37
  setRefSelected(mouseEvent.currentTarget);
38
38
  }
39
+ function _handleFocus(data, focusEvent) {
40
+ focusEvent === null || focusEvent === void 0 ? void 0 : focusEvent.persist();
41
+ setCalloutData(data);
42
+ setIsCalloutVisible(true);
43
+ setRefSelected(focusEvent.currentTarget);
44
+ }
39
45
  function _handleStackedHover(stage, subValue, mouseEvent) {
40
46
  mouseEvent === null || mouseEvent === void 0 ? void 0 : mouseEvent.persist();
41
47
  setHoveredStage(subValue.category);
@@ -48,6 +54,17 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
48
54
  setIsCalloutVisible(true);
49
55
  setRefSelected(mouseEvent.currentTarget);
50
56
  }
57
+ function _handleStackedFocus(stage, subValue, focusEvent) {
58
+ focusEvent === null || focusEvent === void 0 ? void 0 : focusEvent.persist();
59
+ setCalloutData({
60
+ stage: stage,
61
+ value: subValue.value,
62
+ color: subValue.color,
63
+ category: subValue.category,
64
+ });
65
+ setIsCalloutVisible(true);
66
+ setRefSelected(focusEvent.currentTarget);
67
+ }
51
68
  function _handleMouseOut() {
52
69
  setHoveredStage(null);
53
70
  setIsCalloutVisible(false);
@@ -76,20 +93,28 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
76
93
  function noLegendHighlighted() {
77
94
  return getHighlightedLegend().length === 0;
78
95
  }
79
- function _getEventHandlerProps(data) {
96
+ function _getEventHandlerProps(data, opacity) {
80
97
  if ('subValue' in data) {
81
98
  return {
82
99
  culture: props.culture,
83
- onMouseOver: function (event) { return _handleStackedHover(data.stage, data.subValue, event); },
84
- onMouseMove: function (event) { return _handleStackedHover(data.stage, data.subValue, event); },
100
+ onMouseOver: opacity === 1
101
+ ? function (event) { return _handleStackedHover(data.stage, data.subValue, event); }
102
+ : undefined,
103
+ onMouseMove: opacity === 1
104
+ ? function (event) { return _handleStackedHover(data.stage, data.subValue, event); }
105
+ : undefined,
106
+ onFocus: function (event) { return _handleStackedFocus(data.stage, data.subValue, event); },
107
+ onBlur: function () { return _handleMouseOut(); },
85
108
  onMouseOut: function () { return _handleMouseOut(); },
86
109
  };
87
110
  }
88
111
  else {
89
112
  return {
90
113
  culture: props.culture,
91
- onMouseOver: function (event) { return _handleHover(data, event); },
92
- onMouseMove: function (event) { return _handleHover(data, event); },
114
+ onMouseOver: opacity === 1 ? function (event) { return _handleHover(data, event); } : undefined,
115
+ onMouseMove: opacity === 1 ? function (event) { return _handleHover(data, event); } : undefined,
116
+ onFocus: function (event) { return _handleFocus(data, event); },
117
+ onBlur: function () { return _handleMouseOut(); },
93
118
  onMouseOut: function () { return _handleMouseOut(); },
94
119
  };
95
120
  }
@@ -106,11 +131,11 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
106
131
  return textElement;
107
132
  }
108
133
  function _renderFunnelSegment(_a) {
109
- var key = _a.key, pathD = _a.pathD, fill = _a.fill, opacity = _a.opacity, textProps = _a.textProps, data = _a.data;
110
- var eventHandlers = _getEventHandlerProps(data);
134
+ var key = _a.key, pathD = _a.pathD, fill = _a.fill, opacity = _a.opacity, textProps = _a.textProps, data = _a.data, isFocusable = _a.isFocusable;
135
+ var eventHandlers = _getEventHandlerProps(data, opacity);
111
136
  var textColor = (0, utilities_1.getContrastTextColor)(fill, props.theme);
112
137
  return (React.createElement("g", { key: key },
113
- React.createElement("path", tslib_1.__assign({ d: pathD, fill: fill, opacity: opacity }, eventHandlers)),
138
+ React.createElement("path", tslib_1.__assign({ d: pathD, fill: fill, opacity: opacity }, eventHandlers, { "data-is-focusable": isFocusable })),
114
139
  textProps && React.createElement("g", tslib_1.__assign({}, eventHandlers), _renderSegmentText(tslib_1.__assign(tslib_1.__assign({}, textProps), { textColor: textColor })))));
115
140
  }
116
141
  function _createFunnel(containerHeight, containerWidth) {
@@ -118,9 +143,9 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
118
143
  var funnelWidth = containerWidth;
119
144
  var funnelHeight = containerHeight * 0.8;
120
145
  return data.map(function (d, i) {
121
- var geometryProps = props.orientation === 'horizontal'
122
- ? (0, funnelGeometry_1.getHorizontalFunnelSegmentGeometry)({ d: d, i: i, data: data, funnelWidth: funnelWidth, funnelHeight: funnelHeight, isRTL: isRTL })
123
- : (0, funnelGeometry_1.getVerticalFunnelSegmentGeometry)({ d: d, i: i, data: data, funnelWidth: funnelWidth, funnelHeight: funnelHeight, isRTL: isRTL });
146
+ var geometryProps = props.orientation === 'vertical'
147
+ ? (0, funnelGeometry_1.getVerticalFunnelSegmentGeometry)({ d: d, i: i, data: data, funnelWidth: funnelWidth, funnelHeight: funnelHeight, isRTL: isRTL })
148
+ : (0, funnelGeometry_1.getHorizontalFunnelSegmentGeometry)({ d: d, i: i, data: data, funnelWidth: funnelWidth, funnelHeight: funnelHeight, isRTL: isRTL });
124
149
  var pathD = geometryProps.pathD, textX = geometryProps.textX, textY = geometryProps.textY, availableWidth = geometryProps.availableWidth;
125
150
  var minTextWidth = 16;
126
151
  var eventHandlerProps = _getEventHandlerProps(d);
@@ -132,6 +157,7 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
132
157
  opacity: legendHighlighted(d.stage) || noLegendHighlighted() ? 1 : 0.1,
133
158
  textProps: textProps,
134
159
  data: d,
160
+ isFocusable: legendHighlighted(d.stage) || noLegendHighlighted() ? true : false,
135
161
  });
136
162
  });
137
163
  }
@@ -141,9 +167,9 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
141
167
  function _renderStackedSegment(stage, subValue, stageIndex, subValueIndex, geometryParams) {
142
168
  // Ensure stages have subValues for geometry functions
143
169
  var stagesWithSubValues = geometryParams.stages.map(function (s) { return (tslib_1.__assign(tslib_1.__assign({}, s), { subValues: s.subValues || [] })); });
144
- var geom = props.orientation === 'horizontal'
145
- ? (0, funnelGeometry_1.getStackedHorizontalFunnelSegmentGeometry)(tslib_1.__assign(tslib_1.__assign({}, geometryParams), { stages: stagesWithSubValues, i: stageIndex, k: subValueIndex }))
146
- : (0, funnelGeometry_1.getStackedVerticalFunnelSegmentGeometry)(tslib_1.__assign(tslib_1.__assign({}, geometryParams), { stages: stagesWithSubValues, i: stageIndex, k: subValueIndex }));
170
+ var geom = props.orientation === 'vertical'
171
+ ? (0, funnelGeometry_1.getStackedVerticalFunnelSegmentGeometry)(tslib_1.__assign(tslib_1.__assign({}, geometryParams), { stages: stagesWithSubValues, i: stageIndex, k: subValueIndex }))
172
+ : (0, funnelGeometry_1.getStackedHorizontalFunnelSegmentGeometry)(tslib_1.__assign(tslib_1.__assign({}, geometryParams), { stages: stagesWithSubValues, i: stageIndex, k: subValueIndex }));
147
173
  var minTextWidth = 16;
148
174
  var eventHandlerProps = _getEventHandlerProps({ stage: stage.stage, subValue: subValue });
149
175
  var textProps = (0, funnelGeometry_1.getSegmentTextProps)(tslib_1.__assign({ availableWidth: geom.availableWidth, minTextWidth: minTextWidth, textX: geom.textX, textY: geom.textY, value: subValue.value }, eventHandlerProps));
@@ -154,6 +180,9 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
154
180
  opacity: (isStackedFunnelData(props.data) && legendHighlighted(subValue.category)) || noLegendHighlighted() ? 1 : 0.1,
155
181
  textProps: textProps,
156
182
  data: { stage: stage.stage, subValue: subValue },
183
+ isFocusable: (isStackedFunnelData(props.data) && legendHighlighted(subValue.category)) || noLegendHighlighted()
184
+ ? true
185
+ : false,
157
186
  });
158
187
  }
159
188
  function _createStackedFunnel(containerHeight, containerWidth) {
@@ -254,7 +283,7 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
254
283
  exports.FunnelChartBase.displayName = 'FunnelChart';
255
284
  // eslint-disable-next-line @typescript-eslint/no-deprecated
256
285
  exports.FunnelChartBase.defaultProps = {
257
- orientation: 'horizontal',
286
+ orientation: 'vertical',
258
287
  };
259
288
  });
260
289
  //# sourceMappingURL=FunnelChart.base.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FunnelChart.base.js","sourceRoot":"../src/","sources":["components/FunnelChart/FunnelChart.base.tsx"],"names":[],"mappings":";;;;IAwBA,IAAM,aAAa,GAAG,IAAA,8BAAkB,GAA8C,CAAC;IAE1E,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CAAC,CAAC,CAAC,CACF,6BAAK,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,gBAAc,8BAA8B,GAAI,CAC/G,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,uBAAe,CAAC,WAAW,GAAG,aAAa,CAAC;IAC5C,4DAA4D;IAC5D,uBAAe,CAAC,YAAY,GAAG;QAC7B,WAAW,EAAE,YAAY;KAC1B,CAAC","sourcesContent":["import * as React from 'react';\nimport { classNamesFunction, getId, getRTL } from '@fluentui/react/lib/Utilities';\nimport {\n IFunnelChartDataPoint,\n IFunnelChartProps,\n IFunnelChartStyleProps,\n IFunnelChartStyles,\n} from './FunnelChart.types';\nimport { FocusZone, FocusZoneDirection } from '@fluentui/react-focus';\nimport { ILegend, ILegendContainer, Legends } from '../Legends/index';\nimport { Callout, DirectionalHint } from '@fluentui/react/lib/Callout';\nimport { ChartHoverCard } from '../../utilities/ChartHoverCard/ChartHoverCard';\nimport { formatToLocaleString } from '@fluentui/chart-utilities';\nimport { IImageExportOptions } from '../../types/index';\nimport { toImage as convertToImage } from '../../utilities/image-export-utils';\nimport { getContrastTextColor } from '../../utilities/utilities';\nimport {\n getHorizontalFunnelSegmentGeometry,\n getVerticalFunnelSegmentGeometry,\n getSegmentTextProps,\n getStackedHorizontalFunnelSegmentGeometry,\n getStackedVerticalFunnelSegmentGeometry,\n} from './funnelGeometry';\n\nconst getClassNames = classNamesFunction<IFunnelChartStyleProps, IFunnelChartStyles>();\n\nexport const FunnelChartBase: React.FunctionComponent<IFunnelChartProps> = React.forwardRef<\n HTMLDivElement,\n IFunnelChartProps\n>((props, forwardedRef) => {\n const _tooltipId: string = getId('FunnelChartTooltipId_');\n const _emptyChartId: string = getId('_FunnelChart_empty');\n const isRTL = getRTL();\n\n const [hoveredStage, setHoveredStage] = React.useState<string | null>(null);\n const [isCalloutVisible, setIsCalloutVisible] = React.useState(false);\n const [calloutData, setCalloutData] = React.useState<IFunnelChartDataPoint | null>(null);\n const [refSelected, setRefSelected] = React.useState<SVGElement | null>(null);\n const [selectedLegends, setSelectedLegends] = React.useState<string[]>([]);\n const chartContainerRef = React.useRef<HTMLDivElement | null>(null);\n const legendsRef = React.useRef<ILegendContainer | null>(null);\n const isStacked = isStackedFunnelData(props.data);\n\n React.useEffect(() => {\n if (props.legendProps?.selectedLegends) {\n setSelectedLegends(props.legendProps.selectedLegends);\n }\n }, [props.legendProps?.selectedLegends]);\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n chartContainer: chartContainerRef ?? null,\n toImage: (opts?: IImageExportOptions): Promise<string> => {\n return convertToImage(chartContainerRef.current, legendsRef.current?.toSVG, getRTL(), opts);\n },\n }),\n [],\n );\n\n function _handleHover(data: IFunnelChartDataPoint, mouseEvent: React.MouseEvent<SVGElement>) {\n mouseEvent?.persist();\n setHoveredStage(data.stage as string);\n setCalloutData(data);\n setIsCalloutVisible(true);\n setRefSelected(mouseEvent.currentTarget);\n }\n\n function _handleStackedHover(\n stage: string,\n subValue: { category: string; value: number; color: string },\n mouseEvent: React.MouseEvent<SVGElement>,\n ) {\n mouseEvent?.persist();\n setHoveredStage(subValue.category);\n setCalloutData({\n stage,\n value: subValue.value,\n color: subValue.color,\n category: subValue.category,\n } as IFunnelChartDataPoint);\n setIsCalloutVisible(true);\n setRefSelected(mouseEvent.currentTarget);\n }\n\n function _handleMouseOut() {\n setHoveredStage(null);\n setIsCalloutVisible(false);\n setCalloutData(null);\n setRefSelected(null);\n }\n\n function _onLegendSelectionChange(\n legendsSelected: string[],\n event: React.MouseEvent<HTMLButtonElement>,\n currentLegend?: ILegend,\n ): void {\n if (props.legendProps?.canSelectMultipleLegends) {\n setSelectedLegends(legendsSelected);\n } else {\n setSelectedLegends(legendsSelected.slice(-1));\n }\n\n if (props.legendProps?.onChange) {\n props.legendProps.onChange(legendsSelected, event, currentLegend);\n }\n }\n\n const _onLegendSelectionChangeCallback = React.useCallback(_onLegendSelectionChange, [props.legendProps]);\n\n function getHighlightedLegend(): string[] {\n return selectedLegends.length > 0 ? selectedLegends : hoveredStage ? [hoveredStage] : [];\n }\n\n function legendHighlighted(legend: string): boolean {\n return getHighlightedLegend().includes(legend);\n }\n\n function noLegendHighlighted(): boolean {\n return getHighlightedLegend().length === 0;\n }\n\n function _getEventHandlerProps(\n data: IFunnelChartDataPoint | { stage: string; subValue: { category: string; value: number; color: string } },\n ) {\n if ('subValue' in data) {\n return {\n culture: props.culture,\n onMouseOver: (event: React.MouseEvent<SVGElement>) => _handleStackedHover(data.stage, data.subValue, event),\n onMouseMove: (event: React.MouseEvent<SVGElement>) => _handleStackedHover(data.stage, data.subValue, event),\n onMouseOut: () => _handleMouseOut(),\n };\n } else {\n return {\n culture: props.culture,\n onMouseOver: (event: React.MouseEvent<SVGElement>) => _handleHover(data, event),\n onMouseMove: (event: React.MouseEvent<SVGElement>) => _handleHover(data, event),\n onMouseOut: () => _handleMouseOut(),\n };\n }\n }\n\n function _renderSegmentText({\n show,\n x,\n y,\n value,\n textColor,\n }: {\n show: boolean;\n x: number;\n y: number;\n value: number;\n textColor: string;\n }) {\n if (!show) {\n return null;\n }\n\n const textElement = (\n <text x={isRTL ? funnelWidth - x : x} y={y} textAnchor=\"middle\" alignmentBaseline=\"middle\" fill={textColor}>\n {formatToLocaleString(value.toString(), props.culture) as React.ReactNode}\n </text>\n );\n\n if (isRTL) {\n return <g transform={`scale(-1,1) translate(${-funnelWidth},0)`}>{textElement}</g>;\n }\n return textElement;\n }\n\n function _renderFunnelSegment({\n key,\n pathD,\n fill,\n opacity,\n textProps,\n data,\n }: {\n key: string | number;\n pathD: string;\n fill: string;\n opacity: number;\n textProps?: {\n show: boolean;\n x: number;\n y: number;\n value: number;\n };\n data: IFunnelChartDataPoint | { stage: string; subValue: { category: string; value: number; color: string } };\n }) {\n const eventHandlers = _getEventHandlerProps(data);\n const textColor = getContrastTextColor(fill, props.theme!);\n\n return (\n <g key={key}>\n <path d={pathD} fill={fill} opacity={opacity} {...eventHandlers} />\n {textProps && <g {...eventHandlers}>{_renderSegmentText({ ...textProps, textColor })}</g>}\n </g>\n );\n }\n\n function _createFunnel(\n containerHeight: number,\n containerWidth: number,\n ): // eslint-disable-next-line @typescript-eslint/no-deprecated\n JSX.Element[] {\n const { data } = props;\n const funnelWidth = containerWidth;\n const funnelHeight = containerHeight * 0.8;\n\n return data.map((d, i) => {\n const geometryProps =\n props.orientation === 'horizontal'\n ? getHorizontalFunnelSegmentGeometry({ d, i, data, funnelWidth, funnelHeight, isRTL })\n : getVerticalFunnelSegmentGeometry({ d, i, data, funnelWidth, funnelHeight, isRTL });\n\n const { pathD, textX, textY, availableWidth } = geometryProps;\n const minTextWidth = 16;\n const eventHandlerProps = _getEventHandlerProps(d);\n const textProps = getSegmentTextProps({\n availableWidth,\n minTextWidth,\n textX,\n textY,\n value: d.value!,\n ...eventHandlerProps,\n });\n\n return _renderFunnelSegment({\n key: i,\n pathD,\n fill: d.color!,\n opacity: legendHighlighted(d.stage as string) || noLegendHighlighted() ? 1 : 0.1,\n textProps,\n data: d,\n });\n });\n }\n\n function isStackedFunnelData(data: IFunnelChartDataPoint[]): boolean {\n return Array.isArray(data) && data.every(stage => Array.isArray(stage.subValues));\n }\n\n function _renderStackedSegment(\n stage: IFunnelChartDataPoint,\n subValue: { value: number; color: string; category: string },\n stageIndex: number,\n subValueIndex: number,\n geometryParams: {\n stages: IFunnelChartDataPoint[];\n totals: number[];\n maxTotal: number;\n funnelWidth: number;\n funnelHeight: number;\n isRTL: boolean;\n },\n ): // eslint-disable-next-line @typescript-eslint/no-deprecated\n JSX.Element {\n // Ensure stages have subValues for geometry functions\n const stagesWithSubValues = geometryParams.stages.map(s => ({\n ...s,\n subValues: s.subValues || [],\n }));\n\n const geom =\n props.orientation === 'horizontal'\n ? getStackedHorizontalFunnelSegmentGeometry({\n ...geometryParams,\n stages: stagesWithSubValues,\n i: stageIndex,\n k: subValueIndex,\n })\n : getStackedVerticalFunnelSegmentGeometry({\n ...geometryParams,\n stages: stagesWithSubValues,\n i: stageIndex,\n k: subValueIndex,\n });\n\n const minTextWidth = 16;\n const eventHandlerProps = _getEventHandlerProps({ stage: stage.stage as string, subValue });\n const textProps = getSegmentTextProps({\n availableWidth: geom.availableWidth,\n minTextWidth,\n textX: geom.textX,\n textY: geom.textY,\n value: subValue.value,\n ...eventHandlerProps,\n });\n\n return _renderFunnelSegment({\n key: `${stageIndex}-${subValueIndex}`,\n pathD: geom.pathD,\n fill: subValue.color,\n opacity:\n (isStackedFunnelData(props.data) && legendHighlighted(subValue.category)) || noLegendHighlighted() ? 1 : 0.1,\n textProps,\n data: { stage: stage.stage as string, subValue },\n });\n }\n\n function _createStackedFunnel(\n containerHeight: number,\n containerWidth: number,\n ): // eslint-disable-next-line @typescript-eslint/no-deprecated\n JSX.Element[] {\n const { data } = props;\n\n const stages = data;\n const totals = stages.map(s => s?.subValues?.reduce((sum, subValue) => sum + subValue.value, 0) ?? 0);\n const maxTotal = Math.max(...totals);\n\n const funnelWidth = containerWidth;\n const funnelHeight = containerHeight * 0.8;\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const paths: JSX.Element[] = [];\n\n const geometryParams = {\n stages,\n totals,\n maxTotal,\n funnelWidth,\n funnelHeight,\n isRTL,\n };\n\n for (let i = 0; i < stages.length; i++) {\n const cur = stages[i];\n for (let k = 0; k < (cur.subValues ?? []).length; k++) {\n const v = cur.subValues?.[k];\n if (!v) {\n continue;\n }\n paths.push(_renderStackedSegment(cur, v, i, k, geometryParams));\n }\n }\n return paths;\n }\n\n function _renderLegends(): // eslint-disable-next-line @typescript-eslint/no-deprecated\n JSX.Element {\n if (props.hideLegend) {\n return <></>;\n }\n let legends: ILegend[];\n\n if (isStacked) {\n // Collect unique categories and their color\n const categoryMap: Record<string, string> = {};\n props.data.forEach((stage: IFunnelChartDataPoint) => {\n (stage.subValues || []).forEach(sub => {\n if (!(sub.category in categoryMap)) {\n categoryMap[sub.category] = sub.color;\n }\n });\n });\n legends = Object.entries(categoryMap).map(([category, color]) => ({\n title: category,\n color,\n hoverAction: () => setHoveredStage(category),\n onMouseOutAction: () => setHoveredStage(null),\n }));\n } else {\n legends = props.data.map((d: IFunnelChartDataPoint) => ({\n title: d.stage as string,\n color: d.color!,\n hoverAction: () => setHoveredStage(d.stage as string),\n onMouseOutAction: () => setHoveredStage(null),\n }));\n }\n\n return (\n <div style={{ display: 'flex', justifyContent: 'center' }}>\n <Legends\n ref={legendsRef}\n legends={legends}\n centerLegends={true}\n onChange={_onLegendSelectionChangeCallback}\n {...props.legendProps}\n />\n </div>\n );\n }\n\n function _isChartEmpty(): boolean {\n return !(props.data && props.data.length > 0);\n }\n\n const calloutProps = {\n isCalloutVisible,\n directionalHint: DirectionalHint.topAutoEdge,\n id: `toolTip${_tooltipId}`,\n target: refSelected,\n color: calloutData?.color,\n XValue: calloutData?.stage,\n YValue: calloutData?.value,\n isBeakVisible: false,\n gapSpace: 15,\n onDismiss: () => {\n setIsCalloutVisible(false);\n },\n preventDismissOnLostFocus: true,\n ...props.calloutProps,\n };\n\n const width = props.width || 350;\n const height = props.height || 500;\n const classNames = getClassNames(props.styles!, {\n theme: props.theme!,\n className: props.className,\n chartWidth: width,\n chartHeight: height,\n });\n\n const funnelMarginTop = 40;\n const funnelWidth = width * 0.8;\n const funnelOffsetX = (width - funnelWidth) / 2;\n\n return !_isChartEmpty() ? (\n <div ref={chartContainerRef} className={classNames.root}>\n <FocusZone direction={FocusZoneDirection.horizontal}>\n <svg width={width} height={height} className={classNames.chart} role={'img'} aria-label={props.chartTitle}>\n <g\n transform={\n isRTL\n ? `translate(${funnelOffsetX + funnelWidth}, ${funnelMarginTop}) scale(-1,1)`\n : `translate(${funnelOffsetX}, ${funnelMarginTop})`\n }\n >\n {isStacked\n ? _createStackedFunnel(height - funnelMarginTop, funnelWidth)\n : _createFunnel(height - funnelMarginTop, funnelWidth)}\n </g>\n {isCalloutVisible && (\n <Callout {...calloutProps}>\n <ChartHoverCard\n XValue={calloutProps?.XValue as string}\n YValue={calloutProps?.YValue}\n color={calloutProps?.color}\n />\n </Callout>\n )}\n </svg>\n </FocusZone>\n {_renderLegends()}\n </div>\n ) : (\n <div id={_emptyChartId} role={'alert'} style={{ opacity: '0' }} aria-label={'Graph has no data to display'} />\n );\n});\nFunnelChartBase.displayName = 'FunnelChart';\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nFunnelChartBase.defaultProps = {\n orientation: 'horizontal',\n};\n"]}
1
+ {"version":3,"file":"FunnelChart.base.js","sourceRoot":"../src/","sources":["components/FunnelChart/FunnelChart.base.tsx"],"names":[],"mappings":";;;;IAwBA,IAAM,aAAa,GAAG,IAAA,8BAAkB,GAA8C,CAAC;IAE1E,QAAA,eAAe,GAA+C,KAAK,CAAC,UAAU,CAGzF,UAAC,KAAK,EAAE,YAAY;;QACpB,IAAM,UAAU,GAAW,IAAA,iBAAK,EAAC,uBAAuB,CAAC,CAAC;QAC1D,IAAM,aAAa,GAAW,IAAA,iBAAK,EAAC,oBAAoB,CAAC,CAAC;QAC1D,IAAM,KAAK,GAAG,IAAA,kBAAM,GAAE,CAAC;QAEjB,IAAA,KAAkC,KAAK,CAAC,QAAQ,CAAgB,IAAI,CAAC,EAApE,YAAY,QAAA,EAAE,eAAe,QAAuC,CAAC;QACtE,IAAA,KAA0C,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAA9D,gBAAgB,QAAA,EAAE,mBAAmB,QAAyB,CAAC;QAChE,IAAA,KAAgC,KAAK,CAAC,QAAQ,CAA+B,IAAI,CAAC,EAAjF,WAAW,QAAA,EAAE,cAAc,QAAsD,CAAC;QACnF,IAAA,KAAgC,KAAK,CAAC,QAAQ,CAAoB,IAAI,CAAC,EAAtE,WAAW,QAAA,EAAE,cAAc,QAA2C,CAAC;QACxE,IAAA,KAAwC,KAAK,CAAC,QAAQ,CAAW,EAAE,CAAC,EAAnE,eAAe,QAAA,EAAE,kBAAkB,QAAgC,CAAC;QAC3E,IAAM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,oBAAC,uBAAS,IAAC,SAAS,EAAE,gCAAkB,CAAC,UAAU;gBACjD,6BAAK,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,gBAAc,KAAK,CAAC,UAAU;oBACvG,2BACE,SAAS,EACP,KAAK;4BACH,CAAC,CAAC,oBAAa,aAAa,GAAG,WAAW,eAAK,eAAe,kBAAe;4BAC7E,CAAC,CAAC,oBAAa,aAAa,eAAK,eAAe,MAAG,IAGtD,SAAS;wBACR,CAAC,CAAC,oBAAoB,CAAC,MAAM,GAAG,eAAe,EAAE,WAAW,CAAC;wBAC7D,CAAC,CAAC,aAAa,CAAC,MAAM,GAAG,eAAe,EAAE,WAAW,CAAC,CACtD;oBACH,gBAAgB,IAAI,CACnB,oBAAC,iBAAO,uBAAK,YAAY;wBACvB,oBAAC,+BAAc,IACb,MAAM,EAAE,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,MAAgB,EACtC,MAAM,EAAE,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,MAAM,EAC5B,KAAK,EAAE,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,KAAK,GAC1B,CACM,CACX,CACG,CACI;YACX,cAAc,EAAE,CACb,CACP,CAAC,CAAC,CAAC,CACF,6BAAK,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,gBAAc,8BAA8B,GAAI,CAC/G,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,uBAAe,CAAC,WAAW,GAAG,aAAa,CAAC;IAC5C,4DAA4D;IAC5D,uBAAe,CAAC,YAAY,GAAG;QAC7B,WAAW,EAAE,UAAU;KACxB,CAAC","sourcesContent":["import * as React from 'react';\nimport { classNamesFunction, getId, getRTL } from '@fluentui/react/lib/Utilities';\nimport {\n IFunnelChartDataPoint,\n IFunnelChartProps,\n IFunnelChartStyleProps,\n IFunnelChartStyles,\n} from './FunnelChart.types';\nimport { FocusZone, FocusZoneDirection } from '@fluentui/react-focus';\nimport { ILegend, ILegendContainer, Legends } from '../Legends/index';\nimport { Callout, DirectionalHint } from '@fluentui/react/lib/Callout';\nimport { ChartHoverCard } from '../../utilities/ChartHoverCard/ChartHoverCard';\nimport { formatToLocaleString } from '@fluentui/chart-utilities';\nimport { IImageExportOptions } from '../../types/index';\nimport { toImage as convertToImage } from '../../utilities/image-export-utils';\nimport { getContrastTextColor } from '../../utilities/utilities';\nimport {\n getHorizontalFunnelSegmentGeometry,\n getVerticalFunnelSegmentGeometry,\n getSegmentTextProps,\n getStackedHorizontalFunnelSegmentGeometry,\n getStackedVerticalFunnelSegmentGeometry,\n} from './funnelGeometry';\n\nconst getClassNames = classNamesFunction<IFunnelChartStyleProps, IFunnelChartStyles>();\n\nexport const FunnelChartBase: React.FunctionComponent<IFunnelChartProps> = React.forwardRef<\n HTMLDivElement,\n IFunnelChartProps\n>((props, forwardedRef) => {\n const _tooltipId: string = getId('FunnelChartTooltipId_');\n const _emptyChartId: string = getId('_FunnelChart_empty');\n const isRTL = getRTL();\n\n const [hoveredStage, setHoveredStage] = React.useState<string | null>(null);\n const [isCalloutVisible, setIsCalloutVisible] = React.useState(false);\n const [calloutData, setCalloutData] = React.useState<IFunnelChartDataPoint | null>(null);\n const [refSelected, setRefSelected] = React.useState<SVGElement | null>(null);\n const [selectedLegends, setSelectedLegends] = React.useState<string[]>([]);\n const chartContainerRef = React.useRef<HTMLDivElement | null>(null);\n const legendsRef = React.useRef<ILegendContainer | null>(null);\n const isStacked = isStackedFunnelData(props.data);\n\n React.useEffect(() => {\n if (props.legendProps?.selectedLegends) {\n setSelectedLegends(props.legendProps.selectedLegends);\n }\n }, [props.legendProps?.selectedLegends]);\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n chartContainer: chartContainerRef ?? null,\n toImage: (opts?: IImageExportOptions): Promise<string> => {\n return convertToImage(chartContainerRef.current, legendsRef.current?.toSVG, getRTL(), opts);\n },\n }),\n [],\n );\n\n function _handleHover(data: IFunnelChartDataPoint, mouseEvent: React.MouseEvent<SVGElement>) {\n mouseEvent?.persist();\n setHoveredStage(data.stage as string);\n setCalloutData(data);\n setIsCalloutVisible(true);\n setRefSelected(mouseEvent.currentTarget);\n }\n\n function _handleFocus(data: IFunnelChartDataPoint, focusEvent: React.FocusEvent<SVGPathElement>) {\n focusEvent?.persist();\n setCalloutData(data);\n setIsCalloutVisible(true);\n setRefSelected(focusEvent.currentTarget);\n }\n\n function _handleStackedHover(\n stage: string,\n subValue: { category: string; value: number; color: string },\n mouseEvent: React.MouseEvent<SVGElement>,\n ) {\n mouseEvent?.persist();\n setHoveredStage(subValue.category);\n setCalloutData({\n stage,\n value: subValue.value,\n color: subValue.color,\n category: subValue.category,\n } as IFunnelChartDataPoint);\n setIsCalloutVisible(true);\n setRefSelected(mouseEvent.currentTarget);\n }\n\n function _handleStackedFocus(\n stage: string,\n subValue: { category: string; value: number; color: string },\n focusEvent: React.FocusEvent<SVGPathElement>,\n ) {\n focusEvent?.persist();\n setCalloutData({\n stage,\n value: subValue.value,\n color: subValue.color,\n category: subValue.category,\n } as IFunnelChartDataPoint);\n setIsCalloutVisible(true);\n setRefSelected(focusEvent.currentTarget);\n }\n\n function _handleMouseOut() {\n setHoveredStage(null);\n setIsCalloutVisible(false);\n setCalloutData(null);\n setRefSelected(null);\n }\n\n function _onLegendSelectionChange(\n legendsSelected: string[],\n event: React.MouseEvent<HTMLButtonElement>,\n currentLegend?: ILegend,\n ): void {\n if (props.legendProps?.canSelectMultipleLegends) {\n setSelectedLegends(legendsSelected);\n } else {\n setSelectedLegends(legendsSelected.slice(-1));\n }\n\n if (props.legendProps?.onChange) {\n props.legendProps.onChange(legendsSelected, event, currentLegend);\n }\n }\n\n const _onLegendSelectionChangeCallback = React.useCallback(_onLegendSelectionChange, [props.legendProps]);\n\n function getHighlightedLegend(): string[] {\n return selectedLegends.length > 0 ? selectedLegends : hoveredStage ? [hoveredStage] : [];\n }\n\n function legendHighlighted(legend: string): boolean {\n return getHighlightedLegend().includes(legend);\n }\n\n function noLegendHighlighted(): boolean {\n return getHighlightedLegend().length === 0;\n }\n\n function _getEventHandlerProps(\n data: IFunnelChartDataPoint | { stage: string; subValue: { category: string; value: number; color: string } },\n opacity?: number,\n ) {\n if ('subValue' in data) {\n return {\n culture: props.culture,\n onMouseOver:\n opacity === 1\n ? (event: React.MouseEvent<SVGElement>) => _handleStackedHover(data.stage, data.subValue, event)\n : undefined,\n onMouseMove:\n opacity === 1\n ? (event: React.MouseEvent<SVGElement>) => _handleStackedHover(data.stage, data.subValue, event)\n : undefined,\n onFocus: (event: React.FocusEvent<SVGPathElement>) => _handleStackedFocus(data.stage, data.subValue, event),\n onBlur: () => _handleMouseOut(),\n onMouseOut: () => _handleMouseOut(),\n };\n } else {\n return {\n culture: props.culture,\n onMouseOver: opacity === 1 ? (event: React.MouseEvent<SVGElement>) => _handleHover(data, event) : undefined,\n onMouseMove: opacity === 1 ? (event: React.MouseEvent<SVGElement>) => _handleHover(data, event) : undefined,\n onFocus: (event: React.FocusEvent<SVGPathElement>) => _handleFocus(data, event),\n onBlur: () => _handleMouseOut(),\n onMouseOut: () => _handleMouseOut(),\n };\n }\n }\n\n function _renderSegmentText({\n show,\n x,\n y,\n value,\n textColor,\n }: {\n show: boolean;\n x: number;\n y: number;\n value: number;\n textColor: string;\n }) {\n if (!show) {\n return null;\n }\n\n const textElement = (\n <text x={isRTL ? funnelWidth - x : x} y={y} textAnchor=\"middle\" alignmentBaseline=\"middle\" fill={textColor}>\n {formatToLocaleString(value.toString(), props.culture) as React.ReactNode}\n </text>\n );\n\n if (isRTL) {\n return <g transform={`scale(-1,1) translate(${-funnelWidth},0)`}>{textElement}</g>;\n }\n return textElement;\n }\n\n function _renderFunnelSegment({\n key,\n pathD,\n fill,\n opacity,\n textProps,\n data,\n isFocusable,\n }: {\n key: string | number;\n pathD: string;\n fill: string;\n opacity: number;\n textProps?: {\n show: boolean;\n x: number;\n y: number;\n value: number;\n };\n data: IFunnelChartDataPoint | { stage: string; subValue: { category: string; value: number; color: string } };\n isFocusable?: boolean;\n }) {\n const eventHandlers = _getEventHandlerProps(data, opacity);\n const textColor = getContrastTextColor(fill, props.theme!);\n\n return (\n <g key={key}>\n <path d={pathD} fill={fill} opacity={opacity} {...eventHandlers} data-is-focusable={isFocusable} />\n {textProps && <g {...eventHandlers}>{_renderSegmentText({ ...textProps, textColor })}</g>}\n </g>\n );\n }\n\n function _createFunnel(\n containerHeight: number,\n containerWidth: number,\n ): // eslint-disable-next-line @typescript-eslint/no-deprecated\n JSX.Element[] {\n const { data } = props;\n const funnelWidth = containerWidth;\n const funnelHeight = containerHeight * 0.8;\n\n return data.map((d, i) => {\n const geometryProps =\n props.orientation === 'vertical'\n ? getVerticalFunnelSegmentGeometry({ d, i, data, funnelWidth, funnelHeight, isRTL })\n : getHorizontalFunnelSegmentGeometry({ d, i, data, funnelWidth, funnelHeight, isRTL });\n\n const { pathD, textX, textY, availableWidth } = geometryProps;\n const minTextWidth = 16;\n const eventHandlerProps = _getEventHandlerProps(d);\n const textProps = getSegmentTextProps({\n availableWidth,\n minTextWidth,\n textX,\n textY,\n value: d.value!,\n ...eventHandlerProps,\n });\n\n return _renderFunnelSegment({\n key: i,\n pathD,\n fill: d.color!,\n opacity: legendHighlighted(d.stage as string) || noLegendHighlighted() ? 1 : 0.1,\n textProps,\n data: d,\n isFocusable: legendHighlighted(d.stage as string) || noLegendHighlighted() ? true : false,\n });\n });\n }\n\n function isStackedFunnelData(data: IFunnelChartDataPoint[]): boolean {\n return Array.isArray(data) && data.every(stage => Array.isArray(stage.subValues));\n }\n\n function _renderStackedSegment(\n stage: IFunnelChartDataPoint,\n subValue: { value: number; color: string; category: string },\n stageIndex: number,\n subValueIndex: number,\n geometryParams: {\n stages: IFunnelChartDataPoint[];\n totals: number[];\n maxTotal: number;\n funnelWidth: number;\n funnelHeight: number;\n isRTL: boolean;\n },\n ): // eslint-disable-next-line @typescript-eslint/no-deprecated\n JSX.Element {\n // Ensure stages have subValues for geometry functions\n const stagesWithSubValues = geometryParams.stages.map(s => ({\n ...s,\n subValues: s.subValues || [],\n }));\n\n const geom =\n props.orientation === 'vertical'\n ? getStackedVerticalFunnelSegmentGeometry({\n ...geometryParams,\n stages: stagesWithSubValues,\n i: stageIndex,\n k: subValueIndex,\n })\n : getStackedHorizontalFunnelSegmentGeometry({\n ...geometryParams,\n stages: stagesWithSubValues,\n i: stageIndex,\n k: subValueIndex,\n });\n\n const minTextWidth = 16;\n const eventHandlerProps = _getEventHandlerProps({ stage: stage.stage as string, subValue });\n const textProps = getSegmentTextProps({\n availableWidth: geom.availableWidth,\n minTextWidth,\n textX: geom.textX,\n textY: geom.textY,\n value: subValue.value,\n ...eventHandlerProps,\n });\n\n return _renderFunnelSegment({\n key: `${stageIndex}-${subValueIndex}`,\n pathD: geom.pathD,\n fill: subValue.color,\n opacity:\n (isStackedFunnelData(props.data) && legendHighlighted(subValue.category)) || noLegendHighlighted() ? 1 : 0.1,\n textProps,\n data: { stage: stage.stage as string, subValue },\n isFocusable:\n (isStackedFunnelData(props.data) && legendHighlighted(subValue.category)) || noLegendHighlighted()\n ? true\n : false,\n });\n }\n\n function _createStackedFunnel(\n containerHeight: number,\n containerWidth: number,\n ): // eslint-disable-next-line @typescript-eslint/no-deprecated\n JSX.Element[] {\n const { data } = props;\n\n const stages = data;\n const totals = stages.map(s => s?.subValues?.reduce((sum, subValue) => sum + subValue.value, 0) ?? 0);\n const maxTotal = Math.max(...totals);\n\n const funnelWidth = containerWidth;\n const funnelHeight = containerHeight * 0.8;\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const paths: JSX.Element[] = [];\n\n const geometryParams = {\n stages,\n totals,\n maxTotal,\n funnelWidth,\n funnelHeight,\n isRTL,\n };\n\n for (let i = 0; i < stages.length; i++) {\n const cur = stages[i];\n for (let k = 0; k < (cur.subValues ?? []).length; k++) {\n const v = cur.subValues?.[k];\n if (!v) {\n continue;\n }\n paths.push(_renderStackedSegment(cur, v, i, k, geometryParams));\n }\n }\n return paths;\n }\n\n function _renderLegends(): // eslint-disable-next-line @typescript-eslint/no-deprecated\n JSX.Element {\n if (props.hideLegend) {\n return <></>;\n }\n let legends: ILegend[];\n\n if (isStacked) {\n // Collect unique categories and their color\n const categoryMap: Record<string, string> = {};\n props.data.forEach((stage: IFunnelChartDataPoint) => {\n (stage.subValues || []).forEach(sub => {\n if (!(sub.category in categoryMap)) {\n categoryMap[sub.category] = sub.color;\n }\n });\n });\n legends = Object.entries(categoryMap).map(([category, color]) => ({\n title: category,\n color,\n hoverAction: () => setHoveredStage(category),\n onMouseOutAction: () => setHoveredStage(null),\n }));\n } else {\n legends = props.data.map((d: IFunnelChartDataPoint) => ({\n title: d.stage as string,\n color: d.color!,\n hoverAction: () => setHoveredStage(d.stage as string),\n onMouseOutAction: () => setHoveredStage(null),\n }));\n }\n\n return (\n <div style={{ display: 'flex', justifyContent: 'center' }}>\n <Legends\n ref={legendsRef}\n legends={legends}\n centerLegends={true}\n onChange={_onLegendSelectionChangeCallback}\n {...props.legendProps}\n />\n </div>\n );\n }\n\n function _isChartEmpty(): boolean {\n return !(props.data && props.data.length > 0);\n }\n\n const calloutProps = {\n isCalloutVisible,\n directionalHint: DirectionalHint.topAutoEdge,\n id: `toolTip${_tooltipId}`,\n target: refSelected,\n color: calloutData?.color,\n XValue: calloutData?.stage,\n YValue: calloutData?.value,\n isBeakVisible: false,\n gapSpace: 15,\n onDismiss: () => {\n setIsCalloutVisible(false);\n },\n preventDismissOnLostFocus: true,\n ...props.calloutProps,\n };\n\n const width = props.width || 350;\n const height = props.height || 500;\n const classNames = getClassNames(props.styles!, {\n theme: props.theme!,\n className: props.className,\n chartWidth: width,\n chartHeight: height,\n });\n\n const funnelMarginTop = 40;\n const funnelWidth = width * 0.8;\n const funnelOffsetX = (width - funnelWidth) / 2;\n\n return !_isChartEmpty() ? (\n <div ref={chartContainerRef} className={classNames.root}>\n <FocusZone direction={FocusZoneDirection.horizontal}>\n <svg width={width} height={height} className={classNames.chart} role={'img'} aria-label={props.chartTitle}>\n <g\n transform={\n isRTL\n ? `translate(${funnelOffsetX + funnelWidth}, ${funnelMarginTop}) scale(-1,1)`\n : `translate(${funnelOffsetX}, ${funnelMarginTop})`\n }\n >\n {isStacked\n ? _createStackedFunnel(height - funnelMarginTop, funnelWidth)\n : _createFunnel(height - funnelMarginTop, funnelWidth)}\n </g>\n {isCalloutVisible && (\n <Callout {...calloutProps}>\n <ChartHoverCard\n XValue={calloutProps?.XValue as string}\n YValue={calloutProps?.YValue}\n color={calloutProps?.color}\n />\n </Callout>\n )}\n </svg>\n </FocusZone>\n {_renderLegends()}\n </div>\n ) : (\n <div id={_emptyChartId} role={'alert'} style={{ opacity: '0' }} aria-label={'Graph has no data to display'} />\n );\n});\nFunnelChartBase.displayName = 'FunnelChart';\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nFunnelChartBase.defaultProps = {\n orientation: 'vertical',\n};\n"]}
@@ -20,7 +20,7 @@ interface ISubValue {
20
20
  interface IStage {
21
21
  subValues: ISubValue[];
22
22
  }
23
- export declare function getHorizontalFunnelSegmentGeometry({ d, i, data, funnelWidth, funnelHeight, isRTL, }: {
23
+ export declare function getVerticalFunnelSegmentGeometry({ d, i, data, funnelWidth, funnelHeight, isRTL, }: {
24
24
  d: IFunnelChartDataPoint;
25
25
  i: number;
26
26
  data: IFunnelChartDataPoint[];
@@ -28,7 +28,7 @@ export declare function getHorizontalFunnelSegmentGeometry({ d, i, data, funnelW
28
28
  funnelHeight: number;
29
29
  isRTL: boolean;
30
30
  }): IFunnelSegmentGeometry;
31
- export declare function getVerticalFunnelSegmentGeometry({ d, i, data, funnelWidth, funnelHeight, isRTL, }: {
31
+ export declare function getHorizontalFunnelSegmentGeometry({ d, i, data, funnelWidth, funnelHeight, isRTL, }: {
32
32
  d: IFunnelChartDataPoint;
33
33
  i: number;
34
34
  data: IFunnelChartDataPoint[];
@@ -36,7 +36,7 @@ export declare function getVerticalFunnelSegmentGeometry({ d, i, data, funnelWid
36
36
  funnelHeight: number;
37
37
  isRTL: boolean;
38
38
  }): IFunnelSegmentGeometry;
39
- export declare function getStackedHorizontalFunnelSegmentGeometry({ i, k, stages, totals, maxTotal, funnelWidth, funnelHeight, }: {
39
+ export declare function getStackedVerticalFunnelSegmentGeometry({ i, k, stages, totals, maxTotal, funnelWidth, funnelHeight, }: {
40
40
  i: number;
41
41
  k: number;
42
42
  stages: IStage[];
@@ -45,7 +45,7 @@ export declare function getStackedHorizontalFunnelSegmentGeometry({ i, k, stages
45
45
  funnelWidth: number;
46
46
  funnelHeight: number;
47
47
  }): IStackedFunnelSegmentGeometry;
48
- export declare function getStackedVerticalFunnelSegmentGeometry({ i, k, stages, totals, maxTotal, funnelWidth, funnelHeight, }: {
48
+ export declare function getStackedHorizontalFunnelSegmentGeometry({ i, k, stages, totals, maxTotal, funnelWidth, funnelHeight, }: {
49
49
  i: number;
50
50
  k: number;
51
51
  stages: IStage[];
@@ -61,8 +61,8 @@ export declare function getSegmentTextProps({ availableWidth, minTextWidth, text
61
61
  textY: number;
62
62
  value: number;
63
63
  culture: string | undefined;
64
- onMouseOver: (event: React.MouseEvent<SVGElement>) => void;
65
- onMouseMove: (event: React.MouseEvent<SVGElement>) => void;
64
+ onMouseOver: ((event: React.MouseEvent<SVGElement>) => void) | undefined;
65
+ onMouseMove: ((event: React.MouseEvent<SVGElement>) => void) | undefined;
66
66
  onMouseOut: () => void;
67
67
  }): {
68
68
  show: boolean;
@@ -70,8 +70,8 @@ export declare function getSegmentTextProps({ availableWidth, minTextWidth, text
70
70
  y: number;
71
71
  value: number;
72
72
  culture: string | undefined;
73
- onMouseOver: (event: React.MouseEvent<SVGElement>) => void;
74
- onMouseMove: (event: React.MouseEvent<SVGElement>) => void;
73
+ onMouseOver: ((event: React.MouseEvent<SVGElement>) => void) | undefined;
74
+ onMouseMove: ((event: React.MouseEvent<SVGElement>) => void) | undefined;
75
75
  onMouseOut: () => void;
76
76
  };
77
77
  export {};
@@ -1,8 +1,8 @@
1
1
  define(["require", "exports"], function (require, exports) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getSegmentTextProps = exports.getStackedVerticalFunnelSegmentGeometry = exports.getStackedHorizontalFunnelSegmentGeometry = exports.getVerticalFunnelSegmentGeometry = exports.getHorizontalFunnelSegmentGeometry = void 0;
5
- function getHorizontalFunnelSegmentGeometry(_a) {
4
+ exports.getSegmentTextProps = exports.getStackedHorizontalFunnelSegmentGeometry = exports.getStackedVerticalFunnelSegmentGeometry = exports.getHorizontalFunnelSegmentGeometry = exports.getVerticalFunnelSegmentGeometry = void 0;
5
+ function getVerticalFunnelSegmentGeometry(_a) {
6
6
  var d = _a.d, i = _a.i, data = _a.data, funnelWidth = _a.funnelWidth, funnelHeight = _a.funnelHeight, isRTL = _a.isRTL;
7
7
  var segmentHeight = funnelHeight / data.length;
8
8
  var widthScale = function (value) { return (value / Math.max.apply(Math, data.map(function (dataPoint) { return dataPoint.value; }))) * funnelWidth; };
@@ -27,8 +27,8 @@ define(["require", "exports"], function (require, exports) {
27
27
  var pathD = "M".concat(xStart, ",").concat(i * segmentHeight, "\n L").concat(funnelWidth - xStart, ",").concat(i * segmentHeight, "\n L").concat(funnelWidth - xEnd, ",").concat((i + 1) * segmentHeight, "\n L").concat(xEnd, ",").concat((i + 1) * segmentHeight, "\n Z");
28
28
  return { pathD: pathD, textX: textX, textY: textY, availableWidth: availableWidth };
29
29
  }
30
- exports.getHorizontalFunnelSegmentGeometry = getHorizontalFunnelSegmentGeometry;
31
- function getVerticalFunnelSegmentGeometry(_a) {
30
+ exports.getVerticalFunnelSegmentGeometry = getVerticalFunnelSegmentGeometry;
31
+ function getHorizontalFunnelSegmentGeometry(_a) {
32
32
  var d = _a.d, i = _a.i, data = _a.data, funnelWidth = _a.funnelWidth, funnelHeight = _a.funnelHeight, isRTL = _a.isRTL;
33
33
  var segmentWidth = funnelWidth / data.length;
34
34
  var heightScale = function (value) { return (value / Math.max.apply(Math, data.map(function (dataPoint) { return dataPoint.value; }))) * funnelHeight; };
@@ -69,8 +69,8 @@ define(["require", "exports"], function (require, exports) {
69
69
  var pathD = "M".concat(x0, ",").concat(yOffset, "\n L").concat(x1, ",").concat(nextYOffset, "\n L").concat(x1, ",").concat(funnelHeight - nextYOffset, "\n L").concat(x0, ",").concat(funnelHeight - yOffset, "\n Z");
70
70
  return { pathD: pathD, textX: textX, textY: textY, availableWidth: availableWidth };
71
71
  }
72
- exports.getVerticalFunnelSegmentGeometry = getVerticalFunnelSegmentGeometry;
73
- function getStackedHorizontalFunnelSegmentGeometry(_a) {
72
+ exports.getHorizontalFunnelSegmentGeometry = getHorizontalFunnelSegmentGeometry;
73
+ function getStackedVerticalFunnelSegmentGeometry(_a) {
74
74
  var _b, _c;
75
75
  var i = _a.i, k = _a.k, stages = _a.stages, totals = _a.totals, maxTotal = _a.maxTotal, funnelWidth = _a.funnelWidth, funnelHeight = _a.funnelHeight;
76
76
  var segmentHeight = funnelHeight / stages.length;
@@ -119,8 +119,8 @@ define(["require", "exports"], function (require, exports) {
119
119
  var pathD = "M".concat(topStart, ",").concat(i * segmentHeight, "\n L").concat(topEnd, ",").concat(i * segmentHeight, "\n L").concat(botEnd, ",").concat((i + 1) * segmentHeight, "\n L").concat(botStart, ",").concat((i + 1) * segmentHeight, "\n Z");
120
120
  return { pathD: pathD, textX: textX, textY: textY, availableWidth: availableWidth };
121
121
  }
122
- exports.getStackedHorizontalFunnelSegmentGeometry = getStackedHorizontalFunnelSegmentGeometry;
123
- function getStackedVerticalFunnelSegmentGeometry(_a) {
122
+ exports.getStackedVerticalFunnelSegmentGeometry = getStackedVerticalFunnelSegmentGeometry;
123
+ function getStackedHorizontalFunnelSegmentGeometry(_a) {
124
124
  var _b, _c;
125
125
  var i = _a.i, k = _a.k, stages = _a.stages, totals = _a.totals, maxTotal = _a.maxTotal, funnelWidth = _a.funnelWidth, funnelHeight = _a.funnelHeight;
126
126
  var segmentWidth = funnelWidth / stages.length;
@@ -185,7 +185,7 @@ define(["require", "exports"], function (require, exports) {
185
185
  var pathD = "M".concat(leftStart, ",").concat(topStart, "\n L").concat(leftEnd, ",").concat(botStart, "\n L").concat(leftEnd, ",").concat(botEnd, "\n L").concat(leftStart, ",").concat(topEnd, "\n Z");
186
186
  return { pathD: pathD, textX: textX, textY: textY, availableWidth: availableWidth };
187
187
  }
188
- exports.getStackedVerticalFunnelSegmentGeometry = getStackedVerticalFunnelSegmentGeometry;
188
+ exports.getStackedHorizontalFunnelSegmentGeometry = getStackedHorizontalFunnelSegmentGeometry;
189
189
  function getSegmentTextProps(_a) {
190
190
  var availableWidth = _a.availableWidth, _b = _a.minTextWidth, minTextWidth = _b === void 0 ? 24 : _b, textX = _a.textX, textY = _a.textY, value = _a.value, culture = _a.culture, onMouseOver = _a.onMouseOver, onMouseMove = _a.onMouseMove, onMouseOut = _a.onMouseOut;
191
191
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"funnelGeometry.js","sourceRoot":"../src/","sources":["components/FunnelChart/funnelGeometry.ts"],"names":[],"mappings":";;;;IA2BA,SAAgB,kCAAkC,CAAC,EAclD;YAbC,CAAC,OAAA,EACD,CAAC,OAAA,EACD,IAAI,UAAA,EACJ,WAAW,iBAAA,EACX,YAAY,kBAAA,EACZ,KAAK,WAAA;QASL,IAAM,aAAa,GAAG,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC;QACjD,IAAM,UAAU,GAAG,UAAC,KAAa,IAAK,OAAA,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,OAAR,IAAI,EAAQ,IAAI,CAAC,GAAG,CAAC,UAAA,SAAS,IAAI,OAAA,SAAS,CAAC,KAAM,EAAhB,CAAgB,CAAC,CAAC,CAAC,GAAG,WAAW,EAA5E,CAA4E,CAAC;QACnH,IAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,KAAM,CAAC,CA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B,CAAC,EAoBnC;YAnBC,cAAc,oBAAA,EACd,oBAAiB,EAAjB,YAAY,mBAAG,EAAE,KAAA,EACjB,KAAK,WAAA,EACL,KAAK,WAAA,EACL,KAAK,WAAA,EACL,OAAO,aAAA,EACP,WAAW,iBAAA,EACX,WAAW,iBAAA,EACX,UAAU,gBAAA;QAYV,OAAO;YACL,IAAI,EAAE,cAAc,GAAG,YAAY,IAAI,cAAc,GAAG,CAAC;YACzD,CAAC,EAAE,KAAK;YACR,CAAC,EAAE,KAAK;YACR,KAAK,OAAA;YACL,OAAO,SAAA;YACP,WAAW,aAAA;YACX,WAAW,aAAA;YACX,UAAU,YAAA;SACX,CAAC;IACJ,CAAC;IA/BD,kDA+BC","sourcesContent":["import * as React from 'react';\nimport { IFunnelChartDataPoint } from './FunnelChart.types';\n\nexport interface IFunnelSegmentGeometry {\n pathD: string;\n textX: number;\n textY: number;\n availableWidth: number;\n}\n\nexport interface IStackedFunnelSegmentGeometry {\n pathD: string;\n textX: number;\n textY: number;\n availableWidth: number;\n}\n\ninterface ISubValue {\n category: string;\n value: number;\n color: string;\n}\n\ninterface IStage {\n subValues: ISubValue[];\n}\n\nexport function getHorizontalFunnelSegmentGeometry({\n d,\n i,\n data,\n funnelWidth,\n funnelHeight,\n isRTL,\n}: {\n d: IFunnelChartDataPoint;\n i: number;\n data: IFunnelChartDataPoint[];\n funnelWidth: number;\n funnelHeight: number;\n isRTL: boolean;\n}): IFunnelSegmentGeometry {\n const segmentHeight = funnelHeight / data.length;\n const widthScale = (value: number) => (value / Math.max(...data.map(dataPoint => dataPoint.value!))) * funnelWidth;\n const topWidth = widthScale(d.value!);\n const bottomWidth = i < data.length - 1 ? widthScale(data[i + 1].value!) : 0;\n const xOffset = (funnelWidth - topWidth) / 2;\n const nextXOffset = (funnelWidth - bottomWidth) / 2;\n const xStart = isRTL ? funnelWidth - xOffset : xOffset;\n const xEnd = isRTL ? funnelWidth - nextXOffset : nextXOffset;\n\n const isLastSegment = i === data.length - 1;\n const textY = isLastSegment ? i * segmentHeight + segmentHeight * 0.33 : i * segmentHeight + segmentHeight / 2;\n\n const textX = funnelWidth / 2;\n let availableWidth = topWidth;\n if (isLastSegment) {\n const yFromTop = textY - i * segmentHeight;\n const widthAtY = topWidth * (1 - yFromTop / segmentHeight);\n availableWidth = Math.max(widthAtY * 0.8, 0);\n } else {\n availableWidth = Math.min(topWidth, bottomWidth) * 0.9;\n }\n const pathD = `M${xStart},${i * segmentHeight}\n L${funnelWidth - xStart},${i * segmentHeight}\n L${funnelWidth - xEnd},${(i + 1) * segmentHeight}\n L${xEnd},${(i + 1) * segmentHeight}\n Z`;\n return { pathD, textX, textY, availableWidth };\n}\n\nexport function getVerticalFunnelSegmentGeometry({\n d,\n i,\n data,\n funnelWidth,\n funnelHeight,\n isRTL,\n}: {\n d: IFunnelChartDataPoint;\n i: number;\n data: IFunnelChartDataPoint[];\n funnelWidth: number;\n funnelHeight: number;\n isRTL: boolean;\n}): IFunnelSegmentGeometry {\n const segmentWidth = funnelWidth / data.length;\n const heightScale = (value: number) => (value / Math.max(...data.map(dataPoint => dataPoint.value!))) * funnelHeight;\n const leftHeight = heightScale(d.value!);\n const rightHeight = i < data.length - 1 ? heightScale(data[i + 1].value!) : 0;\n const yOffset = (funnelHeight - leftHeight) / 2;\n const nextYOffset = (funnelHeight - rightHeight) / 2;\n const x0 = i * segmentWidth;\n const x1 = (i + 1) * segmentWidth;\n\n const isLastSegment = i === data.length - 1;\n let textX: number;\n let textY: number;\n let availableWidth = segmentWidth * 0.8;\n\n if (isLastSegment) {\n // For the triangular last segment, position text at 1/4 from the left edge\n textX = x0 + (x1 - x0) * 0.25;\n textY = funnelHeight / 2;\n\n // For triangular segments, we need to check both height and width constraints\n // The segment needs to be large enough to contain text\n const segmentArea = (leftHeight * segmentWidth) / 2; // Area of triangle\n const minAreaForText = 800; // Minimum area needed to show text\n\n if (leftHeight < 40 || segmentArea < minAreaForText) {\n // Hide text if height is too small or area is insufficient\n availableWidth = 0;\n } else {\n // Calculate available width at text position\n const widthAtTextPosition = (x1 - x0) * 0.75;\n availableWidth = widthAtTextPosition * 0.6;\n }\n } else {\n textX = (x0 + x1) / 2;\n textY = funnelHeight / 2;\n const minHeight = Math.min(leftHeight, rightHeight);\n availableWidth = minHeight > 20 ? segmentWidth * 0.8 : 0;\n }\n\n const pathD = `M${x0},${yOffset}\n L${x1},${nextYOffset}\n L${x1},${funnelHeight - nextYOffset}\n L${x0},${funnelHeight - yOffset}\n Z`;\n return { pathD, textX, textY, availableWidth };\n}\n\nexport function getStackedHorizontalFunnelSegmentGeometry({\n i,\n k,\n stages,\n totals,\n maxTotal,\n funnelWidth,\n funnelHeight,\n}: {\n i: number;\n k: number;\n stages: IStage[];\n totals: number[];\n maxTotal: number;\n funnelWidth: number;\n funnelHeight: number;\n}): IStackedFunnelSegmentGeometry {\n const segmentHeight = funnelHeight / stages.length;\n const cur = stages[i];\n const next = stages[i + 1] || { subValues: [] };\n const curTotal = totals[i] || 1;\n const nextTotal = totals[i + 1] || 0;\n\n let cumTop = 0;\n let cumBot = 0;\n for (let idx = 0; idx < k; idx++) {\n const v = cur.subValues[idx];\n const vNext = next.subValues?.find((x: ISubValue) => x.category === v.category);\n const val = v.value;\n const nextVal = vNext ? vNext.value : 0;\n cumTop += (val / curTotal) * (curTotal / maxTotal) * funnelWidth;\n cumBot += (nextVal / nextTotal || 0) * (nextTotal / maxTotal) * funnelWidth;\n }\n const v = cur.subValues[k];\n const vNext = next.subValues?.find((x: ISubValue) => x.category === v.category);\n const val = v.value;\n const nextVal = vNext ? vNext.value : 0;\n const topW = (val / curTotal) * (curTotal / maxTotal) * funnelWidth;\n const botW = (nextVal / nextTotal || 0) * (nextTotal / maxTotal) * funnelWidth;\n const topStart = (funnelWidth - (curTotal / maxTotal) * funnelWidth) / 2 + cumTop;\n const topEnd = topStart + topW;\n const botStart = (funnelWidth - (nextTotal / maxTotal) * funnelWidth) / 2 + cumBot;\n const botEnd = botStart + botW;\n const textX = (topStart + topEnd + botStart + botEnd) / 4;\n\n const isLastSegment = i === stages.length - 1;\n const textY = isLastSegment ? i * segmentHeight + segmentHeight * 0.33 : (i + 0.5) * segmentHeight;\n\n // Calculate available width based on this specific segment's width\n let availableWidth: number;\n if (isLastSegment) {\n // For triangular last segment, use the width at text Y position\n const yFromTop = textY - i * segmentHeight;\n const widthRatio = 1 - yFromTop / segmentHeight;\n availableWidth = topW * widthRatio;\n } else {\n // For trapezoidal segments, use the actual segment width\n availableWidth = Math.min(topW, botW);\n }\n\n const pathD = `M${topStart},${i * segmentHeight}\n L${topEnd},${i * segmentHeight}\n L${botEnd},${(i + 1) * segmentHeight}\n L${botStart},${(i + 1) * segmentHeight}\n Z`;\n return { pathD, textX, textY, availableWidth };\n}\n\nexport function getStackedVerticalFunnelSegmentGeometry({\n i,\n k,\n stages,\n totals,\n maxTotal,\n funnelWidth,\n funnelHeight,\n}: {\n i: number;\n k: number;\n stages: IStage[];\n totals: number[];\n maxTotal: number;\n funnelWidth: number;\n funnelHeight: number;\n}): IStackedFunnelSegmentGeometry {\n const segmentWidth = funnelWidth / stages.length;\n const cur = stages[i];\n const next = stages[i + 1] || { subValues: [] };\n const curTotal = totals[i] || 1;\n const nextTotal = totals[i + 1] || 0;\n\n let cumTop = 0;\n let cumBot = 0;\n for (let idx = 0; idx < k; idx++) {\n const v = cur.subValues[idx];\n const vNext = next.subValues?.find((x: ISubValue) => x.category === v.category);\n const val = v.value;\n const nextVal = vNext ? vNext.value : 0;\n cumTop += (val / curTotal) * (curTotal / maxTotal) * funnelHeight;\n cumBot += (nextVal / nextTotal || 0) * (nextTotal / maxTotal) * funnelHeight;\n }\n const v = cur.subValues[k];\n const vNext = next.subValues?.find((x: ISubValue) => x.category === v.category);\n const val = v.value;\n const nextVal = vNext ? vNext.value : 0;\n const topH = (val / curTotal) * (curTotal / maxTotal) * funnelHeight;\n const botH = (nextVal / nextTotal || 0) * (nextTotal / maxTotal) * funnelHeight;\n const leftStart = i * segmentWidth;\n const leftEnd = (i + 1) * segmentWidth;\n const topStart = (funnelHeight - (curTotal / maxTotal) * funnelHeight) / 2 + cumTop;\n const topEnd = topStart + topH;\n const botStart = (funnelHeight - (nextTotal / maxTotal) * funnelHeight) / 2 + cumBot;\n const botEnd = botStart + botH;\n\n const isLastSegment = i === stages.length - 1;\n let textX: number;\n let textY: number;\n let availableWidth: number;\n\n if (isLastSegment) {\n textX = leftStart + (leftEnd - leftStart) * 0.25;\n textY = (topStart + topEnd) / 2;\n // For triangular segments, calculate available width at text position\n const segmentWidthAtTextPos = (leftEnd - leftStart) * 0.5;\n availableWidth = segmentWidthAtTextPos * 0.8;\n\n // For triangular last segments, also check if there's enough height\n // The segment area should be large enough to contain text\n const segmentArea = (topH * segmentWidth) / 2;\n if (topH < 24 || segmentArea < 600) {\n availableWidth = 0;\n }\n } else {\n textX = (leftStart + leftEnd) / 2;\n textY = (topStart + topEnd + botStart + botEnd) / 4;\n // For trapezoidal segments, use full segment width\n availableWidth = Math.abs(leftEnd - leftStart) * 0.9;\n\n // Check if the segment has sufficient height for text\n // For non-last segments, we need to ensure there's enough vertical space\n const avgHeight = (topH + botH) / 2;\n if (avgHeight < 20) {\n availableWidth = 0;\n }\n }\n\n const pathD = `M${leftStart},${topStart}\n L${leftEnd},${botStart}\n L${leftEnd},${botEnd}\n L${leftStart},${topEnd}\n Z`;\n return { pathD, textX, textY, availableWidth };\n}\n\nexport function getSegmentTextProps({\n availableWidth,\n minTextWidth = 24,\n textX,\n textY,\n value,\n culture,\n onMouseOver,\n onMouseMove,\n onMouseOut,\n}: {\n availableWidth: number;\n minTextWidth?: number;\n textX: number;\n textY: number;\n value: number;\n culture: string | undefined;\n onMouseOver: (event: React.MouseEvent<SVGElement>) => void;\n onMouseMove: (event: React.MouseEvent<SVGElement>) => void;\n onMouseOut: () => void;\n}) {\n return {\n show: availableWidth > minTextWidth && availableWidth > 0,\n x: textX,\n y: textY,\n value,\n culture,\n onMouseOver,\n onMouseMove,\n onMouseOut,\n };\n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CAAC,GAAG,CAAC,CAAC;YACpD,mDAAmD;YACnD,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG,GAAG,CAAC;YAErD,sDAAsD;YACtD,yEAAyE;YACzE,IAAM,SAAS,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;YACpC,IAAI,SAAS,GAAG,EAAE,EAAE,CAAC;gBACnB,cAAc,GAAG,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;QAED,IAAM,KAAK,GAAG,WAAI,SAAS,cAAI,QAAQ,oBAClC,OAAO,cAAI,QAAQ,oBACnB,OAAO,cAAI,MAAM,oBACjB,SAAS,cAAI,MAAM,YACpB,CAAC;QACL,OAAO,EAAE,KAAK,OAAA,EAAE,KAAK,OAAA,EAAE,KAAK,OAAA,EAAE,cAAc,gBAAA,EAAE,CAAC;IACjD,CAAC;IApFD,8FAoFC;IAED,SAAgB,mBAAmB,CAAC,EAoBnC;YAnBC,cAAc,oBAAA,EACd,oBAAiB,EAAjB,YAAY,mBAAG,EAAE,KAAA,EACjB,KAAK,WAAA,EACL,KAAK,WAAA,EACL,KAAK,WAAA,EACL,OAAO,aAAA,EACP,WAAW,iBAAA,EACX,WAAW,iBAAA,EACX,UAAU,gBAAA;QAYV,OAAO;YACL,IAAI,EAAE,cAAc,GAAG,YAAY,IAAI,cAAc,GAAG,CAAC;YACzD,CAAC,EAAE,KAAK;YACR,CAAC,EAAE,KAAK;YACR,KAAK,OAAA;YACL,OAAO,SAAA;YACP,WAAW,aAAA;YACX,WAAW,aAAA;YACX,UAAU,YAAA;SACX,CAAC;IACJ,CAAC;IA/BD,kDA+BC","sourcesContent":["import * as React from 'react';\nimport { IFunnelChartDataPoint } from './FunnelChart.types';\n\nexport interface IFunnelSegmentGeometry {\n pathD: string;\n textX: number;\n textY: number;\n availableWidth: number;\n}\n\nexport interface IStackedFunnelSegmentGeometry {\n pathD: string;\n textX: number;\n textY: number;\n availableWidth: number;\n}\n\ninterface ISubValue {\n category: string;\n value: number;\n color: string;\n}\n\ninterface IStage {\n subValues: ISubValue[];\n}\n\nexport function getVerticalFunnelSegmentGeometry({\n d,\n i,\n data,\n funnelWidth,\n funnelHeight,\n isRTL,\n}: {\n d: IFunnelChartDataPoint;\n i: number;\n data: IFunnelChartDataPoint[];\n funnelWidth: number;\n funnelHeight: number;\n isRTL: boolean;\n}): IFunnelSegmentGeometry {\n const segmentHeight = funnelHeight / data.length;\n const widthScale = (value: number) => (value / Math.max(...data.map(dataPoint => dataPoint.value!))) * funnelWidth;\n const topWidth = widthScale(d.value!);\n const bottomWidth = i < data.length - 1 ? widthScale(data[i + 1].value!) : 0;\n const xOffset = (funnelWidth - topWidth) / 2;\n const nextXOffset = (funnelWidth - bottomWidth) / 2;\n const xStart = isRTL ? funnelWidth - xOffset : xOffset;\n const xEnd = isRTL ? funnelWidth - nextXOffset : nextXOffset;\n\n const isLastSegment = i === data.length - 1;\n const textY = isLastSegment ? i * segmentHeight + segmentHeight * 0.33 : i * segmentHeight + segmentHeight / 2;\n\n const textX = funnelWidth / 2;\n let availableWidth = topWidth;\n if (isLastSegment) {\n const yFromTop = textY - i * segmentHeight;\n const widthAtY = topWidth * (1 - yFromTop / segmentHeight);\n availableWidth = Math.max(widthAtY * 0.8, 0);\n } else {\n availableWidth = Math.min(topWidth, bottomWidth) * 0.9;\n }\n const pathD = `M${xStart},${i * segmentHeight}\n L${funnelWidth - xStart},${i * segmentHeight}\n L${funnelWidth - xEnd},${(i + 1) * segmentHeight}\n L${xEnd},${(i + 1) * segmentHeight}\n Z`;\n return { pathD, textX, textY, availableWidth };\n}\n\nexport function getHorizontalFunnelSegmentGeometry({\n d,\n i,\n data,\n funnelWidth,\n funnelHeight,\n isRTL,\n}: {\n d: IFunnelChartDataPoint;\n i: number;\n data: IFunnelChartDataPoint[];\n funnelWidth: number;\n funnelHeight: number;\n isRTL: boolean;\n}): IFunnelSegmentGeometry {\n const segmentWidth = funnelWidth / data.length;\n const heightScale = (value: number) => (value / Math.max(...data.map(dataPoint => dataPoint.value!))) * funnelHeight;\n const leftHeight = heightScale(d.value!);\n const rightHeight = i < data.length - 1 ? heightScale(data[i + 1].value!) : 0;\n const yOffset = (funnelHeight - leftHeight) / 2;\n const nextYOffset = (funnelHeight - rightHeight) / 2;\n const x0 = i * segmentWidth;\n const x1 = (i + 1) * segmentWidth;\n\n const isLastSegment = i === data.length - 1;\n let textX: number;\n let textY: number;\n let availableWidth = segmentWidth * 0.8;\n\n if (isLastSegment) {\n // For the triangular last segment, position text at 1/4 from the left edge\n textX = x0 + (x1 - x0) * 0.25;\n textY = funnelHeight / 2;\n\n // For triangular segments, we need to check both height and width constraints\n // The segment needs to be large enough to contain text\n const segmentArea = (leftHeight * segmentWidth) / 2; // Area of triangle\n const minAreaForText = 800; // Minimum area needed to show text\n\n if (leftHeight < 40 || segmentArea < minAreaForText) {\n // Hide text if height is too small or area is insufficient\n availableWidth = 0;\n } else {\n // Calculate available width at text position\n const widthAtTextPosition = (x1 - x0) * 0.75;\n availableWidth = widthAtTextPosition * 0.6;\n }\n } else {\n textX = (x0 + x1) / 2;\n textY = funnelHeight / 2;\n const minHeight = Math.min(leftHeight, rightHeight);\n availableWidth = minHeight > 20 ? segmentWidth * 0.8 : 0;\n }\n\n const pathD = `M${x0},${yOffset}\n L${x1},${nextYOffset}\n L${x1},${funnelHeight - nextYOffset}\n L${x0},${funnelHeight - yOffset}\n Z`;\n return { pathD, textX, textY, availableWidth };\n}\n\nexport function getStackedVerticalFunnelSegmentGeometry({\n i,\n k,\n stages,\n totals,\n maxTotal,\n funnelWidth,\n funnelHeight,\n}: {\n i: number;\n k: number;\n stages: IStage[];\n totals: number[];\n maxTotal: number;\n funnelWidth: number;\n funnelHeight: number;\n}): IStackedFunnelSegmentGeometry {\n const segmentHeight = funnelHeight / stages.length;\n const cur = stages[i];\n const next = stages[i + 1] || { subValues: [] };\n const curTotal = totals[i] || 1;\n const nextTotal = totals[i + 1] || 0;\n\n let cumTop = 0;\n let cumBot = 0;\n for (let idx = 0; idx < k; idx++) {\n const v = cur.subValues[idx];\n const vNext = next.subValues?.find((x: ISubValue) => x.category === v.category);\n const val = v.value;\n const nextVal = vNext ? vNext.value : 0;\n cumTop += (val / curTotal) * (curTotal / maxTotal) * funnelWidth;\n cumBot += (nextVal / nextTotal || 0) * (nextTotal / maxTotal) * funnelWidth;\n }\n const v = cur.subValues[k];\n const vNext = next.subValues?.find((x: ISubValue) => x.category === v.category);\n const val = v.value;\n const nextVal = vNext ? vNext.value : 0;\n const topW = (val / curTotal) * (curTotal / maxTotal) * funnelWidth;\n const botW = (nextVal / nextTotal || 0) * (nextTotal / maxTotal) * funnelWidth;\n const topStart = (funnelWidth - (curTotal / maxTotal) * funnelWidth) / 2 + cumTop;\n const topEnd = topStart + topW;\n const botStart = (funnelWidth - (nextTotal / maxTotal) * funnelWidth) / 2 + cumBot;\n const botEnd = botStart + botW;\n const textX = (topStart + topEnd + botStart + botEnd) / 4;\n\n const isLastSegment = i === stages.length - 1;\n const textY = isLastSegment ? i * segmentHeight + segmentHeight * 0.33 : (i + 0.5) * segmentHeight;\n\n // Calculate available width based on this specific segment's width\n let availableWidth: number;\n if (isLastSegment) {\n // For triangular last segment, use the width at text Y position\n const yFromTop = textY - i * segmentHeight;\n const widthRatio = 1 - yFromTop / segmentHeight;\n availableWidth = topW * widthRatio;\n } else {\n // For trapezoidal segments, use the actual segment width\n availableWidth = Math.min(topW, botW);\n }\n\n const pathD = `M${topStart},${i * segmentHeight}\n L${topEnd},${i * segmentHeight}\n L${botEnd},${(i + 1) * segmentHeight}\n L${botStart},${(i + 1) * segmentHeight}\n Z`;\n return { pathD, textX, textY, availableWidth };\n}\n\nexport function getStackedHorizontalFunnelSegmentGeometry({\n i,\n k,\n stages,\n totals,\n maxTotal,\n funnelWidth,\n funnelHeight,\n}: {\n i: number;\n k: number;\n stages: IStage[];\n totals: number[];\n maxTotal: number;\n funnelWidth: number;\n funnelHeight: number;\n}): IStackedFunnelSegmentGeometry {\n const segmentWidth = funnelWidth / stages.length;\n const cur = stages[i];\n const next = stages[i + 1] || { subValues: [] };\n const curTotal = totals[i] || 1;\n const nextTotal = totals[i + 1] || 0;\n\n let cumTop = 0;\n let cumBot = 0;\n for (let idx = 0; idx < k; idx++) {\n const v = cur.subValues[idx];\n const vNext = next.subValues?.find((x: ISubValue) => x.category === v.category);\n const val = v.value;\n const nextVal = vNext ? vNext.value : 0;\n cumTop += (val / curTotal) * (curTotal / maxTotal) * funnelHeight;\n cumBot += (nextVal / nextTotal || 0) * (nextTotal / maxTotal) * funnelHeight;\n }\n const v = cur.subValues[k];\n const vNext = next.subValues?.find((x: ISubValue) => x.category === v.category);\n const val = v.value;\n const nextVal = vNext ? vNext.value : 0;\n const topH = (val / curTotal) * (curTotal / maxTotal) * funnelHeight;\n const botH = (nextVal / nextTotal || 0) * (nextTotal / maxTotal) * funnelHeight;\n const leftStart = i * segmentWidth;\n const leftEnd = (i + 1) * segmentWidth;\n const topStart = (funnelHeight - (curTotal / maxTotal) * funnelHeight) / 2 + cumTop;\n const topEnd = topStart + topH;\n const botStart = (funnelHeight - (nextTotal / maxTotal) * funnelHeight) / 2 + cumBot;\n const botEnd = botStart + botH;\n\n const isLastSegment = i === stages.length - 1;\n let textX: number;\n let textY: number;\n let availableWidth: number;\n\n if (isLastSegment) {\n textX = leftStart + (leftEnd - leftStart) * 0.25;\n textY = (topStart + topEnd) / 2;\n // For triangular segments, calculate available width at text position\n const segmentWidthAtTextPos = (leftEnd - leftStart) * 0.5;\n availableWidth = segmentWidthAtTextPos * 0.8;\n\n // For triangular last segments, also check if there's enough height\n // The segment area should be large enough to contain text\n const segmentArea = (topH * segmentWidth) / 2;\n if (topH < 24 || segmentArea < 600) {\n availableWidth = 0;\n }\n } else {\n textX = (leftStart + leftEnd) / 2;\n textY = (topStart + topEnd + botStart + botEnd) / 4;\n // For trapezoidal segments, use full segment width\n availableWidth = Math.abs(leftEnd - leftStart) * 0.9;\n\n // Check if the segment has sufficient height for text\n // For non-last segments, we need to ensure there's enough vertical space\n const avgHeight = (topH + botH) / 2;\n if (avgHeight < 20) {\n availableWidth = 0;\n }\n }\n\n const pathD = `M${leftStart},${topStart}\n L${leftEnd},${botStart}\n L${leftEnd},${botEnd}\n L${leftStart},${topEnd}\n Z`;\n return { pathD, textX, textY, availableWidth };\n}\n\nexport function getSegmentTextProps({\n availableWidth,\n minTextWidth = 24,\n textX,\n textY,\n value,\n culture,\n onMouseOver,\n onMouseMove,\n onMouseOut,\n}: {\n availableWidth: number;\n minTextWidth?: number;\n textX: number;\n textY: number;\n value: number;\n culture: string | undefined;\n onMouseOver: ((event: React.MouseEvent<SVGElement>) => void) | undefined;\n onMouseMove: ((event: React.MouseEvent<SVGElement>) => void) | undefined;\n onMouseOut: () => void;\n}) {\n return {\n show: availableWidth > minTextWidth && availableWidth > 0,\n x: textX,\n y: textY,\n value,\n culture,\n onMouseOver,\n onMouseMove,\n onMouseOut,\n };\n}\n"]}
@@ -46,6 +46,7 @@ define(["require", "exports", "tslib", "react", "d3-selection", "../Legends/inde
46
46
  var _m = React.useState(''), refSelected = _m[0], setRefSelected = _m[1];
47
47
  var prevSelectedLegendsRef = React.useRef(undefined);
48
48
  var _isScatterPolarRef = React.useRef(false);
49
+ var _isTextMode = React.useRef(false);
49
50
  var classNames = getClassNames(props.styles, {
50
51
  theme: props.theme,
51
52
  });
@@ -333,13 +334,17 @@ define(["require", "exports", "tslib", "react", "d3-selection", "../Legends/inde
333
334
  var isLegendSelected = _legendHighlighted(legendVal) || _noLegendHighlighted() || isSelectedLegend;
334
335
  var currentPointHidden = ((_s = (_r = _points.current) === null || _r === void 0 ? void 0 : _r[i]) === null || _s === void 0 ? void 0 : _s.hideNonActiveDots) && activePoint !== circleId;
335
336
  var text = (_u = (_t = _points.current) === null || _t === void 0 ? void 0 : _t[i].data[j]) === null || _u === void 0 ? void 0 : _u.text;
336
- pointsForSeries.push(React.createElement(React.Fragment, null,
337
- React.createElement("circle", tslib_1.__assign({ id: circleId, key: circleId, r: Math.max(circleRadius, 4), cx: ((_v = _xAxisScale.current) === null || _v === void 0 ? void 0 : _v.call(_xAxisScale, x)) + _xBandwidth.current, cy: (_w = _yAxisScale.current) === null || _w === void 0 ? void 0 : _w.call(_yAxisScale, y), "data-is-focusable": isLegendSelected, onMouseOver: function (event) {
338
- return _handleHover(x, y, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData, event);
339
- }, onMouseMove: function (event) {
340
- return _handleHover(x, y, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData, event);
341
- }, onMouseOut: _handleMouseOut, onFocus: function () { return _handleFocus(seriesId, x, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData); }, onBlur: _handleMouseOut }, _getClickHandler((_z = (_y = (_x = _points.current) === null || _x === void 0 ? void 0 : _x[i]) === null || _y === void 0 ? void 0 : _y.data[j]) === null || _z === void 0 ? void 0 : _z.onDataPointClick), { opacity: isLegendSelected && !currentPointHidden ? 1 : 0.1, fill: _getPointFill(seriesColor, circleId), stroke: seriesColor, role: "img", "aria-label": _getAriaLabel(i, j), tabIndex: ((_1 = (_0 = _points.current) === null || _0 === void 0 ? void 0 : _0[i]) === null || _1 === void 0 ? void 0 : _1.legend) !== '' ? 0 : undefined })),
342
- !_isScatterPolarRef.current && text && (React.createElement("text", { key: "".concat(circleId, "-label"), x: ((_2 = _xAxisScale.current) === null || _2 === void 0 ? void 0 : _2.call(_xAxisScale, x)) + _xBandwidth.current, y: ((_3 = _yAxisScale.current) === null || _3 === void 0 ? void 0 : _3.call(_yAxisScale, y)) + Math.max(circleRadius + 12, 16), className: classNames.markerLabel }, text))));
337
+ if (!_isTextMode.current) {
338
+ pointsForSeries.push(React.createElement(React.Fragment, null,
339
+ React.createElement("circle", tslib_1.__assign({ id: circleId, key: circleId, r: Math.max(circleRadius, 4), cx: ((_v = _xAxisScale.current) === null || _v === void 0 ? void 0 : _v.call(_xAxisScale, x)) + _xBandwidth.current, cy: (_w = _yAxisScale.current) === null || _w === void 0 ? void 0 : _w.call(_yAxisScale, y), "data-is-focusable": isLegendSelected, onMouseOver: function (event) {
340
+ return _handleHover(x, y, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData, event);
341
+ }, onMouseMove: function (event) {
342
+ return _handleHover(x, y, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData, event);
343
+ }, onMouseOut: _handleMouseOut, onFocus: function () { return _handleFocus(seriesId, x, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData); }, onBlur: _handleMouseOut }, _getClickHandler((_z = (_y = (_x = _points.current) === null || _x === void 0 ? void 0 : _x[i]) === null || _y === void 0 ? void 0 : _y.data[j]) === null || _z === void 0 ? void 0 : _z.onDataPointClick), { opacity: isLegendSelected && !currentPointHidden ? 1 : 0.1, fill: _getPointFill(seriesColor, circleId), stroke: seriesColor, role: "img", "aria-label": _getAriaLabel(i, j), tabIndex: ((_1 = (_0 = _points.current) === null || _0 === void 0 ? void 0 : _0[i]) === null || _1 === void 0 ? void 0 : _1.legend) !== '' ? 0 : undefined }))));
344
+ }
345
+ if ((!_isScatterPolarRef.current || _isTextMode) && text) {
346
+ pointsForSeries.push(React.createElement("text", { key: "".concat(circleId, "-label"), x: ((_2 = _xAxisScale.current) === null || _2 === void 0 ? void 0 : _2.call(_xAxisScale, x)) + _xBandwidth.current, y: ((_3 = _yAxisScale.current) === null || _3 === void 0 ? void 0 : _3.call(_yAxisScale, y)) + Math.max(circleRadius + 12, 16), className: classNames.markerLabel }, text));
347
+ }
343
348
  };
344
349
  for (var j = 0; j < ((_l = (_k = (_j = _points.current) === null || _j === void 0 ? void 0 : _j[i]) === null || _k === void 0 ? void 0 : _k.data) === null || _l === void 0 ? void 0 : _l.length); j++) {
345
350
  _loop_2(j);
@@ -414,6 +419,7 @@ define(["require", "exports", "tslib", "react", "d3-selection", "../Legends/inde
414
419
  _xAxisScale.current = xScale;
415
420
  _yAxisScale.current = yScale;
416
421
  _isScatterPolarRef.current = (0, index_2.isScatterPolarSeries)(_points.current);
422
+ _isTextMode.current = (0, index_2.isTextMode)(_points.current);
417
423
  renderSeries.current = _createPlot(xElement, containerHeight);
418
424
  }, [renderSeries, _xAxisScale, _yAxisScale, _createPlot]);
419
425
  /**
@@ -462,7 +468,7 @@ define(["require", "exports", "tslib", "react", "d3-selection", "../Legends/inde
462
468
  // reduce computation cost by only creating legendBars
463
469
  // if when hideLegend is false.
464
470
  // NOTE: they are rendered only when hideLegend is false in CartesianChart.
465
- if (!props.hideLegend) {
471
+ if (!props.hideLegend && !_isTextMode.current) {
466
472
  legendBars = _createLegends(_points.current); // ToDo: Memoize legends to improve performance.
467
473
  }
468
474
  var calloutProps = tslib_1.__assign({ isCalloutVisible: isCalloutVisible, directionalHint: react_1.DirectionalHint.topAutoEdge, YValueHover: YValueHover, hoverXValue: hoverXValue, id: "toolTip".concat(_uniqueCallOutID.current), target: refSelected, isBeakVisible: false, gapSpace: 15, onDismiss: _closeCallout, preventDismissOnEvent: function () { return true; }, hidden: !(!props.hideTooltip && isCalloutVisible), descriptionMessage: props.getCalloutDescriptionMessage && stackCalloutProps