@fluentui/react-charting 5.23.87 → 5.23.89

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 (104) hide show
  1. package/CHANGELOG.json +79 -1
  2. package/CHANGELOG.md +28 -2
  3. package/dist/react-charting.d.ts +72 -3
  4. package/dist/react-charting.js +1 -1
  5. package/dist/react-charting.min.js +1 -1
  6. package/etc/react-charting.api.md +37 -1
  7. package/lib/ChartTable.d.ts +1 -0
  8. package/lib/ChartTable.js +2 -0
  9. package/lib/ChartTable.js.map +1 -0
  10. package/lib/components/ChartTable/ChartTable.base.d.ts +10 -0
  11. package/lib/components/ChartTable/ChartTable.base.js +44 -0
  12. package/lib/components/ChartTable/ChartTable.base.js.map +1 -0
  13. package/lib/components/ChartTable/ChartTable.d.ts +7 -0
  14. package/lib/components/ChartTable/ChartTable.js +9 -0
  15. package/lib/components/ChartTable/ChartTable.js.map +1 -0
  16. package/lib/components/ChartTable/ChartTable.styles.d.ts +2 -0
  17. package/lib/components/ChartTable/ChartTable.styles.js +28 -0
  18. package/lib/components/ChartTable/ChartTable.styles.js.map +1 -0
  19. package/lib/components/ChartTable/ChartTable.types.d.ts +58 -0
  20. package/lib/components/ChartTable/ChartTable.types.js +2 -0
  21. package/lib/components/ChartTable/ChartTable.types.js.map +1 -0
  22. package/lib/components/ChartTable/index.d.ts +2 -0
  23. package/lib/components/ChartTable/index.js +3 -0
  24. package/lib/components/ChartTable/index.js.map +1 -0
  25. package/lib/components/DeclarativeChart/DeclarativeChart.d.ts +7 -3
  26. package/lib/components/DeclarativeChart/DeclarativeChart.js +15 -11
  27. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  28. package/lib/components/DeclarativeChart/PlotlyColorAdapter.d.ts +7 -0
  29. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +103 -0
  30. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
  31. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -11
  32. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +155 -113
  33. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  34. package/lib/index.d.ts +2 -0
  35. package/lib/index.js +1 -0
  36. package/lib/index.js.map +1 -1
  37. package/lib/utilities/image-export-utils.js +25 -3
  38. package/lib/utilities/image-export-utils.js.map +1 -1
  39. package/lib-amd/ChartTable.d.ts +1 -0
  40. package/lib-amd/ChartTable.js +6 -0
  41. package/lib-amd/ChartTable.js.map +1 -0
  42. package/lib-amd/components/ChartTable/ChartTable.base.d.ts +10 -0
  43. package/lib-amd/components/ChartTable/ChartTable.base.js +45 -0
  44. package/lib-amd/components/ChartTable/ChartTable.base.js.map +1 -0
  45. package/lib-amd/components/ChartTable/ChartTable.d.ts +7 -0
  46. package/lib-amd/components/ChartTable/ChartTable.js +11 -0
  47. package/lib-amd/components/ChartTable/ChartTable.js.map +1 -0
  48. package/lib-amd/components/ChartTable/ChartTable.styles.d.ts +2 -0
  49. package/lib-amd/components/ChartTable/ChartTable.styles.js +32 -0
  50. package/lib-amd/components/ChartTable/ChartTable.styles.js.map +1 -0
  51. package/lib-amd/components/ChartTable/ChartTable.types.d.ts +58 -0
  52. package/lib-amd/components/ChartTable/ChartTable.types.js +5 -0
  53. package/lib-amd/components/ChartTable/ChartTable.types.js.map +1 -0
  54. package/lib-amd/components/ChartTable/index.d.ts +2 -0
  55. package/lib-amd/components/ChartTable/index.js +7 -0
  56. package/lib-amd/components/ChartTable/index.js.map +1 -0
  57. package/lib-amd/components/DeclarativeChart/DeclarativeChart.d.ts +7 -3
  58. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +14 -11
  59. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  60. package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.d.ts +7 -0
  61. package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.js +108 -0
  62. package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
  63. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -11
  64. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +157 -115
  65. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  66. package/lib-amd/index.d.ts +2 -0
  67. package/lib-amd/index.js +3 -2
  68. package/lib-amd/index.js.map +1 -1
  69. package/lib-amd/utilities/image-export-utils.js +25 -3
  70. package/lib-amd/utilities/image-export-utils.js.map +1 -1
  71. package/lib-commonjs/ChartTable.d.ts +1 -0
  72. package/lib-commonjs/ChartTable.js +5 -0
  73. package/lib-commonjs/ChartTable.js.map +1 -0
  74. package/lib-commonjs/components/ChartTable/ChartTable.base.d.ts +10 -0
  75. package/lib-commonjs/components/ChartTable/ChartTable.base.js +47 -0
  76. package/lib-commonjs/components/ChartTable/ChartTable.base.js.map +1 -0
  77. package/lib-commonjs/components/ChartTable/ChartTable.d.ts +7 -0
  78. package/lib-commonjs/components/ChartTable/ChartTable.js +12 -0
  79. package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -0
  80. package/lib-commonjs/components/ChartTable/ChartTable.styles.d.ts +2 -0
  81. package/lib-commonjs/components/ChartTable/ChartTable.styles.js +32 -0
  82. package/lib-commonjs/components/ChartTable/ChartTable.styles.js.map +1 -0
  83. package/lib-commonjs/components/ChartTable/ChartTable.types.d.ts +58 -0
  84. package/lib-commonjs/components/ChartTable/ChartTable.types.js +3 -0
  85. package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -0
  86. package/lib-commonjs/components/ChartTable/index.d.ts +2 -0
  87. package/lib-commonjs/components/ChartTable/index.js +6 -0
  88. package/lib-commonjs/components/ChartTable/index.js.map +1 -0
  89. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.d.ts +7 -3
  90. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +14 -10
  91. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  92. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.d.ts +7 -0
  93. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +110 -0
  94. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
  95. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -11
  96. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +157 -115
  97. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  98. package/lib-commonjs/index.d.ts +2 -0
  99. package/lib-commonjs/index.js +3 -1
  100. package/lib-commonjs/index.js.map +1 -1
  101. package/lib-commonjs/utilities/image-export-utils.js +25 -3
  102. package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
  103. package/package.json +5 -5
  104. package/src/components/ChartTable/ChartTable.types.ts +68 -0
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { IChartTableProps } from './ChartTable.types';
3
+ import { IImageExportOptions } from '../../types/index';
4
+ export declare class ChartTableBase extends React.Component<IChartTableProps> {
5
+ private _isRTL;
6
+ private _rootElem;
7
+ constructor(props: IChartTableProps);
8
+ toImage: (opts?: IImageExportOptions) => Promise<string>;
9
+ render(): JSX.Element;
10
+ }
@@ -0,0 +1,45 @@
1
+ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities", "../../utilities/image-export-utils"], function (require, exports, tslib_1, React, Utilities_1, image_export_utils_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ChartTableBase = void 0;
5
+ var getClassNames = (0, Utilities_1.classNamesFunction)();
6
+ var ChartTableBase = /** @class */ (function (_super) {
7
+ tslib_1.__extends(ChartTableBase, _super);
8
+ function ChartTableBase(props) {
9
+ var _this = _super.call(this, props) || this;
10
+ _this.toImage = function (opts) {
11
+ return (0, image_export_utils_1.toImage)(_this._rootElem, undefined, _this._isRTL, opts);
12
+ };
13
+ (0, Utilities_1.initializeComponentRef)(_this);
14
+ _this._isRTL = (0, Utilities_1.getRTL)(props.theme);
15
+ return _this;
16
+ }
17
+ ChartTableBase.prototype.render = function () {
18
+ var _this = this;
19
+ var _a = this.props, headers = _a.headers, rows = _a.rows, width = _a.width, height = _a.height, styles = _a.styles, theme = _a.theme;
20
+ var classNames = getClassNames(styles, {
21
+ theme: theme,
22
+ });
23
+ if (!headers || headers.length === 0) {
24
+ return React.createElement("div", null, "No data available");
25
+ }
26
+ return (React.createElement("div", { ref: function (el) { return (_this._rootElem = el); }, className: classNames.root, style: { height: height ? "".concat(height, "px") : '650px', overflow: 'hidden' } },
27
+ React.createElement("svg", { width: width !== null && width !== void 0 ? width : '100%', height: height !== null && height !== void 0 ? height : '650px' },
28
+ React.createElement("foreignObject", { x: "0", y: "0", width: "100%", height: "100%" },
29
+ React.createElement("div", { style: {
30
+ maxHeight: height ? "".concat(height, "px") : '650px',
31
+ overflowY: 'auto',
32
+ overflowX: 'auto',
33
+ } },
34
+ React.createElement("table", { className: classNames.table, style: {
35
+ width: width ? "".concat(width, "px") : '100%',
36
+ } },
37
+ React.createElement("thead", null,
38
+ React.createElement("tr", null, headers.map(function (header, idx) { return (React.createElement("th", { key: idx, className: classNames.headerCell }, header)); }))),
39
+ rows && rows.length > 0 && (React.createElement("tbody", null, rows.map(function (row, rowIdx) { return (React.createElement("tr", { key: rowIdx }, row.map(function (cell, colIdx) { return (React.createElement("td", { key: colIdx, className: classNames.bodyCell }, cell)); }))); })))))))));
40
+ };
41
+ return ChartTableBase;
42
+ }(React.Component));
43
+ exports.ChartTableBase = ChartTableBase;
44
+ });
45
+ //# sourceMappingURL=ChartTable.base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartTable.base.js","sourceRoot":"../src/","sources":["components/ChartTable/ChartTable.base.tsx"],"names":[],"mappings":";;;;IAOA,IAAM,aAAa,GAAG,IAAA,8BAAkB,GAA4C,CAAC;IAErF;QAAoC,0CAAiC;QAInE,wBAAY,KA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,EAAC,MAAM,EAAC,MAAM;wBACnD,6BACE,KAAK,EAAE;gCACL,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,UAAG,MAAM,OAAI,CAAC,CAAC,CAAC,OAAO;gCAC3C,SAAS,EAAE,MAAM;gCACjB,SAAS,EAAE,MAAM;6BAClB;4BAED,+BACE,SAAS,EAAE,UAAU,CAAC,KAAK,EAC3B,KAAK,EAAE;oCACL,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,UAAG,KAAK,OAAI,CAAC,CAAC,CAAC,MAAM;iCACrC;gCAED;oCACE,gCACG,OAAO,CAAC,GAAG,CAAC,UAAC,MAAM,EAAE,GAAG,IAAK,OAAA,CAC5B,4BAAI,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,CAAC,UAAU,IAC3C,MAAM,CACJ,CACN,EAJ6B,CAI7B,CAAC,CACC,CACC;gCACP,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAC1B,mCACG,IAAI,CAAC,GAAG,CAAC,UAAC,GAAG,EAAE,MAAM,IAAK,OAAA,CACzB,4BAAI,GAAG,EAAE,MAAM,IACZ,GAAG,CAAC,GAAG,CAAC,UAAC,IAAI,EAAE,MAAM,IAAK,OAAA,CACzB,4BAAI,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,QAAQ,IAC5C,IAAI,CACF,CACN,EAJ0B,CAI1B,CAAC,CACC,CACN,EAR0B,CAQ1B,CAAC,CACI,CACT,CACK,CACJ,CACQ,CACZ,CACF,CACP,CAAC;QACJ,CAAC;QACH,qBAAC;IAAD,CAAC,AA1ED,CAAoC,KAAK,CAAC,SAAS,GA0ElD;IA1EY,wCAAc","sourcesContent":["import * as React from 'react';\nimport { IChartTableProps } from './ChartTable.types';\nimport { IChartTableStyleProps, IChartTableStyles } from '../../index';\nimport { classNamesFunction, getRTL, initializeComponentRef } from '@fluentui/react/lib/Utilities';\nimport { IImageExportOptions } from '../../types/index';\nimport { toImage } from '../../utilities/image-export-utils';\n\nconst getClassNames = classNamesFunction<IChartTableStyleProps, IChartTableStyles>();\n\nexport class ChartTableBase extends React.Component<IChartTableProps> {\n private _isRTL: boolean;\n private _rootElem: HTMLDivElement | null;\n\n constructor(props: IChartTableProps) {\n super(props);\n initializeComponentRef(this);\n this._isRTL = getRTL(props.theme);\n }\n public toImage = (opts?: IImageExportOptions): Promise<string> => {\n return toImage(this._rootElem, undefined, this._isRTL, opts);\n };\n\n public render(): JSX.Element {\n const { headers, rows, width, height, styles, theme } = this.props;\n\n const classNames = getClassNames(styles!, {\n theme: theme!,\n });\n\n if (!headers || headers.length === 0) {\n return <div>No data available</div>;\n }\n\n return (\n <div\n ref={el => (this._rootElem = el)}\n className={classNames.root}\n style={{ height: height ? `${height}px` : '650px', overflow: 'hidden' }}\n >\n <svg width={width ?? '100%'} height={height ?? '650px'}>\n <foreignObject x=\"0\" y=\"0\" width=\"100%\" height=\"100%\">\n <div\n style={{\n maxHeight: height ? `${height}px` : '650px',\n overflowY: 'auto',\n overflowX: 'auto',\n }}\n >\n <table\n className={classNames.table}\n style={{\n width: width ? `${width}px` : '100%',\n }}\n >\n <thead>\n <tr>\n {headers.map((header, idx) => (\n <th key={idx} className={classNames.headerCell}>\n {header}\n </th>\n ))}\n </tr>\n </thead>\n {rows && rows.length > 0 && (\n <tbody>\n {rows.map((row, rowIdx) => (\n <tr key={rowIdx}>\n {row.map((cell, colIdx) => (\n <td key={colIdx} className={classNames.bodyCell}>\n {cell}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n )}\n </table>\n </div>\n </foreignObject>\n </svg>\n </div>\n );\n }\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { IChartTableProps } from '../../index';
3
+ /**
4
+ * ChartTable component
5
+ * {@docCategory ChartTable}
6
+ */
7
+ export declare const ChartTable: React.FunctionComponent<IChartTableProps>;
@@ -0,0 +1,11 @@
1
+ define(["require", "exports", "@fluentui/react/lib/Utilities", "./ChartTable.base", "./ChartTable.styles"], function (require, exports, Utilities_1, ChartTable_base_1, ChartTable_styles_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ChartTable = void 0;
5
+ /**
6
+ * ChartTable component
7
+ * {@docCategory ChartTable}
8
+ */
9
+ exports.ChartTable = (0, Utilities_1.styled)(ChartTable_base_1.ChartTableBase, ChartTable_styles_1.getStyles);
10
+ });
11
+ //# sourceMappingURL=ChartTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartTable.js","sourceRoot":"../src/","sources":["components/ChartTable/ChartTable.tsx"],"names":[],"mappings":";;;;IAMA;;;OAGG;IACU,QAAA,UAAU,GAA8C,IAAA,kBAAM,EAIzE,gCAAc,EAAE,6BAAS,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { styled } from '@fluentui/react/lib/Utilities';\nimport { IChartTableProps, IChartTableStyleProps, IChartTableStyles } from '../../index';\nimport { ChartTableBase } from './ChartTable.base';\nimport { getStyles } from './ChartTable.styles';\n\n/**\n * ChartTable component\n * {@docCategory ChartTable}\n */\nexport const ChartTable: React.FunctionComponent<IChartTableProps> = styled<\n IChartTableProps,\n IChartTableStyleProps,\n IChartTableStyles\n>(ChartTableBase, getStyles);\n"]}
@@ -0,0 +1,2 @@
1
+ import { IChartTableStyleProps, IChartTableStyles } from './ChartTable.types';
2
+ export declare const getStyles: (props: IChartTableStyleProps) => IChartTableStyles;
@@ -0,0 +1,32 @@
1
+ define(["require", "exports", "tslib", "@fluentui/react/lib/Styling"], function (require, exports, tslib_1, Styling_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.getStyles = void 0;
5
+ var getStyles = function (props) {
6
+ var _a, _b;
7
+ var theme = props.theme;
8
+ var fonts = theme.fonts;
9
+ return {
10
+ root: {
11
+ width: '100%',
12
+ overflowX: 'auto',
13
+ },
14
+ table: {
15
+ borderCollapse: 'collapse',
16
+ },
17
+ headerCell: tslib_1.__assign(tslib_1.__assign({}, fonts.small), { fontWeight: Styling_1.FontWeights.semibold, backgroundColor: theme.palette.neutralQuaternary, color: theme.semanticColors.bodyText, padding: '8px', textAlign: 'left', border: "2px solid ".concat(theme.palette.neutralLighter), selectors: (_a = {},
18
+ _a[Styling_1.HighContrastSelector] = {
19
+ backgroundColor: 'Window',
20
+ color: 'WindowText',
21
+ },
22
+ _a) }),
23
+ bodyCell: tslib_1.__assign(tslib_1.__assign({}, fonts.small), { padding: '8px', border: "2px solid ".concat(theme.palette.neutralLighter), color: theme.semanticColors.bodyText, textAlign: 'left', selectors: (_b = {},
24
+ _b[Styling_1.HighContrastSelector] = {
25
+ color: 'WindowText',
26
+ },
27
+ _b) }),
28
+ };
29
+ };
30
+ exports.getStyles = getStyles;
31
+ });
32
+ //# sourceMappingURL=ChartTable.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartTable.styles.js","sourceRoot":"../src/","sources":["components/ChartTable/ChartTable.styles.ts"],"names":[],"mappings":";;;;IAGO,IAAM,SAAS,GAAG,UAAC,KAA4B;;QAC5C,IAAA,KAAK,GAAK,KAAK,MAAV,CAAW;QAChB,IAAA,KAAK,GAAK,KAAM,MAAX,CAAY;QAEzB,OAAO;YACL,IAAI,EAAE;gBACJ,KAAK,EAAE,MAAM;gBACb,SAAS,EAAE,MAAM;aAClB;YACD,KAAK,EAAE;gBACL,cAAc,EAAE,UAAU;aAC3B;YACD,UAAU,wCACL,KAAK,CAAC,KAAK,KACd,UAAU,EAAE,qBAAW,CAAC,QAAQ,EAChC,eAAe,EAAE,KAAM,CAAC,OAAO,CAAC,iBAAiB,EACjD,KAAK,EAAE,KAAM,CAAC,cAAc,CAAC,QAAQ,EACrC,OAAO,EAAE,KAAK,EACd,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,oBAAa,KAAM,CAAC,OAAO,CAAC,cAAc,CAAE,EACpD,SAAS;oBACP,GAAC,8BAAoB,IAAG;wBACtB,eAAe,EAAE,QAAQ;wBACzB,KAAK,EAAE,YAAY;qBACpB;0BAEJ;YACD,QAAQ,wCACH,KAAK,CAAC,KAAK,KACd,OAAO,EAAE,KAAK,EACd,MAAM,EAAE,oBAAa,KAAM,CAAC,OAAO,CAAC,cAAc,CAAE,EACpD,KAAK,EAAE,KAAM,CAAC,cAAc,CAAC,QAAQ,EACrC,SAAS,EAAE,MAAM,EACjB,SAAS;oBACP,GAAC,8BAAoB,IAAG;wBACtB,KAAK,EAAE,YAAY;qBACpB;0BAEJ;SACF,CAAC;IACJ,CAAC,CAAC;IAxCW,QAAA,SAAS,aAwCpB","sourcesContent":["import { IChartTableStyleProps, IChartTableStyles } from './ChartTable.types';\nimport { FontWeights, HighContrastSelector } from '@fluentui/react/lib/Styling';\n\nexport const getStyles = (props: IChartTableStyleProps): IChartTableStyles => {\n const { theme } = props;\n const { fonts } = theme!;\n\n return {\n root: {\n width: '100%',\n overflowX: 'auto',\n },\n table: {\n borderCollapse: 'collapse',\n },\n headerCell: {\n ...fonts.small,\n fontWeight: FontWeights.semibold,\n backgroundColor: theme!.palette.neutralQuaternary,\n color: theme!.semanticColors.bodyText,\n padding: '8px',\n textAlign: 'left',\n border: `2px solid ${theme!.palette.neutralLighter}`,\n selectors: {\n [HighContrastSelector]: {\n backgroundColor: 'Window',\n color: 'WindowText',\n },\n },\n },\n bodyCell: {\n ...fonts.small,\n padding: '8px',\n border: `2px solid ${theme!.palette.neutralLighter}`,\n color: theme!.semanticColors.bodyText,\n textAlign: 'left',\n selectors: {\n [HighContrastSelector]: {\n color: 'WindowText',\n },\n },\n },\n };\n};\n"]}
@@ -0,0 +1,58 @@
1
+ import { ITheme, IStyle } from '@fluentui/react/lib/Styling';
2
+ import { IRefObject, IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';
3
+ import { IChart } from '../../types/index';
4
+ export interface IChartTableStyleProps {
5
+ theme: ITheme;
6
+ className?: string;
7
+ }
8
+ /**
9
+ * Chart Table properties
10
+ * {@docCategory ChartTable}
11
+ */
12
+ export interface IChartTableProps {
13
+ /**
14
+ * 1d or 2d Array of header values.
15
+ */
16
+ headers: (string | number | boolean | null)[] | (string | number | boolean | null)[][];
17
+ /**
18
+ * Array of rows. Each row corresponds to one data entry under each column.
19
+ */
20
+ rows: (string | number | boolean | null)[][];
21
+ /**
22
+ * Optional width for the table
23
+ * @default '100%'
24
+ */
25
+ width?: string | number;
26
+ /**
27
+ * Optional height for the table
28
+ * @default '650px'
29
+ */
30
+ height?: string | number;
31
+ /**
32
+ * Theme (provided through customization)
33
+ */
34
+ theme?: ITheme;
35
+ /**
36
+ * Additional class name(s) to apply to the table chart
37
+ */
38
+ className?: string;
39
+ /**
40
+ * Call to provide customized styling that will layer on top of the variant rules.
41
+ */
42
+ styles?: IStyleFunctionOrObject<IChartTableStyleProps, IChartTableStyles>;
43
+ /**
44
+ * Optional callback to access the IChart interface. Use this instead of ref for accessing
45
+ * the public methods and properties of the component.
46
+ */
47
+ componentRef?: IRefObject<IChart>;
48
+ }
49
+ /**
50
+ * Table Chart styles
51
+ * {@docCategory ChartTable}
52
+ */
53
+ export interface IChartTableStyles {
54
+ root?: IStyle;
55
+ table?: IStyle;
56
+ headerCell?: IStyle;
57
+ bodyCell?: IStyle;
58
+ }
@@ -0,0 +1,5 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ });
5
+ //# sourceMappingURL=ChartTable.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartTable.types.js","sourceRoot":"../src/","sources":["components/ChartTable/ChartTable.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ITheme, IStyle } from '@fluentui/react/lib/Styling';\nimport { IRefObject, IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';\nimport { IChart } from '../../types/index';\n\nexport interface IChartTableStyleProps {\n theme: ITheme;\n className?: string;\n}\n\n/**\n * Chart Table properties\n * {@docCategory ChartTable}\n */\nexport interface IChartTableProps {\n /**\n * 1d or 2d Array of header values.\n */\n headers: (string | number | boolean | null)[] | (string | number | boolean | null)[][];\n\n /**\n * Array of rows. Each row corresponds to one data entry under each column.\n */\n rows: (string | number | boolean | null)[][];\n\n /**\n * Optional width for the table\n * @default '100%'\n */\n width?: string | number;\n\n /**\n * Optional height for the table\n * @default '650px'\n */\n height?: string | number;\n\n /**\n * Theme (provided through customization)\n */\n theme?: ITheme;\n\n /**\n * Additional class name(s) to apply to the table chart\n */\n className?: string;\n\n /**\n * Call to provide customized styling that will layer on top of the variant rules.\n */\n styles?: IStyleFunctionOrObject<IChartTableStyleProps, IChartTableStyles>;\n\n /**\n * Optional callback to access the IChart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: IRefObject<IChart>;\n}\n\n/**\n * Table Chart styles\n * {@docCategory ChartTable}\n */\nexport interface IChartTableStyles {\n root?: IStyle;\n table?: IStyle;\n headerCell?: IStyle;\n bodyCell?: IStyle;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './ChartTable';
2
+ export * from './ChartTable.types';
@@ -0,0 +1,7 @@
1
+ define(["require", "exports", "tslib", "./ChartTable", "./ChartTable.types"], function (require, exports, tslib_1, ChartTable_1, ChartTable_types_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(ChartTable_1, exports);
5
+ tslib_1.__exportStar(ChartTable_types_1, exports);
6
+ });
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/ChartTable/index.ts"],"names":[],"mappings":";;;IAAA,4CAA6B;IAC7B,kDAAmC","sourcesContent":["export * from './ChartTable';\nexport * from './ChartTable.types';\n"]}
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { IRefObject } from '@fluentui/react/lib/Utilities';
3
+ import type { ColorwayType } from './PlotlyColorAdapter';
3
4
  import { IImageExportOptions } from '../../types/index';
