@fluentui/react-charting 5.23.28 → 5.23.30

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 (202) hide show
  1. package/CHANGELOG.json +49 -1
  2. package/CHANGELOG.md +23 -2
  3. package/dist/react-charting.d.ts +54 -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 +31 -0
  7. package/lib/DeclarativeChart.d.ts +1 -1
  8. package/lib/DeclarativeChart.js +1 -1
  9. package/lib/DeclarativeChart.js.map +1 -1
  10. package/lib/components/AreaChart/AreaChart.base.d.ts +4 -1
  11. package/lib/components/AreaChart/AreaChart.base.js +12 -2
  12. package/lib/components/AreaChart/AreaChart.base.js.map +1 -1
  13. package/lib/components/CommonComponents/CartesianChart.base.d.ts +3 -2
  14. package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
  15. package/lib/components/CommonComponents/CartesianChart.types.d.ts +11 -2
  16. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  17. package/lib/components/DeclarativeChart/DeclarativeChart.d.ts +13 -1
  18. package/lib/components/DeclarativeChart/DeclarativeChart.js +27 -22
  19. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  20. package/lib/components/DeclarativeChart/imageExporter.d.ts +10 -0
  21. package/lib/components/DeclarativeChart/imageExporter.js +222 -0
  22. package/lib/components/DeclarativeChart/imageExporter.js.map +1 -0
  23. package/lib/components/DeclarativeChart/index.d.ts +2 -0
  24. package/lib/components/DeclarativeChart/index.js +2 -0
  25. package/lib/components/DeclarativeChart/index.js.map +1 -0
  26. package/lib/components/DonutChart/Arc/Arc.d.ts +1 -0
  27. package/lib/components/DonutChart/Arc/Arc.js +13 -8
  28. package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
  29. package/lib/components/DonutChart/Arc/Arc.types.d.ts +1 -1
  30. package/lib/components/DonutChart/Arc/Arc.types.js.map +1 -1
  31. package/lib/components/DonutChart/DonutChart.base.d.ts +7 -3
  32. package/lib/components/DonutChart/DonutChart.base.js +55 -26
  33. package/lib/components/DonutChart/DonutChart.base.js.map +1 -1
  34. package/lib/components/DonutChart/DonutChart.types.d.ts +7 -2
  35. package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
  36. package/lib/components/DonutChart/Pie/Pie.types.d.ts +1 -1
  37. package/lib/components/DonutChart/Pie/Pie.types.js.map +1 -1
  38. package/lib/components/GaugeChart/GaugeChart.base.d.ts +3 -1
  39. package/lib/components/GaugeChart/GaugeChart.base.js +9 -1
  40. package/lib/components/GaugeChart/GaugeChart.base.js.map +1 -1
  41. package/lib/components/GaugeChart/GaugeChart.types.d.ts +7 -2
  42. package/lib/components/GaugeChart/GaugeChart.types.js.map +1 -1
  43. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +4 -1
  44. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +12 -2
  45. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  46. package/lib/components/HeatMapChart/HeatMapChart.base.d.ts +4 -2
  47. package/lib/components/HeatMapChart/HeatMapChart.base.js +12 -2
  48. package/lib/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  49. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +4 -2
  50. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +12 -2
  51. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
  52. package/lib/components/LineChart/LineChart.base.d.ts +4 -1
  53. package/lib/components/LineChart/LineChart.base.js +12 -2
  54. package/lib/components/LineChart/LineChart.base.js.map +1 -1
  55. package/lib/components/SankeyChart/SankeyChart.base.d.ts +3 -3
  56. package/lib/components/SankeyChart/SankeyChart.base.js +2 -1
  57. package/lib/components/SankeyChart/SankeyChart.base.js.map +1 -1
  58. package/lib/components/SankeyChart/SankeyChart.types.d.ts +7 -2
  59. package/lib/components/SankeyChart/SankeyChart.types.js.map +1 -1
  60. package/lib/components/VerticalBarChart/VerticalBarChart.base.d.ts +4 -1
  61. package/lib/components/VerticalBarChart/VerticalBarChart.base.js +12 -2
  62. package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  63. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +4 -1
  64. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +12 -2
  65. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  66. package/lib/index.d.ts +2 -2
  67. package/lib/index.js.map +1 -1
  68. package/lib/types/IDataPoint.d.ts +6 -0
  69. package/lib/types/IDataPoint.js.map +1 -1
  70. package/lib-amd/DeclarativeChart.d.ts +1 -1
  71. package/lib-amd/DeclarativeChart.js +2 -2
  72. package/lib-amd/DeclarativeChart.js.map +1 -1
  73. package/lib-amd/components/AreaChart/AreaChart.base.d.ts +4 -1
  74. package/lib-amd/components/AreaChart/AreaChart.base.js +11 -1
  75. package/lib-amd/components/AreaChart/AreaChart.base.js.map +1 -1
  76. package/lib-amd/components/CommonComponents/CartesianChart.base.d.ts +3 -2
  77. package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
  78. package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +11 -2
  79. package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
  80. package/lib-amd/components/DeclarativeChart/DeclarativeChart.d.ts +13 -1
  81. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +27 -24
  82. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  83. package/lib-amd/components/DeclarativeChart/imageExporter.d.ts +10 -0
  84. package/lib-amd/components/DeclarativeChart/imageExporter.js +227 -0
  85. package/lib-amd/components/DeclarativeChart/imageExporter.js.map +1 -0
  86. package/lib-amd/components/DeclarativeChart/index.d.ts +2 -0
  87. package/lib-amd/components/DeclarativeChart/index.js +6 -0
  88. package/lib-amd/components/DeclarativeChart/index.js.map +1 -0
  89. package/lib-amd/components/DonutChart/Arc/Arc.d.ts +1 -0
  90. package/lib-amd/components/DonutChart/Arc/Arc.js +13 -8
  91. package/lib-amd/components/DonutChart/Arc/Arc.js.map +1 -1
  92. package/lib-amd/components/DonutChart/Arc/Arc.types.d.ts +1 -1
  93. package/lib-amd/components/DonutChart/Arc/Arc.types.js.map +1 -1
  94. package/lib-amd/components/DonutChart/DonutChart.base.d.ts +7 -3
  95. package/lib-amd/components/DonutChart/DonutChart.base.js +54 -25
  96. package/lib-amd/components/DonutChart/DonutChart.base.js.map +1 -1
  97. package/lib-amd/components/DonutChart/DonutChart.types.d.ts +7 -2
  98. package/lib-amd/components/DonutChart/DonutChart.types.js.map +1 -1
  99. package/lib-amd/components/DonutChart/Pie/Pie.types.d.ts +1 -1
  100. package/lib-amd/components/DonutChart/Pie/Pie.types.js.map +1 -1
  101. package/lib-amd/components/GaugeChart/GaugeChart.base.d.ts +3 -1
  102. package/lib-amd/components/GaugeChart/GaugeChart.base.js +8 -0
  103. package/lib-amd/components/GaugeChart/GaugeChart.base.js.map +1 -1
  104. package/lib-amd/components/GaugeChart/GaugeChart.types.d.ts +7 -2
  105. package/lib-amd/components/GaugeChart/GaugeChart.types.js.map +1 -1
  106. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +4 -1
  107. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +11 -1
  108. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  109. package/lib-amd/components/HeatMapChart/HeatMapChart.base.d.ts +4 -2
  110. package/lib-amd/components/HeatMapChart/HeatMapChart.base.js +11 -1
  111. package/lib-amd/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  112. package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +4 -2
  113. package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +11 -1
  114. package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
  115. package/lib-amd/components/LineChart/LineChart.base.d.ts +4 -1
  116. package/lib-amd/components/LineChart/LineChart.base.js +11 -1
  117. package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
  118. package/lib-amd/components/SankeyChart/SankeyChart.base.d.ts +3 -3
  119. package/lib-amd/components/SankeyChart/SankeyChart.base.js +1 -0
  120. package/lib-amd/components/SankeyChart/SankeyChart.base.js.map +1 -1
  121. package/lib-amd/components/SankeyChart/SankeyChart.types.d.ts +7 -2
  122. package/lib-amd/components/SankeyChart/SankeyChart.types.js.map +1 -1
  123. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.d.ts +4 -1
  124. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +11 -1
  125. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  126. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +4 -1
  127. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +11 -1
  128. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  129. package/lib-amd/index.d.ts +2 -2
  130. package/lib-amd/index.js.map +1 -1
  131. package/lib-amd/types/IDataPoint.d.ts +6 -0
  132. package/lib-amd/types/IDataPoint.js.map +1 -1
  133. package/lib-commonjs/DeclarativeChart.d.ts +1 -1
  134. package/lib-commonjs/DeclarativeChart.js +1 -1
  135. package/lib-commonjs/DeclarativeChart.js.map +1 -1
  136. package/lib-commonjs/components/AreaChart/AreaChart.base.d.ts +4 -1
  137. package/lib-commonjs/components/AreaChart/AreaChart.base.js +11 -1
  138. package/lib-commonjs/components/AreaChart/AreaChart.base.js.map +1 -1
  139. package/lib-commonjs/components/CommonComponents/CartesianChart.base.d.ts +3 -2
  140. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
  141. package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +11 -2
  142. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  143. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.d.ts +13 -1
  144. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +28 -24
  145. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  146. package/lib-commonjs/components/DeclarativeChart/imageExporter.d.ts +10 -0
  147. package/lib-commonjs/components/DeclarativeChart/imageExporter.js +226 -0
  148. package/lib-commonjs/components/DeclarativeChart/imageExporter.js.map +1 -0
  149. package/lib-commonjs/components/DeclarativeChart/index.d.ts +2 -0
  150. package/lib-commonjs/components/DeclarativeChart/index.js +5 -0
  151. package/lib-commonjs/components/DeclarativeChart/index.js.map +1 -0
  152. package/lib-commonjs/components/DonutChart/Arc/Arc.d.ts +1 -0
  153. package/lib-commonjs/components/DonutChart/Arc/Arc.js +13 -8
  154. package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
  155. package/lib-commonjs/components/DonutChart/Arc/Arc.types.d.ts +1 -1
  156. package/lib-commonjs/components/DonutChart/Arc/Arc.types.js.map +1 -1
  157. package/lib-commonjs/components/DonutChart/DonutChart.base.d.ts +7 -3
  158. package/lib-commonjs/components/DonutChart/DonutChart.base.js +54 -25
  159. package/lib-commonjs/components/DonutChart/DonutChart.base.js.map +1 -1
  160. package/lib-commonjs/components/DonutChart/DonutChart.types.d.ts +7 -2
  161. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
  162. package/lib-commonjs/components/DonutChart/Pie/Pie.types.d.ts +1 -1
  163. package/lib-commonjs/components/DonutChart/Pie/Pie.types.js.map +1 -1
  164. package/lib-commonjs/components/GaugeChart/GaugeChart.base.d.ts +3 -1
  165. package/lib-commonjs/components/GaugeChart/GaugeChart.base.js +8 -0
  166. package/lib-commonjs/components/GaugeChart/GaugeChart.base.js.map +1 -1
  167. package/lib-commonjs/components/GaugeChart/GaugeChart.types.d.ts +7 -2
  168. package/lib-commonjs/components/GaugeChart/GaugeChart.types.js.map +1 -1
  169. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +4 -1
  170. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +11 -1
  171. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  172. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.d.ts +4 -2
  173. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js +11 -1
  174. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  175. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +4 -2
  176. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +11 -1
  177. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
  178. package/lib-commonjs/components/LineChart/LineChart.base.d.ts +4 -1
  179. package/lib-commonjs/components/LineChart/LineChart.base.js +11 -1
  180. package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
  181. package/lib-commonjs/components/SankeyChart/SankeyChart.base.d.ts +3 -3
  182. package/lib-commonjs/components/SankeyChart/SankeyChart.base.js +1 -0
  183. package/lib-commonjs/components/SankeyChart/SankeyChart.base.js.map +1 -1
  184. package/lib-commonjs/components/SankeyChart/SankeyChart.types.d.ts +7 -2
  185. package/lib-commonjs/components/SankeyChart/SankeyChart.types.js.map +1 -1
  186. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.d.ts +4 -1
  187. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +11 -1
  188. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  189. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +4 -1
  190. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +11 -1
  191. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  192. package/lib-commonjs/index.d.ts +2 -2
  193. package/lib-commonjs/index.js.map +1 -1
  194. package/lib-commonjs/types/IDataPoint.d.ts +6 -0
  195. package/lib-commonjs/types/IDataPoint.js.map +1 -1
  196. package/package.json +4 -4
  197. package/src/components/CommonComponents/CartesianChart.types.ts +13 -1
  198. package/src/components/DonutChart/Arc/Arc.types.ts +1 -1
  199. package/src/components/DonutChart/DonutChart.types.ts +8 -2
  200. package/src/components/DonutChart/Pie/Pie.types.ts +1 -1
  201. package/src/components/GaugeChart/GaugeChart.types.ts +8 -2
  202. package/src/components/SankeyChart/SankeyChart.types.ts +8 -2
