@fluentui/react-charts 0.0.0-nightly-20251009-0406.1 → 0.0.0-nightly-20251010-0407.1

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 (39) hide show
  1. package/CHANGELOG.md +15 -15
  2. package/dist/index.d.ts +10 -0
  3. package/lib/components/CommonComponents/ChartPopover.js +2 -1
  4. package/lib/components/CommonComponents/ChartPopover.js.map +1 -1
  5. package/lib/components/CommonComponents/ChartPopover.types.js.map +1 -1
  6. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +5 -1
  7. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  8. package/lib/components/DonutChart/Arc/Arc.js +8 -7
  9. package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
  10. package/lib/components/DonutChart/DonutChart.js +8 -28
  11. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  12. package/lib/components/DonutChart/Pie/Pie.js +4 -4
  13. package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
  14. package/lib/components/FunnelChart/FunnelChart.js +23 -45
  15. package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
  16. package/lib/components/GaugeChart/GaugeChart.js +21 -46
  17. package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
  18. package/lib/components/LineChart/LineChart.js +110 -73
  19. package/lib/components/LineChart/LineChart.js.map +1 -1
  20. package/lib/types/DataPoint.js.map +1 -1
  21. package/lib-commonjs/components/CommonComponents/ChartPopover.js +2 -1
  22. package/lib-commonjs/components/CommonComponents/ChartPopover.js.map +1 -1
  23. package/lib-commonjs/components/CommonComponents/ChartPopover.types.js.map +1 -1
  24. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +5 -1
  25. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  26. package/lib-commonjs/components/DonutChart/Arc/Arc.js +8 -7
  27. package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
  28. package/lib-commonjs/components/DonutChart/DonutChart.js +8 -28
  29. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  30. package/lib-commonjs/components/DonutChart/Pie/Pie.js +4 -4
  31. package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
  32. package/lib-commonjs/components/FunnelChart/FunnelChart.js +23 -45
  33. package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
  34. package/lib-commonjs/components/GaugeChart/GaugeChart.js +21 -46
  35. package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
  36. package/lib-commonjs/components/LineChart/LineChart.js +110 -73
  37. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  38. package/lib-commonjs/types/DataPoint.js.map +1 -1
  39. package/package.json +12 -12
@@ -26,12 +26,12 @@ const Arc = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
26
26
  }, [
27
27
  props
28
28
  ]);
