@fluentui/react-charting 5.24.15 → 5.24.17
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 +49 -1
- package/CHANGELOG.md +23 -2
- package/dist/react-charting.d.ts +1 -1
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +1 -1
- package/lib/components/ChartTable/ChartTable.base.js +83 -4
- package/lib/components/ChartTable/ChartTable.base.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +72 -25
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.base.js +44 -15
- package/lib/components/FunnelChart/FunnelChart.base.js.map +1 -1
- package/lib/components/FunnelChart/funnelGeometry.d.ts +8 -8
- package/lib/components/FunnelChart/funnelGeometry.js +4 -4
- package/lib/components/FunnelChart/funnelGeometry.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.base.js +15 -9
- package/lib/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib/types/IDataPoint.d.ts +1 -1
- package/lib/types/IDataPoint.js.map +1 -1
- package/lib/utilities/utilities.d.ts +6 -0
- package/lib/utilities/utilities.js +10 -0
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-amd/components/ChartTable/ChartTable.base.js +81 -4
- package/lib-amd/components/ChartTable/ChartTable.base.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +72 -25
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/FunnelChart/FunnelChart.base.js +44 -15
- package/lib-amd/components/FunnelChart/FunnelChart.base.js.map +1 -1
- package/lib-amd/components/FunnelChart/funnelGeometry.d.ts +8 -8
- package/lib-amd/components/FunnelChart/funnelGeometry.js +9 -9
- package/lib-amd/components/FunnelChart/funnelGeometry.js.map +1 -1
- package/lib-amd/components/ScatterChart/ScatterChart.base.js +14 -8
- package/lib-amd/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib-amd/types/IDataPoint.d.ts +1 -1
- package/lib-amd/types/IDataPoint.js.map +1 -1
- package/lib-amd/utilities/utilities.d.ts +6 -0
- package/lib-amd/utilities/utilities.js +12 -1
- package/lib-amd/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.base.js +82 -3
- package/lib-commonjs/components/ChartTable/ChartTable.base.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +72 -25
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.base.js +44 -15
- package/lib-commonjs/components/FunnelChart/FunnelChart.base.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/funnelGeometry.d.ts +8 -8
- package/lib-commonjs/components/FunnelChart/funnelGeometry.js +9 -9
- package/lib-commonjs/components/FunnelChart/funnelGeometry.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js +14 -8
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib-commonjs/types/IDataPoint.d.ts +1 -1
- package/lib-commonjs/types/IDataPoint.js.map +1 -1
- package/lib-commonjs/utilities/utilities.d.ts +6 -0
- package/lib-commonjs/utilities/utilities.js +12 -1
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,7 +1,31 @@
|
|
|
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) {
|
|
1
|
+
define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities", "../../utilities/image-export-utils", "d3-color", "../../utilities/colors"], function (require, exports, tslib_1, React, Utilities_1, image_export_utils_1, d3, colors_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.ChartTableBase = void 0;
|
|
5
|
+
function invertHexColor(hex, theme) {
|
|
6
|
+
var color = d3.color(hex);
|
|
7
|
+
if (!color) {
|
|
8
|
+
return theme.semanticColors.bodyText;
|
|
9
|
+
}
|
|
10
|
+
var rgb = color.rgb();
|
|
11
|
+
return d3.rgb(255 - rgb.r, 255 - rgb.g, 255 - rgb.b).formatHex();
|
|
12
|
+
}
|
|
13
|
+
function getSafeBackgroundColor(theme, foreground, background) {
|
|
14
|
+
var fallbackFg = theme.semanticColors.bodyText;
|
|
15
|
+
var fallbackBg = theme.semanticColors.bodyBackground;
|
|
16
|
+
var fg = d3.color(foreground || fallbackFg);
|
|
17
|
+
var bg = d3.color(background || fallbackBg);
|
|
18
|
+
if (!fg || !bg) {
|
|
19
|
+
return fallbackBg;
|
|
20
|
+
}
|
|
21
|
+
var contrast = (0, colors_1.getColorContrast)(fg.formatHex(), bg.formatHex());
|
|
22
|
+
if (contrast >= 3) {
|
|
23
|
+
return bg.formatHex();
|
|
24
|
+
}
|
|
25
|
+
var invertedBg = invertHexColor(bg.formatHex(), theme);
|
|
26
|
+
var invertedContrast = (0, colors_1.getColorContrast)(fg.formatHex(), invertedBg);
|
|
27
|
+
return invertedContrast >= 3 ? invertedBg : fallbackBg;
|
|
28
|
+
}
|
|
5
29
|
var getClassNames = (0, Utilities_1.classNamesFunction)();
|
|
6
30
|
var ChartTableBase = /** @class */ (function (_super) {
|
|
7
31
|
tslib_1.__extends(ChartTableBase, _super);
|
|
@@ -17,13 +41,47 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
|
|
|
17
41
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
18
42
|
ChartTableBase.prototype.render = function () {
|
|
19
43
|
var _this = this;
|
|
20
|
-
var _a
|
|
44
|
+
var _a;
|
|
45
|
+
var _b = this.props, headers = _b.headers, rows = _b.rows, width = _b.width, height = _b.height, styles = _b.styles, theme = _b.theme;
|
|
21
46
|
var classNames = getClassNames(styles, {
|
|
22
47
|
theme: theme,
|
|
23
48
|
});
|
|
24
49
|
if (!headers || headers.length === 0) {
|
|
25
50
|
return React.createElement("div", null, "No data available");
|
|
26
51
|
}
|
|
52
|
+
var bgColorSet = new Set();
|
|
53
|
+
headers.forEach(function (header) {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
var bg = (_a = header === null || header === void 0 ? void 0 : header.style) === null || _a === void 0 ? void 0 : _a.backgroundColor;
|
|
56
|
+
var normalized = (_b = d3.color(bg || '')) === null || _b === void 0 ? void 0 : _b.formatHex();
|
|
57
|
+
if (normalized) {
|
|
58
|
+
bgColorSet.add(normalized);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
var sharedBackgroundColor;
|
|
62
|
+
var useSharedBackground = false;
|
|
63
|
+
/*
|
|
64
|
+
If we have only one or two unique background colors, we can consider using a shared background color
|
|
65
|
+
for the table headers. This is to ensure better contrast with the foreground text.
|
|
66
|
+
For size 1, we will consider that as default color if it satisfies the contrast ratio.
|
|
67
|
+
There could also be a scenario where backgroundcolor array is of size 2, for eg: ["dimsgray", "gray"],
|
|
68
|
+
which will assign 1st column header bg color to dimsgray and rest to gray. so our logic of shared background
|
|
69
|
+
color won't run here. So will consider for size 2 as well.
|
|
70
|
+
For size greater than this, we will consider that user wants different colors and will let color contrast fail
|
|
71
|
+
if any.
|
|
72
|
+
*/
|
|
73
|
+
if (bgColorSet.size === 1 || bgColorSet.size === 2) {
|
|
74
|
+
var candidateBg = bgColorSet.size === 1 ? Array.from(bgColorSet)[0] : Array.from(bgColorSet)[1];
|
|
75
|
+
for (var _i = 0, headers_1 = headers; _i < headers_1.length; _i++) {
|
|
76
|
+
var header = headers_1[_i];
|
|
77
|
+
var fg = (_a = header === null || header === void 0 ? void 0 : header.style) === null || _a === void 0 ? void 0 : _a.color;
|
|
78
|
+
if (fg && (0, colors_1.getColorContrast)(fg, candidateBg) >= 3) {
|
|
79
|
+
sharedBackgroundColor = candidateBg;
|
|
80
|
+
useSharedBackground = true;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
27
85
|
return (React.createElement("div", { ref: function (el) { return (_this._rootElem = el); }, className: classNames.root, style: { height: height ? "".concat(height, "px") : '650px', overflow: 'hidden' } },
|
|
28
86
|
React.createElement("svg", { width: width !== null && width !== void 0 ? width : '100%', height: height !== null && height !== void 0 ? height : '650px', className: classNames.chart },
|
|
29
87
|
React.createElement("foreignObject", { x: "0", y: "0", width: "100%", height: "100%" },
|
|
@@ -36,8 +94,27 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
|
|
|
36
94
|
width: width ? "".concat(width, "px") : '100%',
|
|
37
95
|
} },
|
|
38
96
|
React.createElement("thead", null,
|
|
39
|
-
React.createElement("tr", null, headers.map(function (header, idx) {
|
|
40
|
-
|
|
97
|
+
React.createElement("tr", null, headers.map(function (header, idx) {
|
|
98
|
+
var style = tslib_1.__assign({}, header === null || header === void 0 ? void 0 : header.style);
|
|
99
|
+
var fg = style.color;
|
|
100
|
+
var bg = style.backgroundColor;
|
|
101
|
+
if (useSharedBackground) {
|
|
102
|
+
style.backgroundColor = sharedBackgroundColor;
|
|
103
|
+
}
|
|
104
|
+
else if (fg || bg) {
|
|
105
|
+
style.backgroundColor = getSafeBackgroundColor(theme, fg, bg);
|
|
106
|
+
}
|
|
107
|
+
return (React.createElement("th", { key: idx, className: classNames.headerCell, style: style }, header.value));
|
|
108
|
+
}))),
|
|
109
|
+
rows && rows.length > 0 && (React.createElement("tbody", null, rows.map(function (row, rowIdx) { return (React.createElement("tr", { key: rowIdx }, row.map(function (cell, colIdx) {
|
|
110
|
+
var style = tslib_1.__assign({}, cell === null || cell === void 0 ? void 0 : cell.style);
|
|
111
|
+
var fg = style.color;
|
|
112
|
+
var bg = style.backgroundColor;
|
|
113
|
+
if (fg || bg) {
|
|
114
|
+
style.backgroundColor = getSafeBackgroundColor(theme, fg, bg);
|
|
115
|
+
}
|
|
116
|
+
return (React.createElement("td", { key: colIdx, className: classNames.bodyCell, style: style }, cell.value));
|
|
117
|
+
}))); })))))))));
|
|
41
118
|
};
|
|
42
119
|
return ChartTableBase;
|
|
43
120
|
}(React.Component));
|
|
@@ -1 +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,KAAuB;YACjC,YAAA,MAAK,YAAC,KAAK,CAAC,SAAC;YAIR,aAAO,GAAG,UAAC,IAA0B;gBAC1C,OAAO,IAAA,4BAAO,EAAC,KAAI,CAAC,SAAS,EAAE,SAAS,EAAE,KAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC/D,CAAC,CAAC;YALA,IAAA,kCAAsB,EAAC,KAAI,CAAC,CAAC;YAC7B,KAAI,CAAC,MAAM,GAAG,IAAA,kBAAM,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC;;QACpC,CAAC;QAKD,4DAA4D;QACrD,+BAAM,GAAb;YAAA,iBA4DC;YA3DO,IAAA,KAAkD,IAAI,CAAC,KAAK,EAA1D,OAAO,aAAA,EAAE,IAAI,UAAA,EAAE,KAAK,WAAA,EAAE,MAAM,YAAA,EAAE,MAAM,YAAA,EAAE,KAAK,WAAe,CAAC;YAEnE,IAAM,UAAU,GAAG,aAAa,CAAC,MAAO,EAAE;gBACxC,KAAK,EAAE,KAAM;aACd,CAAC,CAAC;YAEH,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACrC,OAAO,qDAA4B,CAAC;YACtC,CAAC;YAED,OAAO,CACL,6BACE,GAAG,EAAE,UAAA,EAAE,IAAI,OAAA,CAAC,KAAI,CAAC,SAAS,GAAG,EAAE,CAAC,EAArB,CAAqB,EAChC,SAAS,E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AAM,IAAK,OAAA,CACzB,4BAAI,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,IAChE,IAAI,CAAC,KAAK,CACR,CACN,EAJ0B,CAI1B,CAAC,CACC,CACN,EAR0B,CAQ1B,CAAC,CACI,CACT,CACK,CACJ,CACQ,CACZ,CACF,CACP,CAAC;QACJ,CAAC;QACH,qBAAC;IAAD,CAAC,AA3ED,CAAoC,KAAK,CAAC,SAAS,GA2ElD;IA3EY,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 // eslint-disable-next-line @typescript-eslint/no-deprecated\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'} className={classNames.chart}>\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} style={header?.style}>\n {header.value}\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} style={cell?.style}>\n {cell.value}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n )}\n </table>\n </div>\n </foreignObject>\n </svg>\n </div>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ChartTable.base.js","sourceRoot":"../src/","sources":["components/ChartTable/ChartTable.base.tsx"],"names":[],"mappings":";;;;IAUA,SAAS,cAAc,CAAC,GAAW,EAAE,KAAa;QAChD,IAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,KAAK,CAAC,cAAc,CAAC,QAAS,CAAC;QACxC,CAAC;QACD,IAAM,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;IACnE,CAAC;IAED,SAAS,sBAAsB,CAAC,KAAa,EAAE,UAAmB,EAAE,UAAmB;QACrF,IAAM,UAAU,GAAG,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC;QACjD,IAAM,UAAU,GAAG,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;QAEvD,IAAM,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,IAAI,UAAU,CAAC,CAAC;QAC9C,IAAM,EAAE,GAAG,EAAE,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,CACT,CACK,CACJ,CACQ,CACZ,CACF,CACP,CAAC;QACJ,CAAC;QACH,qBAAC;IAAD,CAAC,AA9HD,CAAoC,KAAK,CAAC,SAAS,GA8HlD;IA9HY,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';\nimport * as d3 from 'd3-color';\nimport { getColorContrast } from '../../utilities/colors';\nimport { ITheme } from '@fluentui/react';\n\nfunction invertHexColor(hex: string, theme: ITheme): string {\n const color = d3.color(hex);\n if (!color) {\n return theme.semanticColors.bodyText!;\n }\n const rgb = color.rgb();\n return d3.rgb(255 - rgb.r, 255 - rgb.g, 255 - rgb.b).formatHex();\n}\n\nfunction getSafeBackgroundColor(theme: ITheme, foreground?: string, background?: string): string {\n const fallbackFg = theme.semanticColors.bodyText;\n const fallbackBg = theme.semanticColors.bodyBackground;\n\n const fg = d3.color(foreground || fallbackFg);\n const bg = d3.color(background || fallbackBg);\n if (!fg || !bg) {\n return fallbackBg;\n }\n const contrast = getColorContrast(fg.formatHex(), bg.formatHex());\n if (contrast >= 3) {\n return bg.formatHex();\n }\n\n const invertedBg = invertHexColor(bg.formatHex(), theme);\n const invertedContrast = getColorContrast(fg.formatHex(), invertedBg);\n return invertedContrast >= 3 ? invertedBg : fallbackBg;\n}\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 // eslint-disable-next-line @typescript-eslint/no-deprecated\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 const bgColorSet = new Set<string>();\n headers.forEach(header => {\n const bg = header?.style?.backgroundColor;\n const normalized = d3.color(bg || '')?.formatHex();\n if (normalized) {\n bgColorSet.add(normalized);\n }\n });\n let sharedBackgroundColor: string | undefined;\n let useSharedBackground = false;\n\n /*\n If we have only one or two unique background colors, we can consider using a shared background color\n for the table headers. This is to ensure better contrast with the foreground text.\n For size 1, we will consider that as default color if it satisfies the contrast ratio.\n There could also be a scenario where backgroundcolor array is of size 2, for eg: [\"dimsgray\", \"gray\"],\n which will assign 1st column header bg color to dimsgray and rest to gray. so our logic of shared background\n color won't run here. So will consider for size 2 as well.\n For size greater than this, we will consider that user wants different colors and will let color contrast fail\n if any.\n */\n if (bgColorSet.size === 1 || bgColorSet.size === 2) {\n const candidateBg = bgColorSet.size === 1 ? Array.from(bgColorSet)[0] : Array.from(bgColorSet)[1];\n for (const header of headers) {\n const fg = header?.style?.color;\n if (fg && getColorContrast(fg, candidateBg) >= 3) {\n sharedBackgroundColor = candidateBg;\n useSharedBackground = true;\n break;\n }\n }\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'} className={classNames.chart}>\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 const style = { ...header?.style };\n const fg = style.color;\n const bg = style.backgroundColor;\n\n if (useSharedBackground) {\n style.backgroundColor = sharedBackgroundColor;\n } else if (fg || bg) {\n style.backgroundColor = getSafeBackgroundColor(theme!, fg, bg);\n }\n return (\n <th key={idx} className={classNames.headerCell} style={style}>\n {header.value}\n </th>\n );\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 const style = { ...cell?.style };\n const fg = style.color;\n const bg = style.backgroundColor;\n if (fg || bg) {\n style.backgroundColor = getSafeBackgroundColor(theme!, fg, bg);\n }\n return (\n <td key={colIdx} className={classNames.bodyCell} style={style}>\n {cell.value}\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n )}\n </table>\n </div>\n </foreignObject>\n </svg>\n </div>\n );\n }\n}\n"]}
|
|
@@ -330,7 +330,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
330
330
|
});
|
|
331
331
|
});
|
|
332
332
|
var vsbcData = Object.values(mapXToDataPoints);
|
|
333
|
-
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: vsbcData, width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barWidth: 'auto', yMaxValue: yMaxValue, yMinValue: yMinValue, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, supportNegativeData: true, barGapMax: 2, showYAxisLables: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, wrapXAxisLables: typeof ((_d = vsbcData[0]) === null || _d === void 0 ? void 0 : _d.xAxisPoint) === 'string' }), getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getYMinMaxValues(input.data[0], input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat);
|
|
333
|
+
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: vsbcData, width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barWidth: 'auto', yMaxValue: yMaxValue, yMinValue: yMinValue, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, supportNegativeData: true, barGapMax: 2, showYAxisLables: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, wrapXAxisLables: typeof ((_d = vsbcData[0]) === null || _d === void 0 ? void 0 : _d.xAxisPoint) === 'string' }), getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getYMinMaxValues(input.data[0], input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getBarProps(input.data, input.layout));
|
|
334
334
|
};
|
|
335
335
|
exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
|
|
336
336
|
var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -376,7 +376,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
376
376
|
});
|
|
377
377
|
});
|
|
378
378
|
var gvbcData = Object.values(mapXToDataPoints);
|
|
379
|
-
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: gvbcData, width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barwidth: 'auto', mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, wrapXAxisLables: typeof ((_d = gvbcData[0]) === null || _d === void 0 ? void 0 : _d.name) === 'string' }), getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getYMinMaxValues(input.data[0], input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat);
|
|
379
|
+
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: gvbcData, width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barwidth: 'auto', mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, wrapXAxisLables: typeof ((_d = gvbcData[0]) === null || _d === void 0 ? void 0 : _d.name) === 'string' }), getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getYMinMaxValues(input.data[0], input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getBarProps(input.data, input.layout));
|
|
380
380
|
};
|
|
381
381
|
exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
|
|
382
382
|
var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -453,12 +453,14 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
453
453
|
var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme) {
|
|
454
454
|
var _a, _b, _c, _d;
|
|
455
455
|
var isScatterMarkers = [
|
|
456
|
+
'text',
|
|
456
457
|
'markers',
|
|
457
458
|
'text+markers',
|
|
458
459
|
'markers+text',
|
|
459
460
|
'lines+markers',
|
|
460
461
|
'markers+line',
|
|
461
462
|
'text+lines+markers',
|
|
463
|
+
'lines+markers+text',
|
|
462
464
|
].includes((_a = input.data[0]) === null || _a === void 0 ? void 0 : _a.mode);
|
|
463
465
|
var isAreaChart = chartType === 'area';
|
|
464
466
|
var isScatterChart = chartType === 'scatter';
|
|
@@ -586,9 +588,9 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
586
588
|
var scalingFactor = 0.01;
|
|
587
589
|
var gapFactor = 1 / (1 + scalingFactor * numberOfRows);
|
|
588
590
|
var barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
|
|
589
|
-
return tslib_1.__assign(tslib_1.__assign({ data: chartData, secondaryYAxistitle: typeof ((_k = (_j = input.layout) === null || _j === void 0 ? void 0 : _j.yaxis2) === null || _k === void 0 ? void 0 : _k.title) === 'string'
|
|
591
|
+
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: chartData, secondaryYAxistitle: typeof ((_k = (_j = input.layout) === null || _j === void 0 ? void 0 : _j.yaxis2) === null || _k === void 0 ? void 0 : _k.title) === 'string'
|
|
590
592
|
? (_m = (_l = input.layout) === null || _l === void 0 ? void 0 : _l.yaxis2) === null || _m === void 0 ? void 0 : _m.title
|
|
591
|
-
: ((_q = (_p = (_o = input.layout) === null || _o === void 0 ? void 0 : _o.yaxis2) === null || _p === void 0 ? void 0 : _p.title) === null || _q === void 0 ? void 0 : _q.text) || '', barHeight: barHeight, showYAxisLables: true, height: chartHeight, width: (_r = input.layout) === null || _r === void 0 ? void 0 : _r.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout));
|
|
593
|
+
: ((_q = (_p = (_o = input.layout) === null || _o === void 0 ? void 0 : _o.yaxis2) === null || _p === void 0 ? void 0 : _p.title) === null || _q === void 0 ? void 0 : _q.text) || '', barHeight: barHeight, showYAxisLables: true, height: chartHeight, width: (_r = input.layout) === null || _r === void 0 ? void 0 : _r.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getBarProps(input.data, input.layout, true));
|
|
592
594
|
};
|
|
593
595
|
exports.transformPlotlyJsonToHorizontalBarWithAxisProps = transformPlotlyJsonToHorizontalBarWithAxisProps;
|
|
594
596
|
var transformPlotlyJsonToGanttChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -635,7 +637,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
635
637
|
.filter(function (point) { return point !== null; });
|
|
636
638
|
})
|
|
637
639
|
.flat();
|
|
638
|
-
return tslib_1.__assign(tslib_1.__assign({ data: chartData, showYAxisLables: true, height: (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 350, width: (_c = input.layout) === null || _c === void 0 ? void 0 : _c.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true, useUTC: false }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout));
|
|
640
|
+
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: chartData, showYAxisLables: true, height: (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 350, width: (_c = input.layout) === null || _c === void 0 ? void 0 : _c.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true, useUTC: false }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getBarProps(input.data, input.layout, true));
|
|
639
641
|
};
|
|
640
642
|
exports.transformPlotlyJsonToGanttChartProps = transformPlotlyJsonToGanttChartProps;
|
|
641
643
|
var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -902,7 +904,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
902
904
|
return "".concat(prefix !== null && prefix !== void 0 ? prefix : '').concat(formatted).concat(suffix !== null && suffix !== void 0 ? suffix : '');
|
|
903
905
|
};
|
|
904
906
|
var transformPlotlyJsonToChartTableProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
905
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
907
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
906
908
|
var tableData = input.data[0];
|
|
907
909
|
var normalizeHeaders = function (values, header) {
|
|
908
910
|
var cleanedValues = Array.isArray(values[0])
|
|
@@ -914,11 +916,11 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
914
916
|
})
|
|
915
917
|
: values.map(function (cell) { return cleanText(cell); });
|
|
916
918
|
return cleanedValues.map(function (value, colIndex) {
|
|
917
|
-
var _a, _b, _c;
|
|
919
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
918
920
|
var fontColorRaw = (_a = header === null || header === void 0 ? void 0 : header.font) === null || _a === void 0 ? void 0 : _a.color;
|
|
919
921
|
var fontColor;
|
|
920
922
|
if (Array.isArray(fontColorRaw)) {
|
|
921
|
-
var colorEntry = fontColorRaw[colIndex];
|
|
923
|
+
var colorEntry = (_b = fontColorRaw[colIndex]) !== null && _b !== void 0 ? _b : fontColorRaw[0];
|
|
922
924
|
if (Array.isArray(colorEntry)) {
|
|
923
925
|
fontColor = typeof colorEntry[0] === 'string' ? colorEntry[0] : undefined;
|
|
924
926
|
}
|
|
@@ -929,28 +931,37 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
929
931
|
else if (typeof fontColorRaw === 'string') {
|
|
930
932
|
fontColor = fontColorRaw;
|
|
931
933
|
}
|
|
932
|
-
var fontSizeRaw = (
|
|
934
|
+
var fontSizeRaw = (_c = header === null || header === void 0 ? void 0 : header.font) === null || _c === void 0 ? void 0 : _c.size;
|
|
933
935
|
var fontSize;
|
|
934
936
|
if (Array.isArray(fontSizeRaw)) {
|
|
935
|
-
|
|
937
|
+
var fontSizeEntry = (_d = fontSizeRaw[colIndex]) !== null && _d !== void 0 ? _d : fontSizeRaw[0];
|
|
938
|
+
fontSize = Array.isArray(fontSizeRaw[0])
|
|
939
|
+
? (_e = fontSizeRaw[0][colIndex]) !== null && _e !== void 0 ? _e : fontSizeRaw[0][0]
|
|
940
|
+
: typeof fontSizeEntry === 'number'
|
|
941
|
+
? fontSizeEntry
|
|
942
|
+
: undefined;
|
|
936
943
|
}
|
|
937
944
|
else if (typeof fontSizeRaw === 'number') {
|
|
938
945
|
fontSize = fontSizeRaw;
|
|
939
946
|
}
|
|
940
947
|
var updatedColIndex = colIndex >= 1 ? 1 : 0;
|
|
941
|
-
var fillColorRaw = (
|
|
942
|
-
var backgroundColor = Array.isArray(fillColorRaw)
|
|
948
|
+
var fillColorRaw = (_f = header === null || header === void 0 ? void 0 : header.fill) === null || _f === void 0 ? void 0 : _f.color;
|
|
949
|
+
var backgroundColor = Array.isArray(fillColorRaw)
|
|
950
|
+
? (_g = fillColorRaw[updatedColIndex]) !== null && _g !== void 0 ? _g : fillColorRaw[0]
|
|
951
|
+
: fillColorRaw;
|
|
943
952
|
var textAlignRaw = header === null || header === void 0 ? void 0 : header.align;
|
|
944
|
-
var textAlign = Array.isArray(textAlignRaw) ? textAlignRaw[colIndex] : textAlignRaw;
|
|
953
|
+
var textAlign = Array.isArray(textAlignRaw) ? (_h = textAlignRaw[colIndex]) !== null && _h !== void 0 ? _h : textAlignRaw[0] : textAlignRaw;
|
|
945
954
|
var style = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, (typeof fontColor === 'string' ? { color: fontColor } : {})), (typeof fontSize === 'number' ? { fontSize: fontSize } : {})), (typeof backgroundColor === 'string' ? { backgroundColor: backgroundColor } : {})), (textAlign ? { textAlign: textAlign } : {}));
|
|
946
955
|
return { value: value, style: style };
|
|
947
956
|
});
|
|
948
957
|
};
|
|
949
958
|
var columns = (_b = (_a = tableData.cells) === null || _a === void 0 ? void 0 : _a.values) !== null && _b !== void 0 ? _b : [];
|
|
950
|
-
var cells = tableData.cells
|
|
959
|
+
var cells = tableData.cells && Object.keys(tableData.cells).length > 0
|
|
960
|
+
? tableData.cells
|
|
961
|
+
: (_g = (_f = (_e = (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.template) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.table) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.cells;
|
|
951
962
|
var rows = columns[0].map(function (_, rowIndex) {
|
|
952
963
|
return columns.map(function (col, colIndex) {
|
|
953
|
-
var _a, _b, _c;
|
|
964
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
954
965
|
var cellValue = col[rowIndex];
|
|
955
966
|
var cleanValue = typeof cellValue === 'string' ? cleanText(cellValue) : cellValue;
|
|
956
967
|
var formattedValue = typeof cleanValue === 'string' || typeof cleanValue === 'number'
|
|
@@ -959,17 +970,17 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
959
970
|
var rawFontColor = (_a = cells === null || cells === void 0 ? void 0 : cells.font) === null || _a === void 0 ? void 0 : _a.color;
|
|
960
971
|
var fontColor;
|
|
961
972
|
if (Array.isArray(rawFontColor)) {
|
|
962
|
-
var entry = rawFontColor[colIndex];
|
|
973
|
+
var entry = (_b = rawFontColor[colIndex]) !== null && _b !== void 0 ? _b : rawFontColor[0];
|
|
963
974
|
var colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
964
975
|
fontColor = typeof colorValue === 'string' ? colorValue : undefined;
|
|
965
976
|
}
|
|
966
977
|
else if (typeof rawFontColor === 'string') {
|
|
967
978
|
fontColor = rawFontColor;
|
|
968
979
|
}
|
|
969
|
-
var rawFontSize = (
|
|
980
|
+
var rawFontSize = (_c = cells === null || cells === void 0 ? void 0 : cells.font) === null || _c === void 0 ? void 0 : _c.size;
|
|
970
981
|
var fontSize;
|
|
971
982
|
if (Array.isArray(rawFontSize)) {
|
|
972
|
-
var entry = rawFontSize[colIndex];
|
|
983
|
+
var entry = (_d = rawFontSize[colIndex]) !== null && _d !== void 0 ? _d : rawFontSize[0];
|
|
973
984
|
var fontSizeValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
974
985
|
fontSize = typeof fontSizeValue === 'number' ? fontSizeValue : undefined;
|
|
975
986
|
}
|
|
@@ -977,17 +988,17 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
977
988
|
fontSize = rawFontSize;
|
|
978
989
|
}
|
|
979
990
|
var updatedColIndex = colIndex >= 1 ? 1 : 0;
|
|
980
|
-
var rawBackgroundColor = (
|
|
991
|
+
var rawBackgroundColor = (_e = cells === null || cells === void 0 ? void 0 : cells.fill) === null || _e === void 0 ? void 0 : _e.color;
|
|
981
992
|
var backgroundColor;
|
|
982
993
|
if (Array.isArray(rawBackgroundColor)) {
|
|
983
|
-
var entry = rawBackgroundColor[updatedColIndex];
|
|
994
|
+
var entry = (_f = rawBackgroundColor[updatedColIndex]) !== null && _f !== void 0 ? _f : rawBackgroundColor[0];
|
|
984
995
|
var colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
985
996
|
backgroundColor = typeof colorValue === 'string' ? colorValue : undefined;
|
|
986
997
|
}
|
|
987
998
|
else if (typeof rawBackgroundColor === 'string') {
|
|
988
999
|
backgroundColor = rawBackgroundColor;
|
|
989
1000
|
}
|
|
990
|
-
var rawTextAlign = Array.isArray(cells === null || cells === void 0 ? void 0 : cells.align) ? cells.align[colIndex] : cells === null || cells === void 0 ? void 0 : cells.align;
|
|
1001
|
+
var rawTextAlign = Array.isArray(cells === null || cells === void 0 ? void 0 : cells.align) ? (_g = cells.align[colIndex]) !== null && _g !== void 0 ? _g : cells.align[0] : cells === null || cells === void 0 ? void 0 : cells.align;
|
|
991
1002
|
var textAlign = rawTextAlign;
|
|
992
1003
|
var style = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, (fontColor ? { color: fontColor } : {})), (typeof fontSize === 'number' ? { fontSize: fontSize } : {})), (backgroundColor ? { backgroundColor: backgroundColor } : {})), (textAlign ? { textAlign: textAlign } : {}));
|
|
993
1004
|
return {
|
|
@@ -997,13 +1008,15 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
997
1008
|
});
|
|
998
1009
|
});
|
|
999
1010
|
var styles = {
|
|
1000
|
-
root: tslib_1.__assign({}, (((
|
|
1011
|
+
root: tslib_1.__assign({}, (((_j = (_h = input.layout) === null || _h === void 0 ? void 0 : _h.font) === null || _j === void 0 ? void 0 : _j.size) ? { fontSize: input.layout.font.size } : {})),
|
|
1001
1012
|
};
|
|
1002
1013
|
return {
|
|
1003
|
-
headers: normalizeHeaders((
|
|
1014
|
+
headers: normalizeHeaders((_l = (_k = tableData.header) === null || _k === void 0 ? void 0 : _k.values) !== null && _l !== void 0 ? _l : [], tableData.header && Object.keys(tableData.header).length > 0
|
|
1015
|
+
? tableData.header
|
|
1016
|
+
: (_p = (_o = (_m = input.layout) === null || _m === void 0 ? void 0 : _m.template) === null || _o === void 0 ? void 0 : _o.data) === null || _p === void 0 ? void 0 : _p.table[0].header),
|
|
1004
1017
|
rows: rows,
|
|
1005
|
-
width: (
|
|
1006
|
-
height: (
|
|
1018
|
+
width: (_q = input.layout) === null || _q === void 0 ? void 0 : _q.width,
|
|
1019
|
+
height: (_r = input.layout) === null || _r === void 0 ? void 0 : _r.height,
|
|
1007
1020
|
styles: styles,
|
|
1008
1021
|
};
|
|
1009
1022
|
};
|
|
@@ -1761,5 +1774,39 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
1761
1774
|
}
|
|
1762
1775
|
return new Date(value);
|
|
1763
1776
|
};
|
|
1777
|
+
var getBarProps = function (data, layout, isHorizontal) {
|
|
1778
|
+
var padding;
|
|
1779
|
+
if (typeof (layout === null || layout === void 0 ? void 0 : layout.bargap) === 'number') {
|
|
1780
|
+
padding = layout.bargap;
|
|
1781
|
+
}
|
|
1782
|
+
var plotlyBarWidths = data
|
|
1783
|
+
.map(function (series) {
|
|
1784
|
+
if (series.type === 'bar' && ((0, chart_utilities_1.isArrayOrTypedArray)(series.width) || typeof series.width === 'number')) {
|
|
1785
|
+
return series.width;
|
|
1786
|
+
}
|
|
1787
|
+
return [];
|
|
1788
|
+
})
|
|
1789
|
+
.flat();
|
|
1790
|
+
var maxPlotlyBarWidth = (0, d3_array_1.max)(plotlyBarWidths);
|
|
1791
|
+
if (typeof maxPlotlyBarWidth === 'number') {
|
|
1792
|
+
padding = 1 - maxPlotlyBarWidth;
|
|
1793
|
+
padding = Math.max(0, Math.min(padding, 1));
|
|
1794
|
+
}
|
|
1795
|
+
if (typeof padding === 'undefined') {
|
|
1796
|
+
return {};
|
|
1797
|
+
}
|
|
1798
|
+
if (isHorizontal) {
|
|
1799
|
+
return {
|
|
1800
|
+
maxBarHeight: 1000,
|
|
1801
|
+
yAxisPadding: padding,
|
|
1802
|
+
};
|
|
1803
|
+
}
|
|
1804
|
+
return {
|
|
1805
|
+
barWidth: 'auto',
|
|
1806
|
+
maxBarWidth: 1000,
|
|
1807
|
+
xAxisInnerPadding: padding,
|
|
1808
|
+
xAxisOuterPadding: padding / 2,
|
|
1809
|
+
};
|
|
1810
|
+
};
|
|
1764
1811
|
});
|
|
1765
1812
|
//# sourceMappingURL=PlotlySchemaAdapter.js.map
|