@@ -1 +1 @@
1
- {"version":3,"file":"DeclarativeChart.js","sourceRoot":"../src/","sources":["components/DeclarativeChart/DeclarativeChart.tsx"],"names":[],"mappings":";AAAA,yDAAyD;AACzD,uDAAuD;AACvD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,EAC9B,sCAAsC,EACtC,+CAA+C,EAC/C,WAAW,EACX,aAAa,EACb,iCAAiC,EACjC,gCAAgC,EAChC,+BAA+B,EAC/B,8BAA8B,EAC9B,6BAA6B,GAC9B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO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I,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAG,CAAC,CAAC,0CAAE,IAAI,0CAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBACvC,OAAO,CACL,oBAAC,UAAU,eACL,+BAA+B,CAAC,YAAY,EAAE,QAAQ,EAAE,WAAW,CAAC,IACxE,WAAW,EAAE,WAAW,IACxB,CACH,CAAC;YACJ,CAAC;YACD,OAAO,sDAA6B,CAAC;QACvC,KAAK,WAAW;YACd,OAAO,CACL,oBAAC,gBAAgB,eACX,6BAA6B,CAAC,YAAY,EAAE,QAAQ,EAAE,WAAW,CAAC,IACtE,WAAW,EAAE,WAAW,IACxB,CACH,CAAC;QACJ;YACE,OAAO,sDAA6B,CAAC;IACzC,CAAC;AACH,CAAC,CAAC,CAAC;AACH,gBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport * as React from 'react';\nimport { DonutChart } from '../DonutChart/index';\nimport { VerticalStackedBarChart } from '../VerticalStackedBarChart/index';\nimport {\n transformPlotlyJsonToDonutProps,\n transformPlotlyJsonToVSBCProps,\n transformPlotlyJsonToScatterChartProps,\n transformPlotlyJsonToHorizontalBarWithAxisProps,\n isDateArray,\n isNumberArray,\n transformPlotlyJsonToHeatmapProps,\n transformPlotlyJsonToSankeyProps,\n transformPlotlyJsonToGaugeProps,\n transformPlotlyJsonToGVBCProps,\n transformPlotlyJsonToVBCProps,\n} from './PlotlySchemaAdapter';\nimport { LineChart } from '../LineChart/index';\nimport { HorizontalBarChartWithAxis } from '../HorizontalBarChartWithAxis/index';\nimport { AreaChart } from '../AreaChart/index';\nimport { HeatMapChart } from '../HeatMapChart/index';\nimport { SankeyChart } from '../SankeyChart/SankeyChart';\nimport { GaugeChart } from '../GaugeChart/index';\nimport { GroupedVerticalBarChart } from '../GroupedVerticalBarChart/index';\nimport { VerticalBarChart } from '../VerticalBarChart/index';\nimport { useTheme } from '@fluentui/react/lib/Theme';\n\nexport const UseIsDarkTheme = (): boolean => {\n const theme = useTheme();\n return theme?.isInverted ?? false;\n};\n\n/**\n * DeclarativeChart schema.\n * {@docCategory DeclarativeChart}\n */\nexport interface Schema {\n /**\n * Plotly schema represented as JSON object\n */\n plotlySchema: any;\n}\n\n/**\n * DeclarativeChart props.\n * {@docCategory DeclarativeChart}\n */\nexport interface DeclarativeChartProps extends React.RefAttributes<HTMLDivElement> {\n /**\n * The schema representing the chart data, layout and configuration\n */\n chartSchema: Schema;\n\n /**\n * Callback when an event occurs\n */\n onSchemaChange?: (eventData: Schema) => void;\n}\n\nconst useColorMapping = () => {\n const colorMap = React.useRef(new Map<string, string>());\n return colorMap;\n};\n\n/**\n * DeclarativeChart component.\n * {@docCategory DeclarativeChart}\n */\nexport const DeclarativeChart: React.FunctionComponent<DeclarativeChartProps> = React.forwardRef<\n HTMLDivElement,\n DeclarativeChartProps\n>((props, forwardedRef) => {\n const { plotlySchema } = props.chartSchema;\n const { data, layout, selectedLegends } = plotlySchema;\n const xValues = data[0].x;\n const isXDate = isDateArray(xValues);\n const isXNumber = isNumberArray(xValues);\n const colorMap = useColorMapping();\n const isDarkTheme = UseIsDarkTheme();\n\n const [activeLegends, setActiveLegends] = React.useState<string[]>(selectedLegends ?? []);\n const onActiveLegendsChange = (keys: string[]) => {\n setActiveLegends(keys);\n if (props.onSchemaChange) {\n props.onSchemaChange({ plotlySchema: { data, layout, selectedLegends: keys } });\n }\n };\n\n const legendProps = {\n canSelectMultipleLegends: false,\n onChange: onActiveLegendsChange,\n ...(activeLegends.length > 0 && { selectedLegend: activeLegends[0] }),\n };\n\n switch (data[0].type) {\n case 'pie':\n return (\n <DonutChart\n {...transformPlotlyJsonToDonutProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={legendProps}\n />\n );\n case 'bar':\n const orientation = data[0].orientation;\n if (orientation === 'h') {\n return (\n <HorizontalBarChartWithAxis\n {...transformPlotlyJsonToHorizontalBarWithAxisProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={legendProps}\n />\n );\n } else {\n if (['group', 'overlay'].includes(plotlySchema?.layout?.barmode)) {\n return (\n <GroupedVerticalBarChart\n {...transformPlotlyJsonToGVBCProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={legendProps}\n />\n );\n }\n return (\n <VerticalStackedBarChart\n {...transformPlotlyJsonToVSBCProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={legendProps}\n />\n );\n }\n case 'scatter':\n const isAreaChart = data.some((series: any) => series.fill === 'tonexty' || series.fill === 'tozeroy');\n if (isXDate || isXNumber) {\n if (isAreaChart) {\n return (\n <AreaChart\n {...transformPlotlyJsonToScatterChartProps({ data, layout }, true, colorMap, isDarkTheme)}\n legendProps={legendProps}\n />\n );\n }\n return (\n <LineChart\n {...transformPlotlyJsonToScatterChartProps({ data, layout }, false, colorMap, isDarkTheme)}\n legendProps={{\n onChange: onActiveLegendsChange,\n canSelectMultipleLegends: true,\n selectedLegends: activeLegends,\n }}\n />\n );\n }\n return (\n <VerticalStackedBarChart\n {...transformPlotlyJsonToVSBCProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={legendProps}\n />\n );\n case 'heatmap':\n return <HeatMapChart {...transformPlotlyJsonToHeatmapProps(plotlySchema)} legendProps={legendProps} />;\n case 'sankey':\n return <SankeyChart {...transformPlotlyJsonToSankeyProps(plotlySchema, colorMap, isDarkTheme)} />;\n case 'indicator':\n if (data?.[0]?.mode?.includes('gauge')) {\n return (\n <GaugeChart\n {...transformPlotlyJsonToGaugeProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={legendProps}\n />\n );\n }\n return <div>Unsupported Schema</div>;\n case 'histogram':\n return (\n <VerticalBarChart\n {...transformPlotlyJsonToVBCProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={legendProps}\n />\n );\n default:\n return <div>Unsupported Schema</div>;\n }\n});\nDeclarativeChart.displayName = 'DeclarativeChart';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xB,YAAY,EAAE,QAAQ,IACtB,CACH,CAAC;QACJ,KAAK,QAAQ;YACX,OAAO,CACL,oBAAC,WAAW,eACN,gCAAgC,CAAC,YAAY,EAAE,QAAQ,EAAE,WAAW,CAAC,IACzE,YAAY,EAAE,QAAQ,IACtB,CACH,CAAC;QACJ,KAAK,WAAW;YACd,IAAI,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAG,CAAC,CAAC,0CAAE,IAAI,0CAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBACvC,OAAO,CACL,oBAAC,UAAU,eACL,+BAA+B,CAAC,YAAY,EAAE,QAAQ,EAAE,WAAW,CAAC,IACxE,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,QAAQ,IACtB,CACH,CAAC;YACJ,CAAC;YACD,OAAO,sDAA6B,CAAC;QACvC,KAAK,WAAW;YACd,OAAO,CACL,oBAAC,gBAAgB,eACX,6BAA6B,CAAC,YAAY,EAAE,QAAQ,EAAE,WAAW,CAAC,IACtE,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,QAAQ,IACtB,CACH,CAAC;QACJ;YACE,OAAO,sDAA6B,CAAC;IACzC,CAAC;AACH,CAAC,CAAC,CAAC;AACH,gBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport * as React from 'react';\nimport { useTheme } from '@fluentui/react';\nimport { IRefObject } from '@fluentui/react/lib/Utilities';\nimport { DonutChart } from '../DonutChart/index';\nimport { VerticalStackedBarChart } from '../VerticalStackedBarChart/index';\nimport {\n transformPlotlyJsonToDonutProps,\n transformPlotlyJsonToVSBCProps,\n transformPlotlyJsonToScatterChartProps,\n transformPlotlyJsonToHorizontalBarWithAxisProps,\n isDateArray,\n isNumberArray,\n transformPlotlyJsonToHeatmapProps,\n transformPlotlyJsonToSankeyProps,\n transformPlotlyJsonToGaugeProps,\n transformPlotlyJsonToGVBCProps,\n transformPlotlyJsonToVBCProps,\n} from './PlotlySchemaAdapter';\nimport { LineChart } from '../LineChart/index';\nimport { HorizontalBarChartWithAxis } from '../HorizontalBarChartWithAxis/index';\nimport { AreaChart } from '../AreaChart/index';\nimport { HeatMapChart } from '../HeatMapChart/index';\nimport { SankeyChart } from '../SankeyChart/SankeyChart';\nimport { GaugeChart } from '../GaugeChart/index';\nimport { GroupedVerticalBarChart } from '../GroupedVerticalBarChart/index';\nimport { VerticalBarChart } from '../VerticalBarChart/index';\nimport { IImageExportOptions, toImage } from './imageExporter';\nimport { IChart } from '../../types/index';\n\n/**\n * DeclarativeChart schema.\n * {@docCategory DeclarativeChart}\n */\nexport interface Schema {\n /**\n * Plotly schema represented as JSON object\n */\n plotlySchema: any;\n}\n\n/**\n * DeclarativeChart props.\n * {@docCategory DeclarativeChart}\n */\nexport interface DeclarativeChartProps extends React.RefAttributes<HTMLDivElement> {\n /**\n * The schema representing the chart data, layout and configuration\n */\n chartSchema: Schema;\n\n /**\n * Callback when an event occurs\n */\n onSchemaChange?: (eventData: Schema) => void;\n\n /**\n * Optional callback to access the IDeclarativeChart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: IRefObject<IDeclarativeChart>;\n}\n\n/**\n * {@docCategory DeclarativeChart}\n */\nexport interface IDeclarativeChart {\n exportAsImage: (opts?: IImageExportOptions) => Promise<string>;\n}\n\nconst useColorMapping = () => {\n const colorMap = React.useRef(new Map<string, string>());\n return colorMap;\n};\n\n/**\n * DeclarativeChart component.\n * {@docCategory DeclarativeChart}\n */\nexport const DeclarativeChart: React.FunctionComponent<DeclarativeChartProps> = React.forwardRef<\n HTMLDivElement,\n DeclarativeChartProps\n>((props, forwardedRef) => {\n const { plotlySchema } = props.chartSchema;\n const { data, layout, selectedLegends } = plotlySchema;\n const xValues = data[0].x;\n const isXDate = isDateArray(xValues);\n const isXNumber = isNumberArray(xValues);\n const colorMap = useColorMapping();\n const theme = useTheme();\n const isDarkTheme = theme?.isInverted ?? false;\n const chartRef = React.useRef<IChart>(null);\n\n const [activeLegends, setActiveLegends] = React.useState<string[]>(selectedLegends ?? []);\n const onActiveLegendsChange = (keys: string[]) => {\n setActiveLegends(keys);\n if (props.onSchemaChange) {\n props.onSchemaChange({ plotlySchema: { data, layout, selectedLegends: keys } });\n }\n };\n\n const legendProps = {\n canSelectMultipleLegends: false,\n onChange: onActiveLegendsChange,\n ...(activeLegends.length > 0 && { selectedLegend: activeLegends[0] }),\n };\n\n const exportAsImage = React.useCallback(\n (opts?: IImageExportOptions) => {\n return toImage(chartRef.current?.chartContainer, {\n background: theme.palette.white,\n ...opts,\n });\n },\n [theme],\n );\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n exportAsImage,\n }),\n [exportAsImage],\n );\n\n switch (data[0].type) {\n case 'pie':\n return (\n <DonutChart\n {...transformPlotlyJsonToDonutProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={{ ...legendProps, canSelectMultipleLegends: true }}\n componentRef={chartRef}\n />\n );\n case 'bar':\n const orientation = data[0].orientation;\n if (orientation === 'h') {\n return (\n <HorizontalBarChartWithAxis\n {...transformPlotlyJsonToHorizontalBarWithAxisProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={legendProps}\n componentRef={chartRef}\n />\n );\n } else {\n if (['group', 'overlay'].includes(plotlySchema?.layout?.barmode)) {\n return (\n <GroupedVerticalBarChart\n {...transformPlotlyJsonToGVBCProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={legendProps}\n componentRef={chartRef}\n />\n );\n }\n return (\n <VerticalStackedBarChart\n {...transformPlotlyJsonToVSBCProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={legendProps}\n componentRef={chartRef}\n />\n );\n }\n case 'scatter':\n const isAreaChart = data.some((series: any) => series.fill === 'tonexty' || series.fill === 'tozeroy');\n if (isXDate || isXNumber) {\n if (isAreaChart) {\n return (\n <AreaChart\n {...transformPlotlyJsonToScatterChartProps({ data, layout }, true, colorMap, isDarkTheme)}\n legendProps={legendProps}\n componentRef={chartRef}\n />\n );\n }\n return (\n <LineChart\n {...transformPlotlyJsonToScatterChartProps({ data, layout }, false, colorMap, isDarkTheme)}\n legendProps={{\n onChange: onActiveLegendsChange,\n canSelectMultipleLegends: true,\n selectedLegends: activeLegends,\n }}\n componentRef={chartRef}\n />\n );\n }\n return (\n <VerticalStackedBarChart\n {...transformPlotlyJsonToVSBCProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={legendProps}\n componentRef={chartRef}\n />\n );\n case 'heatmap':\n return (\n <HeatMapChart\n {...transformPlotlyJsonToHeatmapProps(plotlySchema)}\n legendProps={legendProps}\n componentRef={chartRef}\n />\n );\n case 'sankey':\n return (\n <SankeyChart\n {...transformPlotlyJsonToSankeyProps(plotlySchema, colorMap, isDarkTheme)}\n componentRef={chartRef}\n />\n );\n case 'indicator':\n if (data?.[0]?.mode?.includes('gauge')) {\n return (\n <GaugeChart\n {...transformPlotlyJsonToGaugeProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={legendProps}\n componentRef={chartRef}\n />\n );\n }\n return <div>Unsupported Schema</div>;\n case 'histogram':\n return (\n <VerticalBarChart\n {...transformPlotlyJsonToVBCProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={legendProps}\n componentRef={chartRef}\n />\n );\n default:\n return <div>Unsupported Schema</div>;\n }\n});\nDeclarativeChart.displayName = 'DeclarativeChart';\n"]}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * {@docCategory DeclarativeChart}
3
+ */
4
+ export interface IImageExportOptions {
5
+ width?: number;
6
+ height?: number;
7
+ scale?: number;
8
+ background?: string;
9
+ }
10
+ export declare function toImage(chartContainer?: HTMLElement | null, opts?: IImageExportOptions): Promise<string>;
@@ -0,0 +1,222 @@
1
+ import { create as d3Create, select as d3Select } from 'd3-selection';
2
+ export function toImage(chartContainer, opts) {
3
+ if (opts === void 0) { opts = {}; }
4
+ return new Promise(function (resolve, reject) {
5
+ if (!chartContainer) {
6
+ return reject(new Error('Chart container is not defined'));
7
+ }
8
+ try {
9
+ var background = opts.background || 'white';
10
+ var svg = toSVG(chartContainer, background);
11
+ var svgData = new XMLSerializer().serializeToString(svg.node);
12
+ var svgDataUrl = 'data:image/svg+xml;base64,' + btoa(unescapePonyfill(encodeURIComponent(svgData)));
13
+ svgToPng(svgDataUrl, {
14
+ width: opts.width || svg.width,
15
+ height: opts.height || svg.height,
16
+ scale: opts.scale,
17
+ })
18
+ .then(resolve)
19
+ .catch(reject);
20
+ }
21
+ catch (err) {
22
+ return reject(err);
23
+ }
24
+ });
25
+ }
26
+ function toSVG(chartContainer, background) {
27
+ var svg = chartContainer.querySelector('svg');
28
+ if (!svg) {
29
+ throw new Error('SVG not found');
30
+ }
31
+ var _a = svg.getBoundingClientRect(), svgWidth = _a.width, svgHeight = _a.height;
32
+ var classNames = new Set();
33
+ var legendGroup = cloneLegendsToSVG(chartContainer, svgWidth, svgHeight, classNames);
34
+ var w1 = Math.max(svgWidth, legendGroup.width);
35
+ var h1 = svgHeight + legendGroup.height;
36
+ var clonedSvg = d3Select(svg.cloneNode(true))
37
+ .attr('width', null)
38
+ .attr('height', null)
39
+ .attr('viewBox', null);
40
+ if (legendGroup.node) {
41
+ clonedSvg.append(function () { return legendGroup.node; });
42
+ }
43
+ clonedSvg
44
+ .insert('rect', ':first-child')
45
+ .attr('x', 0)
46
+ .attr('y', 0)
47
+ .attr('width', w1)
48
+ .attr('height', h1)
49
+ .attr('fill', background);
50
+ var svgElements = svg.getElementsByTagName('*');
51
+ var styleSheets = document.styleSheets;
52
+ var styleRules = [];
53
+ for (var i = svgElements.length - 1; i--;) {
54
+ svgElements[i].classList.forEach(function (className) {
55
+ classNames.add(".".concat(className));
56
+ });
57
+ }
58
+ for (var i = 0; i < styleSheets.length; i++) {
59
+ var rules = styleSheets[i].cssRules;
60
+ for (var j = 0; j < rules.length; j++) {
61
+ if (rules[j].constructor.name === 'CSSStyleRule') {
62
+ var selectorText = rules[j].selectorText;
63
+ var hasClassName = selectorText.split(' ').some(function (word) { return classNames.has(word); });
64
+ if (hasClassName) {
65
+ styleRules.push(rules[j].cssText);
66
+ }
67
+ }
68
+ }
69
+ }
70
+ var xmlDocument = new DOMParser().parseFromString('<svg></svg>', 'image/svg+xml');
71
+ var styleNode = xmlDocument.createCDATASection(styleRules.join(' '));
72
+ clonedSvg.insert('defs', ':first-child').append('style').attr('type', 'text/css').node().appendChild(styleNode);
73
+ clonedSvg.attr('width', w1).attr('height', h1).attr('viewBox', "0 0 ".concat(w1, " ").concat(h1));
74
+ return {
75
+ node: clonedSvg.node(),
76
+ width: w1,
77
+ height: h1,
78
+ };
79
+ }
80
+ function cloneLegendsToSVG(chartContainer, svgWidth, svgHeight, classNames) {
81
+ var legendButtons = chartContainer.querySelectorAll("\n button[class^=\"legend-\"],\n [class^=\"legendContainer-\"] div[class^=\"overflowIndicationTextStyle-\"],\n [class^=\"legendsContainer-\"] div[class^=\"overflowIndicationTextStyle-\"]\n ");
82
+ if (legendButtons.length === 0) {
83
+ return {
84
+ node: null,
85
+ width: 0,
86
+ height: 0,
87
+ };
88
+ }
89
+ var legendGroup = d3Create('svg:g');
90
+ var legendX = 0;
91
+ var legendY = 8;
92
+ var legendLine = [];
93
+ var legendLines = [];
94
+ var legendLineWidths = [];
95
+ for (var i = 0; i < legendButtons.length; i++) {
96
+ var legendWidth = legendButtons[i].getBoundingClientRect().width;
97
+ var legendItem = legendGroup.append('g');
98
+ legendLine.push(legendItem);
99
+ if (legendX + legendWidth > svgWidth && legendLine.length > 1) {
100
+ legendLine.pop();
101
+ legendLines.push(legendLine);
102
+ legendLineWidths.push(legendX);
103
+ legendLine = [legendItem];
104
+ legendX = 0;
105
+ legendY += 32;
106
+ }
107
+ var legendText = void 0;
108
+ var textOffset = 0;
109
+ if (legendButtons[i].tagName.toLowerCase() === 'button') {
110
+ var legendRect = legendButtons[i].querySelector('[class^="rect"]');
111
+ var _a = getComputedStyle(legendRect), legendColor = _a.backgroundColor, legendBorderColor = _a.borderColor;
112
+ legendText = legendButtons[i].querySelector('[class^="text"]');
113
+ legendText.classList.forEach(function (className) { return classNames.add(".".concat(className)); });
114
+ legendItem
115
+ .append('rect')
116
+ .attr('x', legendX + 8)
117
+ .attr('y', svgHeight + legendY + 8)
118
+ .attr('width', 12)
119
+ .attr('height', 12)
120
+ .attr('fill', legendColor)
121
+ .attr('stroke-width', 1)
122
+ .attr('stroke', legendBorderColor);
123
+ textOffset = 28;
124
+ }
125
+ else {
126
+ legendText = legendButtons[i];
127
+ legendText.classList.forEach(function (className) { return classNames.add(".".concat(className)); });
128
+ textOffset = 8;
129
+ }
130
+ legendItem
131
+ .append('text')
132
+ .attr('x', legendX + textOffset)
133
+ .attr('y', svgHeight + legendY + 8)
134
+ .attr('dominant-baseline', 'hanging')
135
+ .attr('class', legendText.getAttribute('class'))
136
+ .text(legendText.textContent);
137
+ legendX += legendWidth;
138
+ }
139
+ legendLines.push(legendLine);
140
+ legendLineWidths.push(legendX);
141
+ legendY += 32;
142
+ var centerLegends = true;
143
+ if (centerLegends) {
144
+ legendLines.forEach(function (ln, idx) {
145
+ var offsetX = Math.max((svgWidth - legendLineWidths[idx]) / 2, 0);
146
+ ln.forEach(function (item) {
147
+ item.attr('transform', "translate(".concat(offsetX, ", 0)"));
148
+ });
149
+ });
150
+ }
151
+ return {
152
+ node: legendGroup.node(),
153
+ width: Math.max.apply(Math, legendLineWidths),
154
+ height: legendY,
155
+ };
156
+ }
157
+ function svgToPng(svgDataUrl, opts) {
158
+ if (opts === void 0) { opts = {}; }
159
+ return new Promise(function (resolve, reject) {
160
+ var scale = opts.scale || 1;
161
+ var w0 = opts.width || 300;
162
+ var h0 = opts.height || 150;
163
+ var w1 = scale * w0;
164
+ var h1 = scale * h0;
165
+ var canvas = document.createElement('canvas');
166
+ var img = new Image();
167
+ canvas.width = w1;
168
+ canvas.height = h1;
169
+ img.onload = function () {
170
+ var ctx = canvas.getContext('2d');
171
+ if (!ctx) {
172
+ return reject(new Error('Canvas context is null'));
173
+ }
174
+ ctx.clearRect(0, 0, w1, h1);
175
+ ctx.drawImage(img, 0, 0, w1, h1);
176
+ var imgData = canvas.toDataURL('image/png');
177
+ resolve(imgData);
178
+ };
179
+ img.onerror = function (err) {
180
+ reject(err);
181
+ };
182
+ img.src = svgDataUrl;
183
+ });
184
+ }
185
+ var hex2 = /^[\da-f]{2}$/i;
186
+ var hex4 = /^[\da-f]{4}$/i;
187
+ /**
188
+ * A ponyfill for the deprecated `unescape` method, taken from the `core-js` library.
189
+ *
190
+ * Source: {@link https://github.com/zloirock/core-js/blob/167136f479d3b8519953f2e4c534ecdd1031d3cf/packages/core-js/modules/es.unescape.js core-js/packages/core-js/modules/es.unescape.js}
191
+ */
192
+ function unescapePonyfill(str) {
193
+ var result = '';
194
+ var length = str.length;
195
+ var index = 0;
196
+ var chr;
197
+ var part;
198
+ while (index < length) {
199
+ chr = str.charAt(index++);
200
+ if (chr === '%') {
201
+ if (str.charAt(index) === 'u') {
202
+ part = str.slice(index + 1, index + 5);
203
+ if (hex4.exec(part)) {
204
+ result += String.fromCharCode(parseInt(part, 16));
205
+ index += 5;
206
+ continue;
207
+ }
208
+ }
209
+ else {
210
+ part = str.slice(index, index + 2);
211
+ if (hex2.exec(part)) {
212
+ result += String.fromCharCode(parseInt(part, 16));
213
+ index += 2;
214
+ continue;
215
+ }
216
+ }
217
+ }
218
+ result += chr;
219
+ }
220
+ return result;
221
+ }
222
+ //# sourceMappingURL=imageExporter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imageExporter.js","sourceRoot":"../src/","sources":["components/DeclarativeChart/imageExporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,IAAI,QAAQ,EAAa,MAAM,cAAc,CAAC;AAYjF,MAAM,UAAU,OAAO,CAAC,cAAmC,EAAE,IAA8B;IAA9B,qBAAA,EAAA,SAA8B;IACzF,OAAO,IAAI,OAAO,CAAC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ClD,KAAK,IAAI,CAAC,CAAC;oBACX,SAAS;gBACX,CAAC;YACH,CAAC;QACH,CAAC;QACD,MAAM,IAAI,GAAG,CAAC;IAChB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { create as d3Create, select as d3Select, Selection } from 'd3-selection';\n\n/**\n * {@docCategory DeclarativeChart}\n */\nexport interface IImageExportOptions {\n width?: number;\n height?: number;\n scale?: number;\n background?: string;\n}\n\nexport function toImage(chartContainer?: HTMLElement | null, opts: IImageExportOptions = {}): Promise<string> {\n return new Promise((resolve, reject) => {\n if (!chartContainer) {\n return reject(new Error('Chart container is not defined'));\n }\n\n try {\n const background = opts.background || 'white';\n const svg = toSVG(chartContainer, background);\n\n const svgData = new XMLSerializer().serializeToString(svg.node);\n const svgDataUrl = 'data:image/svg+xml;base64,' + btoa(unescapePonyfill(encodeURIComponent(svgData)));\n\n svgToPng(svgDataUrl, {\n width: opts.width || svg.width,\n height: opts.height || svg.height,\n scale: opts.scale,\n })\n .then(resolve)\n .catch(reject);\n } catch (err) {\n return reject(err);\n }\n });\n}\n\nfunction toSVG(chartContainer: HTMLElement, background: string) {\n const svg = chartContainer.querySelector<SVGSVGElement>('svg');\n if (!svg) {\n throw new Error('SVG not found');\n }\n\n const { width: svgWidth, height: svgHeight } = svg.getBoundingClientRect();\n const classNames = new Set<string>();\n const legendGroup = cloneLegendsToSVG(chartContainer, svgWidth, svgHeight, classNames);\n const w1 = Math.max(svgWidth, legendGroup.width);\n const h1 = svgHeight + legendGroup.height;\n const clonedSvg = d3Select(svg.cloneNode(true) as SVGSVGElement)\n .attr('width', null)\n .attr('height', null)\n .attr('viewBox', null);\n\n if (legendGroup.node) {\n clonedSvg.append(() => legendGroup.node);\n }\n clonedSvg\n .insert('rect', ':first-child')\n .attr('x', 0)\n .attr('y', 0)\n .attr('width', w1)\n .attr('height', h1)\n .attr('fill', background);\n\n const svgElements = svg.getElementsByTagName('*');\n const styleSheets = document.styleSheets;\n const styleRules: string[] = [];\n\n for (let i = svgElements.length - 1; i--; ) {\n svgElements[i].classList.forEach(className => {\n classNames.add(`.${className}`);\n });\n }\n\n for (let i = 0; i < styleSheets.length; i++) {\n const rules = styleSheets[i].cssRules;\n for (let j = 0; j < rules.length; j++) {\n if (rules[j].constructor.name === 'CSSStyleRule') {\n const selectorText = (rules[j] as CSSStyleRule).selectorText;\n const hasClassName = selectorText.split(' ').some(word => classNames.has(word));\n\n if (hasClassName) {\n styleRules.push(rules[j].cssText);\n }\n }\n }\n }\n\n const xmlDocument = new DOMParser().parseFromString('<svg></svg>', 'image/svg+xml');\n const styleNode = xmlDocument.createCDATASection(styleRules.join(' '));\n clonedSvg.insert('defs', ':first-child').append('style').attr('type', 'text/css').node()!.appendChild(styleNode);\n\n clonedSvg.attr('width', w1).attr('height', h1).attr('viewBox', `0 0 ${w1} ${h1}`);\n\n return {\n node: clonedSvg.node()!,\n width: w1,\n height: h1,\n };\n}\n\nfunction cloneLegendsToSVG(chartContainer: HTMLElement, svgWidth: number, svgHeight: number, classNames: Set<string>) {\n const legendButtons = chartContainer.querySelectorAll<HTMLElement>(`\n button[class^=\"legend-\"],\n [class^=\"legendContainer-\"] div[class^=\"overflowIndicationTextStyle-\"],\n [class^=\"legendsContainer-\"] div[class^=\"overflowIndicationTextStyle-\"]\n `);\n if (legendButtons.length === 0) {\n return {\n node: null,\n width: 0,\n height: 0,\n };\n }\n\n const legendGroup = d3Create<SVGGElement>('svg:g');\n let legendX = 0;\n let legendY = 8;\n let legendLine: Selection<SVGGElement, unknown, null, undefined>[] = [];\n const legendLines: (typeof legendLine)[] = [];\n const legendLineWidths: number[] = [];\n\n for (let i = 0; i < legendButtons.length; i++) {\n const { width: legendWidth } = legendButtons[i].getBoundingClientRect();\n const legendItem = legendGroup.append('g');\n\n legendLine.push(legendItem);\n if (legendX + legendWidth > svgWidth && legendLine.length > 1) {\n legendLine.pop();\n legendLines.push(legendLine);\n legendLineWidths.push(legendX);\n\n legendLine = [legendItem];\n legendX = 0;\n legendY += 32;\n }\n\n let legendText: HTMLDivElement | null;\n let textOffset = 0;\n\n if (legendButtons[i].tagName.toLowerCase() === 'button') {\n const legendRect = legendButtons[i].querySelector<HTMLDivElement>('[class^=\"rect\"]');\n const { backgroundColor: legendColor, borderColor: legendBorderColor } = getComputedStyle(legendRect!);\n\n legendText = legendButtons[i].querySelector<HTMLDivElement>('[class^=\"text\"]');\n legendText!.classList.forEach(className => classNames.add(`.${className}`));\n legendItem\n .append('rect')\n .attr('x', legendX + 8)\n .attr('y', svgHeight + legendY + 8)\n .attr('width', 12)\n .attr('height', 12)\n .attr('fill', legendColor)\n .attr('stroke-width', 1)\n .attr('stroke', legendBorderColor);\n textOffset = 28;\n } else {\n legendText = legendButtons[i] as HTMLDivElement;\n legendText.classList.forEach(className => classNames.add(`.${className}`));\n textOffset = 8;\n }\n\n legendItem\n .append('text')\n .attr('x', legendX + textOffset)\n .attr('y', svgHeight + legendY + 8)\n .attr('dominant-baseline', 'hanging')\n .attr('class', legendText!.getAttribute('class'))\n .text(legendText!.textContent);\n legendX += legendWidth;\n }\n\n legendLines.push(legendLine);\n legendLineWidths.push(legendX);\n legendY += 32;\n\n const centerLegends = true;\n if (centerLegends) {\n legendLines.forEach((ln, idx) => {\n const offsetX = Math.max((svgWidth - legendLineWidths[idx]) / 2, 0);\n ln.forEach(item => {\n item.attr('transform', `translate(${offsetX}, 0)`);\n });\n });\n }\n\n return {\n node: legendGroup.node(),\n width: Math.max(...legendLineWidths),\n height: legendY,\n };\n}\n\nfunction svgToPng(svgDataUrl: string, opts: IImageExportOptions = {}): Promise<string> {\n return new Promise((resolve, reject) => {\n const scale = opts.scale || 1;\n const w0 = opts.width || 300;\n const h0 = opts.height || 150;\n const w1 = scale * w0;\n const h1 = scale * h0;\n\n const canvas = document.createElement('canvas');\n const img = new Image();\n\n canvas.width = w1;\n canvas.height = h1;\n\n img.onload = function () {\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n return reject(new Error('Canvas context is null'));\n }\n\n ctx.clearRect(0, 0, w1, h1);\n ctx.drawImage(img, 0, 0, w1, h1);\n\n const imgData = canvas.toDataURL('image/png');\n resolve(imgData);\n };\n\n img.onerror = function (err) {\n reject(err);\n };\n\n img.src = svgDataUrl;\n });\n}\n\nconst hex2 = /^[\\da-f]{2}$/i;\nconst hex4 = /^[\\da-f]{4}$/i;\n\n/**\n * A ponyfill for the deprecated `unescape` method, taken from the `core-js` library.\n *\n * Source: {@link https://github.com/zloirock/core-js/blob/167136f479d3b8519953f2e4c534ecdd1031d3cf/packages/core-js/modules/es.unescape.js core-js/packages/core-js/modules/es.unescape.js}\n */\nfunction unescapePonyfill(str: string) {\n let result = '';\n const length = str.length;\n let index = 0;\n let chr;\n let part;\n while (index < length) {\n chr = str.charAt(index++);\n if (chr === '%') {\n if (str.charAt(index) === 'u') {\n part = str.slice(index + 1, index + 5);\n if (hex4.exec(part)) {\n result += String.fromCharCode(parseInt(part, 16));\n index += 5;\n continue;\n }\n } else {\n part = str.slice(index, index + 2);\n if (hex2.exec(part)) {\n result += String.fromCharCode(parseInt(part, 16));\n index += 2;\n continue;\n }\n }\n }\n result += chr;\n }\n return result;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './DeclarativeChart';
2
+ export type { IImageExportOptions } from './imageExporter';
@@ -0,0 +1,2 @@
1
+ export * from './DeclarativeChart';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/DeclarativeChart/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC","sourcesContent":["export * from './DeclarativeChart';\nexport type { IImageExportOptions } from './imageExporter';\n"]}
@@ -17,5 +17,6 @@ export declare class Arc extends React.Component<IArcProps, IArcState> {
17
17
  private _onBlur;
18
18
  private _redirectToUrl;
19
19
  private _getAriaLabel;
20
+ private _shouldHighlightArc;
20
21
  private _renderArcLabel;
21
22
  }