4
5
  /**
5
6
  * DeclarativeChart schema.
@@ -30,10 +31,13 @@ export interface DeclarativeChartProps extends React.RefAttributes<HTMLDivElemen
30
31
  */
31
32
  componentRef?: IRefObject<IDeclarativeChart>;
32
33
  /**
33
- * Optional prop to use Fluent UI color palette for the chart or not.
34
- * @default true
34
+ * Optional prop to specify the colorway type of the chart.
35
+ * - 'default': Use Fluent UI color palette aligning with plotly colorway.
36
+ * - 'builtin': Use Fluent UI colorway.
37
+ * - 'others': Reserved for future colorways.
38
+ * @default 'default'
35
39
  */
36
- useFluentVizColorPalette?: boolean;
40
+ colorwayType?: ColorwayType;
37
41
  }
38
42
  /**
39
43
  * {@docCategory DeclarativeChart}
@@ -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"], 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) {
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", "../ChartTable/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) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.DeclarativeChart = void 0;
@@ -12,6 +12,7 @@ define(["require", "exports", "tslib", "react", "@fluentui/react", "../DonutChar
12
12
  var ResponsiveGaugeChart = (0, withResponsiveContainer_1.withResponsiveContainer)(index_7.GaugeChart);
13
13
  var ResponsiveGroupedVerticalBarChart = (0, withResponsiveContainer_1.withResponsiveContainer)(index_8.GroupedVerticalBarChart);
14
14
  var ResponsiveVerticalBarChart = (0, withResponsiveContainer_1.withResponsiveContainer)(index_9.VerticalBarChart);
15
+ var ResponsiveChartTable = (0, withResponsiveContainer_1.withResponsiveContainer)(index_10.ChartTable);
15
16
  var useColorMapping = function () {
16
17
  var colorMap = React.useRef(new Map());
17
18
  return colorMap;
@@ -70,7 +71,7 @@ define(["require", "exports", "tslib", "react", "@fluentui/react", "../DonutChar
70
71
  var renderLineArea = function (plotlyData, isAreaChart) {
71
72
  var _a;
72
73
  var isScatterMarkers = ['markers', 'text+markers', 'markers+text'].includes((_a = plotlyData[0]) === null || _a === void 0 ? void 0 : _a.mode);
73
- var chartProps = tslib_1.__assign(tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToScatterChartProps)({ data: plotlyData, layout: plotlyInput.layout }, isAreaChart, colorMap, props.useFluentVizColorPalette, isDarkTheme)), commonProps);
74
+ var chartProps = tslib_1.__assign(tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToScatterChartProps)({ data: plotlyData, layout: plotlyInput.layout }, isAreaChart, isScatterMarkers, colorMap, props.colorwayType, isDarkTheme)), commonProps);
74
75
  if (isAreaChart) {
75
76
  return React.createElement(ResponsiveAreaChart, tslib_1.__assign({}, chartProps));
76
77
  }
@@ -100,7 +101,7 @@ define(["require", "exports", "tslib", "react", "@fluentui/react", "../DonutChar
100
101
  if (isAreaChart) {
101
102
  throw new Error('Fallback to VerticalStackedBarChart is not allowed for Area Charts.');
102
103
  }
103
- return (React.createElement(ResponsiveVerticalStackedBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVSBCProps)(plotlyInputWithValidData, colorMap, isDarkTheme, fallbackVSBC), commonProps)));
104
+ return (React.createElement(ResponsiveVerticalStackedBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVSBCProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme, fallbackVSBC), commonProps)));
104
105
  };
105
106
  var exportAsImage = React.useCallback(function (opts) {
106
107
  return new Promise(function (resolve, reject) {
@@ -118,21 +119,23 @@ define(["require", "exports", "tslib", "react", "@fluentui/react", "../DonutChar
118
119
  }); }, [exportAsImage]);
119
120
  switch (chart.type) {
120
121
  case 'donut':
121
- return (React.createElement(ResponsiveDonutChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToDonutProps)(plotlyInputWithValidData, colorMap, props.useFluentVizColorPalette, isDarkTheme), commonProps)));
122
+ return (React.createElement(ResponsiveDonutChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToDonutProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
122
123
  case 'horizontalbar':
123
- return (React.createElement(ResponsiveHorizontalBarChartWithAxis, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToHorizontalBarWithAxisProps)(plotlyInputWithValidData, colorMap, isDarkTheme), commonProps)));
124
+ return (React.createElement(ResponsiveHorizontalBarChartWithAxis, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToHorizontalBarWithAxisProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
124
125
  case 'groupedverticalbar':
125
- return (React.createElement(ResponsiveGroupedVerticalBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToGVBCProps)(plotlyInputWithValidData, colorMap, isDarkTheme), commonProps)));
126
+ return (React.createElement(ResponsiveGroupedVerticalBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToGVBCProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
126
127
  case 'verticalstackedbar':
127
- return (React.createElement(ResponsiveVerticalStackedBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVSBCProps)(plotlyInputWithValidData, colorMap, isDarkTheme), commonProps)));
128
+ return (React.createElement(ResponsiveVerticalStackedBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVSBCProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
128
129
  case 'heatmap':
129
130
  return (React.createElement(ResponsiveHeatMapChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToHeatmapProps)(plotlyInputWithValidData), commonProps, { legendProps: {} })));
130
131
  case 'sankey':
131
- return (React.createElement(ResponsiveSankeyChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToSankeyProps)(plotlyInputWithValidData, colorMap, isDarkTheme), commonProps)));
132
+ return (React.createElement(ResponsiveSankeyChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToSankeyProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
132
133
  case 'gauge':
133
- return (React.createElement(ResponsiveGaugeChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToGaugeProps)(plotlyInputWithValidData, colorMap, isDarkTheme), commonProps)));
134
+ return (React.createElement(ResponsiveGaugeChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToGaugeProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
134
135
  case 'verticalbar':
135
- return (React.createElement(ResponsiveVerticalBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVBCProps)(plotlyInputWithValidData, colorMap, isDarkTheme), commonProps)));
136
+ return (React.createElement(ResponsiveVerticalBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVBCProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
137
+ case 'table':
138
+ return (React.createElement(ResponsiveChartTable, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToChartTableProps)(plotlyInputWithValidData, colorMap, isDarkTheme), commonProps)));
136
139
  case 'area':
137
140
  case 'line':
138
141
  case 'fallback':
@@ -150,7 +153,7 @@ define(["require", "exports", "tslib", "react", "@fluentui/react", "../DonutChar
150
153
  });
151
154
  exports.DeclarativeChart.displayName = 'DeclarativeChart';
152
155
  exports.DeclarativeChart.defaultProps = {
153
- useFluentVizColorPalette: true,
156
+ colorwayType: 'default',
154
157
  };
155
158
  });
156
159
  //# sourceMappingURL=DeclarativeChart.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DeclarativeChart.js","sourceRoot":"../src/","sources":["components/DeclarativeChart/DeclarativeChart.tsx"],"names":[],"mappings":";;;;IA0CA,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;IACnE,IAAM,oBAAoB,G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WAAW,CAAC,EAChF,WAAW,EACf,CACH,CAAC;YACJ,KAAK,aAAa;gBAChB,OAAO,CACL,oBAAC,0BAA0B,uBACrB,IAAA,mDAA6B,EAAC,wBAAwB,EAAE,QAAQ,EAAE,WAAW,CAAC,EAC9E,WAAW,EACf,CACH,CAAC;YACJ,KAAK,MAAM,CAAC;YACZ,KAAK,MAAM,CAAC;YACZ,KAAK,UAAU,CAAC;YAChB,KAAK,cAAc;gBACjB,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;oBAClC,IAAM,mBAAmB,GAAG,IAAA,6CAAuB,EAAC,wBAAwB,CAAC,CAAC;oBAC9E,wBAAwB,CAAC,IAAI,GAAG,mBAAmB,CAAC,IAAI,CAAC;gBAC3D,CAAC;gBACD,kGAAkG;gBAClG,IAAM,WAAW,GAAG,wBAAwB,CAAC,IAAI,CAAC,IAAI,CACpD,UAAC,MAAgB,IAAK,OAAA,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,CAAC,UAAU,EAA7E,CAA6E,CACpG,CAAC;gBACF,OAAO,mBAAmB,CAAC,WAAW,CAAC,CAAC;YAC1C;gBACE,MAAM,IAAI,KAAK,CAAC,kCAA2B,MAAA,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,0CAAE,IAAI,CAAE,CAAC,CAAC;QACzF,CAAC;IACH,CAAC,CAAC,CAAC;IACH,wBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC;IAClD,wBAAgB,CAAC,YAAY,GAAG;QAC9B,wBAAwB,EAAE,IAAI;KAC/B,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 } from '@fluentui/chart-utilities';\nimport {\n isArrayOrTypedArray,\n isDateArray,\n isNumberArray,\n isYearArray,\n mapFluentChart,\n sanitizeJson,\n} from '@fluentui/chart-utilities';\n\nimport {\n isMonthArray,\n correctYearMonth,\n transformPlotlyJsonToDonutProps,\n transformPlotlyJsonToVSBCProps,\n transformPlotlyJsonToScatterChartProps,\n transformPlotlyJsonToHorizontalBarWithAxisProps,\n transformPlotlyJsonToHeatmapProps,\n transformPlotlyJsonToSankeyProps,\n transformPlotlyJsonToGaugeProps,\n transformPlotlyJsonToGVBCProps,\n transformPlotlyJsonToVBCProps,\n projectPolarToCartesian,\n} from './PlotlySchemaAdapter';\nimport { LineChart, ILineChartProps } from '../LineChart/index';\nimport { HorizontalBarChartWithAxis } from '../HorizontalBarChartWithAxis/index';\nimport { AreaChart, IAreaChartProps } 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';\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);\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 use Fluent UI color palette for the chart or not.\n * @default true\n */\n useFluentVizColorPalette?: boolean;\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 } = 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[0]]),\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\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 const renderLineArea = (plotlyData: Data[], isAreaChart: boolean): JSX.Element => {\n const isScatterMarkers = ['markers', 'text+markers', 'markers+text'].includes((plotlyData[0] as PlotData)?.mode);\n const chartProps: ILineChartProps | IAreaChartProps = {\n ...transformPlotlyJsonToScatterChartProps(\n { data: plotlyData, layout: plotlyInput.layout },\n isAreaChart,\n colorMap,\n props.useFluentVizColorPalette!,\n isDarkTheme,\n ),\n ...commonProps,\n };\n if (isAreaChart) {\n return <ResponsiveAreaChart {...chartProps} />;\n }\n return <ResponsiveLineChart {...chartProps} lineMode={isScatterMarkers ? 'scatter' : 'default'} />;\n };\n\n const checkAndRenderChart = (isAreaChart: boolean = false) => {\n let fallbackVSBC = false;\n const xValues = (plotlyInputWithValidData.data[0] as PlotData).x;\n const isXDate = isDateArray(xValues);\n const isXNumber = isNumberArray(xValues);\n const isXMonth = isMonthArray(xValues);\n\n // Consider year as categorical variable not numeric continuous variable\n // Also year is not considered a date variable as it is represented as a point\n // in time and brings additional complexity of handling timezone and locale\n // formatting given the current design of the charting library\n const isXYear = isYearArray(xValues);\n\n if ((isXDate || isXNumber) && !isXYear) {\n return renderLineArea(plotlyInputWithValidData.data, isAreaChart);\n } else if (isXMonth) {\n const updatedData = plotlyInputWithValidData.data.map((dataPoint: PlotData) => ({\n ...dataPoint,\n x: correctYearMonth(dataPoint.x),\n }));\n return renderLineArea(updatedData, isAreaChart);\n }\n // Unsupported schema, render as VerticalStackedBarChart\n fallbackVSBC = true;\n if (isAreaChart) {\n throw new Error('Fallback to VerticalStackedBarChart is not allowed for Area Charts.');\n }\n return (\n <ResponsiveVerticalStackedBarChart\n {...transformPlotlyJsonToVSBCProps(plotlyInputWithValidData, colorMap, isDarkTheme, fallbackVSBC)}\n {...commonProps}\n />\n );\n };\n\n const exportAsImage = React.useCallback(\n (opts?: IImageExportOptions): Promise<string> => {\n return new Promise((resolve, reject) => {\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 switch (chart.type) {\n case 'donut':\n return (\n <ResponsiveDonutChart\n {...transformPlotlyJsonToDonutProps(\n plotlyInputWithValidData,\n colorMap,\n props.useFluentVizColorPalette!,\n isDarkTheme,\n )}\n {...commonProps}\n />\n );\n case 'horizontalbar':\n return (\n <ResponsiveHorizontalBarChartWithAxis\n {...transformPlotlyJsonToHorizontalBarWithAxisProps(plotlyInputWithValidData, colorMap, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'groupedverticalbar':\n return (\n <ResponsiveGroupedVerticalBarChart\n {...transformPlotlyJsonToGVBCProps(plotlyInputWithValidData, colorMap, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'verticalstackedbar':\n return (\n <ResponsiveVerticalStackedBarChart\n {...transformPlotlyJsonToVSBCProps(plotlyInputWithValidData, colorMap, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'heatmap':\n return (\n <ResponsiveHeatMapChart\n {...transformPlotlyJsonToHeatmapProps(plotlyInputWithValidData)}\n {...commonProps}\n legendProps={{}}\n />\n );\n case 'sankey':\n return (\n <ResponsiveSankeyChart\n {...transformPlotlyJsonToSankeyProps(plotlyInputWithValidData, colorMap, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'gauge':\n return (\n <ResponsiveGaugeChart\n {...transformPlotlyJsonToGaugeProps(plotlyInputWithValidData, colorMap, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'verticalbar':\n return (\n <ResponsiveVerticalBarChart\n {...transformPlotlyJsonToVBCProps(plotlyInputWithValidData, colorMap, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'area':\n case 'line':\n case 'fallback':\n case 'scatterpolar':\n if (chart.type === 'scatterpolar') {\n const cartesianProjection = projectPolarToCartesian(plotlyInputWithValidData);\n plotlyInputWithValidData.data = cartesianProjection.data;\n }\n // Need recheck for area chart as we don't have ability to check for valid months in previous step\n const isAreaChart = plotlyInputWithValidData.data.some(\n (series: PlotData) => series.fill === 'tonexty' || series.fill === 'tozeroy' || !!series.stackgroup,\n );\n return checkAndRenderChart(isAreaChart);\n default:\n throw new Error(`Unsupported chart type :${plotlyInputWithValidData.data[0]?.type}`);\n }\n});\nDeclarativeChart.displayName = 'DeclarativeChart';\nDeclarativeChart.defaultProps = {\n useFluentVizColorPalette: true,\n};\n"]}
1
+ {"version":3,"file":"DeclarativeChart.js","sourceRoot":"../src/","sources":["components/DeclarativeChart/DeclarativeChart.tsx"],"names":[],"mappings":";;;;IA6CA,IAAM,oBAAoB,GAAG,IAAA,iDAAuB,EAAC,kBAAU,CAAC,CAAC;IACjE,IAAM,iCAAiC,GAAG,IAAA,iDAAuB,EAAC,+BAAuB,CAAC,CAAC;IAC3F,IAAM,mBAAmB,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BAAwB,CAAC,IAAI,CAAC,IAAI,CACpD,UAAC,MAAgB,IAAK,OAAA,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,CAAC,UAAU,EAA7E,CAA6E,CACpG,CAAC;gBACF,OAAO,mBAAmB,CAAC,WAAW,CAAC,CAAC;YAC1C;gBACE,MAAM,IAAI,KAAK,CAAC,kCAA2B,MAAA,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,0CAAE,IAAI,CAAE,CAAC,CAAC;QACzF,CAAC;IACH,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 } from '@fluentui/chart-utilities';\nimport {\n isArrayOrTypedArray,\n isDateArray,\n isNumberArray,\n isYearArray,\n mapFluentChart,\n sanitizeJson,\n} from '@fluentui/chart-utilities';\n\nimport {\n isMonthArray,\n correctYearMonth,\n transformPlotlyJsonToDonutProps,\n transformPlotlyJsonToVSBCProps,\n transformPlotlyJsonToScatterChartProps,\n transformPlotlyJsonToHorizontalBarWithAxisProps,\n transformPlotlyJsonToHeatmapProps,\n transformPlotlyJsonToSankeyProps,\n transformPlotlyJsonToGaugeProps,\n transformPlotlyJsonToGVBCProps,\n transformPlotlyJsonToVBCProps,\n transformPlotlyJsonToChartTableProps,\n projectPolarToCartesian,\n} from './PlotlySchemaAdapter';\nimport type { ColorwayType } from './PlotlyColorAdapter';\nimport { LineChart, ILineChartProps } from '../LineChart/index';\nimport { HorizontalBarChartWithAxis } from '../HorizontalBarChartWithAxis/index';\nimport { AreaChart, IAreaChartProps } 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 { ChartTable } from '../ChartTable/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 ResponsiveChartTable = withResponsiveContainer(ChartTable);\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\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[0]]),\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\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 const renderLineArea = (plotlyData: Data[], isAreaChart: boolean): JSX.Element => {\n const isScatterMarkers = ['markers', 'text+markers', 'markers+text'].includes((plotlyData[0] as PlotData)?.mode);\n const chartProps: ILineChartProps | IAreaChartProps = {\n ...transformPlotlyJsonToScatterChartProps(\n { data: plotlyData, layout: plotlyInput.layout },\n isAreaChart,\n isScatterMarkers,\n colorMap,\n props.colorwayType,\n isDarkTheme,\n ),\n ...commonProps,\n };\n if (isAreaChart) {\n return <ResponsiveAreaChart {...chartProps} />;\n }\n return <ResponsiveLineChart {...chartProps} lineMode={isScatterMarkers ? 'scatter' : 'default'} />;\n };\n\n const checkAndRenderChart = (isAreaChart: boolean = false) => {\n let fallbackVSBC = false;\n const xValues = (plotlyInputWithValidData.data[0] as PlotData).x;\n const isXDate = isDateArray(xValues);\n const isXNumber = isNumberArray(xValues);\n const isXMonth = isMonthArray(xValues);\n\n // Consider year as categorical variable not numeric continuous variable\n // Also year is not considered a date variable as it is represented as a point\n // in time and brings additional complexity of handling timezone and locale\n // formatting given the current design of the charting library\n const isXYear = isYearArray(xValues);\n\n if ((isXDate || isXNumber) && !isXYear) {\n return renderLineArea(plotlyInputWithValidData.data, isAreaChart);\n } else if (isXMonth) {\n const updatedData = plotlyInputWithValidData.data.map((dataPoint: PlotData) => ({\n ...dataPoint,\n x: correctYearMonth(dataPoint.x),\n }));\n return renderLineArea(updatedData, isAreaChart);\n }\n // Unsupported schema, render as VerticalStackedBarChart\n fallbackVSBC = true;\n if (isAreaChart) {\n throw new Error('Fallback to VerticalStackedBarChart is not allowed for Area Charts.');\n }\n return (\n <ResponsiveVerticalStackedBarChart\n {...transformPlotlyJsonToVSBCProps(\n plotlyInputWithValidData,\n colorMap,\n props.colorwayType,\n isDarkTheme,\n fallbackVSBC,\n )}\n {...commonProps}\n />\n );\n };\n\n const exportAsImage = React.useCallback(\n (opts?: IImageExportOptions): Promise<string> => {\n return new Promise((resolve, reject) => {\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 switch (chart.type) {\n case 'donut':\n return (\n <ResponsiveDonutChart\n {...transformPlotlyJsonToDonutProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'horizontalbar':\n return (\n <ResponsiveHorizontalBarChartWithAxis\n {...transformPlotlyJsonToHorizontalBarWithAxisProps(\n plotlyInputWithValidData,\n colorMap,\n props.colorwayType,\n isDarkTheme,\n )}\n {...commonProps}\n />\n );\n case 'groupedverticalbar':\n return (\n <ResponsiveGroupedVerticalBarChart\n {...transformPlotlyJsonToGVBCProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'verticalstackedbar':\n return (\n <ResponsiveVerticalStackedBarChart\n {...transformPlotlyJsonToVSBCProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'heatmap':\n return (\n <ResponsiveHeatMapChart\n {...transformPlotlyJsonToHeatmapProps(plotlyInputWithValidData)}\n {...commonProps}\n legendProps={{}}\n />\n );\n case 'sankey':\n return (\n <ResponsiveSankeyChart\n {...transformPlotlyJsonToSankeyProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'gauge':\n return (\n <ResponsiveGaugeChart\n {...transformPlotlyJsonToGaugeProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'verticalbar':\n return (\n <ResponsiveVerticalBarChart\n {...transformPlotlyJsonToVBCProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'table':\n return (\n <ResponsiveChartTable\n {...transformPlotlyJsonToChartTableProps(plotlyInputWithValidData, colorMap, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'area':\n case 'line':\n case 'fallback':\n case 'scatterpolar':\n if (chart.type === 'scatterpolar') {\n const cartesianProjection = projectPolarToCartesian(plotlyInputWithValidData);\n plotlyInputWithValidData.data = cartesianProjection.data;\n }\n // Need recheck for area chart as we don't have ability to check for valid months in previous step\n const isAreaChart = plotlyInputWithValidData.data.some(\n (series: PlotData) => series.fill === 'tonexty' || series.fill === 'tozeroy' || !!series.stackgroup,\n );\n return checkAndRenderChart(isAreaChart);\n default:\n throw new Error(`Unsupported chart type :${plotlyInputWithValidData.data[0]?.type}`);\n }\n});\nDeclarativeChart.displayName = 'DeclarativeChart';\nDeclarativeChart.defaultProps = {\n colorwayType: 'default',\n};\n"]}
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import type { PieColors, Color } from '@fluentui/chart-utilities';
3
+ export type ColorwayType = 'default' | 'builtin' | 'others' | undefined;
4
+ export declare const getColor: (legendLabel: string, colorMap: React.MutableRefObject<Map<string, string>>, isDarkTheme?: boolean) => string;
5
+ export declare const getSchemaColors: (colorway: string[] | undefined, colors: PieColors | Color | Color[] | string | null | undefined, colorMap: React.MutableRefObject<Map<string, string>>, isDarkTheme?: boolean) => string[] | string | undefined;
6
+ export declare const extractColor: (colorway: string[] | undefined, colorwayType: ColorwayType, colors: PieColors | Color | Color[] | string | null | undefined, colorMap: React.MutableRefObject<Map<string, string>>, isDarkTheme?: boolean) => string | string[] | undefined;
7
+ export declare const resolveColor: (extractedColors: string[] | string | null | undefined, index: number, legend: string, colorMap: React.MutableRefObject<Map<string, string>>, isDarkTheme?: boolean) => string;
@@ -0,0 +1,108 @@
1
+ define(["require", "exports", "d3-color", "@fluentui/chart-utilities", "../../utilities/utilities", "../../utilities/colors"], function (require, exports, d3_color_1, chart_utilities_1, utilities_1, colors_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.resolveColor = exports.extractColor = exports.getSchemaColors = exports.getColor = void 0;
5
+ var DEFAULT_PLOTLY_COLORWAY = [
6
+ '#636efa', //1
7
+ '#ef553b', //2
8
+ '#00cc96', //3
9
+ '#ab63fa', //4
10
+ '#ffa15a', //5
11
+ '#19d3f3', //6
12
+ '#ff6692', //7
13
+ '#b6e880', //8
14
+ '#ff97ff', //9
15
+ '#fecb52', //10
16
+ ];
17
+ var PLOTLY_FLUENTVIZ_COLORWAY_MAPPING = [
18
+ colors_1.DataVizPalette.color1, //1
19
+ colors_1.DataVizPalette.warning, //2
20
+ colors_1.DataVizPalette.color8, //3
21
+ colors_1.DataVizPalette.color4, //4
22
+ colors_1.DataVizPalette.color7, //5
23
+ colors_1.DataVizPalette.color6, //6
24
+ colors_1.DataVizPalette.color2, //7
25
+ colors_1.DataVizPalette.color5, //8
26
+ colors_1.DataVizPalette.color9, //9
27
+ colors_1.DataVizPalette.color10, //10
28
+ ];
29
+ function getPlotlyColorway(colorway) {
30
+ var isPlotlyColorway = (0, chart_utilities_1.isArrayOrTypedArray)(colorway) &&
31
+ (0, utilities_1.areArraysEqual)(colorway === null || colorway === void 0 ? void 0 : colorway.map(function (c) { return c.toLowerCase(); }), DEFAULT_PLOTLY_COLORWAY);
32
+ return isPlotlyColorway ? 'plotly' : 'others';
33
+ }
34
+ function tryMapFluentDataViz(hexColor, templateColorway, isDarkTheme) {
35
+ if (templateColorway !== 'plotly') {
36
+ return hexColor;
37
+ }
38
+ var index = DEFAULT_PLOTLY_COLORWAY.indexOf(hexColor.toLowerCase());
39
+ if (index !== -1) {
40
+ return (0, colors_1.getColorFromToken)(PLOTLY_FLUENTVIZ_COLORWAY_MAPPING[index], isDarkTheme);
41
+ }
42
+ return hexColor;
43
+ }
44
+ var getColor = function (legendLabel, colorMap, isDarkTheme) {
45
+ if (!colorMap.current.has(legendLabel)) {
46
+ var nextColor = void 0;
47
+ if (colorMap.current.size < PLOTLY_FLUENTVIZ_COLORWAY_MAPPING.length) {
48
+ // Get first 10 colors from plotly-fluentviz colorway mapping
49
+ nextColor = (0, colors_1.getColorFromToken)(PLOTLY_FLUENTVIZ_COLORWAY_MAPPING[colorMap.current.size], isDarkTheme);
50
+ }
51
+ else {
52
+ nextColor = (0, colors_1.getNextColor)(colorMap.current.size, 0, isDarkTheme);
53
+ }
54
+ colorMap.current.set(legendLabel, nextColor);
55
+ return nextColor;
56
+ }
57
+ return colorMap.current.get(legendLabel);
58
+ };
59
+ exports.getColor = getColor;
60
+ var getSchemaColors = function (colorway, colors, colorMap, isDarkTheme) {
61
+ var hexColors = [];
62
+ if (!colors) {
63
+ return undefined;
64
+ }
65
+ var templateColorway = getPlotlyColorway(colorway);
66
+ if ((0, chart_utilities_1.isArrayOrTypedArray)(colors)) {
67
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
68
+ colors.forEach(function (element, index) {
69
+ var colorString = element === null || element === void 0 ? void 0 : element.toString().trim();
70
+ var nextFluentColor = (0, exports.getColor)("Label_".concat(index), colorMap, isDarkTheme);
71
+ if (colorString) {
72
+ var parsedColor = (0, d3_color_1.color)(colorString);
73
+ hexColors.push(parsedColor ? tryMapFluentDataViz(parsedColor.formatHex(), templateColorway, isDarkTheme) : nextFluentColor);
74
+ }
75
+ else {
76
+ hexColors.push(nextFluentColor);
77
+ }
78
+ });
79
+ }
80
+ else if (typeof colors === 'string') {
81
+ var parsedColor = (0, d3_color_1.color)(colors);
82
+ return parsedColor
83
+ ? tryMapFluentDataViz(parsedColor.formatHex(), templateColorway, isDarkTheme)
84
+ : (0, exports.getColor)('Label_0', colorMap, isDarkTheme);
85
+ }
86
+ return hexColors;
87
+ };
88
+ exports.getSchemaColors = getSchemaColors;
89
+ var extractColor = function (colorway, colorwayType, colors, colorMap, isDarkTheme) {
90
+ return colorwayType === 'default' && colors ? (0, exports.getSchemaColors)(colorway, colors, colorMap, isDarkTheme) : undefined;
91
+ };
92
+ exports.extractColor = extractColor;
93
+ var resolveColor = function (extractedColors, index, legend, colorMap, isDarkTheme) {
94
+ var color = '';
95
+ if (extractedColors && (0, chart_utilities_1.isArrayOrTypedArray)(extractedColors) && extractedColors[index]) {
96
+ color = extractedColors[index % extractedColors.length];
97
+ }
98
+ else if (typeof extractedColors === 'string') {
99
+ color = extractedColors;
100
+ }
101
+ else {
102
+ color = (0, exports.getColor)(legend, colorMap, isDarkTheme);
103
+ }
104
+ return color;
105
+ };
106
+ exports.resolveColor = resolveColor;
107
+ });
108
+ //# sourceMappingURL=PlotlyColorAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlotlyColorAdapter.js","sourceRoot":"../src/","sources":["components/DeclarativeChart/PlotlyColorAdapter.ts"],"names":[],"mappings":";;;;IAaA,IAAM,uBAAuB,GAAG;QAC9B,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,IAAI;KAChB,CAAC;IAEF,IAAM,iCAAiC,GAAG;QACxC,uBAAc,CAAC,MAAM,EAAE,GAAG;QAC1B,uBAAc,CAAC,OAAO,EAAE,GAAG;QAC3B,uBAAc,CAAC,MAAM,EAAE,GAAG;QAC1B,uBAAc,CAAC,MAAM,EAAE,GAAG;QAC1B,uBAAc,C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,IAAI,OAAO,eAAe,KAAK,QAAQ,EAAE,CAAC;YAC/C,KAAK,GAAG,eAAe,CAAC;QAC1B,CAAC;aAAM,CAAC;YACN,KAAK,GAAG,IAAA,gBAAQ,EAAC,MAAM,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;QAClD,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAhBW,QAAA,YAAY,gBAgBvB","sourcesContent":["import * as React from 'react';\nimport { color as d3Color } from 'd3-color';\nimport type { PieColors, Color } from '@fluentui/chart-utilities';\nimport { isArrayOrTypedArray } from '@fluentui/chart-utilities';\nimport { areArraysEqual } from '../../utilities/utilities';\nimport { DataVizPalette, getColorFromToken, getNextColor } from '../../utilities/colors';\n\ntype PlotlyColorway = 'plotly' | 'others';\n\n// The color sequences in plotly express are defined here:\n// https://plotly.com/python/discrete-color/#:~:text=Join%20now.-,Color%20Sequences%20in%20Plotly%20Express,-By%20default%2C%20Plotly\nexport type ColorwayType = 'default' | 'builtin' | 'others' | undefined;\n\nconst DEFAULT_PLOTLY_COLORWAY = [\n '#636efa', //1\n '#ef553b', //2\n '#00cc96', //3\n '#ab63fa', //4\n '#ffa15a', //5\n '#19d3f3', //6\n '#ff6692', //7\n '#b6e880', //8\n '#ff97ff', //9\n '#fecb52', //10\n];\n\nconst PLOTLY_FLUENTVIZ_COLORWAY_MAPPING = [\n DataVizPalette.color1, //1\n DataVizPalette.warning, //2\n DataVizPalette.color8, //3\n DataVizPalette.color4, //4\n DataVizPalette.color7, //5\n DataVizPalette.color6, //6\n DataVizPalette.color2, //7\n DataVizPalette.color5, //8\n DataVizPalette.color9, //9\n DataVizPalette.color10, //10\n];\n\nfunction getPlotlyColorway(colorway: string[] | undefined): PlotlyColorway {\n const isPlotlyColorway =\n isArrayOrTypedArray(colorway) &&\n areArraysEqual(\n colorway?.map(c => c.toLowerCase()),\n DEFAULT_PLOTLY_COLORWAY,\n );\n\n return isPlotlyColorway ? 'plotly' : 'others';\n}\n\nfunction tryMapFluentDataViz(hexColor: string, templateColorway: PlotlyColorway, isDarkTheme?: boolean): string {\n if (templateColorway !== 'plotly') {\n return hexColor;\n }\n const index = DEFAULT_PLOTLY_COLORWAY.indexOf(hexColor.toLowerCase());\n if (index !== -1) {\n return getColorFromToken(PLOTLY_FLUENTVIZ_COLORWAY_MAPPING[index], isDarkTheme);\n }\n return hexColor;\n}\n\nexport const getColor = (\n legendLabel: string,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): string => {\n if (!colorMap.current.has(legendLabel)) {\n let nextColor: string;\n if (colorMap.current.size < PLOTLY_FLUENTVIZ_COLORWAY_MAPPING.length) {\n // Get first 10 colors from plotly-fluentviz colorway mapping\n nextColor = getColorFromToken(PLOTLY_FLUENTVIZ_COLORWAY_MAPPING[colorMap.current.size], isDarkTheme);\n } else {\n nextColor = getNextColor(colorMap.current.size, 0, isDarkTheme);\n }\n colorMap.current.set(legendLabel, nextColor);\n return nextColor;\n }\n\n return colorMap.current.get(legendLabel) as string;\n};\n\nexport const getSchemaColors = (\n colorway: string[] | undefined,\n colors: PieColors | Color | Color[] | string | null | undefined,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): string[] | string | undefined => {\n const hexColors: string[] = [];\n if (!colors) {\n return undefined;\n }\n const templateColorway = getPlotlyColorway(colorway);\n if (isArrayOrTypedArray(colors)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (colors as any[]).forEach((element, index) => {\n const colorString = element?.toString().trim();\n const nextFluentColor = getColor(`Label_${index}`, colorMap, isDarkTheme);\n if (colorString) {\n const parsedColor = d3Color(colorString);\n hexColors.push(\n parsedColor ? tryMapFluentDataViz(parsedColor.formatHex(), templateColorway, isDarkTheme) : nextFluentColor,\n );\n } else {\n hexColors.push(nextFluentColor);\n }\n });\n } else if (typeof colors === 'string') {\n const parsedColor = d3Color(colors);\n return parsedColor\n ? tryMapFluentDataViz(parsedColor.formatHex(), templateColorway, isDarkTheme)\n : getColor('Label_0', colorMap, isDarkTheme);\n }\n return hexColors;\n};\n\nexport const extractColor = (\n colorway: string[] | undefined,\n colorwayType: ColorwayType,\n colors: PieColors | Color | Color[] | string | null | undefined,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): string | string[] | undefined => {\n return colorwayType === 'default' && colors ? getSchemaColors(colorway, colors, colorMap, isDarkTheme) : undefined;\n};\n\nexport const resolveColor = (\n extractedColors: string[] | string | null | undefined,\n index: number,\n legend: string,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): string => {\n let color = '';\n if (extractedColors && isArrayOrTypedArray(extractedColors) && extractedColors[index]) {\n color = extractedColors[index % extractedColors.length];\n } else if (typeof extractedColors === 'string') {\n color = extractedColors;\n } else {\n color = getColor(legend, colorMap, isDarkTheme);\n }\n return color;\n};\n"]}