29
- function _onFocus(data, id, event) {
30
- props.onFocusCallback(data, id, event, currentRef.current);
29
+ function _onFocus(data, id, event, targetElement) {
30
+ props.onFocusCallback(data, id, event, currentRef.current, targetElement);
31
31
  }
32
- function _hoverOn(data, mouseEvent) {
32
+ function _hoverOn(data, mouseEvent, targetElement) {
33
33
  mouseEvent.persist();
34
- props.hoverOnCallback(data, mouseEvent);
34
+ props.hoverOnCallback(data, mouseEvent, targetElement);
35
35
  }
36
36
  function _hoverOff() {
37
37
  props.hoverLeaveCallback();
@@ -85,6 +85,7 @@ const Arc = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
85
85
  const id = props.uniqText + (typeof props.data.data.legend === 'string' ? props.data.data.legend.replace(/\s+/g, '') : '') + props.data.data.data;
86
86
  const opacity = activeArc && activeArc.length > 0 ? activeArc.includes((_props_data = props.data) === null || _props_data === void 0 ? void 0 : _props_data.data.legend) ? 1 : 0.1 : 1;
87
87
  const cornerRadius = props.roundCorners ? 3 : 0;
88
+ const targetElement = document.getElementById(id);
88
89
  return /*#__PURE__*/ _react.createElement("g", {
89
90
  ref: currentRef
90
91
  }, !!focusedArcId && focusedArcId === id && // TODO innerradius and outerradius were absent
@@ -109,9 +110,9 @@ const Arc = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
109
110
  fill: props.color,
110
111
  cursor: href ? 'pointer' : 'default'
111
112
  },
112
- onFocus: (event)=>_onFocus(props.data.data, id, event),
113
- onMouseOver: (event)=>_hoverOn(props.data.data, event),
114
- onMouseMove: (event)=>_hoverOn(props.data.data, event),
113
+ onFocus: (event)=>_onFocus(props.data.data, id, event, targetElement),
114
+ onMouseOver: (event)=>_hoverOn(props.data.data, event, targetElement),
115
+ onMouseMove: (event)=>_hoverOn(props.data.data, event, targetElement),
115
116
  onMouseLeave: _hoverOff,
116
117
  tabIndex: _shouldHighlightArc(props.data.data.legend) || ((_props_activeArc = props.activeArc) === null || _props_activeArc === void 0 ? void 0 : _props_activeArc.length) === 0 ? 0 : undefined,
117
118
  onBlur: _onBlur,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/DonutChart/Arc/Arc.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { arc as d3Arc } from 'd3-shape';\nimport { useArcStyles } from './useArcStyles.styles';\nimport { ChartDataPoint } from '../index';\nimport { ArcProps } from './index';\nimport { format as d3Format } from 'd3-format';\nimport { formatScientificLimitWidth, useRtl } from '../../../utilities/index';\n\n// Create a Arc within Donut Chart variant which uses these default styles and this styled subcomponent.\n/**\n * Arc component within Donut Chart.\n * {@docCategory ArcDonutChart}\n */\nexport const Arc: React.FunctionComponent<ArcProps> = React.forwardRef<HTMLDivElement, ArcProps>(\n (props, forwardedRef) => {\n const arc = d3Arc();\n const currentRef = React.createRef<SVGPathElement>();\n const _isRTL: boolean = useRtl();\n const classes = useArcStyles(props);\n\n React.useEffect(() => {\n _updateChart(props);\n }, [props]);\n\n function _onFocus(data: ChartDataPoint, id: string, event: React.FocusEvent<SVGPathElement, Element>): void {\n props.onFocusCallback!(data, id, event, currentRef.current);\n }\n\n function _hoverOn(data: ChartDataPoint, mouseEvent: React.MouseEvent<SVGPathElement>): void {\n mouseEvent.persist();\n props.hoverOnCallback!(data, mouseEvent);\n }\n\n function _hoverOff(): void {\n props.hoverLeaveCallback!();\n }\n\n function _onBlur(): void {\n props.onBlurCallback!();\n }\n\n function _getAriaLabel(): string {\n const point = props.data!.data;\n const legend = point.xAxisCalloutData || point.legend;\n const yValue = point.yAxisCalloutData || point.data || 0;\n return point.callOutAccessibilityData?.ariaLabel || (legend ? `${legend}, ` : '') + `${yValue}.`;\n }\n\n function _shouldHighlightArc(legend?: string): boolean {\n const { activeArc } = props;\n // If no activeArc is provided, highlight all arcs. Otherwise, only highlight the arcs that are active.\n return !activeArc || activeArc.length === 0 || legend === undefined || activeArc.includes(legend);\n }\n\n function _renderArcLabel(className: string) {\n const { data, innerRadius, outerRadius, showLabelsInPercent, totalValue, hideLabels } = props;\n\n if (\n hideLabels ||\n Math.abs(data!.endAngle - data!.startAngle) < Math.PI / 12 ||\n !_shouldHighlightArc(data!.data.legend!)\n ) {\n return null;\n }\n\n const [base, perp] = arc.centroid({ ...data!, innerRadius, outerRadius });\n const hyp = Math.sqrt(base * base + perp * perp);\n const labelRadius = Math.max(innerRadius!, outerRadius!) + 2;\n const angle = (data!.startAngle + data!.endAngle) / 2;\n const arcValue = data!.value;\n\n return (\n <text\n x={(hyp === 0 ? 0 : base / hyp) * labelRadius}\n y={(hyp === 0 ? 0 : perp / hyp) * labelRadius}\n textAnchor={angle > Math.PI !== _isRTL ? 'end' : 'start'}\n dominantBaseline={angle > Math.PI / 2 && angle < (3 * Math.PI) / 2 ? 'hanging' : 'auto'}\n className={className}\n aria-hidden={true}\n >\n {showLabelsInPercent\n ? d3Format('.0%')(totalValue! === 0 ? 0 : arcValue / totalValue!)\n : formatScientificLimitWidth(arcValue)}\n </text>\n );\n }\n\n function _updateChart(newProps: ArcProps): void {\n if (newProps.arc && newProps.innerRadius && newProps.outerRadius) {\n newProps.arc.innerRadius(newProps.innerRadius);\n newProps.arc.outerRadius(newProps.outerRadius);\n }\n }\n\n const { href, focusedArcId, activeArc } = props;\n //TO DO 'replace' is throwing error\n const id =\n props.uniqText! +\n (typeof props.data!.data.legend === 'string' ? props.data!.data.legend.replace(/\\s+/g, '') : '') +\n props.data!.data.data;\n const opacity: number =\n activeArc && activeArc.length > 0 ? (activeArc.includes(props.data?.data.legend!) ? 1 : 0.1) : 1;\n const cornerRadius = props.roundCorners ? 3 : 0;\n return (\n <g ref={currentRef}>\n {!!focusedArcId && focusedArcId === id && (\n // TODO innerradius and outerradius were absent\n <path\n id={id + 'focusRing'}\n d={\n arc.cornerRadius(cornerRadius)({\n ...props.data!,\n innerRadius: props.innerRadius,\n outerRadius: props.outerRadius,\n })!\n }\n className={classes.focusRing}\n />\n )}\n <path\n // TODO innerradius and outerradius were absent\n id={id}\n d={\n arc.cornerRadius(cornerRadius)({\n ...props.data!,\n innerRadius: props.innerRadius,\n outerRadius: props.outerRadius,\n })!\n }\n className={classes.root}\n style={{ fill: props.color, cursor: href ? 'pointer' : 'default' }}\n onFocus={event => _onFocus(props.data!.data, id, event)}\n onMouseOver={event => _hoverOn(props.data!.data, event)}\n onMouseMove={event => _hoverOn(props.data!.data, event)}\n onMouseLeave={_hoverOff}\n tabIndex={_shouldHighlightArc(props.data!.data.legend!) || props.activeArc?.length === 0 ? 0 : undefined}\n onBlur={_onBlur}\n opacity={opacity}\n onClick={props.data?.data.onClick}\n aria-label={_getAriaLabel()}\n role=\"img\"\n />\n {_renderArcLabel(classes.arcLabel)}\n </g>\n );\n },\n);\nArc.displayName = 'Arc';\n"],"names":["React","arc","d3Arc","useArcStyles","format","d3Format","formatScientificLimitWidth","useRtl","Arc","forwardRef","props","forwardedRef","currentRef","createRef","_isRTL","classes","useEffect","_updateChart","_onFocus","data","id","event","onFocusCallback","current","_hoverOn","mouseEvent","persist","hoverOnCallback","_hoverOff","hoverLeaveCallback","_onBlur","onBlurCallback","_getAriaLabel","point","legend","xAxisCalloutData","yValue","yAxisCalloutData","callOutAccessibilityData","ariaLabel","_shouldHighlightArc","activeArc","length","undefined","includes","_renderArcLabel","className","innerRadius","outerRadius","showLabelsInPercent","totalValue","hideLabels","Math","abs","endAngle","startAngle","PI","base","perp","centroid","hyp","sqrt","labelRadius","max","angle","arcValue","value","text","x","y","textAnchor","dominantBaseline","aria-hidden","newProps","href","focusedArcId","uniqText","replace","opacity","cornerRadius","roundCorners","g","ref","path","d","focusRing","root","style","fill","color","cursor","onFocus","onMouseOver","onMouseMove","onMouseLeave","tabIndex","onBlur","onClick","aria-label","role","arcLabel","displayName"],"mappings":"AAAA;;;;;+BAeaQ;;;;;;;iEAbU,QAAQ;yBACF,WAAW;oCACX,wBAAwB;0BAGlB,YAAY;uBACI,2BAA2B;AAOvE,YAAMA,WAAAA,GAAyCR,OAAMS,UAAU,CACpE,CAACC,OAAOC;QAuFoDD,aAkCOA,kBAGlDA;IA3Hf,MAAMT,UAAMC,YAAAA;IACZ,MAAMU,aAAAA,WAAAA,GAAaZ,OAAMa,SAAS;IAClC,MAAMC,SAAkBP,iBAAAA;IACxB,MAAMQ,cAAUZ,gCAAAA,EAAaO;IAE7BV,OAAMgB,SAAS,CAAC;QACdC,aAAaP;IACf,GAAG;QAACA;KAAM;IAEV,SAASQ,SAASC,IAAoB,EAAEC,EAAU,EAAEC,KAAgD;QAClGX,MAAMY,eAAe,CAAEH,MAAMC,IAAIC,OAAOT,WAAWW,OAAO;IAC5D;IAEA,SAASC,SAASL,IAAoB,EAAEM,UAA4C;QAClFA,WAAWC,OAAO;QAClBhB,MAAMiB,eAAe,CAAER,MAAMM;IAC/B;IAEA,SAASG;QACPlB,MAAMmB,kBAAkB;IAC1B;IAEA,SAASC;QACPpB,MAAMqB,cAAc;IACtB;IAEA,SAASC;YAIAC;QAHP,MAAMA,QAAQvB,MAAMS,IAAI,CAAEA,IAAI;QAC9B,MAAMe,SAASD,MAAME,gBAAgB,IAAIF,MAAMC,MAAM;QAC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;QAENtD,gBAAgB9B,QAAQqF,QAAQ;AAGvC,GACA;AACF5F,IAAI6F,WAAW,GAAG"}
1
+ {"version":3,"sources":["../src/components/DonutChart/Arc/Arc.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { arc as d3Arc } from 'd3-shape';\nimport { useArcStyles } from './useArcStyles.styles';\nimport { ChartDataPoint } from '../index';\nimport { ArcProps } from './index';\nimport { format as d3Format } from 'd3-format';\nimport { formatScientificLimitWidth, useRtl } from '../../../utilities/index';\n\n// Create a Arc within Donut Chart variant which uses these default styles and this styled subcomponent.\n/**\n * Arc component within Donut Chart.\n * {@docCategory ArcDonutChart}\n */\nexport const Arc: React.FunctionComponent<ArcProps> = React.forwardRef<HTMLDivElement, ArcProps>(\n (props, forwardedRef) => {\n const arc = d3Arc();\n const currentRef = React.createRef<SVGPathElement>();\n const _isRTL: boolean = useRtl();\n const classes = useArcStyles(props);\n\n React.useEffect(() => {\n _updateChart(props);\n }, [props]);\n\n function _onFocus(\n data: ChartDataPoint,\n id: string,\n event: React.FocusEvent<SVGPathElement, Element>,\n targetElement?: HTMLElement | null,\n ): void {\n props.onFocusCallback!(data, id, event, currentRef.current, targetElement);\n }\n\n function _hoverOn(\n data: ChartDataPoint,\n mouseEvent: React.MouseEvent<SVGPathElement>,\n targetElement?: HTMLElement | null,\n ): void {\n mouseEvent.persist();\n props.hoverOnCallback!(data, mouseEvent, targetElement);\n }\n\n function _hoverOff(): void {\n props.hoverLeaveCallback!();\n }\n\n function _onBlur(): void {\n props.onBlurCallback!();\n }\n\n function _getAriaLabel(): string {\n const point = props.data!.data;\n const legend = point.xAxisCalloutData || point.legend;\n const yValue = point.yAxisCalloutData || point.data || 0;\n return point.callOutAccessibilityData?.ariaLabel || (legend ? `${legend}, ` : '') + `${yValue}.`;\n }\n\n function _shouldHighlightArc(legend?: string): boolean {\n const { activeArc } = props;\n // If no activeArc is provided, highlight all arcs. Otherwise, only highlight the arcs that are active.\n return !activeArc || activeArc.length === 0 || legend === undefined || activeArc.includes(legend);\n }\n\n function _renderArcLabel(className: string) {\n const { data, innerRadius, outerRadius, showLabelsInPercent, totalValue, hideLabels } = props;\n\n if (\n hideLabels ||\n Math.abs(data!.endAngle - data!.startAngle) < Math.PI / 12 ||\n !_shouldHighlightArc(data!.data.legend!)\n ) {\n return null;\n }\n\n const [base, perp] = arc.centroid({ ...data!, innerRadius, outerRadius });\n const hyp = Math.sqrt(base * base + perp * perp);\n const labelRadius = Math.max(innerRadius!, outerRadius!) + 2;\n const angle = (data!.startAngle + data!.endAngle) / 2;\n const arcValue = data!.value;\n\n return (\n <text\n x={(hyp === 0 ? 0 : base / hyp) * labelRadius}\n y={(hyp === 0 ? 0 : perp / hyp) * labelRadius}\n textAnchor={angle > Math.PI !== _isRTL ? 'end' : 'start'}\n dominantBaseline={angle > Math.PI / 2 && angle < (3 * Math.PI) / 2 ? 'hanging' : 'auto'}\n className={className}\n aria-hidden={true}\n >\n {showLabelsInPercent\n ? d3Format('.0%')(totalValue! === 0 ? 0 : arcValue / totalValue!)\n : formatScientificLimitWidth(arcValue)}\n </text>\n );\n }\n\n function _updateChart(newProps: ArcProps): void {\n if (newProps.arc && newProps.innerRadius && newProps.outerRadius) {\n newProps.arc.innerRadius(newProps.innerRadius);\n newProps.arc.outerRadius(newProps.outerRadius);\n }\n }\n\n const { href, focusedArcId, activeArc } = props;\n //TO DO 'replace' is throwing error\n const id =\n props.uniqText! +\n (typeof props.data!.data.legend === 'string' ? props.data!.data.legend.replace(/\\s+/g, '') : '') +\n props.data!.data.data;\n const opacity: number =\n activeArc && activeArc.length > 0 ? (activeArc.includes(props.data?.data.legend!) ? 1 : 0.1) : 1;\n const cornerRadius = props.roundCorners ? 3 : 0;\n const targetElement = document.getElementById(id);\n return (\n <g ref={currentRef}>\n {!!focusedArcId && focusedArcId === id && (\n // TODO innerradius and outerradius were absent\n <path\n id={id + 'focusRing'}\n d={\n arc.cornerRadius(cornerRadius)({\n ...props.data!,\n innerRadius: props.innerRadius,\n outerRadius: props.outerRadius,\n })!\n }\n className={classes.focusRing}\n />\n )}\n <path\n // TODO innerradius and outerradius were absent\n id={id}\n d={\n arc.cornerRadius(cornerRadius)({\n ...props.data!,\n innerRadius: props.innerRadius,\n outerRadius: props.outerRadius,\n })!\n }\n className={classes.root}\n style={{ fill: props.color, cursor: href ? 'pointer' : 'default' }}\n onFocus={event => _onFocus(props.data!.data, id, event, targetElement)}\n onMouseOver={event => _hoverOn(props.data!.data, event, targetElement)}\n onMouseMove={event => _hoverOn(props.data!.data, event, targetElement)}\n onMouseLeave={_hoverOff}\n tabIndex={_shouldHighlightArc(props.data!.data.legend!) || props.activeArc?.length === 0 ? 0 : undefined}\n onBlur={_onBlur}\n opacity={opacity}\n onClick={props.data?.data.onClick}\n aria-label={_getAriaLabel()}\n role=\"img\"\n />\n {_renderArcLabel(classes.arcLabel)}\n </g>\n );\n },\n);\nArc.displayName = 'Arc';\n"],"names":["React","arc","d3Arc","useArcStyles","format","d3Format","formatScientificLimitWidth","useRtl","Arc","forwardRef","props","forwardedRef","currentRef","createRef","_isRTL","classes","useEffect","_updateChart","_onFocus","data","id","event","targetElement","onFocusCallback","current","_hoverOn","mouseEvent","persist","hoverOnCallback","_hoverOff","hoverLeaveCallback","_onBlur","onBlurCallback","_getAriaLabel","point","legend","xAxisCalloutData","yValue","yAxisCalloutData","callOutAccessibilityData","ariaLabel","_shouldHighlightArc","activeArc","length","undefined","includes","_renderArcLabel","className","innerRadius","outerRadius","showLabelsInPercent","totalValue","hideLabels","Math","abs","endAngle","startAngle","PI","base","perp","centroid","hyp","sqrt","labelRadius","max","angle","arcValue","value","text","x","y","textAnchor","dominantBaseline","aria-hidden","newProps","href","focusedArcId","uniqText","replace","opacity","cornerRadius","roundCorners","document","getElementById","g","ref","path","d","focusRing","root","style","fill","color","cursor","onFocus","onMouseOver","onMouseMove","onMouseLeave","tabIndex","onBlur","onClick","aria-label","role","arcLabel","displayName"],"mappings":"AAAA;;;;;;;;;;;;iE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,+CAA+C;QAC/ClE,IAAIA;QACJmE,GACEtF,IAAI+E,YAAY,CAACA,cAAc;YAC7B,GAAGtE,MAAMS,IAAI;YACb6B,aAAatC,MAAMsC,WAAW;YAC9BC,aAAavC,MAAMuC,WAAW;QAChC;QAEFF,WAAWhC,QAAQ0E,IAAI;QACvBC,OAAO;YAAEC,MAAMjF,MAAMkF,KAAK;YAAEC,QAAQlB,OAAO,YAAY;QAAU;QACjEmB,SAASzE,CAAAA,QAASH,SAASR,MAAMS,IAAI,CAAEA,IAAI,EAAEC,IAAIC,OAAOC;QACxDyE,aAAa1E,CAAAA,QAASI,SAASf,MAAMS,IAAI,CAAEA,IAAI,EAAEE,OAAOC;QACxD0E,aAAa3E,CAAAA,QAASI,SAASf,MAAMS,IAAI,CAAEA,IAAI,EAAEE,OAAOC;QACxD2E,cAAcpE;QACdqE,UAAUzD,oBAAoB/B,MAAMS,IAAI,CAAEA,IAAI,CAACgB,MAAM,KAAMzB,CAAAA,CAAAA,mBAAAA,MAAMgC,SAAAA,AAAS,MAAA,QAAfhC,qBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,iBAAiBiC,MAAAA,AAAM,MAAK,IAAI,IAAIC;QAC/FuD,QAAQpE;QACRgD,SAASA;QACTqB,OAAO,EAAA,CAAE1F,eAAAA,MAAMS,IAAAA,AAAI,MAAA,QAAVT,iBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,aAAYS,IAAI,CAACiF,OAAO;QACjCC,cAAYpE;QACZqE,MAAK;QAENxD,gBAAgB/B,QAAQwF,QAAQ;AAGvC,GACA;AACF/F,IAAIgG,WAAW,GAAG"}
@@ -40,10 +40,7 @@ const DonutChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
40
40
  const [selectedLegends, setSelectedLegends] = _react.useState(((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) || []);
41
41
  const [focusedArcId, setFocusedArcId] = _react.useState('');
42
42
  const [dataPointCalloutProps, setDataPointCalloutProps] = _react.useState();
43
- const [clickPosition, setClickPosition] = _react.useState({
44
- x: 0,
45
- y: 0
46
- });
43
+ const [refSelected, setRefSelected] = _react.useState(null);
47
44
  const [isPopoverOpen, setPopoverOpen] = _react.useState(false);
48
45
  const prevPropsRef = _react.useRef(null);
49
46
  const _legendsRef = _react.useRef(null);
@@ -136,13 +133,7 @@ const DonutChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
136
133
  props.legendProps.onChange(selectedLegends, event, currentLegend);
137
134
  }
138
135
  }
139
- function _focusCallback(data, id, e) {
140
- let cx = 0;
141
- let cy = 0;
142
- const targetRect = e.target.getBoundingClientRect();
143
- cx = targetRect.left + targetRect.width / 2;
144
- cy = targetRect.top + targetRect.height / 2;
145
- updatePosition(cx, cy);
136
+ function _focusCallback(data, id, e, targetElement) {
146
137
  setPopoverOpen(_noLegendsHighlighted() || _isLegendHighlighted(data.legend));
147
138
  setValue(data.data.toString());
148
139
  setLegend(data.legend);
@@ -151,8 +142,9 @@ const DonutChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
151
142
  setYCalloutValue(data.yAxisCalloutData);
152
143
  setFocusedArcId(id);
153
144
  setDataPointCalloutProps(data);
145
+ setRefSelected(targetElement);
154
146
  }
155
- function _hoverCallback(data, e) {
147
+ function _hoverCallback(data, e, targetElement) {
156
148
  if (_calloutAnchorPoint !== data) {
157
149
  _calloutAnchorPoint = data;
158
150
  setPopoverOpen(_noLegendsHighlighted() || _isLegendHighlighted(data.legend));
@@ -162,7 +154,7 @@ const DonutChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
162
154
  setXCalloutValue(data.xAxisCalloutData);
163
155
  setYCalloutValue(data.yAxisCalloutData);
164
156
  setDataPointCalloutProps(data);
165
- updatePosition(e.clientX, e.clientY);
157
+ setRefSelected(targetElement);
166
158
  }
167
159
  }
168
160
  function _onBlur() {
@@ -230,20 +222,6 @@ const DonutChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
230
222
  };
231
223
  }) : [];
232
224
  }
233
- function updatePosition(newX, newY) {
234
- const threshold = 1; // Set a threshold for movement
235
- const { x, y } = clickPosition;
236
- // Calculate the distance moved
237
- const distance = Math.sqrt(Math.pow(newX - x, 2) + Math.pow(newY - y, 2));
238
- // Update the position only if the distance moved is greater than the threshold
239
- if (distance > threshold) {
240
- setClickPosition({
241
- x: newX,
242
- y: newY
243
- });
244
- setPopoverOpen(true);
245
- }
246
- }
247
225
  /**
248
226
  * When screen resizes, along with screen, chart also auto adjusted.
249
227
  * This method used to adjust height and width of the charts.
@@ -318,7 +296,9 @@ const DonutChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
318
296
  xCalloutValue: xCalloutValue,
319
297
  yCalloutValue: yCalloutValue,
320
298
  culture: (_props_culture = props.culture) !== null && _props_culture !== void 0 ? _props_culture : 'en-us',
321
- clickPosition: clickPosition,
299
+ positioning: {
300
+ target: refSelected
301
+ },
322
302
  isPopoverOpen: !props.hideTooltip && isPopoverOpen && (_noLegendsHighlighted() || _isLegendHighlighted(legend)),
323
303
  legend: legend,
324
304
  YValue: value,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/DonutChart/DonutChart.tsx"],"sourcesContent":["'use client';\n\n/* eslint-disable react/jsx-no-bind */\nimport * as React from 'react';\nimport { Pie } from './Pie/index';\nimport { DonutChartProps } from './DonutChart.types';\nimport { useDonutChartStyles } from './useDonutChartStyles.styles';\nimport { ChartDataPoint } from '../../DonutChart';\nimport { formatToLocaleString } from '@fluentui/chart-utilities';\nimport { areArraysEqual, getColorFromToken, getNextColor, MIN_DONUT_RADIUS, useRtl } from '../../utilities/index';\nimport { Legend, Legends, LegendContainer } from '../../index';\nimport { useId } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { useFocusableGroup } from '@fluentui/react-tabster';\nimport { ChartPopover } from '../CommonComponents/ChartPopover';\nimport { ImageExportOptions } from '../../types/index';\nimport { toImage } from '../../utilities/image-export-utils';\n\nconst MIN_LEGEND_CONTAINER_HEIGHT = 40;\n\n// Create a DonutChart variant which uses these default styles and this styled subcomponent.\n/**\n * Donutchart component.\n * {@docCategory DonutChart}\n */\nexport const DonutChart: React.FunctionComponent<DonutChartProps> = React.forwardRef<HTMLDivElement, DonutChartProps>(\n (props, forwardedRef) => {\n const _rootElem = React.useRef<HTMLDivElement | null>(null);\n const _uniqText: string = useId('_Pie_');\n /* eslint-disable @typescript-eslint/no-explicit-any */\n let _calloutAnchorPoint: ChartDataPoint | null;\n let _emptyChartId: string | null;\n const legendContainer = React.useRef<HTMLDivElement | null>(null);\n const prevSize = React.useRef<{ width?: number; height?: number }>({});\n\n const [value, setValue] = React.useState<string | undefined>('');\n const [legend, setLegend] = React.useState<string | undefined>('');\n const [_width, setWidth] = React.useState<number | undefined>(props.width || 200);\n const [_height, setHeight] = React.useState<number | undefined>(props.height || 200);\n const [activeLegend, setActiveLegend] = React.useState<string | undefined>(undefined);\n const [color, setColor] = React.useState<string | undefined>('');\n const [xCalloutValue, setXCalloutValue] = React.useState<string>('');\n const [yCalloutValue, setYCalloutValue] = React.useState<string>('');\n const [selectedLegends, setSelectedLegends] = React.useState<string[]>(props.legendProps?.selectedLegends || []);\n const [focusedArcId, setFocusedArcId] = React.useState<string>('');\n const [dataPointCalloutProps, setDataPointCalloutProps] = React.useState<ChartDataPoint | undefined>();\n const [clickPosition, setClickPosition] = React.useState({ x: 0, y: 0 });\n const [isPopoverOpen, setPopoverOpen] = React.useState(false);\n const prevPropsRef = React.useRef<DonutChartProps | null>(null);\n const _legendsRef = React.useRef<LegendContainer>(null);\n const _isRTL: boolean = useRtl();\n\n React.useEffect(() => {\n _fitParentContainer();\n }, []);\n\n React.useEffect(() => {\n if (prevPropsRef.current) {\n const prevProps = prevPropsRef.current;\n if (!areArraysEqual(prevProps.legendProps?.selectedLegends, props.legendProps?.selectedLegends)) {\n setSelectedLegends(props.legendProps?.selectedLegends || []);\n }\n }\n prevPropsRef.current = props;\n }, [props]);\n\n React.useEffect(() => {\n if (prevSize.current.height !== props.height || prevSize.current.width !== props.width) {\n _fitParentContainer();\n }\n prevSize.current.height = props.height;\n prevSize.current.width = props.width;\n }, [props.width, props.height]);\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n chartContainer: _rootElem.current,\n toImage: (opts?: ImageExportOptions): Promise<string> => {\n return toImage(_rootElem.current, _legendsRef.current?.toSVG, _isRTL, opts);\n },\n }),\n [],\n );\n\n function _elevateToMinimums(data: ChartDataPoint[]) {\n let sumOfData = 0;\n const minPercent = 0.01;\n const elevatedData: ChartDataPoint[] = [];\n data.forEach(item => {\n sumOfData += item.data!;\n });\n data.forEach(item => {\n elevatedData.push(\n minPercent * sumOfData > item.data! && item.data! > 0\n ? {\n ...item,\n data: minPercent * sumOfData,\n yAxisCalloutData:\n item.yAxisCalloutData === undefined ? item.data!.toLocaleString() : item.yAxisCalloutData,\n }\n : item,\n );\n });\n return elevatedData;\n }\n function _createLegends(chartData: ChartDataPoint[]): JSXElement {\n const legendDataItems = chartData.map((point: ChartDataPoint, index: number) => {\n const color: string = point.color!;\n // mapping data to the format Legends component needs\n const legend: Legend = {\n title: point.legend!,\n color,\n hoverAction: () => {\n _handleChartMouseLeave();\n setActiveLegend(point.legend!);\n },\n onMouseOutAction: () => {\n setActiveLegend(undefined);\n },\n };\n return legend;\n });\n const legends = (\n <Legends\n legends={legendDataItems}\n centerLegends\n overflowText={props.legendsOverflowText}\n {...props.legendProps}\n // eslint-disable-next-line react/jsx-no-bind\n onChange={_onLegendSelectionChange}\n legendRef={_legendsRef}\n />\n );\n return legends;\n }\n function _onLegendSelectionChange(\n selectedLegends: string[],\n event: React.MouseEvent<HTMLButtonElement>,\n currentLegend?: Legend,\n ): void {\n if (props.legendProps && props.legendProps?.canSelectMultipleLegends) {\n setSelectedLegends(selectedLegends);\n } else {\n setSelectedLegends(selectedLegends.slice(-1));\n }\n if (props.legendProps?.onChange) {\n props.legendProps.onChange(selectedLegends, event, currentLegend);\n }\n }\n\n function _focusCallback(data: ChartDataPoint, id: string, e: React.FocusEvent<SVGPathElement>): void {\n let cx = 0;\n let cy = 0;\n\n const targetRect = (e.target as SVGPathElement).getBoundingClientRect();\n cx = targetRect.left + targetRect.width / 2;\n cy = targetRect.top + targetRect.height / 2;\n updatePosition(cx, cy);\n setPopoverOpen(_noLegendsHighlighted() || _isLegendHighlighted(data.legend));\n setValue(data.data!.toString());\n setLegend(data.legend);\n setColor(data.color!);\n setXCalloutValue(data.xAxisCalloutData!);\n setYCalloutValue(data.yAxisCalloutData!);\n setFocusedArcId(id);\n setDataPointCalloutProps(data);\n }\n\n function _hoverCallback(data: ChartDataPoint, e: React.MouseEvent<SVGPathElement>): void {\n if (_calloutAnchorPoint !== data) {\n _calloutAnchorPoint = data;\n setPopoverOpen(_noLegendsHighlighted() || _isLegendHighlighted(data.legend));\n setValue(data.data!.toString());\n setLegend(data.legend);\n setColor(data.color!);\n setXCalloutValue(data.xAxisCalloutData!);\n setYCalloutValue(data.yAxisCalloutData!);\n setDataPointCalloutProps(data);\n updatePosition(e.clientX, e.clientY);\n }\n }\n function _onBlur(): void {\n setFocusedArcId('');\n }\n\n function _hoverLeave(): void {\n /**/\n }\n\n function _handleChartMouseLeave() {\n _calloutAnchorPoint = null;\n setPopoverOpen(false);\n }\n\n function _valueInsideDonut(valueInsideDonut: string | number | undefined, data: ChartDataPoint[]) {\n const highlightedLegends = _getHighlightedLegend();\n if (valueInsideDonut !== undefined && (highlightedLegends.length === 1 || isPopoverOpen)) {\n const pointValue = data.find(point => _isLegendHighlighted(point.legend));\n return pointValue\n ? pointValue.yAxisCalloutData\n ? pointValue.yAxisCalloutData\n : pointValue.data!\n : valueInsideDonut;\n } else if (highlightedLegends.length > 0) {\n let totalValue = 0;\n data.forEach(point => {\n if (highlightedLegends.includes(point.legend!)) {\n totalValue += point.data!;\n }\n });\n return totalValue;\n } else {\n return valueInsideDonut;\n }\n }\n\n function _toLocaleString(data: string | number | undefined) {\n const localeString = formatToLocaleString(data, props.culture);\n if (!localeString) {\n return data;\n }\n return localeString?.toString();\n }\n\n /**\n * This function returns\n * the selected legend if there is one\n * or the hovered legend if none of the legends is selected.\n */\n function _getHighlightedLegend() {\n return selectedLegends.length > 0 ? selectedLegends : activeLegend ? [activeLegend] : [];\n }\n\n function _isLegendHighlighted(legend: string | undefined): boolean {\n return _getHighlightedLegend().includes(legend!);\n }\n\n function _noLegendsHighlighted(): boolean {\n return _getHighlightedLegend().length === 0;\n }\n\n function _isChartEmpty(): boolean {\n return !(\n props.data &&\n props.data.chartData &&\n props.data.chartData!.filter((d: ChartDataPoint) => d.data! > 0).length > 0\n );\n }\n\n function _addDefaultColors(donutChartDataPoint?: ChartDataPoint[]): ChartDataPoint[] {\n return donutChartDataPoint\n ? donutChartDataPoint.map((item, index) => {\n let defaultColor: string;\n if (typeof item.color === 'undefined') {\n defaultColor = getNextColor(index, 0);\n } else {\n defaultColor = getColorFromToken(item.color);\n }\n return { ...item, defaultColor };\n })\n : [];\n }\n\n function updatePosition(newX: number, newY: number) {\n const threshold = 1; // Set a threshold for movement\n const { x, y } = clickPosition;\n // Calculate the distance moved\n const distance = Math.sqrt(Math.pow(newX - x, 2) + Math.pow(newY - y, 2));\n // Update the position only if the distance moved is greater than the threshold\n if (distance > threshold) {\n setClickPosition({ x: newX, y: newY });\n setPopoverOpen(true);\n }\n }\n\n /**\n * When screen resizes, along with screen, chart also auto adjusted.\n * This method used to adjust height and width of the charts.\n */\n function _fitParentContainer(): void {\n //_reqID = requestAnimationFrame(() => {\n let legendContainerHeight;\n if (props.hideLegend) {\n // If there is no legend, need not to allocate some space from total chart space.\n legendContainerHeight = 0;\n } else {\n const legendContainerComputedStyles = legendContainer.current && getComputedStyle(legendContainer.current);\n legendContainerHeight =\n ((legendContainer.current && legendContainer.current.getBoundingClientRect().height) ||\n MIN_LEGEND_CONTAINER_HEIGHT) +\n parseFloat((legendContainerComputedStyles && legendContainerComputedStyles.marginTop) || '0') +\n parseFloat((legendContainerComputedStyles && legendContainerComputedStyles.marginBottom) || '0');\n }\n if (props.parentRef || _rootElem.current) {\n const container = props.parentRef ? props.parentRef : _rootElem.current!;\n const currentContainerWidth = container.getBoundingClientRect().width;\n const currentContainerHeight =\n container.getBoundingClientRect().height > legendContainerHeight\n ? container.getBoundingClientRect().height\n : 200;\n const shouldResize =\n _width !== currentContainerWidth || _height !== currentContainerHeight - legendContainerHeight;\n if (shouldResize) {\n setWidth(currentContainerWidth);\n setHeight(currentContainerHeight - legendContainerHeight);\n }\n }\n //});\n }\n\n const { data, hideLegend = false } = props;\n const points = _addDefaultColors(data?.chartData);\n\n const classes = useDonutChartStyles(props);\n\n const legendBars = _createLegends(points);\n const donutMarginHorizontal = props.hideLabels ? 0 : 80;\n const donutMarginVertical = props.hideLabels ? 0 : 40;\n const outerRadius = Math.min(_width! - donutMarginHorizontal, _height! - donutMarginVertical) / 2;\n const chartData = _elevateToMinimums(points.filter((d: ChartDataPoint) => d.data! >= 0));\n const valueInsideDonut =\n props.innerRadius! > MIN_DONUT_RADIUS ? _valueInsideDonut(props.valueInsideDonut!, chartData!) : '';\n const focusAttributes = useFocusableGroup();\n return !_isChartEmpty() ? (\n <div\n className={classes.root}\n ref={(rootElem: HTMLDivElement | null) => (_rootElem.current = rootElem)}\n onMouseLeave={_handleChartMouseLeave}\n >\n {props.xAxisAnnotation && (\n <text className={classes.axisAnnotation} x={_width! / 2} y={_height! - 10} textAnchor=\"middle\">\n {props.xAxisAnnotation}\n </text>\n )}\n <div className={classes.chartWrapper} {...focusAttributes}>\n <svg className={classes.chart} aria-label={data?.chartTitle} width={_width} height={_height}>\n <Pie\n width={_width!}\n height={_height!}\n outerRadius={outerRadius}\n innerRadius={props.innerRadius!}\n data={chartData!}\n onFocusCallback={_focusCallback}\n hoverOnCallback={_hoverCallback}\n hoverLeaveCallback={_hoverLeave}\n uniqText={_uniqText}\n onBlurCallback={_onBlur}\n activeArc={_getHighlightedLegend()}\n focusedArcId={focusedArcId || ''}\n href={props.href!}\n valueInsideDonut={_toLocaleString(valueInsideDonut)}\n showLabelsInPercent={props.showLabelsInPercent}\n hideLabels={props.hideLabels}\n />\n </svg>\n </div>\n <ChartPopover\n xCalloutValue={xCalloutValue}\n yCalloutValue={yCalloutValue}\n culture={props.culture ?? 'en-us'}\n clickPosition={clickPosition}\n isPopoverOpen={\n !props.hideTooltip && isPopoverOpen && (_noLegendsHighlighted() || _isLegendHighlighted(legend))\n }\n legend={legend!}\n YValue={value!}\n color={color}\n isCalloutForStack={false}\n customCallout={{\n customizedCallout: props.onRenderCalloutPerDataPoint\n ? props.onRenderCalloutPerDataPoint(dataPointCalloutProps!)\n : undefined,\n customCalloutProps: props.calloutPropsPerDataPoint\n ? props.calloutPropsPerDataPoint(dataPointCalloutProps!)\n : undefined,\n }}\n isCartesian={false}\n />\n {!hideLegend && (\n <div ref={(e: HTMLDivElement) => (legendContainer.current = e)} className={classes.legendContainer}>\n {legendBars}\n </div>\n )}\n </div>\n ) : (\n <div id={_emptyChartId!} role={'alert'} style={{ opacity: '0' }} aria-label={'Graph has no data to display'} />\n );\n },\n);\n\nDonutChart.displayName = 'DonutChart';\nDonutChart.defaultProps = {\n innerRadius: 0,\n hideLabels: true,\n};\n"],"names":["React","Pie","useDonutChartStyles","formatToLocaleString","areArraysEqual","getColorFromToken","getNextColor","MIN_DONUT_RADIUS","useRtl","Legends","useId","useFocusableGroup","ChartPopover","toImage","MIN_LEGEND_CONTAINER_HEIGHT","DonutChart","forwardRef","props","forwardedRef","_rootElem","useRef","_uniqText","_calloutAnchorPoint","_emptyChartId","legendContainer","prevSize","value","setValue","useState","legend","setLegend","_width","setWidth","width","_height","setHeight","height","activeLegend","setActiveLegend","undefined","color","setColor","xCalloutValue","setXCalloutValue","yCalloutValue","setYCalloutValue","selectedLegends","setSelectedLegends","legendProps","focusedArcId","setFocusedArcId","dataPointCalloutProps","setDataPointCalloutProps","clickPosition","setClickPosition","x","y","isPopoverOpen","setPopoverOpen","prevPropsRef","_legendsRef","_isRTL","useEffect","_fitParentContainer","current","prevProps","useImperativeHandle","componentRef","chartContainer","opts","toSVG","_elevateToMinimums","data","sumOfData","minPercent","elevatedData","forEach","item","push","yAxisCalloutData","toLocaleString","_createLegends","chartData","legendDataItems","map","point","index","title","hoverAction","_handleChartMouseLeave","onMouseOutAction","legends","centerLegends","overflowText","legendsOverflowText","onChange","_onLegendSelectionChange","legendRef","event","currentLegend","canSelectMultipleLegends","slice","_focusCallback","id","e","cx","cy","targetRect","target","getBoundingClientRect","left","top","updatePosition","_noLegendsHighlighted","_isLegendHighlighted","toString","xAxisCalloutData","_hoverCallback","clientX","clientY","_onBlur","_hoverLeave","_valueInsideDonut","valueInsideDonut","highlightedLegends","_getHighlightedLegend","length","pointValue","find","totalValue","includes","_toLocaleString","localeString","culture","_isChartEmpty","filter","d","_addDefaultColors","donutChartDataPoint","defaultColor","newX","newY","threshold","distance","Math","sqrt","pow","legendContainerHeight","hideLegend","legendContainerComputedStyles","getComputedStyle","parseFloat","marginTop","marginBottom","parentRef","container","currentContainerWidth","currentContainerHeight","shouldResize","points","classes","legendBars","donutMarginHorizontal","hideLabels","donutMarginVertical","outerRadius","min","innerRadius","focusAttributes","div","className","root","ref","rootElem","onMouseLeave","xAxisAnnotation","text","axisAnnotation","textAnchor","chartWrapper","svg","chart","aria-label","chartTitle","onFocusCallback","hoverOnCallback","hoverLeaveCallback","uniqText","onBlurCallback","activeArc","href","showLabelsInPercent","hideTooltip","YValue","isCalloutForStack","customCallout","customizedCallout","onRenderCalloutPerDataPoint","customCalloutProps","calloutPropsPerDataPoint","isCartesian","role","style","opacity","displayName","defaultProps"],"mappings":"AAAA;;;;;+BAyBae;;;;;;;iEAtBU,QAAQ;uBACX,cAAc;2CAEE,+BAA+B;gCAE9B,4BAA4B;wBACyB,wBAAwB;wBACjE,cAAc;gCACzC,4BAA4B;8BAEhB,0BAA0B;8BAC/B,mCAAmC;kCAExC,qCAAqC;AAE7D,MA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AkBQ,gBAAgBR;QAClCoE,qBAAqB9K,MAAM8K,mBAAmB;QAC9C5B,YAAYlJ,MAAMkJ,UAAU;wBAIlC,OAAA,aAAA,CAACvJ,0BAAAA,EAAAA;QACC8B,eAAeA;QACfE,eAAeA;QACfyF,SAASpH,CAAAA,iBAAAA,MAAMoH,OAAO,AAAPA,MAAO,QAAbpH,mBAAAA,KAAAA,IAAAA,iBAAiB;QAC1BoC,eAAeA;QACfI,eACE,CAACxC,MAAM+K,WAAW,IAAIvI,iBAAkBwD,CAAAA,2BAA2BC,qBAAqBrF,OAAAA,CAAM;QAEhGA,QAAQA;QACRoK,QAAQvK;QACRc,OAAOA;QACP0J,mBAAmB;QACnBC,eAAe;YACbC,mBAAmBnL,MAAMoL,2BAA2B,GAChDpL,MAAMoL,2BAA2B,CAAClJ,yBAClCZ;YACJ+J,oBAAoBrL,MAAMsL,wBAAwB,GAC9CtL,MAAMsL,wBAAwB,CAACpJ,yBAC/BZ;QACN;QACAiK,aAAa;QAEd,CAACpD,cAAAA,WAAAA,GACA,OAAA,aAAA,CAACqB,OAAAA;QAAIG,KAAK,CAACpE,IAAuBhF,gBAAgBwC,OAAO,GAAGwC;QAAIkE,WAAWV,QAAQxI,eAAe;OAC/FyI,eAAAA,WAAAA,GAKP,OAAA,aAAA,CAACQ,OAAAA;QAAIlE,IAAIhF;QAAgBkL,MAAM;QAASC,OAAO;YAAEC,SAAS;QAAI;QAAGrB,cAAY;;AAEjF,GACA;AAEFvK,WAAW6L,WAAW,GAAG;AACzB7L,WAAW8L,YAAY,GAAG;IACxBtC,aAAa;IACbJ,YAAY;AACd"}
1
+ {"version":3,"sources":["../src/components/DonutChart/DonutChart.tsx"],"sourcesContent":["'use client';\n\n/* eslint-disable react/jsx-no-bind */\nimport * as React from 'react';\nimport { Pie } from './Pie/index';\nimport { DonutChartProps } from './DonutChart.types';\nimport { useDonutChartStyles } from './useDonutChartStyles.styles';\nimport { ChartDataPoint } from '../../DonutChart';\nimport { formatToLocaleString } from '@fluentui/chart-utilities';\nimport { areArraysEqual, getColorFromToken, getNextColor, MIN_DONUT_RADIUS, useRtl } from '../../utilities/index';\nimport { Legend, Legends, LegendContainer } from '../../index';\nimport { useId } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { useFocusableGroup } from '@fluentui/react-tabster';\nimport { ChartPopover } from '../CommonComponents/ChartPopover';\nimport { ImageExportOptions } from '../../types/index';\nimport { toImage } from '../../utilities/image-export-utils';\n\nconst MIN_LEGEND_CONTAINER_HEIGHT = 40;\n\n// Create a DonutChart variant which uses these default styles and this styled subcomponent.\n/**\n * Donutchart component.\n * {@docCategory DonutChart}\n */\nexport const DonutChart: React.FunctionComponent<DonutChartProps> = React.forwardRef<HTMLDivElement, DonutChartProps>(\n (props, forwardedRef) => {\n const _rootElem = React.useRef<HTMLDivElement | null>(null);\n const _uniqText: string = useId('_Pie_');\n /* eslint-disable @typescript-eslint/no-explicit-any */\n let _calloutAnchorPoint: ChartDataPoint | null;\n let _emptyChartId: string | null;\n const legendContainer = React.useRef<HTMLDivElement | null>(null);\n const prevSize = React.useRef<{ width?: number; height?: number }>({});\n\n const [value, setValue] = React.useState<string | undefined>('');\n const [legend, setLegend] = React.useState<string | undefined>('');\n const [_width, setWidth] = React.useState<number | undefined>(props.width || 200);\n const [_height, setHeight] = React.useState<number | undefined>(props.height || 200);\n const [activeLegend, setActiveLegend] = React.useState<string | undefined>(undefined);\n const [color, setColor] = React.useState<string | undefined>('');\n const [xCalloutValue, setXCalloutValue] = React.useState<string>('');\n const [yCalloutValue, setYCalloutValue] = React.useState<string>('');\n const [selectedLegends, setSelectedLegends] = React.useState<string[]>(props.legendProps?.selectedLegends || []);\n const [focusedArcId, setFocusedArcId] = React.useState<string>('');\n const [dataPointCalloutProps, setDataPointCalloutProps] = React.useState<ChartDataPoint | undefined>();\n const [refSelected, setRefSelected] = React.useState<HTMLElement | null>(null);\n const [isPopoverOpen, setPopoverOpen] = React.useState(false);\n const prevPropsRef = React.useRef<DonutChartProps | null>(null);\n const _legendsRef = React.useRef<LegendContainer>(null);\n const _isRTL: boolean = useRtl();\n\n React.useEffect(() => {\n _fitParentContainer();\n }, []);\n\n React.useEffect(() => {\n if (prevPropsRef.current) {\n const prevProps = prevPropsRef.current;\n if (!areArraysEqual(prevProps.legendProps?.selectedLegends, props.legendProps?.selectedLegends)) {\n setSelectedLegends(props.legendProps?.selectedLegends || []);\n }\n }\n prevPropsRef.current = props;\n }, [props]);\n\n React.useEffect(() => {\n if (prevSize.current.height !== props.height || prevSize.current.width !== props.width) {\n _fitParentContainer();\n }\n prevSize.current.height = props.height;\n prevSize.current.width = props.width;\n }, [props.width, props.height]);\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n chartContainer: _rootElem.current,\n toImage: (opts?: ImageExportOptions): Promise<string> => {\n return toImage(_rootElem.current, _legendsRef.current?.toSVG, _isRTL, opts);\n },\n }),\n [],\n );\n\n function _elevateToMinimums(data: ChartDataPoint[]) {\n let sumOfData = 0;\n const minPercent = 0.01;\n const elevatedData: ChartDataPoint[] = [];\n data.forEach(item => {\n sumOfData += item.data!;\n });\n data.forEach(item => {\n elevatedData.push(\n minPercent * sumOfData > item.data! && item.data! > 0\n ? {\n ...item,\n data: minPercent * sumOfData,\n yAxisCalloutData:\n item.yAxisCalloutData === undefined ? item.data!.toLocaleString() : item.yAxisCalloutData,\n }\n : item,\n );\n });\n return elevatedData;\n }\n function _createLegends(chartData: ChartDataPoint[]): JSXElement {\n const legendDataItems = chartData.map((point: ChartDataPoint, index: number) => {\n const color: string = point.color!;\n // mapping data to the format Legends component needs\n const legend: Legend = {\n title: point.legend!,\n color,\n hoverAction: () => {\n _handleChartMouseLeave();\n setActiveLegend(point.legend!);\n },\n onMouseOutAction: () => {\n setActiveLegend(undefined);\n },\n };\n return legend;\n });\n const legends = (\n <Legends\n legends={legendDataItems}\n centerLegends\n overflowText={props.legendsOverflowText}\n {...props.legendProps}\n // eslint-disable-next-line react/jsx-no-bind\n onChange={_onLegendSelectionChange}\n legendRef={_legendsRef}\n />\n );\n return legends;\n }\n function _onLegendSelectionChange(\n selectedLegends: string[],\n event: React.MouseEvent<HTMLButtonElement>,\n currentLegend?: Legend,\n ): void {\n if (props.legendProps && props.legendProps?.canSelectMultipleLegends) {\n setSelectedLegends(selectedLegends);\n } else {\n setSelectedLegends(selectedLegends.slice(-1));\n }\n if (props.legendProps?.onChange) {\n props.legendProps.onChange(selectedLegends, event, currentLegend);\n }\n }\n\n function _focusCallback(\n data: ChartDataPoint,\n id: string,\n e: React.FocusEvent<SVGPathElement>,\n targetElement?: HTMLElement | null,\n ): void {\n setPopoverOpen(_noLegendsHighlighted() || _isLegendHighlighted(data.legend));\n setValue(data.data!.toString());\n setLegend(data.legend);\n setColor(data.color!);\n setXCalloutValue(data.xAxisCalloutData!);\n setYCalloutValue(data.yAxisCalloutData!);\n setFocusedArcId(id);\n setDataPointCalloutProps(data);\n setRefSelected(targetElement!);\n }\n\n function _hoverCallback(\n data: ChartDataPoint,\n e: React.MouseEvent<SVGPathElement>,\n targetElement?: HTMLElement | null,\n ): void {\n if (_calloutAnchorPoint !== data) {\n _calloutAnchorPoint = data;\n setPopoverOpen(_noLegendsHighlighted() || _isLegendHighlighted(data.legend));\n setValue(data.data!.toString());\n setLegend(data.legend);\n setColor(data.color!);\n setXCalloutValue(data.xAxisCalloutData!);\n setYCalloutValue(data.yAxisCalloutData!);\n setDataPointCalloutProps(data);\n setRefSelected(targetElement!);\n }\n }\n function _onBlur(): void {\n setFocusedArcId('');\n }\n\n function _hoverLeave(): void {\n /**/\n }\n\n function _handleChartMouseLeave() {\n _calloutAnchorPoint = null;\n setPopoverOpen(false);\n }\n\n function _valueInsideDonut(valueInsideDonut: string | number | undefined, data: ChartDataPoint[]) {\n const highlightedLegends = _getHighlightedLegend();\n if (valueInsideDonut !== undefined && (highlightedLegends.length === 1 || isPopoverOpen)) {\n const pointValue = data.find(point => _isLegendHighlighted(point.legend));\n return pointValue\n ? pointValue.yAxisCalloutData\n ? pointValue.yAxisCalloutData\n : pointValue.data!\n : valueInsideDonut;\n } else if (highlightedLegends.length > 0) {\n let totalValue = 0;\n data.forEach(point => {\n if (highlightedLegends.includes(point.legend!)) {\n totalValue += point.data!;\n }\n });\n return totalValue;\n } else {\n return valueInsideDonut;\n }\n }\n\n function _toLocaleString(data: string | number | undefined) {\n const localeString = formatToLocaleString(data, props.culture);\n if (!localeString) {\n return data;\n }\n return localeString?.toString();\n }\n\n /**\n * This function returns\n * the selected legend if there is one\n * or the hovered legend if none of the legends is selected.\n */\n function _getHighlightedLegend() {\n return selectedLegends.length > 0 ? selectedLegends : activeLegend ? [activeLegend] : [];\n }\n\n function _isLegendHighlighted(legend: string | undefined): boolean {\n return _getHighlightedLegend().includes(legend!);\n }\n\n function _noLegendsHighlighted(): boolean {\n return _getHighlightedLegend().length === 0;\n }\n\n function _isChartEmpty(): boolean {\n return !(\n props.data &&\n props.data.chartData &&\n props.data.chartData!.filter((d: ChartDataPoint) => d.data! > 0).length > 0\n );\n }\n\n function _addDefaultColors(donutChartDataPoint?: ChartDataPoint[]): ChartDataPoint[] {\n return donutChartDataPoint\n ? donutChartDataPoint.map((item, index) => {\n let defaultColor: string;\n if (typeof item.color === 'undefined') {\n defaultColor = getNextColor(index, 0);\n } else {\n defaultColor = getColorFromToken(item.color);\n }\n return { ...item, defaultColor };\n })\n : [];\n }\n\n /**\n * When screen resizes, along with screen, chart also auto adjusted.\n * This method used to adjust height and width of the charts.\n */\n function _fitParentContainer(): void {\n //_reqID = requestAnimationFrame(() => {\n let legendContainerHeight;\n if (props.hideLegend) {\n // If there is no legend, need not to allocate some space from total chart space.\n legendContainerHeight = 0;\n } else {\n const legendContainerComputedStyles = legendContainer.current && getComputedStyle(legendContainer.current);\n legendContainerHeight =\n ((legendContainer.current && legendContainer.current.getBoundingClientRect().height) ||\n MIN_LEGEND_CONTAINER_HEIGHT) +\n parseFloat((legendContainerComputedStyles && legendContainerComputedStyles.marginTop) || '0') +\n parseFloat((legendContainerComputedStyles && legendContainerComputedStyles.marginBottom) || '0');\n }\n if (props.parentRef || _rootElem.current) {\n const container = props.parentRef ? props.parentRef : _rootElem.current!;\n const currentContainerWidth = container.getBoundingClientRect().width;\n const currentContainerHeight =\n container.getBoundingClientRect().height > legendContainerHeight\n ? container.getBoundingClientRect().height\n : 200;\n const shouldResize =\n _width !== currentContainerWidth || _height !== currentContainerHeight - legendContainerHeight;\n if (shouldResize) {\n setWidth(currentContainerWidth);\n setHeight(currentContainerHeight - legendContainerHeight);\n }\n }\n //});\n }\n\n const { data, hideLegend = false } = props;\n const points = _addDefaultColors(data?.chartData);\n\n const classes = useDonutChartStyles(props);\n\n const legendBars = _createLegends(points);\n const donutMarginHorizontal = props.hideLabels ? 0 : 80;\n const donutMarginVertical = props.hideLabels ? 0 : 40;\n const outerRadius = Math.min(_width! - donutMarginHorizontal, _height! - donutMarginVertical) / 2;\n const chartData = _elevateToMinimums(points.filter((d: ChartDataPoint) => d.data! >= 0));\n const valueInsideDonut =\n props.innerRadius! > MIN_DONUT_RADIUS ? _valueInsideDonut(props.valueInsideDonut!, chartData!) : '';\n const focusAttributes = useFocusableGroup();\n return !_isChartEmpty() ? (\n <div\n className={classes.root}\n ref={(rootElem: HTMLDivElement | null) => (_rootElem.current = rootElem)}\n onMouseLeave={_handleChartMouseLeave}\n >\n {props.xAxisAnnotation && (\n <text className={classes.axisAnnotation} x={_width! / 2} y={_height! - 10} textAnchor=\"middle\">\n {props.xAxisAnnotation}\n </text>\n )}\n <div className={classes.chartWrapper} {...focusAttributes}>\n <svg className={classes.chart} aria-label={data?.chartTitle} width={_width} height={_height}>\n <Pie\n width={_width!}\n height={_height!}\n outerRadius={outerRadius}\n innerRadius={props.innerRadius!}\n data={chartData!}\n onFocusCallback={_focusCallback}\n hoverOnCallback={_hoverCallback}\n hoverLeaveCallback={_hoverLeave}\n uniqText={_uniqText}\n onBlurCallback={_onBlur}\n activeArc={_getHighlightedLegend()}\n focusedArcId={focusedArcId || ''}\n href={props.href!}\n valueInsideDonut={_toLocaleString(valueInsideDonut)}\n showLabelsInPercent={props.showLabelsInPercent}\n hideLabels={props.hideLabels}\n />\n </svg>\n </div>\n <ChartPopover\n xCalloutValue={xCalloutValue}\n yCalloutValue={yCalloutValue}\n culture={props.culture ?? 'en-us'}\n positioning={{\n target: refSelected,\n }}\n isPopoverOpen={\n !props.hideTooltip && isPopoverOpen && (_noLegendsHighlighted() || _isLegendHighlighted(legend))\n }\n legend={legend!}\n YValue={value!}\n color={color}\n isCalloutForStack={false}\n customCallout={{\n customizedCallout: props.onRenderCalloutPerDataPoint\n ? props.onRenderCalloutPerDataPoint(dataPointCalloutProps!)\n : undefined,\n customCalloutProps: props.calloutPropsPerDataPoint\n ? props.calloutPropsPerDataPoint(dataPointCalloutProps!)\n : undefined,\n }}\n isCartesian={false}\n />\n {!hideLegend && (\n <div ref={(e: HTMLDivElement) => (legendContainer.current = e)} className={classes.legendContainer}>\n {legendBars}\n </div>\n )}\n </div>\n ) : (\n <div id={_emptyChartId!} role={'alert'} style={{ opacity: '0' }} aria-label={'Graph has no data to display'} />\n );\n },\n);\n\nDonutChart.displayName = 'DonutChart';\nDonutChart.defaultProps = {\n innerRadius: 0,\n hideLabels: true,\n};\n"],"names":["React","Pie","useDonutChartStyles","formatToLocaleString","areArraysEqual","getColorFromToken","getNextColor","MIN_DONUT_RADIUS","useRtl","Legends","useId","useFocusableGroup","ChartPopover","toImage","MIN_LEGEND_CONTAINER_HEIGHT","DonutChart","forwardRef","props","forwardedRef","_rootElem","useRef","_uniqText","_calloutAnchorPoint","_emptyChartId","legendContainer","prevSize","value","setValue","useState","legend","setLegend","_width","setWidth","width","_height","setHeight","height","activeLegend","setActiveLegend","undefined","color","setColor","xCalloutValue","setXCalloutValue","yCalloutValue","setYCalloutValue","selectedLegends","setSelectedLegends","legendProps","focusedArcId","setFocusedArcId","dataPointCalloutProps","setDataPointCalloutProps","refSelected","setRefSelected","isPopoverOpen","setPopoverOpen","prevPropsRef","_legendsRef","_isRTL","useEffect","_fitParentContainer","current","prevProps","useImperativeHandle","componentRef","chartContainer","opts","toSVG","_elevateToMinimums","data","sumOfData","minPercent","elevatedData","forEach","item","push","yAxisCalloutData","toLocaleString","_createLegends","chartData","legendDataItems","map","point","index","title","hoverAction","_handleChartMouseLeave","onMouseOutAction","legends","centerLegends","overflowText","legendsOverflowText","onChange","_onLegendSelectionChange","legendRef","event","currentLegend","canSelectMultipleLegends","slice","_focusCallback","id","e","targetElement","_noLegendsHighlighted","_isLegendHighlighted","toString","xAxisCalloutData","_hoverCallback","_onBlur","_hoverLeave","_valueInsideDonut","valueInsideDonut","highlightedLegends","_getHighlightedLegend","length","pointValue","find","totalValue","includes","_toLocaleString","localeString","culture","_isChartEmpty","filter","d","_addDefaultColors","donutChartDataPoint","defaultColor","legendContainerHeight","hideLegend","legendContainerComputedStyles","getComputedStyle","getBoundingClientRect","parseFloat","marginTop","marginBottom","parentRef","container","currentContainerWidth","currentContainerHeight","shouldResize","points","classes","legendBars","donutMarginHorizontal","hideLabels","donutMarginVertical","outerRadius","Math","min","innerRadius","focusAttributes","div","className","root","ref","rootElem","onMouseLeave","xAxisAnnotation","text","axisAnnotation","x","y","textAnchor","chartWrapper","svg","chart","aria-label","chartTitle","onFocusCallback","hoverOnCallback","hoverLeaveCallback","uniqText","onBlurCallback","activeArc","href","showLabelsInPercent","positioning","target","hideTooltip","YValue","isCalloutForStack","customCallout","customizedCallout","onRenderCalloutPerDataPoint","customCalloutProps","calloutPropsPerDataPoint","isCartesian","role","style","opacity","displayName","defaultProps"],"mappings":"AAAA;;;;;+BAyBae;;;;;;;iEAtBU,QAAQ;uBACX,cAAc;2CAEE,+BAA+B;gCAE9B,4BAA4B;wBACyB,wBAAwB;wBACjE,cAAc;gCACzC,4BAA4B;8BAEhB,0BAA0B;8BAC/B,mCAAmC;kCAExC,qCAAqC;AAE7D,MAAMD,8BAA8B;AAO7B,mBAAMC,WAAAA,GAAuDf,OAAMg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AAuB9E,gBAAgBsC,OAAO,GAAGwC;QAAIoD,WAAWX,QAAQvH,eAAe;OAC/FwH,eAAAA,WAAAA,GAKP,OAAA,aAAA,CAACS,OAAAA;QAAIpD,IAAI9E;QAAgBsK,MAAM;QAASC,OAAO;YAAEC,SAAS;QAAI;QAAGvB,cAAY;;AAEjF,GACA;AAEFzJ,WAAWiL,WAAW,GAAG;AACzBjL,WAAWkL,YAAY,GAAG;IACxB1C,aAAa;IACbL,YAAY;AACd"}
@@ -24,11 +24,11 @@ const Pie = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
24
24
  const classes = (0, _usePieStylesstyles.usePieStyles)(props);
25
25
  const pieForFocusRing = (0, _d3shape.pie)().sort(null) // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
26
  .value((d)=>d.data).padAngle(0);
27
- function _focusCallback(data, id, e) {
28
- props.onFocusCallback(data, id, e);
27
+ function _focusCallback(data, id, e, targetElement) {
28
+ props.onFocusCallback(data, id, e, targetElement);
29
29
  }
30
- function _hoverCallback(data, e) {
31
- props.hoverOnCallback(data, e);
30
+ function _hoverCallback(data, e, targetElement) {
31
+ props.hoverOnCallback(data, e, targetElement);
32
32
  }
33
33
  function _computeTotalValue() {
34
34
  let totalValue = 0;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/DonutChart/Pie/Pie.tsx"],"sourcesContent":["'use client';\n\n/* eslint-disable react-hooks/exhaustive-deps */\n/* eslint-disable react/jsx-no-bind */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport * as React from 'react';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { pie as d3Pie } from 'd3-shape';\nimport { PieProps } from './index';\nimport { Arc } from '../Arc/index';\nimport { ChartDataPoint } from '../index';\nimport { usePieStyles } from './usePieStyles.styles';\nimport { wrapTextInsideDonut } from '../../../utilities/index';\nconst TEXT_PADDING: number = 5;\n\n// Create a Pie within Donut Chart variant which uses these default styles and this styled subcomponent.\n/**\n * Pie component within Donut Chart.\n * {@docCategory PieDonutChart}\n */\nexport const Pie: React.FunctionComponent<PieProps> = React.forwardRef<HTMLDivElement, PieProps>(\n (props, forwardedRef) => {\n React.useEffect(() => {\n wrapTextInsideDonut(classes.insideDonutString, props.innerRadius! * 2 - TEXT_PADDING);\n }, []);\n\n let _totalValue: number;\n const classes = usePieStyles(props);\n const pieForFocusRing = d3Pie()\n .sort(null)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .value((d: any) => d.data)\n .padAngle(0);\n\n function _focusCallback(data: ChartDataPoint, id: string, e: React.FocusEvent<SVGPathElement>): void {\n props.onFocusCallback!(data, id, e);\n }\n\n function _hoverCallback(data: ChartDataPoint, e: React.MouseEvent<SVGPathElement>): void {\n props.hoverOnCallback!(data, e);\n }\n\n function _computeTotalValue() {\n let totalValue = 0;\n props.data.forEach((arc: ChartDataPoint) => {\n totalValue += arc.data!;\n });\n return totalValue;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n function arcGenerator(\n d: any,\n i: number,\n focusData: any,\n href?: string,\n ): // eslint-disable-next-line @typescript-eslint/no-deprecated\n JSXElement {\n const color = d && d.data && d.data.color;\n return (\n <Arc\n key={i}\n data={d}\n focusData={focusData}\n innerRadius={props.innerRadius}\n outerRadius={props.outerRadius}\n color={color!}\n onFocusCallback={_focusCallback}\n hoverOnCallback={_hoverCallback}\n onBlurCallback={props.onBlurCallback}\n hoverLeaveCallback={props.hoverLeaveCallback}\n uniqText={props.uniqText}\n activeArc={props.activeArc}\n href={href}\n calloutId={props.calloutId}\n valueInsideDonut={props.valueInsideDonut}\n focusedArcId={props.focusedArcId}\n showLabelsInPercent={props.showLabelsInPercent}\n totalValue={_totalValue}\n hideLabels={props.hideLabels}\n />\n );\n }\n\n const { data } = props;\n const focusData = pieForFocusRing(data.map(d => d.data!));\n\n const piechart = d3Pie<ChartDataPoint>()\n .sort(null)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .value((d: any) => d.data)\n .padAngle(0.02)(data);\n const translate = `translate(${props.width / 2}, ${props.height / 2})`;\n\n _totalValue = _computeTotalValue();\n\n return (\n <g transform={translate}>\n {piechart.map((d: any, i: number) => arcGenerator(d, i, focusData[i], props.href))}\n {props.valueInsideDonut && (\n <text y={5} textAnchor=\"middle\" dominantBaseline=\"middle\" className={classes.insideDonutString}>\n {props.valueInsideDonut}\n </text>\n )}\n </g>\n );\n },\n);\nPie.displayName = 'Pie';\n"],"names":["React","pie","d3Pie","Arc","usePieStyles","wrapTextInsideDonut","TEXT_PADDING","Pie","forwardRef","props","forwardedRef","useEffect","classes","insideDonutString","innerRadius","_totalValue","pieForFocusRing","sort","value","d","data","padAngle","_focusCallback","id","e","onFocusCallback","_hoverCallback","hoverOnCallback","_computeTotalValue","totalValue","forEach","arc","arcGenerator","i","focusData","href","color","key","outerRadius","onBlurCallback","hoverLeaveCallback","uniqText","activeArc","calloutId","valueInsideDonut","focusedArcId","showLabelsInPercent","hideLabels","map","piechart","translate","width","height","g","transform","text","y","textAnchor","dominantBaseline","className","displayName"],"mappings":"AAAA;;;;;+BAoBaO;;;;;;;iEAfU,QAAQ;yBAEF,WAAW;uBAEpB,eAAe;oCAEN,wBAAwB;wBACjB,2BAA2B;AAC/D,MAAMD,eAAuB;AAOtB,YAAMC,WAAAA,GAAyCP,OAAMQ,UAAU,CACpE,CAACC,OAAOC;IACNV,OAAMW,SAAS,CAAC;YACdN,2BAAAA,EAAoBO,QAAQC,iBAAiB,EAAEJ,MAAMK,WAAW,GAAI,IAAIR;IAC1E,GAAG,EAAE;IAEL,IAAIS;IACJ,MAAMH,cAAUR,gCAAAA,EAAaK;IAC7B,MAAMO,sBAAkBd,YAAAA,IACrBe,IAAI,CAAC,MACN,8DAA8D;KAC7DC,KAAK,CAAC,CAACC,IAAWA,EAAEC,IAAI,EACxBC,QAAQ,CAAC;IAEZ,SAASC,eAAeF,IAAoB,EAAEG,EAAU,EAAEC,CAAmC;QAC3Ff,MAAMgB,eAAe,CAAEL,MAAMG,IAAIC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AE,EAAE,EAAE1C,MAAM2C,MAAM,GAAG,EAAE,CAAC,CAAC;IAEtErC,cAAca;IAEd,OAAA,WAAA,GACE,OAAA,aAAA,CAACyB,KAAAA;QAAEC,WAAWJ;OACXD,SAASD,GAAG,CAAC,CAAC7B,GAAQc,IAAcD,aAAab,GAAGc,GAAGC,SAAS,CAACD,EAAE,EAAExB,MAAM0B,IAAI,IAC/E1B,MAAMmC,gBAAgB,IAAA,WAAA,GACrB,OAAA,aAAA,CAACW,QAAAA;QAAKC,GAAG;QAAGC,YAAW;QAASC,kBAAiB;QAASC,WAAW/C,QAAQC,iBAAiB;OAC3FJ,MAAMmC,gBAAgB;AAKjC,GACA;AACFrC,IAAIqD,WAAW,GAAG"}
1
+ {"version":3,"sources":["../src/components/DonutChart/Pie/Pie.tsx"],"sourcesContent":["'use client';\n\n/* eslint-disable react-hooks/exhaustive-deps */\n/* eslint-disable react/jsx-no-bind */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport * as React from 'react';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { pie as d3Pie } from 'd3-shape';\nimport { PieProps } from './index';\nimport { Arc } from '../Arc/index';\nimport { ChartDataPoint } from '../index';\nimport { usePieStyles } from './usePieStyles.styles';\nimport { wrapTextInsideDonut } from '../../../utilities/index';\nconst TEXT_PADDING: number = 5;\n\n// Create a Pie within Donut Chart variant which uses these default styles and this styled subcomponent.\n/**\n * Pie component within Donut Chart.\n * {@docCategory PieDonutChart}\n */\nexport const Pie: React.FunctionComponent<PieProps> = React.forwardRef<HTMLDivElement, PieProps>(\n (props, forwardedRef) => {\n React.useEffect(() => {\n wrapTextInsideDonut(classes.insideDonutString, props.innerRadius! * 2 - TEXT_PADDING);\n }, []);\n\n let _totalValue: number;\n const classes = usePieStyles(props);\n const pieForFocusRing = d3Pie()\n .sort(null)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .value((d: any) => d.data)\n .padAngle(0);\n\n function _focusCallback(\n data: ChartDataPoint,\n id: string,\n e: React.FocusEvent<SVGPathElement>,\n targetElement?: HTMLElement | null,\n ): void {\n props.onFocusCallback!(data, id, e, targetElement);\n }\n\n function _hoverCallback(\n data: ChartDataPoint,\n e: React.MouseEvent<SVGPathElement>,\n targetElement?: HTMLElement | null,\n ): void {\n props.hoverOnCallback!(data, e, targetElement);\n }\n\n function _computeTotalValue() {\n let totalValue = 0;\n props.data.forEach((arc: ChartDataPoint) => {\n totalValue += arc.data!;\n });\n return totalValue;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n function arcGenerator(\n d: any,\n i: number,\n focusData: any,\n href?: string,\n ): // eslint-disable-next-line @typescript-eslint/no-deprecated\n JSXElement {\n const color = d && d.data && d.data.color;\n return (\n <Arc\n key={i}\n data={d}\n focusData={focusData}\n innerRadius={props.innerRadius}\n outerRadius={props.outerRadius}\n color={color!}\n onFocusCallback={_focusCallback}\n hoverOnCallback={_hoverCallback}\n onBlurCallback={props.onBlurCallback}\n hoverLeaveCallback={props.hoverLeaveCallback}\n uniqText={props.uniqText}\n activeArc={props.activeArc}\n href={href}\n calloutId={props.calloutId}\n valueInsideDonut={props.valueInsideDonut}\n focusedArcId={props.focusedArcId}\n showLabelsInPercent={props.showLabelsInPercent}\n totalValue={_totalValue}\n hideLabels={props.hideLabels}\n />\n );\n }\n\n const { data } = props;\n const focusData = pieForFocusRing(data.map(d => d.data!));\n\n const piechart = d3Pie<ChartDataPoint>()\n .sort(null)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .value((d: any) => d.data)\n .padAngle(0.02)(data);\n const translate = `translate(${props.width / 2}, ${props.height / 2})`;\n\n _totalValue = _computeTotalValue();\n\n return (\n <g transform={translate}>\n {piechart.map((d: any, i: number) => arcGenerator(d, i, focusData[i], props.href))}\n {props.valueInsideDonut && (\n <text y={5} textAnchor=\"middle\" dominantBaseline=\"middle\" className={classes.insideDonutString}>\n {props.valueInsideDonut}\n </text>\n )}\n </g>\n );\n },\n);\nPie.displayName = 'Pie';\n"],"names":["React","pie","d3Pie","Arc","usePieStyles","wrapTextInsideDonut","TEXT_PADDING","Pie","forwardRef","props","forwardedRef","useEffect","classes","insideDonutString","innerRadius","_totalValue","pieForFocusRing","sort","value","d","data","padAngle","_focusCallback","id","e","targetElement","onFocusCallback","_hoverCallback","hoverOnCallback","_computeTotalValue","totalValue","forEach","arc","arcGenerator","i","focusData","href","color","key","outerRadius","onBlurCallback","hoverLeaveCallback","uniqText","activeArc","calloutId","valueInsideDonut","focusedArcId","showLabelsInPercent","hideLabels","map","piechart","translate","width","height","g","transform","text","y","textAnchor","dominantBaseline","className","displayName"],"mappings":"AAAA;;;;;+BAoBaO;;;;;;;iEAfU,QAAQ;yBAEF,WAAW;uBAEpB,eAAe;oCAEN,wBAAwB;wBACjB,2BAA2B;AAC/D,MAAMD,eAAuB;AAOtB,YAAMC,WAAAA,GAAyCP,OAAMQ,UAAU,CACpE,CAACC,OAAOC;IACNV,OAAMW,SAAS,CAAC;YACdN,2BAAAA,EAAoBO,QAAQC,iBAAiB,EAAEJ,MAAMK,WAAW,GAAI,IAAIR;IAC1E,GAAG,EAAE;IAEL,IAAIS;IACJ,MAAMH,cAAUR,gCAAAA,EAAaK;IAC7B,MAAMO,sBAAkBd,YAAAA,IACrBe,IAAI,CAAC,MACN,8DAA8D;KAC7DC,KAAK,CAAC,CAACC,IAAWA,EAAEC,IAAI,EACxBC,QAAQ,CAAC;IAEZ,SAASC,eACPF,IAAoB,EACpBG,EAAU,EACVC,CAAmC,EACnCC,aAAkC;QAElChB,MAAMiB,eAAe,CAAEN,MAAMG,IAAIC,GAAGC;IACtC;IAEA,SAASE,eACPP,IAAoB,EACpBI,CAAmC,EACnCC,aAAkC;QAElChB,MAAMmB,eAAe,CAAER,MAAMI,GAAGC;IAClC;IAEA,SAASI;QACP,IAAIC,aAAa;QACjBrB,MAAMW,IAAI,CAACW,OAAO,CAAC,CAACC;YAClBF,cAAcE,IAAIZ,IAAI;QACxB;QACA,OAAOU;IACT;IAEA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,EAAEzB,MAAM2B,IAAI,IAC/E3B,MAAMoC,gBAAgB,IAAA,WAAA,GACrB,OAAA,aAAA,CAACW,QAAAA;QAAKC,GAAG;QAAGC,YAAW;QAASC,kBAAiB;QAASC,WAAWhD,QAAQC,iBAAiB;OAC3FJ,MAAMoC,gBAAgB;AAKjC,GACA;AACFtC,IAAIsD,WAAW,GAAG"}
@@ -28,11 +28,8 @@ const FunnelChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
28
28
  const [hoveredStage, setHoveredStage] = _react.useState(null);
29
29
  const [calloutData, setCalloutData] = _react.useState(null);
30
30
  const [selectedLegends, setSelectedLegends] = _react.useState([]);
31
- const [clickPosition, setClickPosition] = _react.useState({
32
- x: 0,
33
- y: 0
34
- });
35
31
  const [isPopoverOpen, setPopoverOpen] = _react.useState(false);
32
+ const [refSelected, setRefSelected] = _react.useState(null);
36
33
  const chartContainerRef = _react.useRef(null);
37
34
  const isStacked = isStackedFunnelData(props.data);
38
35
  const _legendsRef = _react.useRef(null);
@@ -50,48 +47,38 @@ const FunnelChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
50
47
  return (0, _imageexportutils.toImage)(chartContainerRef.current, (_legendsRef_current = _legendsRef.current) === null || _legendsRef_current === void 0 ? void 0 : _legendsRef_current.toSVG, isRTL, opts);
51
48
  }
52
49
  }), []);
