@fluentui/react-charting 5.24.9 → 5.24.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/CHANGELOG.json +28 -1
  2. package/CHANGELOG.md +13 -2
  3. package/dist/react-charting.d.ts +149 -0
  4. package/dist/react-charting.js +1 -1
  5. package/dist/react-charting.min.js +1 -1
  6. package/etc/react-charting.api.md +40 -0
  7. package/lib/FunnelChart.d.ts +1 -0
  8. package/lib/FunnelChart.js +2 -0
  9. package/lib/FunnelChart.js.map +1 -0
  10. package/lib/components/DeclarativeChart/DeclarativeChart.js +7 -1
  11. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  12. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +2 -0
  13. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +120 -0
  14. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  15. package/lib/components/FunnelChart/FunnelChart.base.d.ts +3 -0
  16. package/lib/components/FunnelChart/FunnelChart.base.js +264 -0
  17. package/lib/components/FunnelChart/FunnelChart.base.js.map +1 -0
  18. package/lib/components/FunnelChart/FunnelChart.d.ts +7 -0
  19. package/lib/components/FunnelChart/FunnelChart.js +9 -0
  20. package/lib/components/FunnelChart/FunnelChart.js.map +1 -0
  21. package/lib/components/FunnelChart/FunnelChart.styles.d.ts +2 -0
  22. package/lib/components/FunnelChart/FunnelChart.styles.js +38 -0
  23. package/lib/components/FunnelChart/FunnelChart.styles.js.map +1 -0
  24. package/lib/components/FunnelChart/FunnelChart.types.d.ts +139 -0
  25. package/lib/components/FunnelChart/FunnelChart.types.js +2 -0
  26. package/lib/components/FunnelChart/FunnelChart.types.js.map +1 -0
  27. package/lib/components/FunnelChart/funnelGeometry.d.ts +77 -0
  28. package/lib/components/FunnelChart/funnelGeometry.js +194 -0
  29. package/lib/components/FunnelChart/funnelGeometry.js.map +1 -0
  30. package/lib/components/FunnelChart/index.d.ts +2 -0
  31. package/lib/components/FunnelChart/index.js +3 -0
  32. package/lib/components/FunnelChart/index.js.map +1 -0
  33. package/lib/components/HeatMapChart/HeatMapChart.base.d.ts +0 -1
  34. package/lib/components/HeatMapChart/HeatMapChart.base.js +2 -16
  35. package/lib/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  36. package/lib/components/LineChart/LineChart.base.d.ts +2 -0
  37. package/lib/components/LineChart/LineChart.base.js +17 -10
  38. package/lib/components/LineChart/LineChart.base.js.map +1 -1
  39. package/lib/components/LineChart/LineChart.types.d.ts +6 -0
  40. package/lib/components/LineChart/LineChart.types.js.map +1 -1
  41. package/lib/index.d.ts +2 -0
  42. package/lib/index.js +1 -0
  43. package/lib/index.js.map +1 -1
  44. package/lib/utilities/utilities.d.ts +3 -0
  45. package/lib/utilities/utilities.js +14 -0
  46. package/lib/utilities/utilities.js.map +1 -1
  47. package/lib-amd/FunnelChart.d.ts +1 -0
  48. package/lib-amd/FunnelChart.js +6 -0
  49. package/lib-amd/FunnelChart.js.map +1 -0
  50. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +6 -1
  51. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  52. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +2 -0
  53. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +122 -1
  54. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  55. package/lib-amd/components/FunnelChart/FunnelChart.base.d.ts +3 -0
  56. package/lib-amd/components/FunnelChart/FunnelChart.base.js +258 -0
  57. package/lib-amd/components/FunnelChart/FunnelChart.base.js.map +1 -0
  58. package/lib-amd/components/FunnelChart/FunnelChart.d.ts +7 -0
  59. package/lib-amd/components/FunnelChart/FunnelChart.js +11 -0
  60. package/lib-amd/components/FunnelChart/FunnelChart.js.map +1 -0
  61. package/lib-amd/components/FunnelChart/FunnelChart.styles.d.ts +2 -0
  62. package/lib-amd/components/FunnelChart/FunnelChart.styles.js +43 -0
  63. package/lib-amd/components/FunnelChart/FunnelChart.styles.js.map +1 -0
  64. package/lib-amd/components/FunnelChart/FunnelChart.types.d.ts +139 -0
  65. package/lib-amd/components/FunnelChart/FunnelChart.types.js +5 -0
  66. package/lib-amd/components/FunnelChart/FunnelChart.types.js.map +1 -0
  67. package/lib-amd/components/FunnelChart/funnelGeometry.d.ts +77 -0
  68. package/lib-amd/components/FunnelChart/funnelGeometry.js +204 -0
  69. package/lib-amd/components/FunnelChart/funnelGeometry.js.map +1 -0
  70. package/lib-amd/components/FunnelChart/index.d.ts +2 -0
  71. package/lib-amd/components/FunnelChart/index.js +7 -0
  72. package/lib-amd/components/FunnelChart/index.js.map +1 -0
  73. package/lib-amd/components/HeatMapChart/HeatMapChart.base.d.ts +0 -1
  74. package/lib-amd/components/HeatMapChart/HeatMapChart.base.js +2 -15
  75. package/lib-amd/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  76. package/lib-amd/components/LineChart/LineChart.base.d.ts +2 -0
  77. package/lib-amd/components/LineChart/LineChart.base.js +17 -10
  78. package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
  79. package/lib-amd/components/LineChart/LineChart.types.d.ts +6 -0
  80. package/lib-amd/components/LineChart/LineChart.types.js.map +1 -1
  81. package/lib-amd/index.d.ts +2 -0
  82. package/lib-amd/index.js +3 -2
  83. package/lib-amd/index.js.map +1 -1
  84. package/lib-amd/utilities/utilities.d.ts +3 -0
  85. package/lib-amd/utilities/utilities.js +17 -2
  86. package/lib-amd/utilities/utilities.js.map +1 -1
  87. package/lib-commonjs/FunnelChart.d.ts +1 -0
  88. package/lib-commonjs/FunnelChart.js +5 -0
  89. package/lib-commonjs/FunnelChart.js.map +1 -0
  90. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +6 -0
  91. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  92. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +2 -0
  93. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +122 -1
  94. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  95. package/lib-commonjs/components/FunnelChart/FunnelChart.base.d.ts +3 -0
  96. package/lib-commonjs/components/FunnelChart/FunnelChart.base.js +267 -0
  97. package/lib-commonjs/components/FunnelChart/FunnelChart.base.js.map +1 -0
  98. package/lib-commonjs/components/FunnelChart/FunnelChart.d.ts +7 -0
  99. package/lib-commonjs/components/FunnelChart/FunnelChart.js +12 -0
  100. package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -0
  101. package/lib-commonjs/components/FunnelChart/FunnelChart.styles.d.ts +2 -0
  102. package/lib-commonjs/components/FunnelChart/FunnelChart.styles.js +42 -0
  103. package/lib-commonjs/components/FunnelChart/FunnelChart.styles.js.map +1 -0
  104. package/lib-commonjs/components/FunnelChart/FunnelChart.types.d.ts +139 -0
  105. package/lib-commonjs/components/FunnelChart/FunnelChart.types.js +3 -0
  106. package/lib-commonjs/components/FunnelChart/FunnelChart.types.js.map +1 -0
  107. package/lib-commonjs/components/FunnelChart/funnelGeometry.d.ts +77 -0
  108. package/lib-commonjs/components/FunnelChart/funnelGeometry.js +202 -0
  109. package/lib-commonjs/components/FunnelChart/funnelGeometry.js.map +1 -0
  110. package/lib-commonjs/components/FunnelChart/index.d.ts +2 -0
  111. package/lib-commonjs/components/FunnelChart/index.js +6 -0
  112. package/lib-commonjs/components/FunnelChart/index.js.map +1 -0
  113. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.d.ts +0 -1
  114. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js +1 -15
  115. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  116. package/lib-commonjs/components/LineChart/LineChart.base.d.ts +2 -0
  117. package/lib-commonjs/components/LineChart/LineChart.base.js +17 -10
  118. package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
  119. package/lib-commonjs/components/LineChart/LineChart.types.d.ts +6 -0
  120. package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
  121. package/lib-commonjs/index.d.ts +2 -0
  122. package/lib-commonjs/index.js +3 -1
  123. package/lib-commonjs/index.js.map +1 -1
  124. package/lib-commonjs/utilities/utilities.d.ts +3 -0
  125. package/lib-commonjs/utilities/utilities.js +17 -1
  126. package/lib-commonjs/utilities/utilities.js.map +1 -1
  127. package/package.json +2 -2
  128. package/src/components/FunnelChart/FunnelChart.types.ts +153 -0
  129. package/src/components/LineChart/LineChart.types.ts +7 -0
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "tslib", "react", "@fluentui/react", "../DonutChart/index", "../VerticalStackedBarChart/index", "@fluentui/chart-utilities", "@fluentui/chart-utilities", "./PlotlySchemaAdapter", "../LineChart/index", "../HorizontalBarChartWithAxis/index", "../AreaChart/index", "../HeatMapChart/index", "../SankeyChart/SankeyChart", "../GaugeChart/index", "../GroupedVerticalBarChart/index", "../VerticalBarChart/index", "../ResponsiveContainer/withResponsiveContainer", "../ScatterChart/index", "../ChartTable/index", "../Legends/index"], function (require, exports, tslib_1, React, react_1, index_1, index_2, chart_utilities_1, chart_utilities_2, PlotlySchemaAdapter_1, index_3, index_4, index_5, index_6, SankeyChart_1, index_7, index_8, index_9, withResponsiveContainer_1, index_10, index_11, index_12) {
1
+ define(["require", "exports", "tslib", "react", "@fluentui/react", "../DonutChart/index", "../VerticalStackedBarChart/index", "@fluentui/chart-utilities", "@fluentui/chart-utilities", "./PlotlySchemaAdapter", "../LineChart/index", "../HorizontalBarChartWithAxis/index", "../AreaChart/index", "../HeatMapChart/index", "../SankeyChart/SankeyChart", "../GaugeChart/index", "../GroupedVerticalBarChart/index", "../VerticalBarChart/index", "../ResponsiveContainer/withResponsiveContainer", "../ScatterChart/index", "../ChartTable/index", "../FunnelChart/FunnelChart", "../Legends/index"], function (require, exports, tslib_1, React, react_1, index_1, index_2, chart_utilities_1, chart_utilities_2, PlotlySchemaAdapter_1, index_3, index_4, index_5, index_6, SankeyChart_1, index_7, index_8, index_9, withResponsiveContainer_1, index_10, index_11, FunnelChart_1, index_12) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.DeclarativeChart = void 0;
@@ -14,6 +14,7 @@ define(["require", "exports", "tslib", "react", "@fluentui/react", "../DonutChar
14
14
  var ResponsiveVerticalBarChart = (0, withResponsiveContainer_1.withResponsiveContainer)(index_9.VerticalBarChart);
15
15
  var ResponsiveScatterChart = (0, withResponsiveContainer_1.withResponsiveContainer)(index_10.ScatterChart);
16
16
  var ResponsiveChartTable = (0, withResponsiveContainer_1.withResponsiveContainer)(index_11.ChartTable);
17
+ var ResponsiveFunnelChart = (0, withResponsiveContainer_1.withResponsiveContainer)(FunnelChart_1.FunnelChart);
17
18
  // Default x-axis key for grouping traces. Also applicable for PieData and SankeyData where x-axis is not defined.
18
19
  var DEFAULT_XAXIS = 'x';
19
20
  var FALLBACK_TYPE = 'fallback';
@@ -100,6 +101,10 @@ define(["require", "exports", "tslib", "react", "@fluentui/react", "../DonutChar
100
101
  renderer: ResponsiveScatterChart,
101
102
  preTransformOperation: LineAreaPreTransformOp,
102
103
  },
104
+ funnel: {
105
+ transformer: PlotlySchemaAdapter_1.transformPlotlyJsonToFunnelChartProps,
106
+ renderer: ResponsiveFunnelChart,
107
+ },
103
108
  fallback: {
104
109
  transformer: PlotlySchemaAdapter_1.transformPlotlyJsonToVSBCProps,
105
110
  renderer: ResponsiveVerticalStackedBarChart,
@@ -1 +1 @@
1
- {"version":3,"file":"DeclarativeChart.js","sourceRoot":"../src/","sources":["components/DeclarativeChart/DeclarativeChart.tsx"],"names":[],"mappings":";;;;IA+CA,IAAM,oBAAoB,GAAG,IAAA,iDAAuB,EAAC,kBAAU,CAAC,CAAC;IACjE,IAAM,iCAAiC,GAAG,IAAA,iDAAuB,EAAC,+BAAuB,CAAC,CAAC;IAC3F,IAAM,mBAAmB,GAAG,IAAA,iDA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,EAAE,CAAC;wBACtF,IAAM,gBAAgB,GAAG,qBAAqB;4BAC5C,CAAC,CAAC,qBAAqB,CAAC,mBAAmB,CAAC;4BAC5C,CAAC,CAAC,mBAAmB,CAAC;wBACxB,IAAM,cAAc,GAAG,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;wBAEvD,OAAO,WAAW,CAChB,QAAQ,EACR,WAAW,EACX,CAAC,gBAAgB,EAAE,WAAW,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,YAAY,EAAE,WAAW,CAAC,wCAE7E,WAAW,KACd,eAAe,EAAE,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,WAAW,EAC5C,eAAe,EAAE,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,WAAW,KAE9C,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,GAAG,mCAAI,CAAC,EACxB,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,MAAM,mCAAI,CAAC,CAC5B,CAAC;oBACJ,CAAC;oBACD,OAAO,yCAAK,CAAC;gBACf,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,KAAK,CAAC,kCAA2B,MAAA,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,0CAAE,IAAI,CAAE,CAAC,CAAC;gBAClF,CAAC;YACH,CAAC,CAAC,CACE;YACL,WAAW,CAAC,OAAO,IAAI,aAAa,CAAC,iBAAiB,CAAC,CACvD,CACJ,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,wBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC;IAClD,wBAAgB,CAAC,YAAY,GAAG;QAC9B,YAAY,EAAE,SAAS;KACxB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\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 { decodeBase64Fields } from '@fluentui/chart-utilities';\nimport type { Data, PlotData, PlotlySchema, OutputChartType, TraceInfo } from '@fluentui/chart-utilities';\nimport { isArrayOrTypedArray, isMonthArray, mapFluentChart, sanitizeJson } from '@fluentui/chart-utilities';\n\nimport type { GridProperties } from './PlotlySchemaAdapter';\nimport {\n correctYearMonth,\n getGridProperties,\n isNonPlotType,\n transformPlotlyJsonToDonutProps,\n transformPlotlyJsonToVSBCProps,\n transformPlotlyJsonToAreaChartProps,\n transformPlotlyJsonToLineChartProps,\n transformPlotlyJsonToHorizontalBarWithAxisProps,\n transformPlotlyJsonToHeatmapProps,\n transformPlotlyJsonToSankeyProps,\n transformPlotlyJsonToGaugeProps,\n transformPlotlyJsonToGVBCProps,\n transformPlotlyJsonToVBCProps,\n transformPlotlyJsonToChartTableProps,\n transformPlotlyJsonToScatterChartProps,\n projectPolarToCartesian,\n getAllupLegendsProps,\n NON_PLOT_KEY_PREFIX,\n SINGLE_REPEAT,\n} from './PlotlySchemaAdapter';\nimport type { ColorwayType } from './PlotlyColorAdapter';\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 { IChart, IImageExportOptions } from '../../types/index';\nimport { withResponsiveContainer } from '../ResponsiveContainer/withResponsiveContainer';\nimport { ScatterChart } from '../ScatterChart/index';\nimport { ChartTable } from '../ChartTable/index';\nimport { ILegendsProps, Legends } from '../Legends/index';\n\nconst ResponsiveDonutChart = withResponsiveContainer(DonutChart);\nconst ResponsiveVerticalStackedBarChart = withResponsiveContainer(VerticalStackedBarChart);\nconst ResponsiveLineChart = withResponsiveContainer(LineChart);\nconst ResponsiveHorizontalBarChartWithAxis = withResponsiveContainer(HorizontalBarChartWithAxis);\nconst ResponsiveAreaChart = withResponsiveContainer(AreaChart);\nconst ResponsiveHeatMapChart = withResponsiveContainer(HeatMapChart);\nconst ResponsiveSankeyChart = withResponsiveContainer(SankeyChart);\nconst ResponsiveGaugeChart = withResponsiveContainer(GaugeChart);\nconst ResponsiveGroupedVerticalBarChart = withResponsiveContainer(GroupedVerticalBarChart);\nconst ResponsiveVerticalBarChart = withResponsiveContainer(VerticalBarChart);\nconst ResponsiveScatterChart = withResponsiveContainer(ScatterChart);\nconst ResponsiveChartTable = withResponsiveContainer(ChartTable);\n\n// Default x-axis key for grouping traces. Also applicable for PieData and SankeyData where x-axis is not defined.\nconst DEFAULT_XAXIS = 'x';\nconst FALLBACK_TYPE = 'fallback';\n\n/**\n * DeclarativeChart schema.\n * {@docCategory DeclarativeChart}\n */\nexport interface Schema {\n /**\n * Plotly schema represented as JSON object\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\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 * Optional prop to specify the colorway type of the chart.\n * - 'default': Use Fluent UI color palette aligning with plotly colorway.\n * - 'builtin': Use Fluent UI colorway.\n * - 'others': Reserved for future colorways.\n * @default 'default'\n */\n colorwayType?: ColorwayType;\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\nfunction renderChart<TProps>(\n Renderer: React.ComponentType<TProps>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n transformer: (...args: any[]) => TProps,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n transformerArgs: any[],\n commonProps: Partial<TProps>,\n cellRow: number,\n cellColumn: number,\n): JSX.Element {\n const chartProps = transformer(...transformerArgs);\n return (\n <div\n key={`${cellRow}_${cellColumn}`}\n style={{\n gridRowStart: cellRow,\n gridRowEnd: cellRow + 1,\n gridColumnStart: cellColumn,\n gridColumnEnd: cellColumn + 1,\n }}\n >\n <Renderer {...chartProps} {...commonProps} />\n </div>\n );\n}\n\ntype PreTransformHooks = {\n preTransformCondition?: (plotlySchema: PlotlySchema) => boolean;\n preTransformOperation?: (plotlySchema: PlotlySchema) => PlotlySchema;\n};\n\nconst LineAreaPreTransformOp = (plotlyInput: PlotlySchema) => {\n const xValues = (plotlyInput.data[0] as PlotData).x;\n const isXMonth = isMonthArray(xValues);\n let renderData = plotlyInput.data;\n if (isXMonth) {\n renderData = plotlyInput.data.map((dataPoint: PlotData) => ({\n ...dataPoint,\n x: correctYearMonth(dataPoint.x),\n }));\n }\n return { data: renderData, layout: plotlyInput.layout };\n};\n\ntype ChartTypeMap = {\n donut: {\n transformer: typeof transformPlotlyJsonToDonutProps;\n renderer: typeof ResponsiveDonutChart;\n } & PreTransformHooks;\n sankey: {\n transformer: typeof transformPlotlyJsonToSankeyProps;\n renderer: typeof ResponsiveSankeyChart;\n } & PreTransformHooks;\n table: {\n transformer: typeof transformPlotlyJsonToChartTableProps;\n renderer: typeof ResponsiveChartTable;\n } & PreTransformHooks;\n horizontalbar: {\n transformer: typeof transformPlotlyJsonToHorizontalBarWithAxisProps;\n renderer: typeof ResponsiveHorizontalBarChartWithAxis;\n } & PreTransformHooks;\n groupedverticalbar: {\n transformer: typeof transformPlotlyJsonToGVBCProps;\n renderer: typeof ResponsiveGroupedVerticalBarChart;\n } & PreTransformHooks;\n verticalstackedbar: {\n transformer: typeof transformPlotlyJsonToVSBCProps;\n renderer: typeof ResponsiveVerticalStackedBarChart;\n } & PreTransformHooks;\n heatmap: {\n transformer: typeof transformPlotlyJsonToHeatmapProps;\n renderer: typeof ResponsiveHeatMapChart;\n } & PreTransformHooks;\n gauge: {\n transformer: typeof transformPlotlyJsonToGaugeProps;\n renderer: typeof ResponsiveGaugeChart;\n } & PreTransformHooks;\n verticalbar: {\n transformer: typeof transformPlotlyJsonToVBCProps;\n renderer: typeof ResponsiveVerticalBarChart;\n } & PreTransformHooks;\n area: {\n transformer: typeof transformPlotlyJsonToAreaChartProps;\n renderer: typeof ResponsiveAreaChart;\n } & PreTransformHooks;\n line: {\n transformer: typeof transformPlotlyJsonToLineChartProps;\n renderer: typeof ResponsiveLineChart;\n } & PreTransformHooks;\n scatter: {\n transformer: typeof transformPlotlyJsonToScatterChartProps;\n renderer: typeof ResponsiveScatterChart;\n } & PreTransformHooks;\n fallback: {\n transformer: typeof transformPlotlyJsonToVSBCProps;\n renderer: typeof ResponsiveVerticalStackedBarChart;\n } & PreTransformHooks;\n};\n\nconst chartMap: ChartTypeMap = {\n // PieData category charts\n donut: {\n transformer: transformPlotlyJsonToDonutProps,\n renderer: ResponsiveDonutChart,\n },\n // SankeyData category charts\n sankey: {\n transformer: transformPlotlyJsonToSankeyProps,\n renderer: ResponsiveSankeyChart,\n },\n // TableData category charts\n table: {\n transformer: transformPlotlyJsonToChartTableProps,\n renderer: ResponsiveChartTable,\n },\n // PlotData category charts\n horizontalbar: {\n transformer: transformPlotlyJsonToHorizontalBarWithAxisProps,\n renderer: ResponsiveHorizontalBarChartWithAxis,\n },\n groupedverticalbar: {\n transformer: transformPlotlyJsonToGVBCProps,\n renderer: ResponsiveGroupedVerticalBarChart,\n },\n verticalstackedbar: {\n transformer: transformPlotlyJsonToVSBCProps,\n renderer: ResponsiveVerticalStackedBarChart,\n },\n heatmap: {\n transformer: transformPlotlyJsonToHeatmapProps,\n renderer: ResponsiveHeatMapChart,\n },\n gauge: {\n transformer: transformPlotlyJsonToGaugeProps,\n renderer: ResponsiveGaugeChart,\n },\n verticalbar: {\n transformer: transformPlotlyJsonToVBCProps,\n renderer: ResponsiveVerticalBarChart,\n },\n area: {\n transformer: transformPlotlyJsonToAreaChartProps,\n renderer: ResponsiveAreaChart,\n preTransformOperation: LineAreaPreTransformOp,\n },\n line: {\n transformer: transformPlotlyJsonToLineChartProps,\n renderer: ResponsiveLineChart,\n preTransformOperation: LineAreaPreTransformOp,\n },\n scatter: {\n transformer: transformPlotlyJsonToScatterChartProps,\n renderer: ResponsiveScatterChart,\n preTransformOperation: LineAreaPreTransformOp,\n },\n fallback: {\n transformer: transformPlotlyJsonToVSBCProps,\n renderer: ResponsiveVerticalStackedBarChart,\n },\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 } = sanitizeJson(props.chartSchema);\n const chart: OutputChartType = mapFluentChart(plotlySchema);\n if (!chart.isValid) {\n throw new Error(`Invalid chart schema: ${chart.errorMessage}`);\n }\n let plotlyInput = plotlySchema as PlotlySchema;\n try {\n plotlyInput = decodeBase64Fields(plotlyInput);\n } catch (error) {\n throw new Error(`Failed to decode plotly schema: ${error}`);\n }\n const plotlyInputWithValidData: PlotlySchema = {\n ...plotlyInput,\n data: chart.validTracesInfo!.map(trace => plotlyInput.data[trace.index]),\n };\n\n const validTracesFilteredIndex: TraceInfo[] = chart.validTracesInfo!.map((trace, index) => ({\n index,\n type: trace.type,\n }));\n\n let { selectedLegends } = plotlySchema;\n const colorMap = useColorMapping();\n const theme = useTheme();\n const isDarkTheme = theme?.isInverted ?? false;\n const chartRef = React.useRef<IChart>(null);\n const isMultiPlot = React.useRef(false);\n\n if (!isArrayOrTypedArray(selectedLegends)) {\n selectedLegends = [];\n }\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: { plotlyInput, selectedLegends: keys } });\n }\n };\n\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { selectedLegends } = plotlySchema;\n setActiveLegends(selectedLegends ?? []);\n }, [props.chartSchema]);\n\n const multiSelectLegendProps = {\n canSelectMultipleLegends: true,\n onChange: onActiveLegendsChange,\n selectedLegends: activeLegends,\n };\n\n const commonProps = {\n legendProps: multiSelectLegendProps,\n componentRef: chartRef,\n calloutProps: { layerProps: { eventBubblingEnabled: true } },\n };\n\n function createLegends(legendProps: ILegendsProps): JSX.Element {\n // eslint-disable-next-line react/jsx-no-bind\n return <Legends {...legendProps} selectedLegends={activeLegends} onChange={onActiveLegendsChange} />;\n }\n\n const exportAsImage = React.useCallback(\n (opts?: IImageExportOptions): Promise<string> => {\n return new Promise((resolve, reject) => {\n if (isMultiPlot.current) {\n return reject(Error('Exporting multi plot charts as image is not supported'));\n }\n if (!chartRef.current || typeof chartRef.current.toImage !== 'function') {\n return reject(Error('Chart cannot be exported as image'));\n }\n\n chartRef.current\n .toImage({\n background: theme.semanticColors.bodyBackground,\n scale: 5,\n ...opts,\n })\n .then(resolve)\n .catch(reject);\n });\n },\n [theme],\n );\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n exportAsImage,\n }),\n [exportAsImage],\n );\n\n if (chart.type === 'scatterpolar') {\n const cartesianProjection = projectPolarToCartesian(plotlyInputWithValidData);\n plotlyInputWithValidData.data = cartesianProjection.data;\n validTracesFilteredIndex.forEach((trace, index) => {\n if (trace.type === 'scatterpolar') {\n validTracesFilteredIndex[index].type = 'line'; // Change type to line for rendering\n }\n });\n }\n\n const groupedTraces: Record<string, number[]> = {};\n let nonCartesianTraceCount = 0;\n plotlyInputWithValidData.data.forEach((trace: Data, index: number) => {\n let traceKey = '';\n if (isNonPlotType(chart.validTracesInfo![index].type)) {\n traceKey = `${NON_PLOT_KEY_PREFIX}${nonCartesianTraceCount + 1}`;\n nonCartesianTraceCount++;\n } else {\n traceKey = (trace as PlotData).xaxis ?? DEFAULT_XAXIS;\n }\n if (!groupedTraces[traceKey]) {\n groupedTraces[traceKey] = [];\n }\n groupedTraces[traceKey].push(index);\n });\n\n isMultiPlot.current = Object.keys(groupedTraces).length > 1;\n const gridProperties: GridProperties = getGridProperties(\n plotlyInputWithValidData,\n isMultiPlot.current,\n chart.validTracesInfo!,\n );\n\n // Render only one plot if the grid properties cannot determine positioning of multiple plots.\n if (\n isMultiPlot.current &&\n gridProperties.templateRows === SINGLE_REPEAT &&\n gridProperties.templateColumns === SINGLE_REPEAT\n ) {\n Object.keys(groupedTraces).forEach((key, index) => {\n if (index > 0) {\n delete groupedTraces[key];\n }\n });\n isMultiPlot.current = false;\n }\n\n const allupLegendsProps = getAllupLegendsProps(\n plotlyInputWithValidData,\n colorMap,\n props.colorwayType,\n chart.validTracesInfo!,\n isDarkTheme,\n );\n\n type ChartType = keyof ChartTypeMap;\n // map through the grouped traces and render the appropriate chart\n return (\n <>\n <div\n style={{\n display: 'grid',\n gridTemplateRows: gridProperties.templateRows,\n gridTemplateColumns: gridProperties.templateColumns,\n }}\n >\n {Object.entries(groupedTraces).map(([xAxisKey, index]) => {\n const plotlyInputForGroup: PlotlySchema = {\n ...plotlyInputWithValidData,\n data: index.map(idx => plotlyInputWithValidData.data[idx]),\n };\n\n const filteredTracesInfo = validTracesFilteredIndex.filter(trace => index.includes(trace.index));\n let chartType =\n validTracesFilteredIndex.some(trace => trace.type === FALLBACK_TYPE) || chart.type === FALLBACK_TYPE\n ? FALLBACK_TYPE\n : filteredTracesInfo[0].type;\n\n if (\n validTracesFilteredIndex.some(trace => trace.type === 'line') &&\n validTracesFilteredIndex.some(trace => trace.type === 'scatter')\n ) {\n chartType = 'line';\n }\n\n const chartEntry = chartMap[chartType as ChartType];\n if (chartEntry) {\n const { transformer, renderer, preTransformCondition, preTransformOperation } = chartEntry;\n if (preTransformCondition === undefined || preTransformCondition(plotlyInputForGroup)) {\n const transformedInput = preTransformOperation\n ? preTransformOperation(plotlyInputForGroup)\n : plotlyInputForGroup;\n const cellProperties = gridProperties.layout[xAxisKey];\n\n return renderChart<ReturnType<typeof transformer>>(\n renderer,\n transformer,\n [transformedInput, isMultiPlot.current, colorMap, props.colorwayType, isDarkTheme],\n {\n ...commonProps,\n xAxisAnnotation: cellProperties?.xAnnotation,\n yAxisAnnotation: cellProperties?.yAnnotation,\n },\n cellProperties?.row ?? 1,\n cellProperties?.column ?? 1,\n );\n }\n return <></>;\n } else {\n throw new Error(`Unsupported chart type :${plotlyInputForGroup.data[0]?.type}`);\n }\n })}\n </div>\n {isMultiPlot.current && createLegends(allupLegendsProps)}\n </>\n );\n});\nDeclarativeChart.displayName = 'DeclarativeChart';\nDeclarativeChart.defaultProps = {\n colorwayType: 'default',\n};\n"]}
1
+ {"version":3,"file":"DeclarativeChart.js","sourceRoot":"../src/","sources":["components/DeclarativeChart/DeclarativeChart.tsx"],"names":[],"mappings":";;;;IAiDA,IAAM,oBAAoB,GAAG,IAAA,iDAAuB,EAAC,kBAAU,CAAC,CAAC;IACjE,IAAM,iCAAiC,GAAG,IAAA,iDAAuB,EAAC,+BAAuB,CAAC,CAAC;IAC3F,IAAM,mBAAmB,GAAG,IAAA,iDAAuB,EAAC,iBAAS,CAAC,CAAC;IAC/D,IAAM,oCAAoC,GAAG,IAAA,iDAAuB,EAAC,kCAA0B,CAAC,CAAC;IACjG,IAAM,mBAAmB,GAAG,IAAA,iDAAuB,EAAC,iBAAS,CAAC,CAAC;IAC/D,IAAM,sBAAsB,GAAG,IAAA,iDAAuB,EAAC,oBAAY,CAAC,CAAC;IACrE,IAAM,qBAAqB,GAAG,IAAA,iDAAuB,EAAC,yBAAW,CAAC,CAAC;I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,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;wBAEvD,OAAO,WAAW,CAChB,QAAQ,EACR,WAAW,EACX,CAAC,gBAAgB,EAAE,WAAW,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,YAAY,EAAE,WAAW,CAAC,wCAE7E,WAAW,KACd,eAAe,EAAE,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,WAAW,EAC5C,eAAe,EAAE,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,WAAW,KAE9C,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,GAAG,mCAAI,CAAC,EACxB,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,MAAM,mCAAI,CAAC,CAC5B,CAAC;oBACJ,CAAC;oBACD,OAAO,yCAAK,CAAC;gBACf,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,KAAK,CAAC,kCAA2B,MAAA,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,0CAAE,IAAI,CAAE,CAAC,CAAC;gBAClF,CAAC;YACH,CAAC,CAAC,CACE;YACL,WAAW,CAAC,OAAO,IAAI,aAAa,CAAC,iBAAiB,CAAC,CACvD,CACJ,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,wBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC;IAClD,wBAAgB,CAAC,YAAY,GAAG;QAC9B,YAAY,EAAE,SAAS;KACxB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\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 { decodeBase64Fields } from '@fluentui/chart-utilities';\nimport type { Data, PlotData, PlotlySchema, OutputChartType, TraceInfo } from '@fluentui/chart-utilities';\nimport { isArrayOrTypedArray, isMonthArray, mapFluentChart, sanitizeJson } from '@fluentui/chart-utilities';\n\nimport type { GridProperties } from './PlotlySchemaAdapter';\nimport {\n correctYearMonth,\n getGridProperties,\n isNonPlotType,\n transformPlotlyJsonToDonutProps,\n transformPlotlyJsonToVSBCProps,\n transformPlotlyJsonToAreaChartProps,\n transformPlotlyJsonToLineChartProps,\n transformPlotlyJsonToHorizontalBarWithAxisProps,\n transformPlotlyJsonToHeatmapProps,\n transformPlotlyJsonToSankeyProps,\n transformPlotlyJsonToGaugeProps,\n transformPlotlyJsonToGVBCProps,\n transformPlotlyJsonToVBCProps,\n transformPlotlyJsonToChartTableProps,\n transformPlotlyJsonToScatterChartProps,\n projectPolarToCartesian,\n getAllupLegendsProps,\n NON_PLOT_KEY_PREFIX,\n SINGLE_REPEAT,\n transformPlotlyJsonToFunnelChartProps,\n} from './PlotlySchemaAdapter';\nimport type { ColorwayType } from './PlotlyColorAdapter';\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 { IChart, IImageExportOptions } from '../../types/index';\nimport { withResponsiveContainer } from '../ResponsiveContainer/withResponsiveContainer';\nimport { ScatterChart } from '../ScatterChart/index';\nimport { ChartTable } from '../ChartTable/index';\nimport { FunnelChart } from '../FunnelChart/FunnelChart';\nimport { ILegendsProps, Legends } from '../Legends/index';\n\nconst ResponsiveDonutChart = withResponsiveContainer(DonutChart);\nconst ResponsiveVerticalStackedBarChart = withResponsiveContainer(VerticalStackedBarChart);\nconst ResponsiveLineChart = withResponsiveContainer(LineChart);\nconst ResponsiveHorizontalBarChartWithAxis = withResponsiveContainer(HorizontalBarChartWithAxis);\nconst ResponsiveAreaChart = withResponsiveContainer(AreaChart);\nconst ResponsiveHeatMapChart = withResponsiveContainer(HeatMapChart);\nconst ResponsiveSankeyChart = withResponsiveContainer(SankeyChart);\nconst ResponsiveGaugeChart = withResponsiveContainer(GaugeChart);\nconst ResponsiveGroupedVerticalBarChart = withResponsiveContainer(GroupedVerticalBarChart);\nconst ResponsiveVerticalBarChart = withResponsiveContainer(VerticalBarChart);\nconst ResponsiveScatterChart = withResponsiveContainer(ScatterChart);\nconst ResponsiveChartTable = withResponsiveContainer(ChartTable);\nconst ResponsiveFunnelChart = withResponsiveContainer(FunnelChart);\n\n// Default x-axis key for grouping traces. Also applicable for PieData and SankeyData where x-axis is not defined.\nconst DEFAULT_XAXIS = 'x';\nconst FALLBACK_TYPE = 'fallback';\n\n/**\n * DeclarativeChart schema.\n * {@docCategory DeclarativeChart}\n */\nexport interface Schema {\n /**\n * Plotly schema represented as JSON object\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\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 * Optional prop to specify the colorway type of the chart.\n * - 'default': Use Fluent UI color palette aligning with plotly colorway.\n * - 'builtin': Use Fluent UI colorway.\n * - 'others': Reserved for future colorways.\n * @default 'default'\n */\n colorwayType?: ColorwayType;\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\nfunction renderChart<TProps>(\n Renderer: React.ComponentType<TProps>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n transformer: (...args: any[]) => TProps,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n transformerArgs: any[],\n commonProps: Partial<TProps>,\n cellRow: number,\n cellColumn: number,\n): JSX.Element {\n const chartProps = transformer(...transformerArgs);\n return (\n <div\n key={`${cellRow}_${cellColumn}`}\n style={{\n gridRowStart: cellRow,\n gridRowEnd: cellRow + 1,\n gridColumnStart: cellColumn,\n gridColumnEnd: cellColumn + 1,\n }}\n >\n <Renderer {...chartProps} {...commonProps} />\n </div>\n );\n}\n\ntype PreTransformHooks = {\n preTransformCondition?: (plotlySchema: PlotlySchema) => boolean;\n preTransformOperation?: (plotlySchema: PlotlySchema) => PlotlySchema;\n};\n\nconst LineAreaPreTransformOp = (plotlyInput: PlotlySchema) => {\n const xValues = (plotlyInput.data[0] as PlotData).x;\n const isXMonth = isMonthArray(xValues);\n let renderData = plotlyInput.data;\n if (isXMonth) {\n renderData = plotlyInput.data.map((dataPoint: PlotData) => ({\n ...dataPoint,\n x: correctYearMonth(dataPoint.x),\n }));\n }\n return { data: renderData, layout: plotlyInput.layout };\n};\n\ntype ChartTypeMap = {\n donut: {\n transformer: typeof transformPlotlyJsonToDonutProps;\n renderer: typeof ResponsiveDonutChart;\n } & PreTransformHooks;\n sankey: {\n transformer: typeof transformPlotlyJsonToSankeyProps;\n renderer: typeof ResponsiveSankeyChart;\n } & PreTransformHooks;\n table: {\n transformer: typeof transformPlotlyJsonToChartTableProps;\n renderer: typeof ResponsiveChartTable;\n } & PreTransformHooks;\n horizontalbar: {\n transformer: typeof transformPlotlyJsonToHorizontalBarWithAxisProps;\n renderer: typeof ResponsiveHorizontalBarChartWithAxis;\n } & PreTransformHooks;\n groupedverticalbar: {\n transformer: typeof transformPlotlyJsonToGVBCProps;\n renderer: typeof ResponsiveGroupedVerticalBarChart;\n } & PreTransformHooks;\n verticalstackedbar: {\n transformer: typeof transformPlotlyJsonToVSBCProps;\n renderer: typeof ResponsiveVerticalStackedBarChart;\n } & PreTransformHooks;\n heatmap: {\n transformer: typeof transformPlotlyJsonToHeatmapProps;\n renderer: typeof ResponsiveHeatMapChart;\n } & PreTransformHooks;\n gauge: {\n transformer: typeof transformPlotlyJsonToGaugeProps;\n renderer: typeof ResponsiveGaugeChart;\n } & PreTransformHooks;\n verticalbar: {\n transformer: typeof transformPlotlyJsonToVBCProps;\n renderer: typeof ResponsiveVerticalBarChart;\n } & PreTransformHooks;\n area: {\n transformer: typeof transformPlotlyJsonToAreaChartProps;\n renderer: typeof ResponsiveAreaChart;\n } & PreTransformHooks;\n line: {\n transformer: typeof transformPlotlyJsonToLineChartProps;\n renderer: typeof ResponsiveLineChart;\n } & PreTransformHooks;\n scatter: {\n transformer: typeof transformPlotlyJsonToScatterChartProps;\n renderer: typeof ResponsiveScatterChart;\n } & PreTransformHooks;\n funnel: {\n transformer: typeof transformPlotlyJsonToFunnelChartProps;\n renderer: typeof ResponsiveFunnelChart;\n } & PreTransformHooks;\n fallback: {\n transformer: typeof transformPlotlyJsonToVSBCProps;\n renderer: typeof ResponsiveVerticalStackedBarChart;\n } & PreTransformHooks;\n};\n\nconst chartMap: ChartTypeMap = {\n // PieData category charts\n donut: {\n transformer: transformPlotlyJsonToDonutProps,\n renderer: ResponsiveDonutChart,\n },\n // SankeyData category charts\n sankey: {\n transformer: transformPlotlyJsonToSankeyProps,\n renderer: ResponsiveSankeyChart,\n },\n // TableData category charts\n table: {\n transformer: transformPlotlyJsonToChartTableProps,\n renderer: ResponsiveChartTable,\n },\n // PlotData category charts\n horizontalbar: {\n transformer: transformPlotlyJsonToHorizontalBarWithAxisProps,\n renderer: ResponsiveHorizontalBarChartWithAxis,\n },\n groupedverticalbar: {\n transformer: transformPlotlyJsonToGVBCProps,\n renderer: ResponsiveGroupedVerticalBarChart,\n },\n verticalstackedbar: {\n transformer: transformPlotlyJsonToVSBCProps,\n renderer: ResponsiveVerticalStackedBarChart,\n },\n heatmap: {\n transformer: transformPlotlyJsonToHeatmapProps,\n renderer: ResponsiveHeatMapChart,\n },\n gauge: {\n transformer: transformPlotlyJsonToGaugeProps,\n renderer: ResponsiveGaugeChart,\n },\n verticalbar: {\n transformer: transformPlotlyJsonToVBCProps,\n renderer: ResponsiveVerticalBarChart,\n },\n area: {\n transformer: transformPlotlyJsonToAreaChartProps,\n renderer: ResponsiveAreaChart,\n preTransformOperation: LineAreaPreTransformOp,\n },\n line: {\n transformer: transformPlotlyJsonToLineChartProps,\n renderer: ResponsiveLineChart,\n preTransformOperation: LineAreaPreTransformOp,\n },\n scatter: {\n transformer: transformPlotlyJsonToScatterChartProps,\n renderer: ResponsiveScatterChart,\n preTransformOperation: LineAreaPreTransformOp,\n },\n funnel: {\n transformer: transformPlotlyJsonToFunnelChartProps,\n renderer: ResponsiveFunnelChart,\n },\n fallback: {\n transformer: transformPlotlyJsonToVSBCProps,\n renderer: ResponsiveVerticalStackedBarChart,\n },\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 } = sanitizeJson(props.chartSchema);\n const chart: OutputChartType = mapFluentChart(plotlySchema);\n if (!chart.isValid) {\n throw new Error(`Invalid chart schema: ${chart.errorMessage}`);\n }\n let plotlyInput = plotlySchema as PlotlySchema;\n try {\n plotlyInput = decodeBase64Fields(plotlyInput);\n } catch (error) {\n throw new Error(`Failed to decode plotly schema: ${error}`);\n }\n const plotlyInputWithValidData: PlotlySchema = {\n ...plotlyInput,\n data: chart.validTracesInfo!.map(trace => plotlyInput.data[trace.index]),\n };\n\n const validTracesFilteredIndex: TraceInfo[] = chart.validTracesInfo!.map((trace, index) => ({\n index,\n type: trace.type,\n }));\n\n let { selectedLegends } = plotlySchema;\n const colorMap = useColorMapping();\n const theme = useTheme();\n const isDarkTheme = theme?.isInverted ?? false;\n const chartRef = React.useRef<IChart>(null);\n const isMultiPlot = React.useRef(false);\n\n if (!isArrayOrTypedArray(selectedLegends)) {\n selectedLegends = [];\n }\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: { plotlyInput, selectedLegends: keys } });\n }\n };\n\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { selectedLegends } = plotlySchema;\n setActiveLegends(selectedLegends ?? []);\n }, [props.chartSchema]);\n\n const multiSelectLegendProps = {\n canSelectMultipleLegends: true,\n onChange: onActiveLegendsChange,\n selectedLegends: activeLegends,\n };\n\n const commonProps = {\n legendProps: multiSelectLegendProps,\n componentRef: chartRef,\n calloutProps: { layerProps: { eventBubblingEnabled: true } },\n };\n\n function createLegends(legendProps: ILegendsProps): JSX.Element {\n // eslint-disable-next-line react/jsx-no-bind\n return <Legends {...legendProps} selectedLegends={activeLegends} onChange={onActiveLegendsChange} />;\n }\n\n const exportAsImage = React.useCallback(\n (opts?: IImageExportOptions): Promise<string> => {\n return new Promise((resolve, reject) => {\n if (isMultiPlot.current) {\n return reject(Error('Exporting multi plot charts as image is not supported'));\n }\n if (!chartRef.current || typeof chartRef.current.toImage !== 'function') {\n return reject(Error('Chart cannot be exported as image'));\n }\n\n chartRef.current\n .toImage({\n background: theme.semanticColors.bodyBackground,\n scale: 5,\n ...opts,\n })\n .then(resolve)\n .catch(reject);\n });\n },\n [theme],\n );\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n exportAsImage,\n }),\n [exportAsImage],\n );\n\n if (chart.type === 'scatterpolar') {\n const cartesianProjection = projectPolarToCartesian(plotlyInputWithValidData);\n plotlyInputWithValidData.data = cartesianProjection.data;\n validTracesFilteredIndex.forEach((trace, index) => {\n if (trace.type === 'scatterpolar') {\n validTracesFilteredIndex[index].type = 'line'; // Change type to line for rendering\n }\n });\n }\n\n const groupedTraces: Record<string, number[]> = {};\n let nonCartesianTraceCount = 0;\n plotlyInputWithValidData.data.forEach((trace: Data, index: number) => {\n let traceKey = '';\n if (isNonPlotType(chart.validTracesInfo![index].type)) {\n traceKey = `${NON_PLOT_KEY_PREFIX}${nonCartesianTraceCount + 1}`;\n nonCartesianTraceCount++;\n } else {\n traceKey = (trace as PlotData).xaxis ?? DEFAULT_XAXIS;\n }\n if (!groupedTraces[traceKey]) {\n groupedTraces[traceKey] = [];\n }\n groupedTraces[traceKey].push(index);\n });\n\n isMultiPlot.current = Object.keys(groupedTraces).length > 1;\n const gridProperties: GridProperties = getGridProperties(\n plotlyInputWithValidData,\n isMultiPlot.current,\n chart.validTracesInfo!,\n );\n\n // Render only one plot if the grid properties cannot determine positioning of multiple plots.\n if (\n isMultiPlot.current &&\n gridProperties.templateRows === SINGLE_REPEAT &&\n gridProperties.templateColumns === SINGLE_REPEAT\n ) {\n Object.keys(groupedTraces).forEach((key, index) => {\n if (index > 0) {\n delete groupedTraces[key];\n }\n });\n isMultiPlot.current = false;\n }\n\n const allupLegendsProps = getAllupLegendsProps(\n plotlyInputWithValidData,\n colorMap,\n props.colorwayType,\n chart.validTracesInfo!,\n isDarkTheme,\n );\n\n type ChartType = keyof ChartTypeMap;\n // map through the grouped traces and render the appropriate chart\n return (\n <>\n <div\n style={{\n display: 'grid',\n gridTemplateRows: gridProperties.templateRows,\n gridTemplateColumns: gridProperties.templateColumns,\n }}\n >\n {Object.entries(groupedTraces).map(([xAxisKey, index]) => {\n const plotlyInputForGroup: PlotlySchema = {\n ...plotlyInputWithValidData,\n data: index.map(idx => plotlyInputWithValidData.data[idx]),\n };\n\n const filteredTracesInfo = validTracesFilteredIndex.filter(trace => index.includes(trace.index));\n let chartType =\n validTracesFilteredIndex.some(trace => trace.type === FALLBACK_TYPE) || chart.type === FALLBACK_TYPE\n ? FALLBACK_TYPE\n : filteredTracesInfo[0].type;\n\n if (\n validTracesFilteredIndex.some(trace => trace.type === 'line') &&\n validTracesFilteredIndex.some(trace => trace.type === 'scatter')\n ) {\n chartType = 'line';\n }\n\n const chartEntry = chartMap[chartType as ChartType];\n if (chartEntry) {\n const { transformer, renderer, preTransformCondition, preTransformOperation } = chartEntry;\n if (preTransformCondition === undefined || preTransformCondition(plotlyInputForGroup)) {\n const transformedInput = preTransformOperation\n ? preTransformOperation(plotlyInputForGroup)\n : plotlyInputForGroup;\n const cellProperties = gridProperties.layout[xAxisKey];\n\n return renderChart<ReturnType<typeof transformer>>(\n renderer,\n transformer,\n [transformedInput, isMultiPlot.current, colorMap, props.colorwayType, isDarkTheme],\n {\n ...commonProps,\n xAxisAnnotation: cellProperties?.xAnnotation,\n yAxisAnnotation: cellProperties?.yAnnotation,\n },\n cellProperties?.row ?? 1,\n cellProperties?.column ?? 1,\n );\n }\n return <></>;\n } else {\n throw new Error(`Unsupported chart type :${plotlyInputForGroup.data[0]?.type}`);\n }\n })}\n </div>\n {isMultiPlot.current && createLegends(allupLegendsProps)}\n </>\n );\n});\nDeclarativeChart.displayName = 'DeclarativeChart';\nDeclarativeChart.defaultProps = {\n colorwayType: 'default',\n};\n"]}
@@ -12,6 +12,7 @@ import { IVerticalBarChartProps } from '../VerticalBarChart/index';
12
12
  import { IChartTableProps } from '../ChartTable/index';
13
13
  import type { Datum, PlotlySchema, PlotData, TypedArray, Color, TraceInfo } from '@fluentui/chart-utilities';
14
14
  import type { ColorwayType } from './PlotlyColorAdapter';
15
+ import { IFunnelChartProps } from '../FunnelChart/FunnelChart.types';
15
16
  import { ILegendsProps } from '../Legends/index';
16
17
  export declare const NON_PLOT_KEY_PREFIX = "nonplot_";
17
18
  export declare const SINGLE_REPEAT = "repeat(1, 1fr)";
@@ -48,6 +49,7 @@ export declare const transformPlotlyJsonToHeatmapProps: (input: PlotlySchema, is
48
49
  export declare const transformPlotlyJsonToSankeyProps: (input: PlotlySchema, isMultiPlot: boolean, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, isDarkTheme?: boolean) => ISankeyChartProps;
49
50
  export declare const transformPlotlyJsonToGaugeProps: (input: PlotlySchema, isMultiPlot: boolean, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, isDarkTheme?: boolean) => IGaugeChartProps;
50
51
  export declare const transformPlotlyJsonToChartTableProps: (input: PlotlySchema, isMultiPlot: boolean, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, isDarkTheme?: boolean) => IChartTableProps;
52
+ export declare const transformPlotlyJsonToFunnelChartProps: (input: PlotlySchema, isMultiPlot: boolean, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, isDarkTheme?: boolean) => IFunnelChartProps;
51
53
  export declare const projectPolarToCartesian: (input: PlotlySchema) => PlotlySchema;
52
54
  /**
53
55
  * Interate iteratively through the trace object and find all the array attributes.
@@ -1,7 +1,7 @@
1
1
  define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../../utilities/colors", "../GaugeChart/index", "../../utilities/utilities", "@fluentui/chart-utilities", "d3-shape", "./PlotlyColorAdapter", "d3-color"], function (require, exports, tslib_1, d3_array_1, d3_scale_1, d3_format_1, colors_1, index_1, utilities_1, chart_utilities_1, d3_shape_1, PlotlyColorAdapter_1, d3_color_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getGridProperties = exports.isNonPlotType = exports.getValidXYRanges = exports.getNumberAtIndexOrDefault = exports.getAllupLegendsProps = exports.findArrayAttributes = exports.projectPolarToCartesian = exports.transformPlotlyJsonToChartTableProps = exports.transformPlotlyJsonToGaugeProps = exports.transformPlotlyJsonToSankeyProps = exports.transformPlotlyJsonToHeatmapProps = exports.transformPlotlyJsonToHorizontalBarWithAxisProps = exports.transformPlotlyJsonToScatterChartProps = exports.transformPlotlyJsonToLineChartProps = exports.transformPlotlyJsonToAreaChartProps = exports.transformPlotlyJsonToVBCProps = exports.transformPlotlyJsonToGVBCProps = exports.transformPlotlyJsonToVSBCProps = exports.transformPlotlyJsonToDonutProps = exports.resolveXAxisPoint = exports._getGaugeAxisColor = exports.correctYearMonth = exports.SINGLE_REPEAT = exports.NON_PLOT_KEY_PREFIX = void 0;
4
+ exports.getGridProperties = exports.isNonPlotType = exports.getValidXYRanges = exports.getNumberAtIndexOrDefault = exports.getAllupLegendsProps = exports.findArrayAttributes = exports.projectPolarToCartesian = exports.transformPlotlyJsonToFunnelChartProps = exports.transformPlotlyJsonToChartTableProps = exports.transformPlotlyJsonToGaugeProps = exports.transformPlotlyJsonToSankeyProps = exports.transformPlotlyJsonToHeatmapProps = exports.transformPlotlyJsonToHorizontalBarWithAxisProps = exports.transformPlotlyJsonToScatterChartProps = exports.transformPlotlyJsonToLineChartProps = exports.transformPlotlyJsonToAreaChartProps = exports.transformPlotlyJsonToVBCProps = exports.transformPlotlyJsonToGVBCProps = exports.transformPlotlyJsonToVSBCProps = exports.transformPlotlyJsonToDonutProps = exports.resolveXAxisPoint = exports._getGaugeAxisColor = exports.correctYearMonth = exports.SINGLE_REPEAT = exports.NON_PLOT_KEY_PREFIX = void 0;
5
5
  exports.NON_PLOT_KEY_PREFIX = 'nonplot_';
6
6
  exports.SINGLE_REPEAT = 'repeat(1, 1fr)';
7
7
  var dashOptions = {
@@ -991,6 +991,127 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
991
991
  };
992
992
  };
993
993
  exports.transformPlotlyJsonToChartTableProps = transformPlotlyJsonToChartTableProps;
994
+ function getCategoriesAndValues(series) {
995
+ var _a, _b, _c, _d;
996
+ var orientation = series.orientation || 'h';
997
+ var y = (_b = (_a = series.labels) !== null && _a !== void 0 ? _a : series.y) !== null && _b !== void 0 ? _b : series.stage;
998
+ var x = (_d = (_c = series.values) !== null && _c !== void 0 ? _c : series.x) !== null && _d !== void 0 ? _d : series.value;
999
+ var xIsString = (0, chart_utilities_1.isStringArray)(x);
1000
+ var yIsString = (0, chart_utilities_1.isStringArray)(y);
1001
+ var xIsNumber = (0, chart_utilities_1.isNumberArray)(x);
1002
+ var yIsNumber = (0, chart_utilities_1.isNumberArray)(y);
1003
+ // Helper to ensure array of (string | number)
1004
+ var toArray = function (arr) {
1005
+ if (Array.isArray(arr)) {
1006
+ return arr;
1007
+ }
1008
+ if (typeof arr === 'string' || typeof arr === 'number') {
1009
+ return [arr];
1010
+ }
1011
+ return [];
1012
+ };
1013
+ if (orientation === 'h') {
1014
+ if (yIsString && xIsNumber) {
1015
+ return { categories: toArray(y), values: toArray(x) };
1016
+ }
1017
+ else if (xIsString && yIsNumber) {
1018
+ return { categories: toArray(x), values: toArray(y) };
1019
+ }
1020
+ else {
1021
+ return { categories: yIsString ? toArray(y) : toArray(x), values: yIsString ? toArray(x) : toArray(y) };
1022
+ }
1023
+ }
1024
+ else {
1025
+ if (xIsString && yIsNumber) {
1026
+ return { categories: toArray(x), values: toArray(y) };
1027
+ }
1028
+ else if (yIsString && xIsNumber) {
1029
+ return { categories: toArray(y), values: toArray(x) };
1030
+ }
1031
+ else {
1032
+ return { categories: xIsString ? toArray(x) : toArray(y), values: xIsString ? toArray(y) : toArray(x) };
1033
+ }
1034
+ }
1035
+ }
1036
+ var transformPlotlyJsonToFunnelChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
1037
+ var _a, _b, _c, _d;
1038
+ var funnelData = [];
1039
+ // Determine if data is stacked based on multiple series with multiple values per series
1040
+ var isStacked = input.data.length > 1 &&
1041
+ input.data.every(function (series) {
1042
+ var _a, _b, _c, _d;
1043
+ var values = (_b = (_a = series.values) !== null && _a !== void 0 ? _a : series.x) !== null && _b !== void 0 ? _b : series.value;
1044
+ var labels = (_d = (_c = series.labels) !== null && _c !== void 0 ? _c : series.y) !== null && _d !== void 0 ? _d : series.stage;
1045
+ return Array.isArray(labels) && Array.isArray(values) && values.length > 1 && labels.length > 1;
1046
+ });
1047
+ if (isStacked) {
1048
+ // Assign a color per series/category and use it for all subValues of that category
1049
+ var seriesColors_1 = {};
1050
+ input.data.forEach(function (series, seriesIdx) {
1051
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1052
+ var category = series.name || "Category ".concat(seriesIdx + 1);
1053
+ // Use the same color for this category across all stages
1054
+ var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.template) === null || _b === void 0 ? void 0 : _b.layout) === null || _c === void 0 ? void 0 : _c.colorway, colorwayType, (_e = (_d = series.marker) === null || _d === void 0 ? void 0 : _d.colors) !== null && _e !== void 0 ? _e : (_f = series.marker) === null || _f === void 0 ? void 0 : _f.color, colorMap, isDarkTheme);
1055
+ // Always use the first color for the series/category
1056
+ var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, 0, category, colorMap, isDarkTheme);
1057
+ seriesColors_1[category] = color;
1058
+ var labels = (_h = (_g = series.labels) !== null && _g !== void 0 ? _g : series.y) !== null && _h !== void 0 ? _h : series.stage;
1059
+ var values = (_k = (_j = series.values) !== null && _j !== void 0 ? _j : series.x) !== null && _k !== void 0 ? _k : series.value;
1060
+ if (!(0, chart_utilities_1.isArrayOrTypedArray)(labels) || !(0, chart_utilities_1.isArrayOrTypedArray)(values)) {
1061
+ return;
1062
+ }
1063
+ if (labels && (0, chart_utilities_1.isArrayOrTypedArray)(labels) && labels.length > 0) {
1064
+ labels.forEach(function (label, i) {
1065
+ var stageIndex = funnelData.findIndex(function (stage) { return stage.stage === label; });
1066
+ var valueNum = Number(values[i]);
1067
+ if (isNaN(valueNum)) {
1068
+ return;
1069
+ }
1070
+ if (stageIndex === -1) {
1071
+ funnelData.push({
1072
+ stage: label,
1073
+ subValues: [{ category: category, value: valueNum, color: color }],
1074
+ });
1075
+ }
1076
+ else {
1077
+ funnelData[stageIndex].subValues.push({ category: category, value: valueNum, color: color });
1078
+ }
1079
+ });
1080
+ }
1081
+ });
1082
+ }
1083
+ else {
1084
+ // Non-stacked data handling (multiple series with single-value arrays)
1085
+ input.data.forEach(function (series, seriesIdx) {
1086
+ var _a, _b, _c, _d, _e, _f;
1087
+ var _g = getCategoriesAndValues(series), categories = _g.categories, values = _g.values;
1088
+ if (!(0, chart_utilities_1.isArrayOrTypedArray)(categories) || !(0, chart_utilities_1.isArrayOrTypedArray)(values)) {
1089
+ return;
1090
+ }
1091
+ var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.template) === null || _b === void 0 ? void 0 : _b.layout) === null || _c === void 0 ? void 0 : _c.colorway, colorwayType, (_e = (_d = series.marker) === null || _d === void 0 ? void 0 : _d.colors) !== null && _e !== void 0 ? _e : (_f = series.marker) === null || _f === void 0 ? void 0 : _f.color, colorMap, isDarkTheme);
1092
+ categories.forEach(function (label, i) {
1093
+ var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, i, label, colorMap, isDarkTheme);
1094
+ var valueNum = Number(values[i]);
1095
+ if (isNaN(valueNum)) {
1096
+ return;
1097
+ }
1098
+ funnelData.push({
1099
+ stage: label,
1100
+ value: valueNum,
1101
+ color: color,
1102
+ });
1103
+ });
1104
+ });
1105
+ }
1106
+ return {
1107
+ data: funnelData,
1108
+ width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width,
1109
+ height: (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height,
1110
+ orientation: ((_c = input.data[0]) === null || _c === void 0 ? void 0 : _c.orientation) === 'v' ? 'vertical' : 'horizontal',
1111
+ hideLegend: isMultiPlot || ((_d = input.layout) === null || _d === void 0 ? void 0 : _d.showlegend) === false,
1112
+ };
1113
+ };
1114
+ exports.transformPlotlyJsonToFunnelChartProps = transformPlotlyJsonToFunnelChartProps;
994
1115
  var projectPolarToCartesian = function (input) {
995
1116
  var _a, _b, _c, _d;
996
1117
  var projection = tslib_1.__assign({}, input);