@fluentui/react-charting 5.23.88 → 5.23.90
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.
- package/CHANGELOG.json +67 -1
- package/CHANGELOG.md +26 -2
- package/dist/react-charting.d.ts +72 -6
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +37 -1
- package/lib/ChartTable.d.ts +1 -0
- package/lib/ChartTable.js +2 -0
- package/lib/ChartTable.js.map +1 -0
- package/lib/components/ChartTable/ChartTable.base.d.ts +10 -0
- package/lib/components/ChartTable/ChartTable.base.js +44 -0
- package/lib/components/ChartTable/ChartTable.base.js.map +1 -0
- package/lib/components/ChartTable/ChartTable.d.ts +7 -0
- package/lib/components/ChartTable/ChartTable.js +9 -0
- package/lib/components/ChartTable/ChartTable.js.map +1 -0
- package/lib/components/ChartTable/ChartTable.styles.d.ts +2 -0
- package/lib/components/ChartTable/ChartTable.styles.js +28 -0
- package/lib/components/ChartTable/ChartTable.styles.js.map +1 -0
- package/lib/components/ChartTable/ChartTable.types.d.ts +58 -0
- package/lib/components/ChartTable/ChartTable.types.js +2 -0
- package/lib/components/ChartTable/ChartTable.types.js.map +1 -0
- package/lib/components/ChartTable/index.d.ts +2 -0
- package/lib/components/ChartTable/index.js +3 -0
- package/lib/components/ChartTable/index.js.map +1 -0
- package/lib/components/DeclarativeChart/DeclarativeChart.d.ts +7 -6
- package/lib/components/DeclarativeChart/DeclarativeChart.js +15 -12
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.d.ts +7 -0
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +103 -0
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -13
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +141 -120
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/LineChart/LineChart.base.js +19 -9
- package/lib/components/LineChart/LineChart.base.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/utilities/image-export-utils.js +25 -3
- package/lib/utilities/image-export-utils.js.map +1 -1
- package/lib-amd/ChartTable.d.ts +1 -0
- package/lib-amd/ChartTable.js +6 -0
- package/lib-amd/ChartTable.js.map +1 -0
- package/lib-amd/components/ChartTable/ChartTable.base.d.ts +10 -0
- package/lib-amd/components/ChartTable/ChartTable.base.js +45 -0
- package/lib-amd/components/ChartTable/ChartTable.base.js.map +1 -0
- package/lib-amd/components/ChartTable/ChartTable.d.ts +7 -0
- package/lib-amd/components/ChartTable/ChartTable.js +11 -0
- package/lib-amd/components/ChartTable/ChartTable.js.map +1 -0
- package/lib-amd/components/ChartTable/ChartTable.styles.d.ts +2 -0
- package/lib-amd/components/ChartTable/ChartTable.styles.js +32 -0
- package/lib-amd/components/ChartTable/ChartTable.styles.js.map +1 -0
- package/lib-amd/components/ChartTable/ChartTable.types.d.ts +58 -0
- package/lib-amd/components/ChartTable/ChartTable.types.js +5 -0
- package/lib-amd/components/ChartTable/ChartTable.types.js.map +1 -0
- package/lib-amd/components/ChartTable/index.d.ts +2 -0
- package/lib-amd/components/ChartTable/index.js +7 -0
- package/lib-amd/components/ChartTable/index.js.map +1 -0
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.d.ts +7 -6
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +14 -12
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.d.ts +7 -0
- package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.js +108 -0
- package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -13
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +143 -124
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/LineChart/LineChart.base.js +19 -9
- package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-amd/index.d.ts +2 -0
- package/lib-amd/index.js +3 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/utilities/image-export-utils.js +25 -3
- package/lib-amd/utilities/image-export-utils.js.map +1 -1
- package/lib-commonjs/ChartTable.d.ts +1 -0
- package/lib-commonjs/ChartTable.js +5 -0
- package/lib-commonjs/ChartTable.js.map +1 -0
- package/lib-commonjs/components/ChartTable/ChartTable.base.d.ts +10 -0
- package/lib-commonjs/components/ChartTable/ChartTable.base.js +47 -0
- package/lib-commonjs/components/ChartTable/ChartTable.base.js.map +1 -0
- package/lib-commonjs/components/ChartTable/ChartTable.d.ts +7 -0
- package/lib-commonjs/components/ChartTable/ChartTable.js +12 -0
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -0
- package/lib-commonjs/components/ChartTable/ChartTable.styles.d.ts +2 -0
- package/lib-commonjs/components/ChartTable/ChartTable.styles.js +32 -0
- package/lib-commonjs/components/ChartTable/ChartTable.styles.js.map +1 -0
- package/lib-commonjs/components/ChartTable/ChartTable.types.d.ts +58 -0
- package/lib-commonjs/components/ChartTable/ChartTable.types.js +3 -0
- package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -0
- package/lib-commonjs/components/ChartTable/index.d.ts +2 -0
- package/lib-commonjs/components/ChartTable/index.js +6 -0
- package/lib-commonjs/components/ChartTable/index.js.map +1 -0
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.d.ts +7 -6
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +14 -11
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.d.ts +7 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +110 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -13
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +143 -124
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.base.js +19 -9
- package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-commonjs/index.d.ts +2 -0
- package/lib-commonjs/index.js +3 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utilities/image-export-utils.js +25 -3
- package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
- package/package.json +4 -4
- package/src/components/ChartTable/ChartTable.types.ts +68 -0
|
@@ -40,6 +40,9 @@ export type ChartDataMode = 'default' | 'fraction' | 'percentage';
|
|
|
40
40
|
// @public (undocumented)
|
|
41
41
|
export const ChartHoverCard: React_2.FunctionComponent<IChartHoverCardProps>;
|
|
42
42
|
|
|
43
|
+
// @public
|
|
44
|
+
export const ChartTable: React_2.FunctionComponent<IChartTableProps>;
|
|
45
|
+
|
|
43
46
|
// @public (undocumented)
|
|
44
47
|
export const DataVizGradientPalette: {
|
|
45
48
|
gradient1: string;
|
|
@@ -127,8 +130,9 @@ export const DeclarativeChart: React_2.FunctionComponent<DeclarativeChartProps>;
|
|
|
127
130
|
// @public
|
|
128
131
|
export interface DeclarativeChartProps extends React_2.RefAttributes<HTMLDivElement> {
|
|
129
132
|
chartSchema: Schema;
|
|
133
|
+
// Warning: (ae-forgotten-export) The symbol "ColorwayType" needs to be exported by the entry point index.d.ts
|
|
134
|
+
colorwayType?: ColorwayType;
|
|
130
135
|
componentRef?: IRefObject<IDeclarativeChart>;
|
|
131
|
-
fluentDataVizColorPalette?: 'default' | 'builtin' | 'override';
|
|
132
136
|
onSchemaChange?: (eventData: Schema) => void;
|
|
133
137
|
}
|
|
134
138
|
|
|
@@ -431,6 +435,38 @@ export interface IChartProps {
|
|
|
431
435
|
SankeyChartData?: ISankeyChartData;
|
|
432
436
|
}
|
|
433
437
|
|
|
438
|
+
// @public
|
|
439
|
+
export interface IChartTableProps {
|
|
440
|
+
className?: string;
|
|
441
|
+
componentRef?: IRefObject<IChart>;
|
|
442
|
+
headers: (string | number | boolean | null)[] | (string | number | boolean | null)[][];
|
|
443
|
+
height?: string | number;
|
|
444
|
+
rows: (string | number | boolean | null)[][];
|
|
445
|
+
styles?: IStyleFunctionOrObject<IChartTableStyleProps, IChartTableStyles>;
|
|
446
|
+
theme?: ITheme;
|
|
447
|
+
width?: string | number;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
// @public (undocumented)
|
|
451
|
+
export interface IChartTableStyleProps {
|
|
452
|
+
// (undocumented)
|
|
453
|
+
className?: string;
|
|
454
|
+
// (undocumented)
|
|
455
|
+
theme: ITheme;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// @public
|
|
459
|
+
export interface IChartTableStyles {
|
|
460
|
+
// (undocumented)
|
|
461
|
+
bodyCell?: IStyle;
|
|
462
|
+
// (undocumented)
|
|
463
|
+
headerCell?: IStyle;
|
|
464
|
+
// (undocumented)
|
|
465
|
+
root?: IStyle;
|
|
466
|
+
// (undocumented)
|
|
467
|
+
table?: IStyle;
|
|
468
|
+
}
|
|
469
|
+
|
|
434
470
|
// @public (undocumented)
|
|
435
471
|
export interface IChildProps {
|
|
436
472
|
// (undocumented)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/ChartTable/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartTable.js","sourceRoot":"../src/","sources":["ChartTable.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC","sourcesContent":["export * from './components/ChartTable/index';\n"]}
|
|
@@ -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,44 @@
|
|
|
1
|
+
import { __extends } from "tslib";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { classNamesFunction, getRTL, initializeComponentRef } from '@fluentui/react/lib/Utilities';
|
|
4
|
+
import { toImage } from '../../utilities/image-export-utils';
|
|
5
|
+
var getClassNames = classNamesFunction();
|
|
6
|
+
var ChartTableBase = /** @class */ (function (_super) {
|
|
7
|
+
__extends(ChartTableBase, _super);
|
|
8
|
+
function ChartTableBase(props) {
|
|
9
|
+
var _this = _super.call(this, props) || this;
|
|
10
|
+
_this.toImage = function (opts) {
|
|
11
|
+
return toImage(_this._rootElem, undefined, _this._isRTL, opts);
|
|
12
|
+
};
|
|
13
|
+
initializeComponentRef(_this);
|
|
14
|
+
_this._isRTL = 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
|
+
export { ChartTableBase };
|
|
44
|
+
//# 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":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEnG,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAE7D,IAAM,aAAa,GAAG,kBAAkB,EAA4C,CAAC;AAErF;IAAoC,kCAAiC;IAInE,wBAAY,KAAuB;QACjC,YAAA,MAAK,YAAC,KAAK,CAAC,SAAC;QAIR,aAAO,GAAG,UAAC,IAA0B;YAC1C,OAAO,OAAO,CAAC,KAAI,CAAC,SAAS,EAAE,SAAS,EAAE,KAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;Q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AS,EAAE,UAAU,CAAC,KAAK,EAC3B,KAAK,EAAE;gCACL,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,UAAG,KAAK,OAAI,CAAC,CAAC,CAAC,MAAM;6BACrC;4BAED;gCACE,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;4BACP,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;IACJ,CAAC;IACH,qBAAC;AAAD,CAAC,AA1ED,CAAoC,KAAK,CAAC,SAAS,GA0ElD","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,9 @@
|
|
|
1
|
+
import { styled } from '@fluentui/react/lib/Utilities';
|
|
2
|
+
import { ChartTableBase } from './ChartTable.base';
|
|
3
|
+
import { getStyles } from './ChartTable.styles';
|
|
4
|
+
/**
|
|
5
|
+
* ChartTable component
|
|
6
|
+
* {@docCategory ChartTable}
|
|
7
|
+
*/
|
|
8
|
+
export var ChartTable = styled(ChartTableBase, getStyles);
|
|
9
|
+
//# sourceMappingURL=ChartTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartTable.js","sourceRoot":"../src/","sources":["components/ChartTable/ChartTable.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD;;;GAGG;AACH,MAAM,CAAC,IAAM,UAAU,GAA8C,MAAM,CAIzE,cAAc,EAAE,SAAS,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,28 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { FontWeights, HighContrastSelector } from '@fluentui/react/lib/Styling';
|
|
3
|
+
export var getStyles = function (props) {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
var theme = props.theme;
|
|
6
|
+
var fonts = theme.fonts;
|
|
7
|
+
return {
|
|
8
|
+
root: {
|
|
9
|
+
width: '100%',
|
|
10
|
+
overflowX: 'auto',
|
|
11
|
+
},
|
|
12
|
+
table: {
|
|
13
|
+
borderCollapse: 'collapse',
|
|
14
|
+
},
|
|
15
|
+
headerCell: __assign(__assign({}, fonts.small), { fontWeight: FontWeights.semibold, backgroundColor: theme.palette.neutralQuaternary, color: theme.semanticColors.bodyText, padding: '8px', textAlign: 'left', border: "2px solid ".concat(theme.palette.neutralLighter), selectors: (_a = {},
|
|
16
|
+
_a[HighContrastSelector] = {
|
|
17
|
+
backgroundColor: 'Window',
|
|
18
|
+
color: 'WindowText',
|
|
19
|
+
},
|
|
20
|
+
_a) }),
|
|
21
|
+
bodyCell: __assign(__assign({}, fonts.small), { padding: '8px', border: "2px solid ".concat(theme.palette.neutralLighter), color: theme.semanticColors.bodyText, textAlign: 'left', selectors: (_b = {},
|
|
22
|
+
_b[HighContrastSelector] = {
|
|
23
|
+
color: 'WindowText',
|
|
24
|
+
},
|
|
25
|
+
_b) }),
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
//# 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":";AACA,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEhF,MAAM,CAAC,IAAM,SAAS,GAAG,UAAC,KAA4B;;IAC5C,IAAA,KAAK,GAAK,KAAK,MAAV,CAAW;IAChB,IAAA,KAAK,GAAK,KAAM,MAAX,CAAY;IAEzB,OAAO;QACL,IAAI,EAAE;YACJ,KAAK,EAAE,MAAM;YACb,SAAS,EAAE,MAAM;SAClB;QACD,KAAK,EAAE;YACL,cAAc,EAAE,UAAU;SAC3B;QACD,UAAU,wBACL,KAAK,CAAC,KAAK,KACd,UAAU,EAAE,WAAW,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;gBACP,GAAC,oBAAoB,IAAG;oBACtB,eAAe,EAAE,QAAQ;oBACzB,KAAK,EAAE,YAAY;iBACpB;sBAEJ;QACD,QAAQ,wBACH,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;gBACP,GAAC,oBAAoB,IAAG;oBACtB,KAAK,EAAE,YAAY;iBACpB;sBAEJ;KACF,CAAC;AACJ,CAAC,CAAC","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 @@
|
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/ChartTable/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC","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,13 +31,13 @@ export interface DeclarativeChartProps extends React.RefAttributes<HTMLDivElemen
|
|
|
30
31
|
*/
|
|
31
32
|
componentRef?: IRefObject<IDeclarativeChart>;
|
|
32
33
|
/**
|
|
33
|
-
* Optional prop to specify the
|
|
34
|
-
* - 'default':
|
|
35
|
-
* - 'builtin': Use Fluent UI
|
|
36
|
-
* - '
|
|
37
|
-
* @default '
|
|
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'
|
|
38
39
|
*/
|
|
39
|
-
|
|
40
|
+
colorwayType?: ColorwayType;
|
|
40
41
|
}
|
|
41
42
|
/**
|
|
42
43
|
* {@docCategory DeclarativeChart}
|
|
@@ -6,7 +6,7 @@ import { DonutChart } from '../DonutChart/index';
|
|
|
6
6
|
import { VerticalStackedBarChart } from '../VerticalStackedBarChart/index';
|
|
7
7
|
import { decodeBase64Fields } from '@fluentui/chart-utilities';
|
|
8
8
|
import { isArrayOrTypedArray, isDateArray, isNumberArray, isYearArray, mapFluentChart, sanitizeJson, } from '@fluentui/chart-utilities';
|
|
9
|
-
import { isMonthArray, correctYearMonth, transformPlotlyJsonToDonutProps, transformPlotlyJsonToVSBCProps, transformPlotlyJsonToScatterChartProps, transformPlotlyJsonToHorizontalBarWithAxisProps, transformPlotlyJsonToHeatmapProps, transformPlotlyJsonToSankeyProps, transformPlotlyJsonToGaugeProps, transformPlotlyJsonToGVBCProps, transformPlotlyJsonToVBCProps, projectPolarToCartesian, } from './PlotlySchemaAdapter';
|
|
9
|
+
import { isMonthArray, correctYearMonth, transformPlotlyJsonToDonutProps, transformPlotlyJsonToVSBCProps, transformPlotlyJsonToScatterChartProps, transformPlotlyJsonToHorizontalBarWithAxisProps, transformPlotlyJsonToHeatmapProps, transformPlotlyJsonToSankeyProps, transformPlotlyJsonToGaugeProps, transformPlotlyJsonToGVBCProps, transformPlotlyJsonToVBCProps, transformPlotlyJsonToChartTableProps, projectPolarToCartesian, } from './PlotlySchemaAdapter';
|
|
10
10
|
import { LineChart } from '../LineChart/index';
|
|
11
11
|
import { HorizontalBarChartWithAxis } from '../HorizontalBarChartWithAxis/index';
|
|
12
12
|
import { AreaChart } from '../AreaChart/index';
|
|
@@ -16,6 +16,7 @@ import { GaugeChart } from '../GaugeChart/index';
|
|
|
16
16
|
import { GroupedVerticalBarChart } from '../GroupedVerticalBarChart/index';
|
|
17
17
|
import { VerticalBarChart } from '../VerticalBarChart/index';
|
|
18
18
|
import { withResponsiveContainer } from '../ResponsiveContainer/withResponsiveContainer';
|
|
19
|
+
import { ChartTable } from '../ChartTable/index';
|
|
19
20
|
var ResponsiveDonutChart = withResponsiveContainer(DonutChart);
|
|
20
21
|
var ResponsiveVerticalStackedBarChart = withResponsiveContainer(VerticalStackedBarChart);
|
|
21
22
|
var ResponsiveLineChart = withResponsiveContainer(LineChart);
|
|
@@ -26,6 +27,7 @@ var ResponsiveSankeyChart = withResponsiveContainer(SankeyChart);
|
|
|
26
27
|
var ResponsiveGaugeChart = withResponsiveContainer(GaugeChart);
|
|
27
28
|
var ResponsiveGroupedVerticalBarChart = withResponsiveContainer(GroupedVerticalBarChart);
|
|
28
29
|
var ResponsiveVerticalBarChart = withResponsiveContainer(VerticalBarChart);
|
|
30
|
+
var ResponsiveChartTable = withResponsiveContainer(ChartTable);
|
|
29
31
|
var useColorMapping = function () {
|
|
30
32
|
var colorMap = React.useRef(new Map());
|
|
31
33
|
return colorMap;
|
|
@@ -81,11 +83,10 @@ export var DeclarativeChart = React.forwardRef(function (props, forwardedRef) {
|
|
|
81
83
|
componentRef: chartRef,
|
|
82
84
|
calloutProps: { layerProps: { eventBubblingEnabled: true } },
|
|
83
85
|
};
|
|
84
|
-
var useFluentVizColorPalette = props.fluentDataVizColorPalette === 'builtin';
|
|
85
86
|
var renderLineArea = function (plotlyData, isAreaChart) {
|
|
86
87
|
var _a;
|
|
87
88
|
var isScatterMarkers = ['markers', 'text+markers', 'markers+text'].includes((_a = plotlyData[0]) === null || _a === void 0 ? void 0 : _a.mode);
|
|
88
|
-
var chartProps = __assign(__assign({}, transformPlotlyJsonToScatterChartProps({ data: plotlyData, layout: plotlyInput.layout }, isAreaChart, colorMap,
|
|
89
|
+
var chartProps = __assign(__assign({}, transformPlotlyJsonToScatterChartProps({ data: plotlyData, layout: plotlyInput.layout }, isAreaChart, isScatterMarkers, colorMap, props.colorwayType, isDarkTheme)), commonProps);
|
|
89
90
|
if (isAreaChart) {
|
|
90
91
|
return React.createElement(ResponsiveAreaChart, __assign({}, chartProps));
|
|
91
92
|
}
|
|
@@ -115,7 +116,7 @@ export var DeclarativeChart = React.forwardRef(function (props, forwardedRef) {
|
|
|
115
116
|
if (isAreaChart) {
|
|
116
117
|
throw new Error('Fallback to VerticalStackedBarChart is not allowed for Area Charts.');
|
|
117
118
|
}
|
|
118
|
-
return (React.createElement(ResponsiveVerticalStackedBarChart, __assign({}, transformPlotlyJsonToVSBCProps(plotlyInputWithValidData, colorMap,
|
|
119
|
+
return (React.createElement(ResponsiveVerticalStackedBarChart, __assign({}, transformPlotlyJsonToVSBCProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme, fallbackVSBC), commonProps)));
|
|
119
120
|
};
|
|
120
121
|
var exportAsImage = React.useCallback(function (opts) {
|
|
121
122
|
return new Promise(function (resolve, reject) {
|
|
@@ -133,21 +134,23 @@ export var DeclarativeChart = React.forwardRef(function (props, forwardedRef) {
|
|
|
133
134
|
}); }, [exportAsImage]);
|
|
134
135
|
switch (chart.type) {
|
|
135
136
|
case 'donut':
|
|
136
|
-
return (React.createElement(ResponsiveDonutChart, __assign({}, transformPlotlyJsonToDonutProps(plotlyInputWithValidData, colorMap,
|
|
137
|
+
return (React.createElement(ResponsiveDonutChart, __assign({}, transformPlotlyJsonToDonutProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
|
|
137
138
|
case 'horizontalbar':
|
|
138
|
-
return (React.createElement(ResponsiveHorizontalBarChartWithAxis, __assign({}, transformPlotlyJsonToHorizontalBarWithAxisProps(plotlyInputWithValidData, colorMap,
|
|
139
|
+
return (React.createElement(ResponsiveHorizontalBarChartWithAxis, __assign({}, transformPlotlyJsonToHorizontalBarWithAxisProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
|
|
139
140
|
case 'groupedverticalbar':
|
|
140
|
-
return (React.createElement(ResponsiveGroupedVerticalBarChart, __assign({}, transformPlotlyJsonToGVBCProps(plotlyInputWithValidData, colorMap,
|
|
141
|
+
return (React.createElement(ResponsiveGroupedVerticalBarChart, __assign({}, transformPlotlyJsonToGVBCProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
|
|
141
142
|
case 'verticalstackedbar':
|
|
142
|
-
return (React.createElement(ResponsiveVerticalStackedBarChart, __assign({}, transformPlotlyJsonToVSBCProps(plotlyInputWithValidData, colorMap,
|
|
143
|
+
return (React.createElement(ResponsiveVerticalStackedBarChart, __assign({}, transformPlotlyJsonToVSBCProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
|
|
143
144
|
case 'heatmap':
|
|
144
145
|
return (React.createElement(ResponsiveHeatMapChart, __assign({}, transformPlotlyJsonToHeatmapProps(plotlyInputWithValidData), commonProps, { legendProps: {} })));
|
|
145
146
|
case 'sankey':
|
|
146
|
-
return (React.createElement(ResponsiveSankeyChart, __assign({}, transformPlotlyJsonToSankeyProps(plotlyInputWithValidData, colorMap, isDarkTheme), commonProps)));
|
|
147
|
+
return (React.createElement(ResponsiveSankeyChart, __assign({}, transformPlotlyJsonToSankeyProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
|
|
147
148
|
case 'gauge':
|
|
148
|
-
return (React.createElement(ResponsiveGaugeChart, __assign({}, transformPlotlyJsonToGaugeProps(plotlyInputWithValidData, colorMap, isDarkTheme), commonProps)));
|
|
149
|
+
return (React.createElement(ResponsiveGaugeChart, __assign({}, transformPlotlyJsonToGaugeProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
|
|
149
150
|
case 'verticalbar':
|
|
150
|
-
return (React.createElement(ResponsiveVerticalBarChart, __assign({}, transformPlotlyJsonToVBCProps(plotlyInputWithValidData, colorMap,
|
|
151
|
+
return (React.createElement(ResponsiveVerticalBarChart, __assign({}, transformPlotlyJsonToVBCProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
|
|
152
|
+
case 'table':
|
|
153
|
+
return (React.createElement(ResponsiveChartTable, __assign({}, transformPlotlyJsonToChartTableProps(plotlyInputWithValidData, colorMap, isDarkTheme), commonProps)));
|
|
151
154
|
case 'area':
|
|
152
155
|
case 'line':
|
|
153
156
|
case 'fallback':
|
|
@@ -165,6 +168,6 @@ export var DeclarativeChart = React.forwardRef(function (props, forwardedRef) {
|
|
|
165
168
|
});
|
|
166
169
|
DeclarativeChart.displayName = 'DeclarativeChart';
|
|
167
170
|
DeclarativeChart.defaultProps = {
|
|
168
|
-
|
|
171
|
+
colorwayType: 'default',
|
|
169
172
|
};
|
|
170
173
|
//# sourceMappingURL=DeclarativeChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeclarativeChart.js","sourceRoot":"../src/","sources":["components/DeclarativeChart/DeclarativeChart.tsx"],"names":[],"mappings":";AAAA,yDAAyD;AACzD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,WAAW,EACX,cAAc,EACd,YAAY,GACb,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,+BAA+B,EAC/B,8BAA8B,EAC9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CAAC;QAChB,KAAK,cAAc;YACjB,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;gBAClC,IAAM,mBAAmB,GAAG,uBAAuB,CAAC,wBAAwB,CAAC,CAAC;gBAC9E,wBAAwB,CAAC,IAAI,GAAG,mBAAmB,CAAC,IAAI,CAAC;YAC3D,CAAC;YACD,kGAAkG;YAClG,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;YACF,OAAO,mBAAmB,CAAC,WAAW,CAAC,CAAC;QAC1C;YACE,MAAM,IAAI,KAAK,CAAC,kCAA2B,MAAA,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,0CAAE,IAAI,CAAE,CAAC,CAAC;IACzF,CAAC;AACH,CAAC,CAAC,CAAC;AACH,gBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC;AAClD,gBAAgB,CAAC,YAAY,GAAG;IAC9B,yBAAyB,EAAE,SAAS;CACrC,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 specify the color palette for the chart.\n * - 'default': Do not use Fluent UI color palette.\n * - 'builtin': Use Fluent UI color palette.\n * - 'override': Reserved for future use.\n * @default 'builtin'\n */\n fluentDataVizColorPalette?: 'default' | 'builtin' | 'override';\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 useFluentVizColorPalette = props.fluentDataVizColorPalette === 'builtin';\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 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(\n plotlyInputWithValidData,\n colorMap,\n useFluentVizColorPalette,\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(\n plotlyInputWithValidData,\n colorMap,\n useFluentVizColorPalette,\n isDarkTheme,\n )}\n {...commonProps}\n />\n );\n case 'horizontalbar':\n return (\n <ResponsiveHorizontalBarChartWithAxis\n {...transformPlotlyJsonToHorizontalBarWithAxisProps(\n plotlyInputWithValidData,\n colorMap,\n useFluentVizColorPalette,\n isDarkTheme,\n )}\n {...commonProps}\n />\n );\n case 'groupedverticalbar':\n return (\n <ResponsiveGroupedVerticalBarChart\n {...transformPlotlyJsonToGVBCProps(plotlyInputWithValidData, colorMap, useFluentVizColorPalette, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'verticalstackedbar':\n return (\n <ResponsiveVerticalStackedBarChart\n {...transformPlotlyJsonToVSBCProps(plotlyInputWithValidData, colorMap, useFluentVizColorPalette, 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, useFluentVizColorPalette, 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 fluentDataVizColorPalette: 'builtin',\n};\n"]}
|
|
1
|
+
{"version":3,"file":"DeclarativeChart.js","sourceRoot":"../src/","sources":["components/DeclarativeChart/DeclarativeChart.tsx"],"names":[],"mappings":";AAAA,yDAAyD;AACzD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,uBAAuB,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AACH,gBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC;AAClD,gBAAgB,CAAC,YAAY,GAAG;IAC9B,YAAY,EAAE,SAAS;CACxB,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,103 @@
|
|
|
1
|
+
import { color as d3Color } from 'd3-color';
|
|
2
|
+
import { isArrayOrTypedArray } from '@fluentui/chart-utilities';
|
|
3
|
+
import { areArraysEqual } from '../../utilities/utilities';
|
|
4
|
+
import { DataVizPalette, getColorFromToken, getNextColor } from '../../utilities/colors';
|
|
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
|
+
DataVizPalette.color1, //1
|
|
19
|
+
DataVizPalette.warning, //2
|
|
20
|
+
DataVizPalette.color8, //3
|
|
21
|
+
DataVizPalette.color4, //4
|
|
22
|
+
DataVizPalette.color7, //5
|
|
23
|
+
DataVizPalette.color6, //6
|
|
24
|
+
DataVizPalette.color2, //7
|
|
25
|
+
DataVizPalette.color5, //8
|
|
26
|
+
DataVizPalette.color9, //9
|
|
27
|
+
DataVizPalette.color10, //10
|
|
28
|
+
];
|
|
29
|
+
function getPlotlyColorway(colorway) {
|
|
30
|
+
var isPlotlyColorway = isArrayOrTypedArray(colorway) &&
|
|
31
|
+
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 getColorFromToken(PLOTLY_FLUENTVIZ_COLORWAY_MAPPING[index], isDarkTheme);
|
|
41
|
+
}
|
|
42
|
+
return hexColor;
|
|
43
|
+
}
|
|
44
|
+
export 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 = getColorFromToken(PLOTLY_FLUENTVIZ_COLORWAY_MAPPING[colorMap.current.size], isDarkTheme);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
nextColor = 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
|
+
export var getSchemaColors = function (colorway, colors, colorMap, isDarkTheme) {
|
|
60
|
+
var hexColors = [];
|
|
61
|
+
if (!colors) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
var templateColorway = getPlotlyColorway(colorway);
|
|
65
|
+
if (isArrayOrTypedArray(colors)) {
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
|
+
colors.forEach(function (element, index) {
|
|
68
|
+
var colorString = element === null || element === void 0 ? void 0 : element.toString().trim();
|
|
69
|
+
var nextFluentColor = getColor("Label_".concat(index), colorMap, isDarkTheme);
|
|
70
|
+
if (colorString) {
|
|
71
|
+
var parsedColor = d3Color(colorString);
|
|
72
|
+
hexColors.push(parsedColor ? tryMapFluentDataViz(parsedColor.formatHex(), templateColorway, isDarkTheme) : nextFluentColor);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
hexColors.push(nextFluentColor);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
else if (typeof colors === 'string') {
|
|
80
|
+
var parsedColor = d3Color(colors);
|
|
81
|
+
return parsedColor
|
|
82
|
+
? tryMapFluentDataViz(parsedColor.formatHex(), templateColorway, isDarkTheme)
|
|
83
|
+
: getColor('Label_0', colorMap, isDarkTheme);
|
|
84
|
+
}
|
|
85
|
+
return hexColors;
|
|
86
|
+
};
|
|
87
|
+
export var extractColor = function (colorway, colorwayType, colors, colorMap, isDarkTheme) {
|
|
88
|
+
return colorwayType === 'default' && colors ? getSchemaColors(colorway, colors, colorMap, isDarkTheme) : undefined;
|
|
89
|
+
};
|
|
90
|
+
export var resolveColor = function (extractedColors, index, legend, colorMap, isDarkTheme) {
|
|
91
|
+
var color = '';
|
|
92
|
+
if (extractedColors && isArrayOrTypedArray(extractedColors) && extractedColors[index]) {
|
|
93
|
+
color = extractedColors[index % extractedColors.length];
|
|
94
|
+
}
|
|
95
|
+
else if (typeof extractedColors === 'string') {
|
|
96
|
+
color = extractedColors;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
color = getColor(legend, colorMap, isDarkTheme);
|
|
100
|
+
}
|
|
101
|
+
return color;
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=PlotlyColorAdapter.js.map
|