@@ -25,11 +25,16 @@ var Arc = /** @class */ (function (_super) {
25
25
  var yValue = point.yAxisCalloutData || point.data || 0;
26
26
  return ((_a = point.callOutAccessibilityData) === null || _a === void 0 ? void 0 : _a.ariaLabel) || (legend ? "".concat(legend, ", ") : '') + "".concat(yValue, ".");
27
27
  };
28
+ _this._shouldHighlightArc = function (legend) {
29
+ var activeArc = _this.props.activeArc;
30
+ // If no activeArc is provided, highlight all arcs. Otherwise, only highlight the arcs that are active.
31
+ return !activeArc || activeArc.length === 0 || legend === undefined || activeArc.includes(legend);
32
+ };
28
33
  _this._renderArcLabel = function (className) {
29
- var _a = _this.props, arc = _a.arc, data = _a.data, innerRadius = _a.innerRadius, outerRadius = _a.outerRadius, showLabelsInPercent = _a.showLabelsInPercent, totalValue = _a.totalValue, hideLabels = _a.hideLabels, activeArc = _a.activeArc;
34
+ var _a = _this.props, arc = _a.arc, data = _a.data, innerRadius = _a.innerRadius, outerRadius = _a.outerRadius, showLabelsInPercent = _a.showLabelsInPercent, totalValue = _a.totalValue, hideLabels = _a.hideLabels;
30
35
  if (hideLabels ||
31
36
  Math.abs(data.endAngle - data.startAngle) < Math.PI / 12 ||
32
- (activeArc !== data.data.legend && activeArc !== '')) {
37
+ !_this._shouldHighlightArc(data.data.legend)) {
33
38
  return null;
34
39
  }
35
40
  var _b = arc.centroid(data), base = _b[0], perp = _b[1];
@@ -51,13 +56,13 @@ var Arc = /** @class */ (function (_super) {
51
56
  _updateChart(newProps);
52
57
  };
53
58
  Arc.prototype.render = function () {
54
- var _a, _b, _c, _d, _e;
55
- var _f = this.props, arc = _f.arc, href = _f.href, focusedArcId = _f.focusedArcId;
59
+ var _a, _b, _c, _d, _e, _f, _g;
60
+ var _h = this.props, arc = _h.arc, href = _h.href, focusedArcId = _h.focusedArcId, activeArc = _h.activeArc;
56
61
  var getClassNames = classNamesFunction();
57
62
  var id = this.props.uniqText + this.props.data.data.legend.replace(/\s+/, '') + this.props.data.data.data;
58
- var opacity = this.props.activeArc === this.props.data.data.legend || this.props.activeArc === '' ? 1 : 0.1;
59
- var startAngle = (_b = (_a = this.props.data) === null || _a === void 0 ? void 0 : _a.startAngle) !== null && _b !== void 0 ? _b : 0;
60
- var endAngle = ((_d = (_c = this.props.data) === null || _c === void 0 ? void 0 : _c.endAngle) !== null && _d !== void 0 ? _d : 0) - startAngle;
63
+ var opacity = activeArc && activeArc.length > 0 ? (activeArc.includes((_a = this.props.data) === null || _a === void 0 ? void 0 : _a.data.legend) ? 1 : 0.1) : 1;
64
+ var startAngle = (_c = (_b = this.props.data) === null || _b === void 0 ? void 0 : _b.startAngle) !== null && _c !== void 0 ? _c : 0;
65
+ var endAngle = ((_e = (_d = this.props.data) === null || _d === void 0 ? void 0 : _d.endAngle) !== null && _e !== void 0 ? _e : 0) - startAngle;
61
66
  var cornerRadius = this.props.roundCorners ? 3 : 0;
62
67
  var classNames = getClassNames(getStyles, {
63
68
  solidFill: this.props.enableGradient ? 'transparent' : this.props.color,
@@ -69,7 +74,7 @@ var Arc = /** @class */ (function (_super) {
69
74
  var clipId = getId('Arc_clip') + "".concat(this.props.color, "_").concat(this.props.nextColor);
70
75
  return (React.createElement("g", { ref: this.currentRef },
71
76
  !!focusedArcId && focusedArcId === id && (React.createElement("path", { id: id + 'focusRing', d: arc.cornerRadius(cornerRadius)(this.props.focusData), className: classNames.focusRing })),
72
- React.createElement("path", { id: id, d: arc.cornerRadius(cornerRadius)(this.props.data), onFocus: this._onFocus.bind(this, this.props.data.data, id), className: classNames.root, "data-is-focusable": this.props.activeArc === this.props.data.data.legend || this.props.activeArc === '', onMouseOver: this._hoverOn.bind(this, this.props.data.data), onMouseMove: this._hoverOn.bind(this, this.props.data.data), onMouseLeave: this._hoverOff, onBlur: this._onBlur, onClick: href ? this._redirectToUrl.bind(this, href) : (_e = this.props.data) === null || _e === void 0 ? void 0 : _e.data.onClick, "aria-label": this._getAriaLabel(), role: "img" }),
77
+ React.createElement("path", { id: id, d: arc.cornerRadius(cornerRadius)(this.props.data), onFocus: this._onFocus.bind(this, this.props.data.data, id), className: classNames.root, "data-is-focusable": this._shouldHighlightArc(this.props.data.data.legend) || ((_f = this.props.activeArc) === null || _f === void 0 ? void 0 : _f.length) === 0, onMouseOver: this._hoverOn.bind(this, this.props.data.data), onMouseMove: this._hoverOn.bind(this, this.props.data.data), onMouseLeave: this._hoverOff, onBlur: this._onBlur, onClick: href ? this._redirectToUrl.bind(this, href) : (_g = this.props.data) === null || _g === void 0 ? void 0 : _g.data.onClick, "aria-label": this._getAriaLabel(), role: "img" }),
73
78
  this._renderArcLabel(classNames.arcLabel),
74
79
  this.props.enableGradient && (React.createElement(React.Fragment, null,
75
80
  React.createElement("clipPath", { id: clipId },
@@ -1 +1 @@
1
- {"version":3,"file":"Arc.js","sourceRoot":"../src/","sources":["components/DonutChart/Arc/Arc.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,IAAI,KAAK,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAMnE;IAAyB,uBAAqC;IAA9D;;QAKS,WAAK,GAAO,EAAE,CAAC;QAEd,gBAAU,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;QAC/C,YAAM,GAAY,MAAM,EAAE,CAAC;QAqF3B,eAAS,GAAG;YAClB,KAAI,CAAC,KAAK,CAAC,kBAAmB,EAAE,CAAC;QACnC,CAAC,CAAC;QAEM,aAAO,GAAG;YAChB,KAAI,CAAC,KAAK,CAAC,cAAe,EAAE,CAAC;QAC/B,CAAC,CAAC;QAMM,mBAAa,GAAG;;YACtB,IAAM,KAAK,GAAG,KAAI,CAAC,KAAK,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AE;KACb,AAFyB,CAExB;IA6IJ,UAAC;CAAA,AAhJD,CAAyB,KAAK,CAAC,SAAS,GAgJvC;SAhJY,GAAG;AAkJhB,SAAS,YAAY,CAAC,QAAmB;IACvC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC/C,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import * as React from 'react';\nimport { arc as d3Arc } from 'd3-shape';\nimport { classNamesFunction, getId, getRTL } from '@fluentui/react/lib/Utilities';\nimport { getStyles } from './Arc.styles';\nimport { IChartDataPoint } from '../index';\nimport { IArcProps, IArcStyleProps, IArcStyles } from './index';\nimport { format as d3Format } from 'd3-format';\nimport { formatValueWithSIPrefix } from '../../../utilities/index';\n\nexport interface IArcState {\n isCalloutVisible?: boolean;\n}\n\nexport class Arc extends React.Component<IArcProps, IArcState> {\n public static defaultProps: Partial<IArcProps> = {\n arc: d3Arc(),\n };\n\n public state: {} = {};\n\n private currentRef = React.createRef<SVGPathElement>();\n private _isRTL: boolean = getRTL();\n\n public static getDerivedStateFromProps(nextProps: Readonly<IArcProps>): Partial<IArcState> | null {\n _updateChart(nextProps);\n return null;\n }\n\n public updateChart(newProps: IArcProps): void {\n _updateChart(newProps);\n }\n\n public render(): JSX.Element {\n const { arc, href, focusedArcId } = this.props;\n const getClassNames = classNamesFunction<IArcStyleProps, IArcStyles>();\n const id = this.props.uniqText! + this.props.data!.data.legend!.replace(/\\s+/, '') + this.props.data!.data.data;\n const opacity: number =\n this.props.activeArc === this.props.data!.data.legend || this.props.activeArc === '' ? 1 : 0.1;\n\n const startAngle = this.props.data?.startAngle ?? 0;\n const endAngle = (this.props.data?.endAngle ?? 0) - startAngle;\n const cornerRadius = this.props.roundCorners ? 3 : 0;\n\n const classNames = getClassNames(getStyles, {\n solidFill: this.props.enableGradient ? 'transparent' : this.props.color,\n gradientFill: `conic-gradient(\n from ${startAngle}rad,\n ${this.props.color},\n ${this.props.nextColor} ${endAngle}rad\n )`,\n href: href!,\n theme: this.props.theme!,\n opacity,\n });\n\n const clipId = getId('Arc_clip') + `${this.props.color}_${this.props.nextColor}`;\n\n return (\n <g ref={this.currentRef}>\n {!!focusedArcId && focusedArcId === id && (\n <path\n id={id + 'focusRing'}\n d={arc.cornerRadius(cornerRadius)(this.props.focusData)}\n className={classNames.focusRing}\n />\n )}\n\n <path\n id={id}\n d={arc.cornerRadius(cornerRadius)(this.props.data)}\n onFocus={this._onFocus.bind(this, this.props.data!.data, id)}\n className={classNames.root}\n data-is-focusable={this.props.activeArc === this.props.data!.data.legend || this.props.activeArc === ''}\n onMouseOver={this._hoverOn.bind(this, this.props.data!.data)}\n onMouseMove={this._hoverOn.bind(this, this.props.data!.data)}\n onMouseLeave={this._hoverOff}\n onBlur={this._onBlur}\n onClick={href ? this._redirectToUrl.bind(this, href) : this.props.data?.data.onClick}\n aria-label={this._getAriaLabel()}\n role=\"img\"\n />\n {this._renderArcLabel(classNames.arcLabel)}\n\n {this.props.enableGradient && (\n <>\n <clipPath id={clipId}>\n <path d={arc.cornerRadius(cornerRadius)(this.props.data)} />\n </clipPath>\n <foreignObject x=\"-50%\" y=\"-50%\" width=\"100%\" height=\"100%\" clipPath={`url(#${clipId})`}>\n <div className={classNames.gradientArc} />\n </foreignObject>\n </>\n )}\n </g>\n );\n }\n\n private _onFocus(data: IChartDataPoint, id: string): void {\n this.props.onFocusCallback!(data, id, this.currentRef.current);\n }\n\n private _hoverOn(data: IChartDataPoint, mouseEvent: React.MouseEvent<SVGPathElement>): void {\n mouseEvent.persist();\n this.props.hoverOnCallback!(data, mouseEvent);\n }\n\n private _hoverOff = (): void => {\n this.props.hoverLeaveCallback!();\n };\n\n private _onBlur = (): void => {\n this.props.onBlurCallback!();\n };\n\n private _redirectToUrl(href: string | undefined): void {\n href ? (window.location.href = href) : '';\n }\n\n private _getAriaLabel = (): string => {\n const point = this.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 private _renderArcLabel = (className: string) => {\n const { arc, data, innerRadius, outerRadius, showLabelsInPercent, totalValue, hideLabels, activeArc } = this.props;\n\n if (\n hideLabels ||\n Math.abs(data!.endAngle - data!.startAngle) < Math.PI / 12 ||\n (activeArc !== data!.data.legend && activeArc !== '')\n ) {\n return null;\n }\n\n const [base, perp] = arc.centroid(data);\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 !== this._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 : formatValueWithSIPrefix(arcValue)}\n </text>\n );\n };\n}\n\nfunction _updateChart(newProps: IArcProps): void {\n newProps.arc.innerRadius(newProps.innerRadius);\n newProps.arc.outerRadius(newProps.outerRadius);\n}\n"]}
1
+ {"version":3,"file":"Arc.js","sourceRoot":"../src/","sources":["components/DonutChart/Arc/Arc.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,IAAI,KAAK,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,MAAM,IAA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gBACX,uCAAe,CAAC,EAAC,MAAM,EAAC,CAAC,EAAC,MAAM,EAAC,KAAK,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,QAAQ,EAAE,eAAQ,MAAM,MAAG;oBACrF,6BAAK,SAAS,EAAE,UAAU,CAAC,WAAW,GAAI,CAC5B,CACf,CACJ,CACC,CACL,CAAC;IACJ,CAAC;IAEO,sBAAQ,GAAhB,UAAiB,IAAqB,EAAE,EAAU;QAChD,IAAI,CAAC,KAAK,CAAC,eAAgB,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACjE,CAAC;IAEO,sBAAQ,GAAhB,UAAiB,IAAqB,EAAE,UAA4C;QAClF,UAAU,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,KAAK,CAAC,eAAgB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAChD,CAAC;IAUO,4BAAc,GAAtB,UAAuB,IAAwB;QAC7C,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5C,CAAC;IAvGa,gBAAY,GAAuB;QAC/C,GAAG,EAAE,KAAK,EAAE;KACb,AAFyB,CAExB;IAmJJ,UAAC;CAAA,AAtJD,CAAyB,KAAK,CAAC,SAAS,GAsJvC;SAtJY,GAAG;AAwJhB,SAAS,YAAY,CAAC,QAAmB;IACvC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC/C,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import * as React from 'react';\nimport { arc as d3Arc } from 'd3-shape';\nimport { classNamesFunction, getId, getRTL } from '@fluentui/react/lib/Utilities';\nimport { getStyles } from './Arc.styles';\nimport { IChartDataPoint } from '../index';\nimport { IArcProps, IArcStyleProps, IArcStyles } from './index';\nimport { format as d3Format } from 'd3-format';\nimport { formatValueWithSIPrefix } from '../../../utilities/index';\n\nexport interface IArcState {\n isCalloutVisible?: boolean;\n}\n\nexport class Arc extends React.Component<IArcProps, IArcState> {\n public static defaultProps: Partial<IArcProps> = {\n arc: d3Arc(),\n };\n\n public state: {} = {};\n\n private currentRef = React.createRef<SVGPathElement>();\n private _isRTL: boolean = getRTL();\n\n public static getDerivedStateFromProps(nextProps: Readonly<IArcProps>): Partial<IArcState> | null {\n _updateChart(nextProps);\n return null;\n }\n\n public updateChart(newProps: IArcProps): void {\n _updateChart(newProps);\n }\n\n public render(): JSX.Element {\n const { arc, href, focusedArcId, activeArc } = this.props;\n const getClassNames = classNamesFunction<IArcStyleProps, IArcStyles>();\n const id = this.props.uniqText! + this.props.data!.data.legend!.replace(/\\s+/, '') + this.props.data!.data.data;\n const opacity: number =\n activeArc && activeArc.length > 0 ? (activeArc.includes(this.props.data?.data.legend!) ? 1 : 0.1) : 1;\n const startAngle = this.props.data?.startAngle ?? 0;\n const endAngle = (this.props.data?.endAngle ?? 0) - startAngle;\n const cornerRadius = this.props.roundCorners ? 3 : 0;\n\n const classNames = getClassNames(getStyles, {\n solidFill: this.props.enableGradient ? 'transparent' : this.props.color,\n gradientFill: `conic-gradient(\n from ${startAngle}rad,\n ${this.props.color},\n ${this.props.nextColor} ${endAngle}rad\n )`,\n href: href!,\n theme: this.props.theme!,\n opacity,\n });\n\n const clipId = getId('Arc_clip') + `${this.props.color}_${this.props.nextColor}`;\n\n return (\n <g ref={this.currentRef}>\n {!!focusedArcId && focusedArcId === id && (\n <path\n id={id + 'focusRing'}\n d={arc.cornerRadius(cornerRadius)(this.props.focusData)}\n className={classNames.focusRing}\n />\n )}\n\n <path\n id={id}\n d={arc.cornerRadius(cornerRadius)(this.props.data)}\n onFocus={this._onFocus.bind(this, this.props.data!.data, id)}\n className={classNames.root}\n data-is-focusable={\n this._shouldHighlightArc(this.props.data!.data.legend!) || this.props.activeArc?.length === 0\n }\n onMouseOver={this._hoverOn.bind(this, this.props.data!.data)}\n onMouseMove={this._hoverOn.bind(this, this.props.data!.data)}\n onMouseLeave={this._hoverOff}\n onBlur={this._onBlur}\n onClick={href ? this._redirectToUrl.bind(this, href) : this.props.data?.data.onClick}\n aria-label={this._getAriaLabel()}\n role=\"img\"\n />\n {this._renderArcLabel(classNames.arcLabel)}\n\n {this.props.enableGradient && (\n <>\n <clipPath id={clipId}>\n <path d={arc.cornerRadius(cornerRadius)(this.props.data)} />\n </clipPath>\n <foreignObject x=\"-50%\" y=\"-50%\" width=\"100%\" height=\"100%\" clipPath={`url(#${clipId})`}>\n <div className={classNames.gradientArc} />\n </foreignObject>\n </>\n )}\n </g>\n );\n }\n\n private _onFocus(data: IChartDataPoint, id: string): void {\n this.props.onFocusCallback!(data, id, this.currentRef.current);\n }\n\n private _hoverOn(data: IChartDataPoint, mouseEvent: React.MouseEvent<SVGPathElement>): void {\n mouseEvent.persist();\n this.props.hoverOnCallback!(data, mouseEvent);\n }\n\n private _hoverOff = (): void => {\n this.props.hoverLeaveCallback!();\n };\n\n private _onBlur = (): void => {\n this.props.onBlurCallback!();\n };\n\n private _redirectToUrl(href: string | undefined): void {\n href ? (window.location.href = href) : '';\n }\n\n private _getAriaLabel = (): string => {\n const point = this.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 private _shouldHighlightArc = (legend?: string): boolean => {\n const { activeArc } = this.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 private _renderArcLabel = (className: string) => {\n const { arc, data, innerRadius, outerRadius, showLabelsInPercent, totalValue, hideLabels } = this.props;\n if (\n hideLabels ||\n Math.abs(data!.endAngle - data!.startAngle) < Math.PI / 12 ||\n !this._shouldHighlightArc(data!.data.legend!)\n ) {\n return null;\n }\n\n const [base, perp] = arc.centroid(data);\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 !== this._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 : formatValueWithSIPrefix(arcValue)}\n </text>\n );\n };\n}\n\nfunction _updateChart(newProps: IArcProps): void {\n newProps.arc.innerRadius(newProps.innerRadius);\n newProps.arc.outerRadius(newProps.outerRadius);\n}\n"]}
@@ -60,7 +60,7 @@ export interface IArcProps {
60
60
  /**
61
61
  * Active Arc for chart
62
62
  */
63
- activeArc?: string;
63
+ activeArc?: string[];
64
64
  /**
65
65
  * internal prop for href
66
66
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Arc.types.js","sourceRoot":"../src/","sources":["components/DonutChart/Arc/Arc.types.ts"],"names":[],"mappings":"","sourcesContent":["import { IStyle, ITheme } from '@fluentui/react/lib/Styling';\nimport { IChartDataPoint } from '../index';\nexport interface IArcProps {\n /**\n * Theme\n */\n theme: ITheme;\n /**\n * Data to render in the Arc.\n */\n data?: IArcData;\n\n /**\n * Data to render focused Arc\n */\n focusData?: IArcData;\n\n /**\n * id of the focused arc\n */\n focusedArcId?: string;\n /**\n * shape for Arc.\n */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n arc?: any;\n\n /**\n * innerRadius of the Arc.\n */\n innerRadius?: number;\n\n /**\n * outerRadius of the Arc.\n */\n outerRadius?: number;\n\n /**\n * Color for the Arc.\n */\n color: string;\n\n /**\n * Defines the function that is executed upon hovering over the legend\n */\n hoverOnCallback?: Function;\n\n /**\n * Defines the function that is executed upon hovering over the legend\n */\n onFocusCallback?: Function;\n\n /**\n * Defines the function that is executed upon hovering Leave the legend\n */\n onBlurCallback?: Function;\n\n /**\n * Defines the function that is executed upon hovering Leave the legend\n */\n hoverLeaveCallback?: Function;\n\n /**\n * Uniq string for chart\n */\n uniqText?: string;\n\n /**\n * string for callout id\n */\n calloutId?: string;\n\n /**\n * Active Arc for chart\n */\n activeArc?: string;\n\n /**\n * internal prop for href\n */\n href?: string;\n\n /**\n * props for inside donut value\n */\n valueInsideDonut?: string | number;\n\n /**\n * Prop to show the arc labels in percentage format\n */\n showLabelsInPercent?: boolean;\n\n /**\n * Prop used to define the sum of all arc values\n */\n totalValue?: number;\n\n /**\n * Prop to hide the arc labels\n */\n hideLabels?: boolean;\n\n /**\n * Prop to enable the gradient in the arc\n * @default false\n */\n enableGradient?: boolean;\n\n /**\n * Prop to enable the round corners in the chart\n * @default false\n */\n roundCorners?: boolean;\n\n /**\n * Next color stop for the gradient\n * [Only used when enableGradient is True].\n */\n nextColor: string;\n}\n\nexport interface IArcData {\n /**\n * Data to render in the chart for individual arc.\n */\n data: IChartDataPoint;\n /**\n * endAngle of the Arc\n */\n endAngle: number;\n /**\n * index of the Arc\n */\n index: number;\n /**\n * padAngle of the Arc\n */\n padAngle: number;\n /**\n * startAngle of the Arc\n */\n startAngle: number;\n /**\n * value of the Arc\n */\n value: number;\n}\n\nexport interface IArcStyleProps {\n /**\n * Theme\n */\n theme: ITheme;\n\n /**\n * internal prop for href\n */\n href: string;\n\n /**\n * solid color for the arc (when enableGradient is false)\n */\n solidFill: string;\n\n /**\n * gradient for the arc (when enableGradient is true)\n */\n gradientFill: string;\n\n /**\n * wether gradients are enabled for the arc\n */\n opacity: number;\n}\n\nexport interface IArcStyles {\n /**\n * Style set for the card header component root\n */\n root: IStyle;\n\n /**\n * Style set for the gradient arc\n */\n gradientArc: IStyle;\n\n /**\n * styles for the focus\n */\n focusRing: IStyle;\n\n /**\n * Style for the arc labels\n */\n arcLabel: IStyle;\n}\n"]}
1
+ {"version":3,"file":"Arc.types.js","sourceRoot":"../src/","sources":["components/DonutChart/Arc/Arc.types.ts"],"names":[],"mappings":"","sourcesContent":["import { IStyle, ITheme } from '@fluentui/react/lib/Styling';\nimport { IChartDataPoint } from '../index';\nexport interface IArcProps {\n /**\n * Theme\n */\n theme: ITheme;\n /**\n * Data to render in the Arc.\n */\n data?: IArcData;\n\n /**\n * Data to render focused Arc\n */\n focusData?: IArcData;\n\n /**\n * id of the focused arc\n */\n focusedArcId?: string;\n /**\n * shape for Arc.\n */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n arc?: any;\n\n /**\n * innerRadius of the Arc.\n */\n innerRadius?: number;\n\n /**\n * outerRadius of the Arc.\n */\n outerRadius?: number;\n\n /**\n * Color for the Arc.\n */\n color: string;\n\n /**\n * Defines the function that is executed upon hovering over the legend\n */\n hoverOnCallback?: Function;\n\n /**\n * Defines the function that is executed upon hovering over the legend\n */\n onFocusCallback?: Function;\n\n /**\n * Defines the function that is executed upon hovering Leave the legend\n */\n onBlurCallback?: Function;\n\n /**\n * Defines the function that is executed upon hovering Leave the legend\n */\n hoverLeaveCallback?: Function;\n\n /**\n * Uniq string for chart\n */\n uniqText?: string;\n\n /**\n * string for callout id\n */\n calloutId?: string;\n\n /**\n * Active Arc for chart\n */\n activeArc?: string[];\n\n /**\n * internal prop for href\n */\n href?: string;\n\n /**\n * props for inside donut value\n */\n valueInsideDonut?: string | number;\n\n /**\n * Prop to show the arc labels in percentage format\n */\n showLabelsInPercent?: boolean;\n\n /**\n * Prop used to define the sum of all arc values\n */\n totalValue?: number;\n\n /**\n * Prop to hide the arc labels\n */\n hideLabels?: boolean;\n\n /**\n * Prop to enable the gradient in the arc\n * @default false\n */\n enableGradient?: boolean;\n\n /**\n * Prop to enable the round corners in the chart\n * @default false\n */\n roundCorners?: boolean;\n\n /**\n * Next color stop for the gradient\n * [Only used when enableGradient is True].\n */\n nextColor: string;\n}\n\nexport interface IArcData {\n /**\n * Data to render in the chart for individual arc.\n */\n data: IChartDataPoint;\n /**\n * endAngle of the Arc\n */\n endAngle: number;\n /**\n * index of the Arc\n */\n index: number;\n /**\n * padAngle of the Arc\n */\n padAngle: number;\n /**\n * startAngle of the Arc\n */\n startAngle: number;\n /**\n * value of the Arc\n */\n value: number;\n}\n\nexport interface IArcStyleProps {\n /**\n * Theme\n */\n theme: ITheme;\n\n /**\n * internal prop for href\n */\n href: string;\n\n /**\n * solid color for the arc (when enableGradient is false)\n */\n solidFill: string;\n\n /**\n * gradient for the arc (when enableGradient is true)\n */\n gradientFill: string;\n\n /**\n * wether gradients are enabled for the arc\n */\n opacity: number;\n}\n\nexport interface IArcStyles {\n /**\n * Style set for the card header component root\n */\n root: IStyle;\n\n /**\n * Style set for the gradient arc\n */\n gradientArc: IStyle;\n\n /**\n * styles for the focus\n */\n focusRing: IStyle;\n\n /**\n * Style for the arc labels\n */\n arcLabel: IStyle;\n}\n"]}
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
  import { ScaleOrdinal } from 'd3-scale';
3
3
  import { IAccessibilityProps } from '../../index';
4
4
  import { IChartDataPoint, IDonutChartProps } from './index';
5
+ import { IChart } from '../../types/index';
5
6
  export interface IDonutChartState {
6
7
  showHover?: boolean;
7
8
  value?: string | undefined;
@@ -13,11 +14,11 @@ export interface IDonutChartState {
13
14
  xCalloutValue?: string;
14
15
  yCalloutValue?: string;
15
16
  focusedArcId?: string;
16
- selectedLegend: string;
17
17
  dataPointCalloutProps?: IChartDataPoint;
18
18
  callOutAccessibilityData?: IAccessibilityProps;
19
+ selectedLegends: string[];
19
20
  }
20
- export declare class DonutChartBase extends React.Component<IDonutChartProps, IDonutChartState> {
21
+ export declare class DonutChartBase extends React.Component<IDonutChartProps, IDonutChartState> implements IChart {
21
22
  static defaultProps: Partial<IDonutChartProps>;
22
23
  _colors: ScaleOrdinal<string, {}>;
23
24
  private _classNames;
@@ -31,10 +32,12 @@ export declare class DonutChartBase extends React.Component<IDonutChartProps, ID
31
32
  constructor(props: IDonutChartProps);
32
33
  componentDidMount(): void;
33
34
  render(): JSX.Element;
35
+ get chartContainer(): HTMLElement | null;
34
36
  private _closeCallout;
35
37
  private _elevateToMinimums;
36
38
  private _setViewBox;
37
39
  private _createLegends;
40
+ private _onLegendSelectionChange;
38
41
  private _focusCallback;
39
42
  private _hoverCallback;
40
43
  private _onBlur;
@@ -46,9 +49,10 @@ export declare class DonutChartBase extends React.Component<IDonutChartProps, ID
46
49
  * This function returns
47
50
  * the selected legend if there is one
48
51
  * or the hovered legend if none of the legends is selected.
49
- * Note: This won't work in case of multiple legends selection.
50
52
  */
51
53
  private _getHighlightedLegend;
54
+ private _isLegendHighlighted;
55
+ private _noLegendsHighlighted;
52
56
  private _isChartEmpty;
53
57
  private _addDefaultColors;
54
58
  }