53
- function _handleHover(data, mouseEvent) {
50
+ function _handleHover(data, mouseEvent, targetElement) {
54
51
  mouseEvent === null || mouseEvent === void 0 ? void 0 : mouseEvent.persist();
55
- updatePosition(mouseEvent.clientX, mouseEvent.clientY);
56
52
  setCalloutData(data);
53
+ setRefSelected(targetElement);
57
54
  setPopoverOpen(true);
58
55
  }
59
- function _handleFocus(data, focusEvent) {
56
+ function _handleFocus(data, focusEvent, targetElement) {
60
57
  focusEvent === null || focusEvent === void 0 ? void 0 : focusEvent.persist();
61
- let x = 0;
62
- let y = 0;
63
- const targetRect = focusEvent.target.getBoundingClientRect();
64
- x = targetRect.left + targetRect.width / 2;
65
- y = targetRect.top + targetRect.height / 2;
66
- updatePosition(x, y);
67
58
  setCalloutData(data);
59
+ setRefSelected(targetElement);
68
60
  setPopoverOpen(true);
69
61
  }
70
- function _handleStackedHover(stage, subValue, mouseEvent) {
62
+ function _handleStackedHover(stage, subValue, mouseEvent, targetElement) {
71
63
  mouseEvent === null || mouseEvent === void 0 ? void 0 : mouseEvent.persist();
72
- updatePosition(mouseEvent.clientX, mouseEvent.clientY);
73
64
  setCalloutData({
74
65
  stage,
75
66
  value: subValue.value,
76
67
  color: subValue.color,
77
68
  category: subValue.category
78
69
  });
70
+ setRefSelected(targetElement);
79
71
  setPopoverOpen(true);
80
72
  }
81
- function _handleStackedFocus(stage, subValue, focusEvent) {
73
+ function _handleStackedFocus(stage, subValue, focusEvent, targetElement) {
82
74
  focusEvent === null || focusEvent === void 0 ? void 0 : focusEvent.persist();
83
- let x = 0;
84
- let y = 0;
85
- const targetRect = focusEvent.target.getBoundingClientRect();
86
- x = targetRect.left + targetRect.width / 2;
87
- y = targetRect.top + targetRect.height / 2;
88
- updatePosition(x, y);
89
75
  setCalloutData({
90
76
  stage,
91
77
  value: subValue.value,
92
78
  color: subValue.color,
93
79
  category: subValue.category
94
80
  });
81
+ setRefSelected(targetElement);
95
82
  setPopoverOpen(true);
96
83
  }
97
84
  function _handleMouseOut() {
@@ -124,22 +111,23 @@ const FunnelChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
124
111
  function noLegendHighlighted() {
125
112
  return getHighlightedLegend().length === 0;
126
113
  }
127
- function _getEventHandlerProps(data, opacity) {
114
+ function _getEventHandlerProps(data, opacity, segmentId) {
115
+ const targetElement = document.getElementById(segmentId);
128
116
  if ('subValue' in data) {
129
117
  return {
130
118
  culture: props.culture,
131
- onMouseOver: opacity == 1 ? (event)=>_handleStackedHover(data.stage, data.subValue, event) : undefined,
132
- onMouseMove: opacity == 1 ? (event)=>_handleStackedHover(data.stage, data.subValue, event) : undefined,
133
- onFocus: (event)=>_handleStackedFocus(data.stage, data.subValue, event),
119
+ onMouseOver: opacity == 1 ? (event)=>_handleStackedHover(data.stage, data.subValue, event, targetElement) : undefined,
120
+ onMouseMove: opacity == 1 ? (event)=>_handleStackedHover(data.stage, data.subValue, event, targetElement) : undefined,
121
+ onFocus: (event)=>_handleStackedFocus(data.stage, data.subValue, event, targetElement),
134
122
  onBlur: ()=>_handleMouseOut(),
135
123
  onMouseOut: ()=>_handleMouseOut()
136
124
  };
137
125
  } else {
138
126
  return {
139
127
  culture: props.culture,
140
- onMouseOver: opacity == 1 ? (event)=>_handleHover(data, event) : undefined,
141
- onMouseMove: opacity == 1 ? (event)=>_handleHover(data, event) : undefined,
142
- onFocus: (event)=>_handleFocus(data, event),
128
+ onMouseOver: opacity == 1 ? (event)=>_handleHover(data, event, targetElement) : undefined,
129
+ onMouseMove: opacity == 1 ? (event)=>_handleHover(data, event, targetElement) : undefined,
130
+ onFocus: (event)=>_handleFocus(data, event, targetElement),
143
131
  onBlur: ()=>_handleMouseOut(),
144
132
  onMouseOut: ()=>_handleMouseOut()
145
133
  };
@@ -165,11 +153,13 @@ const FunnelChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
165
153
  return textElement;
166
154
  }
167
155
  function _renderFunnelSegment({ key, pathD, fill, opacity, textProps, data, tabIndex }) {
168
- const eventHandlers = _getEventHandlerProps(data, opacity);
156
+ const segmentId = `funnel-segment-${key}`;
157
+ const eventHandlers = _getEventHandlerProps(data, opacity, segmentId);
169
158
  const textColor = (0, _colors.getContrastTextColor)(fill);
170
159
  return /*#__PURE__*/ _react.createElement("g", {
171
160
  key: key
172
161
  }, /*#__PURE__*/ _react.createElement("path", {
162
+ id: segmentId,
173
163
  d: pathD,
174
164
  fill: fill,
175
165
  opacity: opacity,
@@ -349,20 +339,6 @@ const FunnelChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
349
339
  function _isChartEmpty() {
350
340
  return !(props.data && props.data.length > 0);
351
341
  }
352
- function updatePosition(newX, newY) {
353
- const threshold = 1; // Set a threshold for movement
354
- const { x, y } = clickPosition;
355
- // Calculate the distance moved
356
- const distance = Math.sqrt(Math.pow(newX - x, 2) + Math.pow(newY - y, 2));
357
- // Update the position only if the distance moved is greater than the threshold
358
- if (distance > threshold) {
359
- setClickPosition({
360
- x: newX,
361
- y: newY
362
- });
363
- setPopoverOpen(true);
364
- }
365
- }
366
342
  const classes = (0, _useFunnelChartStylesstyles.useFunnelChartStyles)(props);
367
343
  const calloutProps = {
368
344
  ...props.calloutProps,
@@ -397,7 +373,9 @@ const FunnelChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
397
373
  XValue: calloutProps === null || calloutProps === void 0 ? void 0 : calloutProps.hoverXValue,
398
374
  yCalloutValue: calloutProps === null || calloutProps === void 0 ? void 0 : calloutProps.YValue,
399
375
  culture: props.culture,
400
- clickPosition: clickPosition,
376
+ positioning: {
377
+ target: refSelected
378
+ },
401
379
  isPopoverOpen: isPopoverOpen,
402
380
  color: calloutProps === null || calloutProps === void 0 ? void 0 : calloutProps.color,
403
381
  isCartesian: false