@fluentui/react-charting 5.24.9 → 5.24.10

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 (129) hide show
  1. package/CHANGELOG.json +28 -1
  2. package/CHANGELOG.md +13 -2
  3. package/dist/react-charting.d.ts +149 -0
  4. package/dist/react-charting.js +1 -1
  5. package/dist/react-charting.min.js +1 -1
  6. package/etc/react-charting.api.md +40 -0
  7. package/lib/FunnelChart.d.ts +1 -0
  8. package/lib/FunnelChart.js +2 -0
  9. package/lib/FunnelChart.js.map +1 -0
  10. package/lib/components/DeclarativeChart/DeclarativeChart.js +7 -1
  11. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  12. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +2 -0
  13. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +120 -0
  14. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  15. package/lib/components/FunnelChart/FunnelChart.base.d.ts +3 -0
  16. package/lib/components/FunnelChart/FunnelChart.base.js +264 -0
  17. package/lib/components/FunnelChart/FunnelChart.base.js.map +1 -0
  18. package/lib/components/FunnelChart/FunnelChart.d.ts +7 -0
  19. package/lib/components/FunnelChart/FunnelChart.js +9 -0
  20. package/lib/components/FunnelChart/FunnelChart.js.map +1 -0
  21. package/lib/components/FunnelChart/FunnelChart.styles.d.ts +2 -0
  22. package/lib/components/FunnelChart/FunnelChart.styles.js +38 -0
  23. package/lib/components/FunnelChart/FunnelChart.styles.js.map +1 -0
  24. package/lib/components/FunnelChart/FunnelChart.types.d.ts +139 -0
  25. package/lib/components/FunnelChart/FunnelChart.types.js +2 -0
  26. package/lib/components/FunnelChart/FunnelChart.types.js.map +1 -0
  27. package/lib/components/FunnelChart/funnelGeometry.d.ts +77 -0
  28. package/lib/components/FunnelChart/funnelGeometry.js +194 -0
  29. package/lib/components/FunnelChart/funnelGeometry.js.map +1 -0
  30. package/lib/components/FunnelChart/index.d.ts +2 -0
  31. package/lib/components/FunnelChart/index.js +3 -0
  32. package/lib/components/FunnelChart/index.js.map +1 -0
  33. package/lib/components/HeatMapChart/HeatMapChart.base.d.ts +0 -1
  34. package/lib/components/HeatMapChart/HeatMapChart.base.js +2 -16
  35. package/lib/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  36. package/lib/components/LineChart/LineChart.base.d.ts +2 -0
  37. package/lib/components/LineChart/LineChart.base.js +17 -10
  38. package/lib/components/LineChart/LineChart.base.js.map +1 -1
  39. package/lib/components/LineChart/LineChart.types.d.ts +6 -0
  40. package/lib/components/LineChart/LineChart.types.js.map +1 -1
  41. package/lib/index.d.ts +2 -0
  42. package/lib/index.js +1 -0
  43. package/lib/index.js.map +1 -1
  44. package/lib/utilities/utilities.d.ts +3 -0
  45. package/lib/utilities/utilities.js +14 -0
  46. package/lib/utilities/utilities.js.map +1 -1
  47. package/lib-amd/FunnelChart.d.ts +1 -0
  48. package/lib-amd/FunnelChart.js +6 -0
  49. package/lib-amd/FunnelChart.js.map +1 -0
  50. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +6 -1
  51. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  52. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +2 -0
  53. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +122 -1
  54. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  55. package/lib-amd/components/FunnelChart/FunnelChart.base.d.ts +3 -0
  56. package/lib-amd/components/FunnelChart/FunnelChart.base.js +258 -0
  57. package/lib-amd/components/FunnelChart/FunnelChart.base.js.map +1 -0
  58. package/lib-amd/components/FunnelChart/FunnelChart.d.ts +7 -0
  59. package/lib-amd/components/FunnelChart/FunnelChart.js +11 -0
  60. package/lib-amd/components/FunnelChart/FunnelChart.js.map +1 -0
  61. package/lib-amd/components/FunnelChart/FunnelChart.styles.d.ts +2 -0
  62. package/lib-amd/components/FunnelChart/FunnelChart.styles.js +43 -0
  63. package/lib-amd/components/FunnelChart/FunnelChart.styles.js.map +1 -0
  64. package/lib-amd/components/FunnelChart/FunnelChart.types.d.ts +139 -0
  65. package/lib-amd/components/FunnelChart/FunnelChart.types.js +5 -0
  66. package/lib-amd/components/FunnelChart/FunnelChart.types.js.map +1 -0
  67. package/lib-amd/components/FunnelChart/funnelGeometry.d.ts +77 -0
  68. package/lib-amd/components/FunnelChart/funnelGeometry.js +204 -0
  69. package/lib-amd/components/FunnelChart/funnelGeometry.js.map +1 -0
  70. package/lib-amd/components/FunnelChart/index.d.ts +2 -0
  71. package/lib-amd/components/FunnelChart/index.js +7 -0
  72. package/lib-amd/components/FunnelChart/index.js.map +1 -0
  73. package/lib-amd/components/HeatMapChart/HeatMapChart.base.d.ts +0 -1
  74. package/lib-amd/components/HeatMapChart/HeatMapChart.base.js +2 -15
  75. package/lib-amd/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  76. package/lib-amd/components/LineChart/LineChart.base.d.ts +2 -0
  77. package/lib-amd/components/LineChart/LineChart.base.js +17 -10
  78. package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
  79. package/lib-amd/components/LineChart/LineChart.types.d.ts +6 -0
  80. package/lib-amd/components/LineChart/LineChart.types.js.map +1 -1
  81. package/lib-amd/index.d.ts +2 -0
  82. package/lib-amd/index.js +3 -2
  83. package/lib-amd/index.js.map +1 -1
  84. package/lib-amd/utilities/utilities.d.ts +3 -0
  85. package/lib-amd/utilities/utilities.js +17 -2
  86. package/lib-amd/utilities/utilities.js.map +1 -1
  87. package/lib-commonjs/FunnelChart.d.ts +1 -0
  88. package/lib-commonjs/FunnelChart.js +5 -0
  89. package/lib-commonjs/FunnelChart.js.map +1 -0
  90. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +6 -0
  91. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  92. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +2 -0
  93. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +122 -1
  94. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  95. package/lib-commonjs/components/FunnelChart/FunnelChart.base.d.ts +3 -0
  96. package/lib-commonjs/components/FunnelChart/FunnelChart.base.js +267 -0
  97. package/lib-commonjs/components/FunnelChart/FunnelChart.base.js.map +1 -0
  98. package/lib-commonjs/components/FunnelChart/FunnelChart.d.ts +7 -0
  99. package/lib-commonjs/components/FunnelChart/FunnelChart.js +12 -0
  100. package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -0
  101. package/lib-commonjs/components/FunnelChart/FunnelChart.styles.d.ts +2 -0
  102. package/lib-commonjs/components/FunnelChart/FunnelChart.styles.js +42 -0
  103. package/lib-commonjs/components/FunnelChart/FunnelChart.styles.js.map +1 -0
  104. package/lib-commonjs/components/FunnelChart/FunnelChart.types.d.ts +139 -0
  105. package/lib-commonjs/components/FunnelChart/FunnelChart.types.js +3 -0
  106. package/lib-commonjs/components/FunnelChart/FunnelChart.types.js.map +1 -0
  107. package/lib-commonjs/components/FunnelChart/funnelGeometry.d.ts +77 -0
  108. package/lib-commonjs/components/FunnelChart/funnelGeometry.js +202 -0
  109. package/lib-commonjs/components/FunnelChart/funnelGeometry.js.map +1 -0
  110. package/lib-commonjs/components/FunnelChart/index.d.ts +2 -0
  111. package/lib-commonjs/components/FunnelChart/index.js +6 -0
  112. package/lib-commonjs/components/FunnelChart/index.js.map +1 -0
  113. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.d.ts +0 -1
  114. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js +1 -15
  115. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  116. package/lib-commonjs/components/LineChart/LineChart.base.d.ts +2 -0
  117. package/lib-commonjs/components/LineChart/LineChart.base.js +17 -10
  118. package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
  119. package/lib-commonjs/components/LineChart/LineChart.types.d.ts +6 -0
  120. package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
  121. package/lib-commonjs/index.d.ts +2 -0
  122. package/lib-commonjs/index.js +3 -1
  123. package/lib-commonjs/index.js.map +1 -1
  124. package/lib-commonjs/utilities/utilities.d.ts +3 -0
  125. package/lib-commonjs/utilities/utilities.js +17 -1
  126. package/lib-commonjs/utilities/utilities.js.map +1 -1
  127. package/package.json +2 -2
  128. package/src/components/FunnelChart/FunnelChart.types.ts +153 -0
  129. package/src/components/LineChart/LineChart.types.ts +7 -0
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import { IFunnelChartProps } from './FunnelChart.types';
3
+ export declare const FunnelChartBase: React.FunctionComponent<IFunnelChartProps>;
@@ -0,0 +1,267 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FunnelChartBase = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var React = require("react");
6
+ var Utilities_1 = require("@fluentui/react/lib/Utilities");
7
+ var react_focus_1 = require("@fluentui/react-focus");
8
+ var index_1 = require("../Legends/index");
9
+ var Callout_1 = require("@fluentui/react/lib/Callout");
10
+ var ChartHoverCard_1 = require("../../utilities/ChartHoverCard/ChartHoverCard");
11
+ var chart_utilities_1 = require("@fluentui/chart-utilities");
12
+ var image_export_utils_1 = require("../../utilities/image-export-utils");
13
+ var utilities_1 = require("../../utilities/utilities");
14
+ var funnelGeometry_1 = require("./funnelGeometry");
15
+ var getClassNames = (0, Utilities_1.classNamesFunction)();
16
+ exports.FunnelChartBase = React.forwardRef(function (props, forwardedRef) {
17
+ var _a;
18
+ var _tooltipId = (0, Utilities_1.getId)('FunnelChartTooltipId_');
19
+ var _emptyChartId = (0, Utilities_1.getId)('_FunnelChart_empty');
20
+ var isRTL = (0, Utilities_1.getRTL)();
21
+ var _b = React.useState(null), hoveredStage = _b[0], setHoveredStage = _b[1];
22
+ var _c = React.useState(false), isCalloutVisible = _c[0], setIsCalloutVisible = _c[1];
23
+ var _d = React.useState(null), calloutData = _d[0], setCalloutData = _d[1];
24
+ var _e = React.useState(null), refSelected = _e[0], setRefSelected = _e[1];
25
+ var _f = React.useState([]), selectedLegends = _f[0], setSelectedLegends = _f[1];
26
+ var chartContainerRef = React.useRef(null);
27
+ var legendsRef = React.useRef(null);
28
+ var isStacked = isStackedFunnelData(props.data);
29
+ React.useEffect(function () {
30
+ var _a;
31
+ if ((_a = props.legendProps) === null || _a === void 0 ? void 0 : _a.selectedLegends) {
32
+ setSelectedLegends(props.legendProps.selectedLegends);
33
+ }
34
+ }, [(_a = props.legendProps) === null || _a === void 0 ? void 0 : _a.selectedLegends]);
35
+ React.useImperativeHandle(props.componentRef, function () { return ({
36
+ chartContainer: chartContainerRef !== null && chartContainerRef !== void 0 ? chartContainerRef : null,
37
+ toImage: function (opts) {
38
+ var _a;
39
+ return (0, image_export_utils_1.toImage)(chartContainerRef.current, (_a = legendsRef.current) === null || _a === void 0 ? void 0 : _a.toSVG, (0, Utilities_1.getRTL)(), opts);
40
+ },
41
+ }); }, []);
42
+ function _handleHover(data, mouseEvent) {
43
+ mouseEvent === null || mouseEvent === void 0 ? void 0 : mouseEvent.persist();
44
+ setHoveredStage(data.stage);
45
+ setCalloutData(data);
46
+ setIsCalloutVisible(true);
47
+ setRefSelected(mouseEvent.currentTarget);
48
+ }
49
+ function _handleStackedHover(stage, subValue, mouseEvent) {
50
+ mouseEvent === null || mouseEvent === void 0 ? void 0 : mouseEvent.persist();
51
+ setHoveredStage(subValue.category);
52
+ setCalloutData({
53
+ stage: stage,
54
+ value: subValue.value,
55
+ color: subValue.color,
56
+ category: subValue.category,
57
+ });
58
+ setIsCalloutVisible(true);
59
+ setRefSelected(mouseEvent.currentTarget);
60
+ }
61
+ function _handleMouseOut() {
62
+ setHoveredStage(null);
63
+ setIsCalloutVisible(false);
64
+ setCalloutData(null);
65
+ setRefSelected(null);
66
+ }
67
+ function _onLegendSelectionChange(legendsSelected, event, currentLegend) {
68
+ var _a, _b;
69
+ if ((_a = props.legendProps) === null || _a === void 0 ? void 0 : _a.canSelectMultipleLegends) {
70
+ setSelectedLegends(legendsSelected);
71
+ }
72
+ else {
73
+ setSelectedLegends(legendsSelected.slice(-1));
74
+ }
75
+ if ((_b = props.legendProps) === null || _b === void 0 ? void 0 : _b.onChange) {
76
+ props.legendProps.onChange(legendsSelected, event, currentLegend);
77
+ }
78
+ }
79
+ var _onLegendSelectionChangeCallback = React.useCallback(_onLegendSelectionChange, [props.legendProps]);
80
+ function getHighlightedLegend() {
81
+ return selectedLegends.length > 0 ? selectedLegends : hoveredStage ? [hoveredStage] : [];
82
+ }
83
+ function legendHighlighted(legend) {
84
+ return getHighlightedLegend().includes(legend);
85
+ }
86
+ function noLegendHighlighted() {
87
+ return getHighlightedLegend().length === 0;
88
+ }
89
+ function _getEventHandlerProps(data) {
90
+ if ('subValue' in data) {
91
+ return {
92
+ culture: props.culture,
93
+ onMouseOver: function (event) { return _handleStackedHover(data.stage, data.subValue, event); },
94
+ onMouseMove: function (event) { return _handleStackedHover(data.stage, data.subValue, event); },
95
+ onMouseOut: function () { return _handleMouseOut(); },
96
+ };
97
+ }
98
+ else {
99
+ return {
100
+ culture: props.culture,
101
+ onMouseOver: function (event) { return _handleHover(data, event); },
102
+ onMouseMove: function (event) { return _handleHover(data, event); },
103
+ onMouseOut: function () { return _handleMouseOut(); },
104
+ };
105
+ }
106
+ }
107
+ function _renderSegmentText(_a) {
108
+ var show = _a.show, x = _a.x, y = _a.y, value = _a.value, textColor = _a.textColor;
109
+ if (!show) {
110
+ return null;
111
+ }
112
+ var textElement = (React.createElement("text", { x: isRTL ? funnelWidth - x : x, y: y, textAnchor: "middle", alignmentBaseline: "middle", fill: textColor }, (0, chart_utilities_1.formatToLocaleString)(value.toString(), props.culture)));
113
+ if (isRTL) {
114
+ return React.createElement("g", { transform: "scale(-1,1) translate(".concat(-funnelWidth, ",0)") }, textElement);
115
+ }
116
+ return textElement;
117
+ }
118
+ function _renderFunnelSegment(_a) {
119
+ var key = _a.key, pathD = _a.pathD, fill = _a.fill, opacity = _a.opacity, textProps = _a.textProps, data = _a.data;
120
+ var eventHandlers = _getEventHandlerProps(data);
121
+ var textColor = (0, utilities_1.getContrastTextColor)(fill, props.theme);
122
+ return (React.createElement("g", { key: key },
123
+ React.createElement("path", tslib_1.__assign({ d: pathD, fill: fill, opacity: opacity }, eventHandlers)),
124
+ textProps && React.createElement("g", tslib_1.__assign({}, eventHandlers), _renderSegmentText(tslib_1.__assign(tslib_1.__assign({}, textProps), { textColor: textColor })))));
125
+ }
126
+ function _createFunnel(containerHeight, containerWidth) {
127
+ var data = props.data;
128
+ var funnelWidth = containerWidth;
129
+ var funnelHeight = containerHeight * 0.8;
130
+ return data.map(function (d, i) {
131
+ var geometryProps = props.orientation === 'horizontal'
132
+ ? (0, funnelGeometry_1.getHorizontalFunnelSegmentGeometry)({ d: d, i: i, data: data, funnelWidth: funnelWidth, funnelHeight: funnelHeight, isRTL: isRTL })
133
+ : (0, funnelGeometry_1.getVerticalFunnelSegmentGeometry)({ d: d, i: i, data: data, funnelWidth: funnelWidth, funnelHeight: funnelHeight, isRTL: isRTL });
134
+ var pathD = geometryProps.pathD, textX = geometryProps.textX, textY = geometryProps.textY, availableWidth = geometryProps.availableWidth;
135
+ var minTextWidth = 16;
136
+ var eventHandlerProps = _getEventHandlerProps(d);
137
+ var textProps = (0, funnelGeometry_1.getSegmentTextProps)(tslib_1.__assign({ availableWidth: availableWidth, minTextWidth: minTextWidth, textX: textX, textY: textY, value: d.value }, eventHandlerProps));
138
+ return _renderFunnelSegment({
139
+ key: i,
140
+ pathD: pathD,
141
+ fill: d.color,
142
+ opacity: legendHighlighted(d.stage) || noLegendHighlighted() ? 1 : 0.1,
143
+ textProps: textProps,
144
+ data: d,
145
+ });
146
+ });
147
+ }
148
+ function isStackedFunnelData(data) {
149
+ return Array.isArray(data) && data.every(function (stage) { return Array.isArray(stage.subValues); });
150
+ }
151
+ function _renderStackedSegment(stage, subValue, stageIndex, subValueIndex, geometryParams) {
152
+ // Ensure stages have subValues for geometry functions
153
+ var stagesWithSubValues = geometryParams.stages.map(function (s) { return (tslib_1.__assign(tslib_1.__assign({}, s), { subValues: s.subValues || [] })); });
154
+ var geom = props.orientation === 'horizontal'
155
+ ? (0, funnelGeometry_1.getStackedHorizontalFunnelSegmentGeometry)(tslib_1.__assign(tslib_1.__assign({}, geometryParams), { stages: stagesWithSubValues, i: stageIndex, k: subValueIndex }))
156
+ : (0, funnelGeometry_1.getStackedVerticalFunnelSegmentGeometry)(tslib_1.__assign(tslib_1.__assign({}, geometryParams), { stages: stagesWithSubValues, i: stageIndex, k: subValueIndex }));
157
+ var minTextWidth = 16;
158
+ var eventHandlerProps = _getEventHandlerProps({ stage: stage.stage, subValue: subValue });
159
+ var textProps = (0, funnelGeometry_1.getSegmentTextProps)(tslib_1.__assign({ availableWidth: geom.availableWidth, minTextWidth: minTextWidth, textX: geom.textX, textY: geom.textY, value: subValue.value }, eventHandlerProps));
160
+ return _renderFunnelSegment({
161
+ key: "".concat(stageIndex, "-").concat(subValueIndex),
162
+ pathD: geom.pathD,
163
+ fill: subValue.color,
164
+ opacity: (isStackedFunnelData(props.data) && legendHighlighted(subValue.category)) || noLegendHighlighted() ? 1 : 0.1,
165
+ textProps: textProps,
166
+ data: { stage: stage.stage, subValue: subValue },
167
+ });
168
+ }
169
+ function _createStackedFunnel(containerHeight, containerWidth) {
170
+ var _a, _b;
171
+ var data = props.data;
172
+ var stages = data;
173
+ var totals = stages.map(function (s) { var _a, _b; return (_b = (_a = s === null || s === void 0 ? void 0 : s.subValues) === null || _a === void 0 ? void 0 : _a.reduce(function (sum, subValue) { return sum + subValue.value; }, 0)) !== null && _b !== void 0 ? _b : 0; });
174
+ var maxTotal = Math.max.apply(Math, totals);
175
+ var funnelWidth = containerWidth;
176
+ var funnelHeight = containerHeight * 0.8;
177
+ var paths = [];
178
+ var geometryParams = {
179
+ stages: stages,
180
+ totals: totals,
181
+ maxTotal: maxTotal,
182
+ funnelWidth: funnelWidth,
183
+ funnelHeight: funnelHeight,
184
+ isRTL: isRTL,
185
+ };
186
+ for (var i = 0; i < stages.length; i++) {
187
+ var cur = stages[i];
188
+ for (var k = 0; k < ((_a = cur.subValues) !== null && _a !== void 0 ? _a : []).length; k++) {
189
+ var v = (_b = cur.subValues) === null || _b === void 0 ? void 0 : _b[k];
190
+ if (!v) {
191
+ continue;
192
+ }
193
+ paths.push(_renderStackedSegment(cur, v, i, k, geometryParams));
194
+ }
195
+ }
196
+ return paths;
197
+ }
198
+ function _renderLegends() {
199
+ if (props.hideLegend) {
200
+ return React.createElement(React.Fragment, null);
201
+ }
202
+ var legends;
203
+ if (isStacked) {
204
+ // Collect unique categories and their color
205
+ var categoryMap_1 = {};
206
+ props.data.forEach(function (stage) {
207
+ (stage.subValues || []).forEach(function (sub) {
208
+ if (!(sub.category in categoryMap_1)) {
209
+ categoryMap_1[sub.category] = sub.color;
210
+ }
211
+ });
212
+ });
213
+ legends = Object.entries(categoryMap_1).map(function (_a) {
214
+ var category = _a[0], color = _a[1];
215
+ return ({
216
+ title: category,
217
+ color: color,
218
+ hoverAction: function () { return setHoveredStage(category); },
219
+ onMouseOutAction: function () { return setHoveredStage(null); },
220
+ });
221
+ });
222
+ }
223
+ else {
224
+ legends = props.data.map(function (d) { return ({
225
+ title: d.stage,
226
+ color: d.color,
227
+ hoverAction: function () { return setHoveredStage(d.stage); },
228
+ onMouseOutAction: function () { return setHoveredStage(null); },
229
+ }); });
230
+ }
231
+ return (React.createElement("div", { style: { display: 'flex', justifyContent: 'center' } },
232
+ React.createElement(index_1.Legends, tslib_1.__assign({ ref: legendsRef, legends: legends, centerLegends: true, onChange: _onLegendSelectionChangeCallback }, props.legendProps))));
233
+ }
234
+ function _isChartEmpty() {
235
+ return !(props.data && props.data.length > 0);
236
+ }
237
+ var calloutProps = tslib_1.__assign({ isCalloutVisible: isCalloutVisible, directionalHint: Callout_1.DirectionalHint.topAutoEdge, id: "toolTip".concat(_tooltipId), target: refSelected, color: calloutData === null || calloutData === void 0 ? void 0 : calloutData.color, XValue: calloutData === null || calloutData === void 0 ? void 0 : calloutData.stage, YValue: calloutData === null || calloutData === void 0 ? void 0 : calloutData.value, isBeakVisible: false, gapSpace: 15, onDismiss: function () {
238
+ setIsCalloutVisible(false);
239
+ }, preventDismissOnLostFocus: true }, props.calloutProps);
240
+ var width = props.width || 350;
241
+ var height = props.height || 500;
242
+ var classNames = getClassNames(props.styles, {
243
+ theme: props.theme,
244
+ className: props.className,
245
+ chartWidth: width,
246
+ chartHeight: height,
247
+ });
248
+ var funnelMarginTop = 40;
249
+ var funnelWidth = width * 0.8;
250
+ var funnelOffsetX = (width - funnelWidth) / 2;
251
+ return !_isChartEmpty() ? (React.createElement("div", { ref: chartContainerRef, className: classNames.root },
252
+ React.createElement(react_focus_1.FocusZone, { direction: react_focus_1.FocusZoneDirection.horizontal },
253
+ React.createElement("svg", { width: width, height: height, className: classNames.chart, role: 'img', "aria-label": props.chartTitle },
254
+ React.createElement("g", { transform: isRTL
255
+ ? "translate(".concat(funnelOffsetX + funnelWidth, ", ").concat(funnelMarginTop, ") scale(-1,1)")
256
+ : "translate(".concat(funnelOffsetX, ", ").concat(funnelMarginTop, ")") }, isStacked
257
+ ? _createStackedFunnel(height - funnelMarginTop, funnelWidth)
258
+ : _createFunnel(height - funnelMarginTop, funnelWidth)),
259
+ isCalloutVisible && (React.createElement(Callout_1.Callout, tslib_1.__assign({}, calloutProps),
260
+ React.createElement(ChartHoverCard_1.ChartHoverCard, { XValue: calloutProps === null || calloutProps === void 0 ? void 0 : calloutProps.XValue, YValue: calloutProps === null || calloutProps === void 0 ? void 0 : calloutProps.YValue, color: calloutProps === null || calloutProps === void 0 ? void 0 : calloutProps.color }))))),
261
+ _renderLegends())) : (React.createElement("div", { id: _emptyChartId, role: 'alert', style: { opacity: '0' }, "aria-label": 'Graph has no data to display' }));
262
+ });
263
+ exports.FunnelChartBase.displayName = 'FunnelChart';
264
+ exports.FunnelChartBase.defaultProps = {
265
+ orientation: 'horizontal',
266
+ };
267
+ //# sourceMappingURL=FunnelChart.base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FunnelChart.base.js","sourceRoot":"../src/","sources":["components/FunnelChart/FunnelChart.base.tsx"],"names":[],"mappings":";;;;AAAA,6BAA+B;AAC/B,2DAAkF;AAOlF,qDAAsE;AACtE,0CAAsE;AACtE,uDAAuE;AACvE,gFAA+E;AAC/E,6DAAiE;AAEjE,yEAA+E;AAC/E,uDAAiE;AACjE,mDAM0B;AAE1B,IAAM,aAAa,GAAG,IAAA,8BAAkB,GAA8C,CAAC;AAE1E,QAAA,eAAe,GAA+C,KAAK,CAAC,UAAU,CAGzF,UAAC,KAAK,EAAE,YAAY;;IACpB,IAAM,UAAU,GAAW,IAAA,iBAAK,EAAC,uBAAuB,CAAC,CAAC;IAC1D,IAAM,aAAa,GAAW,IAAA,iBAAK,EAAC,oBAAoB,CAAC,CAAC;IAC1D,IAAM,KAAK,GAAG,IAAA,kBAAM,GAAE,CAAC;IAEjB,IAAA,KAAkC,KAAK,CAAC,QAAQ,CAAgB,IAAI,CAAC,EAApE,YAAY,QAAA,EAAE,eAAe,QAAuC,CAAC;IACtE,IAAA,KAA0C,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAA9D,gBAAgB,QAAA,EAAE,mBAAmB,QAAyB,CAAC;IAChE,IAAA,KAAgC,KAAK,CAAC,QAAQ,CAA+B,IAAI,CAAC,EAAjF,WAAW,QAAA,EAAE,cAAc,QAAsD,CAAC;IACnF,IAAA,KAAgC,KAAK,CAAC,QAAQ,CAAoB,IAAI,CAAC,EAAtE,WAAW,QAAA,EAAE,cAAc,QAA2C,CAAC;IACxE,IAAA,KAAwC,KAAK,CAAC,QAAQ,CAAW,EAAE,CAAC,EAAnE,eAAe,QAAA,EAAE,kBAAkB,QAAgC,CAAC;IAC3E,IAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,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CAAC,CACtD;gBACH,gBAAgB,IAAI,CACnB,oBAAC,iBAAO,uBAAK,YAAY;oBACvB,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;QACX,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;AACJ,CAAC,CAAC,CAAC;AACH,uBAAe,CAAC,WAAW,GAAG,aAAa,CAAC;AAC5C,uBAAe,CAAC,YAAY,GAAG;IAC7B,WAAW,EAAE,YAAY;CAC1B,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)}\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(containerHeight: number, containerWidth: number): 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 ): 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(containerHeight: number, containerWidth: number): 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 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(): 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';\nFunnelChartBase.defaultProps = {\n orientation: 'horizontal',\n};\n"]}
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { IFunnelChartProps } from './FunnelChart.types';
3
+ /**
4
+ * Funnelchart component.
5
+ * {@docCategory FunnelChart}
6
+ */
7
+ export declare const FunnelChart: React.FunctionComponent<IFunnelChartProps>;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FunnelChart = void 0;
4
+ var react_1 = require("@fluentui/react");
5
+ var FunnelChart_base_1 = require("./FunnelChart.base");
6
+ var FunnelChart_styles_1 = require("./FunnelChart.styles");
7
+ /**
8
+ * Funnelchart component.
9
+ * {@docCategory FunnelChart}
10
+ */
11
+ exports.FunnelChart = (0, react_1.styled)(FunnelChart_base_1.FunnelChartBase, FunnelChart_styles_1.getFunnelChartStyles);
12
+ //# sourceMappingURL=FunnelChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FunnelChart.js","sourceRoot":"../src/","sources":["components/FunnelChart/FunnelChart.tsx"],"names":[],"mappings":";;;AAAA,yCAAyC;AAEzC,uDAAqD;AACrD,2DAA4D;AAG5D;;;GAGG;AACU,QAAA,WAAW,GAA+C,IAAA,cAAM,EAI3E,kCAAe,EAAE,yCAAoB,CAAC,CAAC","sourcesContent":["import { styled } from '@fluentui/react';\nimport * as React from 'react';\nimport { FunnelChartBase } from './FunnelChart.base';\nimport { getFunnelChartStyles } from './FunnelChart.styles';\nimport { IFunnelChartProps, IFunnelChartStyleProps, IFunnelChartStyles } from './FunnelChart.types';\n\n/**\n * Funnelchart component.\n * {@docCategory FunnelChart}\n */\nexport const FunnelChart: React.FunctionComponent<IFunnelChartProps> = styled<\n IFunnelChartProps,\n IFunnelChartStyleProps,\n IFunnelChartStyles\n>(FunnelChartBase, getFunnelChartStyles);\n"]}
@@ -0,0 +1,2 @@
1
+ import { IFunnelChartStyleProps, IFunnelChartStyles } from './FunnelChart.types';
2
+ export declare const getFunnelChartStyles: (props: IFunnelChartStyleProps) => IFunnelChartStyles;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFunnelChartStyles = void 0;
4
+ var Styling_1 = require("@fluentui/react/lib/Styling");
5
+ var getFunnelChartStyles = function (props) {
6
+ var theme = props.theme, className = props.className, chartWidth = props.chartWidth, chartHeight = props.chartHeight;
7
+ return {
8
+ // root: { minHeight: '200px', minWidth: '200px', position: 'relative' },
9
+ root: [
10
+ theme.fonts.medium,
11
+ 'ms-FunnelChart',
12
+ {
13
+ alignItems: 'center',
14
+ width: '100%',
15
+ height: '100%',
16
+ },
17
+ className,
18
+ ],
19
+ chart: {
20
+ display: 'block',
21
+ width: chartWidth,
22
+ height: chartHeight,
23
+ },
24
+ text: [
25
+ theme.fonts.medium,
26
+ {
27
+ pointerEvents: 'none',
28
+ fontWeight: Styling_1.FontWeights.semibold,
29
+ fill: theme.palette.neutralPrimary,
30
+ },
31
+ ],
32
+ subComponentStyles: {
33
+ calloutStyles: {
34
+ root: {
35
+ maxWidth: '238px',
36
+ },
37
+ },
38
+ },
39
+ };
40
+ };
41
+ exports.getFunnelChartStyles = getFunnelChartStyles;
42
+ //# sourceMappingURL=FunnelChart.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FunnelChart.styles.js","sourceRoot":"../src/","sources":["components/FunnelChart/FunnelChart.styles.ts"],"names":[],"mappings":";;;AAAA,uDAA0D;AAGnD,IAAM,oBAAoB,GAAG,UAAC,KAA6B;IACxD,IAAA,KAAK,GAAyC,KAAK,MAA9C,EAAE,SAAS,GAA8B,KAAK,UAAnC,EAAE,UAAU,GAAkB,KAAK,WAAvB,EAAE,WAAW,GAAK,KAAK,YAAV,CAAW;IAC5D,OAAO;QACL,yEAAyE;QACzE,IAAI,EAAE;YACJ,KAAK,CAAC,KAAK,CAAC,MAAM;YAClB,gBAAgB;YAChB;gBACE,UAAU,EAAE,QAAQ;gBACpB,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,MAAM;aACf;YACD,SAAS;SACV;QACD,KAAK,EAAE;YACL,OAAO,EAAE,OAAO;YAChB,KAAK,EAAE,UAAU;YACjB,MAAM,EAAE,WAAW;SACpB;QACD,IAAI,EAAE;YACJ,KAAK,CAAC,KAAK,CAAC,MAAM;YAClB;gBACE,aAAa,EAAE,MAAM;gBACrB,UAAU,EAAE,qBAAW,CAAC,QAAQ;gBAChC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,cAAc;aACnC;SACF;QACD,kBAAkB,EAAE;YAClB,aAAa,EAAE;gBACb,IAAI,EAAE;oBACJ,QAAQ,EAAE,OAAO;iBAClB;aACF;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAnCW,QAAA,oBAAoB,wBAmC/B","sourcesContent":["import { FontWeights } from '@fluentui/react/lib/Styling';\nimport { IFunnelChartStyleProps, IFunnelChartStyles } from './FunnelChart.types';\n\nexport const getFunnelChartStyles = (props: IFunnelChartStyleProps): IFunnelChartStyles => {\n const { theme, className, chartWidth, chartHeight } = props;\n return {\n // root: { minHeight: '200px', minWidth: '200px', position: 'relative' },\n root: [\n theme.fonts.medium,\n 'ms-FunnelChart',\n {\n alignItems: 'center',\n width: '100%',\n height: '100%',\n },\n className,\n ],\n chart: {\n display: 'block',\n width: chartWidth,\n height: chartHeight,\n },\n text: [\n theme.fonts.medium,\n {\n pointerEvents: 'none',\n fontWeight: FontWeights.semibold,\n fill: theme.palette.neutralPrimary,\n },\n ],\n subComponentStyles: {\n calloutStyles: {\n root: {\n maxWidth: '238px',\n },\n },\n },\n };\n};\n"]}
@@ -0,0 +1,139 @@
1
+ import * as React from 'react';
2
+ import { IStyle, ITheme } from '@fluentui/react/lib/Styling';
3
+ import { IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';
4
+ import { ICalloutContentStyleProps, ICalloutContentStyles } from '@fluentui/react/lib/Callout';
5
+ import { ILegendsProps } from '../Legends/index';
6
+ import { ICalloutProps } from '@fluentui/react/lib/Callout';
7
+ /**
8
+ * Data point for funnel chart
9
+ * {@docCategory FunnelChart}
10
+ */
11
+ export interface IFunnelChartDataPoint {
12
+ /**
13
+ * Stage name or identifier
14
+ */
15
+ stage: string | number;
16
+ /**
17
+ * Sub-values for stacked funnel charts
18
+ * Each sub-value represents a category within the stage
19
+ */
20
+ subValues?: Array<{
21
+ category: string;
22
+ value: number;
23
+ color: string;
24
+ }>;
25
+ /**
26
+ * Value for the stage (used for non-stacked funnel charts)
27
+ */
28
+ value?: number;
29
+ /**
30
+ * Color for the stage (used for non-stacked funnel charts)
31
+ */
32
+ color?: string;
33
+ }
34
+ /**
35
+ * Funnel Chart component props
36
+ * {@docCategory FunnelChart}
37
+ */
38
+ export interface IFunnelChartProps {
39
+ /**
40
+ * Data points for the funnel chart
41
+ */
42
+ data: IFunnelChartDataPoint[];
43
+ /**
44
+ * Title for the chart
45
+ */
46
+ chartTitle?: string;
47
+ /**
48
+ * Width of the chart
49
+ */
50
+ width?: number;
51
+ /**
52
+ * Height of the chart
53
+ */
54
+ height?: number;
55
+ /**
56
+ * Decides whether to show/hide legends
57
+ * @defaultvalue false
58
+ */
59
+ hideLegend?: boolean;
60
+ /**
61
+ * Props for the legends in the chart
62
+ */
63
+ legendProps?: Partial<ILegendsProps>;
64
+ /**
65
+ * Props for the callout in the chart
66
+ */
67
+ calloutProps?: Partial<ICalloutProps>;
68
+ /**
69
+ * Theme (provided through customization)
70
+ */
71
+ theme?: ITheme;
72
+ /**
73
+ * Call to provide customized styling that will layer on top of the variant rules
74
+ */
75
+ styles?: IStyleFunctionOrObject<IFunnelChartStyleProps, IFunnelChartStyles>;
76
+ /**
77
+ * Defines the culture to localize the numbers and dates
78
+ */
79
+ culture?: string;
80
+ /**
81
+ * Reference to the chart component
82
+ */
83
+ componentRef?: React.RefObject<any>;
84
+ /**
85
+ * Additional CSS class(es) to apply to the chart
86
+ */
87
+ className?: string;
88
+ /**
89
+ * Orientation of the funnel chart
90
+ * @defaultvalue 'horizontal'
91
+ */
92
+ orientation?: 'horizontal' | 'vertical';
93
+ }
94
+ /**
95
+ * Funnel Chart style properties
96
+ * {@docCategory FunnelChart}
97
+ */
98
+ export interface IFunnelChartStyleProps {
99
+ /**
100
+ * Theme (provided through customization)
101
+ */
102
+ theme: ITheme;
103
+ /**
104
+ * Additional CSS class(es) to apply to the chart
105
+ */
106
+ className?: string;
107
+ /**
108
+ * Width of the chart
109
+ */
110
+ chartWidth: number;
111
+ /**
112
+ * Height of the chart
113
+ */
114
+ chartHeight: number;
115
+ }
116
+ /**
117
+ * Funnel Chart styles
118
+ * {@docCategory FunnelChart}
119
+ */
120
+ export interface IFunnelChartStyles {
121
+ /**
122
+ * Styles for the root element
123
+ */
124
+ root?: IStyle;
125
+ /**
126
+ * Styles for the chart
127
+ */
128
+ chart?: IStyle;
129
+ /**
130
+ * Styles for text elements
131
+ */
132
+ text?: IStyle;
133
+ /**
134
+ * Styles for sub-components
135
+ */
136
+ subComponentStyles: {
137
+ calloutStyles: IStyleFunctionOrObject<ICalloutContentStyleProps, ICalloutContentStyles>;
138
+ };
139
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=FunnelChart.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FunnelChart.types.js","sourceRoot":"../src/","sources":["components/FunnelChart/FunnelChart.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { IStyle, ITheme } from '@fluentui/react/lib/Styling';\nimport { IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';\nimport { ICalloutContentStyleProps, ICalloutContentStyles } from '@fluentui/react/lib/Callout';\nimport { ILegendsProps } from '../Legends/index';\nimport { ICalloutProps } from '@fluentui/react/lib/Callout';\n\n/**\n * Data point for funnel chart\n * {@docCategory FunnelChart}\n */\nexport interface IFunnelChartDataPoint {\n /**\n * Stage name or identifier\n */\n stage: string | number;\n /**\n * Sub-values for stacked funnel charts\n * Each sub-value represents a category within the stage\n */\n subValues?: Array<{ category: string; value: number; color: string }>;\n /**\n * Value for the stage (used for non-stacked funnel charts)\n */\n value?: number;\n /**\n * Color for the stage (used for non-stacked funnel charts)\n */\n color?: string;\n}\n\n/**\n * Funnel Chart component props\n * {@docCategory FunnelChart}\n */\nexport interface IFunnelChartProps {\n /**\n * Data points for the funnel chart\n */\n data: IFunnelChartDataPoint[];\n /**\n * Title for the chart\n */\n chartTitle?: string;\n /**\n * Width of the chart\n */\n width?: number;\n\n /**\n * Height of the chart\n */\n height?: number;\n\n /**\n * Decides whether to show/hide legends\n * @defaultvalue false\n */\n hideLegend?: boolean;\n\n /**\n * Props for the legends in the chart\n */\n legendProps?: Partial<ILegendsProps>;\n\n /**\n * Props for the callout in the chart\n */\n calloutProps?: Partial<ICalloutProps>;\n\n /**\n * Theme (provided through customization)\n */\n theme?: ITheme;\n\n /**\n * Call to provide customized styling that will layer on top of the variant rules\n */\n styles?: IStyleFunctionOrObject<IFunnelChartStyleProps, IFunnelChartStyles>;\n\n /**\n * Defines the culture to localize the numbers and dates\n */\n culture?: string;\n\n /**\n * Reference to the chart component\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n componentRef?: React.RefObject<any>;\n\n /**\n * Additional CSS class(es) to apply to the chart\n */\n className?: string;\n\n /**\n * Orientation of the funnel chart\n * @defaultvalue 'horizontal'\n */\n orientation?: 'horizontal' | 'vertical';\n}\n\n/**\n * Funnel Chart style properties\n * {@docCategory FunnelChart}\n */\nexport interface IFunnelChartStyleProps {\n /**\n * Theme (provided through customization)\n */\n theme: ITheme;\n /**\n * Additional CSS class(es) to apply to the chart\n */\n className?: string;\n /**\n * Width of the chart\n */\n chartWidth: number;\n /**\n * Height of the chart\n */\n chartHeight: number;\n}\n\n/**\n * Funnel Chart styles\n * {@docCategory FunnelChart}\n */\nexport interface IFunnelChartStyles {\n /**\n * Styles for the root element\n */\n root?: IStyle;\n\n /**\n * Styles for the chart\n */\n chart?: IStyle;\n\n /**\n * Styles for text elements\n */\n text?: IStyle;\n\n /**\n * Styles for sub-components\n */\n subComponentStyles: {\n calloutStyles: IStyleFunctionOrObject<ICalloutContentStyleProps, ICalloutContentStyles>;\n };\n}\n"]}
@@ -0,0 +1,77 @@
1
+ import * as React from 'react';
2
+ import { IFunnelChartDataPoint } from './FunnelChart.types';
3
+ export interface IFunnelSegmentGeometry {
4
+ pathD: string;
5
+ textX: number;
6
+ textY: number;
7
+ availableWidth: number;
8
+ }
9
+ export interface IStackedFunnelSegmentGeometry {
10
+ pathD: string;
11
+ textX: number;
12
+ textY: number;
13
+ availableWidth: number;
14
+ }
15
+ interface ISubValue {
16
+ category: string;
17
+ value: number;
18
+ color: string;
19
+ }
20
+ interface IStage {
21
+ subValues: ISubValue[];
22
+ }
23
+ export declare function getHorizontalFunnelSegmentGeometry({ d, i, data, funnelWidth, funnelHeight, isRTL, }: {
24
+ d: IFunnelChartDataPoint;
25
+ i: number;
26
+ data: IFunnelChartDataPoint[];
27
+ funnelWidth: number;
28
+ funnelHeight: number;
29
+ isRTL: boolean;
30
+ }): IFunnelSegmentGeometry;
31
+ export declare function getVerticalFunnelSegmentGeometry({ d, i, data, funnelWidth, funnelHeight, isRTL, }: {
32
+ d: IFunnelChartDataPoint;
33
+ i: number;
34
+ data: IFunnelChartDataPoint[];
35
+ funnelWidth: number;
36
+ funnelHeight: number;
37
+ isRTL: boolean;
38
+ }): IFunnelSegmentGeometry;
39
+ export declare function getStackedHorizontalFunnelSegmentGeometry({ i, k, stages, totals, maxTotal, funnelWidth, funnelHeight, }: {
40
+ i: number;
41
+ k: number;
42
+ stages: IStage[];
43
+ totals: number[];
44
+ maxTotal: number;
45
+ funnelWidth: number;
46
+ funnelHeight: number;
47
+ }): IStackedFunnelSegmentGeometry;
48
+ export declare function getStackedVerticalFunnelSegmentGeometry({ i, k, stages, totals, maxTotal, funnelWidth, funnelHeight, }: {
49
+ i: number;
50
+ k: number;
51
+ stages: IStage[];
52
+ totals: number[];
53
+ maxTotal: number;
54
+ funnelWidth: number;
55
+ funnelHeight: number;
56
+ }): IStackedFunnelSegmentGeometry;
57
+ export declare function getSegmentTextProps({ availableWidth, minTextWidth, textX, textY, value, culture, onMouseOver, onMouseMove, onMouseOut, }: {
58
+ availableWidth: number;
59
+ minTextWidth?: number;
60
+ textX: number;
61
+ textY: number;
62
+ value: number;
63
+ culture: string | undefined;
64
+ onMouseOver: (event: React.MouseEvent<SVGElement>) => void;
65
+ onMouseMove: (event: React.MouseEvent<SVGElement>) => void;
66
+ onMouseOut: () => void;
67
+ }): {
68
+ show: boolean;
69
+ x: number;
70
+ y: number;
71
+ value: number;
72
+ culture: string | undefined;
73
+ onMouseOver: (event: React.MouseEvent<SVGElement>) => void;
74
+ onMouseMove: (event: React.MouseEvent<SVGElement>) => void;
75
+ onMouseOut: () => void;
76
+ };
77
+ export {};