@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
|
@@ -5,6 +5,32 @@ var tslib_1 = require("tslib");
|
|
|
5
5
|
var React = require("react");
|
|
6
6
|
var Utilities_1 = require("@fluentui/react/lib/Utilities");
|
|
7
7
|
var image_export_utils_1 = require("../../utilities/image-export-utils");
|
|
8
|
+
var d3 = require("d3-color");
|
|
9
|
+
var colors_1 = require("../../utilities/colors");
|
|
10
|
+
function invertHexColor(hex, theme) {
|
|
11
|
+
var color = d3.color(hex);
|
|
12
|
+
if (!color) {
|
|
13
|
+
return theme.semanticColors.bodyText;
|
|
14
|
+
}
|
|
15
|
+
var rgb = color.rgb();
|
|
16
|
+
return d3.rgb(255 - rgb.r, 255 - rgb.g, 255 - rgb.b).formatHex();
|
|
17
|
+
}
|
|
18
|
+
function getSafeBackgroundColor(theme, foreground, background) {
|
|
19
|
+
var fallbackFg = theme.semanticColors.bodyText;
|
|
20
|
+
var fallbackBg = theme.semanticColors.bodyBackground;
|
|
21
|
+
var fg = d3.color(foreground || fallbackFg);
|
|
22
|
+
var bg = d3.color(background || fallbackBg);
|
|
23
|
+
if (!fg || !bg) {
|
|
24
|
+
return fallbackBg;
|
|
25
|
+
}
|
|
26
|
+
var contrast = (0, colors_1.getColorContrast)(fg.formatHex(), bg.formatHex());
|
|
27
|
+
if (contrast >= 3) {
|
|
28
|
+
return bg.formatHex();
|
|
29
|
+
}
|
|
30
|
+
var invertedBg = invertHexColor(bg.formatHex(), theme);
|
|
31
|
+
var invertedContrast = (0, colors_1.getColorContrast)(fg.formatHex(), invertedBg);
|
|
32
|
+
return invertedContrast >= 3 ? invertedBg : fallbackBg;
|
|
33
|
+
}
|
|
8
34
|
var getClassNames = (0, Utilities_1.classNamesFunction)();
|
|
9
35
|
var ChartTableBase = /** @class */ (function (_super) {
|
|
10
36
|
tslib_1.__extends(ChartTableBase, _super);
|
|
@@ -20,13 +46,47 @@ var ChartTableBase = /** @class */ (function (_super) {
|
|
|
20
46
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
21
47
|
ChartTableBase.prototype.render = function () {
|
|
22
48
|
var _this = this;
|
|
23
|
-
var _a
|
|
49
|
+
var _a;
|
|
50
|
+
var _b = this.props, headers = _b.headers, rows = _b.rows, width = _b.width, height = _b.height, styles = _b.styles, theme = _b.theme;
|
|
24
51
|
var classNames = getClassNames(styles, {
|
|
25
52
|
theme: theme,
|
|
26
53
|
});
|
|
27
54
|
if (!headers || headers.length === 0) {
|
|
28
55
|
return React.createElement("div", null, "No data available");
|
|
29
56
|
}
|
|
57
|
+
var bgColorSet = new Set();
|
|
58
|
+
headers.forEach(function (header) {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
var bg = (_a = header === null || header === void 0 ? void 0 : header.style) === null || _a === void 0 ? void 0 : _a.backgroundColor;
|
|
61
|
+
var normalized = (_b = d3.color(bg || '')) === null || _b === void 0 ? void 0 : _b.formatHex();
|
|
62
|
+
if (normalized) {
|
|
63
|
+
bgColorSet.add(normalized);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
var sharedBackgroundColor;
|
|
67
|
+
var useSharedBackground = false;
|
|
68
|
+
/*
|
|
69
|
+
If we have only one or two unique background colors, we can consider using a shared background color
|
|
70
|
+
for the table headers. This is to ensure better contrast with the foreground text.
|
|
71
|
+
For size 1, we will consider that as default color if it satisfies the contrast ratio.
|
|
72
|
+
There could also be a scenario where backgroundcolor array is of size 2, for eg: ["dimsgray", "gray"],
|
|
73
|
+
which will assign 1st column header bg color to dimsgray and rest to gray. so our logic of shared background
|
|
74
|
+
color won't run here. So will consider for size 2 as well.
|
|
75
|
+
For size greater than this, we will consider that user wants different colors and will let color contrast fail
|
|
76
|
+
if any.
|
|
77
|
+
*/
|
|
78
|
+
if (bgColorSet.size === 1 || bgColorSet.size === 2) {
|
|
79
|
+
var candidateBg = bgColorSet.size === 1 ? Array.from(bgColorSet)[0] : Array.from(bgColorSet)[1];
|
|
80
|
+
for (var _i = 0, headers_1 = headers; _i < headers_1.length; _i++) {
|
|
81
|
+
var header = headers_1[_i];
|
|
82
|
+
var fg = (_a = header === null || header === void 0 ? void 0 : header.style) === null || _a === void 0 ? void 0 : _a.color;
|
|
83
|
+
if (fg && (0, colors_1.getColorContrast)(fg, candidateBg) >= 3) {
|
|
84
|
+
sharedBackgroundColor = candidateBg;
|
|
85
|
+
useSharedBackground = true;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
30
90
|
return (React.createElement("div", { ref: function (el) { return (_this._rootElem = el); }, className: classNames.root, style: { height: height ? "".concat(height, "px") : '650px', overflow: 'hidden' } },
|
|
31
91
|
React.createElement("svg", { width: width !== null && width !== void 0 ? width : '100%', height: height !== null && height !== void 0 ? height : '650px', className: classNames.chart },
|
|
32
92
|
React.createElement("foreignObject", { x: "0", y: "0", width: "100%", height: "100%" },
|
|
@@ -39,8 +99,27 @@ var ChartTableBase = /** @class */ (function (_super) {
|
|
|
39
99
|
width: width ? "".concat(width, "px") : '100%',
|
|
40
100
|
} },
|
|
41
101
|
React.createElement("thead", null,
|
|
42
|
-
React.createElement("tr", null, headers.map(function (header, idx) {
|
|
43
|
-
|
|
102
|
+
React.createElement("tr", null, headers.map(function (header, idx) {
|
|
103
|
+
var style = tslib_1.__assign({}, header === null || header === void 0 ? void 0 : header.style);
|
|
104
|
+
var fg = style.color;
|
|
105
|
+
var bg = style.backgroundColor;
|
|
106
|
+
if (useSharedBackground) {
|
|
107
|
+
style.backgroundColor = sharedBackgroundColor;
|
|
108
|
+
}
|
|
109
|
+
else if (fg || bg) {
|
|
110
|
+
style.backgroundColor = getSafeBackgroundColor(theme, fg, bg);
|
|
111
|
+
}
|
|
112
|
+
return (React.createElement("th", { key: idx, className: classNames.headerCell, style: style }, header.value));
|
|
113
|
+
}))),
|
|
114
|
+
rows && rows.length > 0 && (React.createElement("tbody", null, rows.map(function (row, rowIdx) { return (React.createElement("tr", { key: rowIdx }, row.map(function (cell, colIdx) {
|
|
115
|
+
var style = tslib_1.__assign({}, cell === null || cell === void 0 ? void 0 : cell.style);
|
|
116
|
+
var fg = style.color;
|
|
117
|
+
var bg = style.backgroundColor;
|
|
118
|
+
if (fg || bg) {
|
|
119
|
+
style.backgroundColor = getSafeBackgroundColor(theme, fg, bg);
|
|
120
|
+
}
|
|
121
|
+
return (React.createElement("td", { key: colIdx, className: classNames.bodyCell, style: style }, cell.value));
|
|
122
|
+
}))); })))))))));
|
|
44
123
|
};
|
|
45
124
|
return ChartTableBase;
|
|
46
125
|
}(React.Component));
|
|
@@ -1 +1 @@
|
|
|
1
|
-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,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;IACJ,CAAC;IACH,qBAAC;AAAD,CAAC,AA3ED,CAAoC,KAAK,CAAC,SAAS,GA2ElD;AA3EY,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":";;;;AAAA,6BAA+B;AAG/B,2DAAmG;AAEnG,yEAA6D;AAC7D,6BAA+B;AAC/B,iDAA0D;AAG1D,SAAS,cAAc,CAAC,GAAW,EAAE,KAAa;IAChD,IAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAC,cAAc,CAAC,QAAS,CAAC;IACxC,CAAC;IACD,IAAM,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;IACxB,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;AACnE,CAAC;AAED,SAAS,sBAAsB,CAAC,KAAa,EAAE,UAAmB,EAAE,UAAmB;IACrF,IAAM,UAAU,GAAG,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC;IACjD,IAAM,UAAU,GAAG,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAEvD,IAAM,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,IAAI,UAAU,CAAC,CAAC;IAC9C,IAAM,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,IAAI,UAAU,CAAC,CAAC;IAC9C,IA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AD,CAAC,AA9HD,CAAoC,KAAK,CAAC,SAAS,GA8HlD;AA9HY,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"]}
|
|
@@ -340,7 +340,7 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
|
|
|
340
340
|
});
|
|
341
341
|
});
|
|
342
342
|
var vsbcData = Object.values(mapXToDataPoints);
|
|
343
|
-
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);
|
|
343
|
+
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));
|
|
344
344
|
};
|
|
345
345
|
exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
|
|
346
346
|
var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -386,7 +386,7 @@ var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, col
|
|
|
386
386
|
});
|
|
387
387
|
});
|
|
388
388
|
var gvbcData = Object.values(mapXToDataPoints);
|
|
389
|
-
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);
|
|
389
|
+
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));
|
|
390
390
|
};
|
|
391
391
|
exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
|
|
392
392
|
var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -463,12 +463,14 @@ exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterCha
|
|
|
463
463
|
var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme) {
|
|
464
464
|
var _a, _b, _c, _d;
|
|
465
465
|
var isScatterMarkers = [
|
|
466
|
+
'text',
|
|
466
467
|
'markers',
|
|
467
468
|
'text+markers',
|
|
468
469
|
'markers+text',
|
|
469
470
|
'lines+markers',
|
|
470
471
|
'markers+line',
|
|
471
472
|
'text+lines+markers',
|
|
473
|
+
'lines+markers+text',
|
|
472
474
|
].includes((_a = input.data[0]) === null || _a === void 0 ? void 0 : _a.mode);
|
|
473
475
|
var isAreaChart = chartType === 'area';
|
|
474
476
|
var isScatterChart = chartType === 'scatter';
|
|
@@ -596,9 +598,9 @@ var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPl
|
|
|
596
598
|
var scalingFactor = 0.01;
|
|
597
599
|
var gapFactor = 1 / (1 + scalingFactor * numberOfRows);
|
|
598
600
|
var barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
|
|
599
|
-
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'
|
|
601
|
+
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'
|
|
600
602
|
? (_m = (_l = input.layout) === null || _l === void 0 ? void 0 : _l.yaxis2) === null || _m === void 0 ? void 0 : _m.title
|
|
601
|
-
: ((_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));
|
|
603
|
+
: ((_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));
|
|
602
604
|
};
|
|
603
605
|
exports.transformPlotlyJsonToHorizontalBarWithAxisProps = transformPlotlyJsonToHorizontalBarWithAxisProps;
|
|
604
606
|
var transformPlotlyJsonToGanttChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -645,7 +647,7 @@ var transformPlotlyJsonToGanttChartProps = function (input, isMultiPlot, colorMa
|
|
|
645
647
|
.filter(function (point) { return point !== null; });
|
|
646
648
|
})
|
|
647
649
|
.flat();
|
|
648
|
-
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));
|
|
650
|
+
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));
|
|
649
651
|
};
|
|
650
652
|
exports.transformPlotlyJsonToGanttChartProps = transformPlotlyJsonToGanttChartProps;
|
|
651
653
|
var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -912,7 +914,7 @@ var formatValue = function (value, colIndex, cells) {
|
|
|
912
914
|
return "".concat(prefix !== null && prefix !== void 0 ? prefix : '').concat(formatted).concat(suffix !== null && suffix !== void 0 ? suffix : '');
|
|
913
915
|
};
|
|
914
916
|
var transformPlotlyJsonToChartTableProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
915
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
917
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
916
918
|
var tableData = input.data[0];
|
|
917
919
|
var normalizeHeaders = function (values, header) {
|
|
918
920
|
var cleanedValues = Array.isArray(values[0])
|
|
@@ -924,11 +926,11 @@ var transformPlotlyJsonToChartTableProps = function (input, isMultiPlot, colorMa
|
|
|
924
926
|
})
|
|
925
927
|
: values.map(function (cell) { return cleanText(cell); });
|
|
926
928
|
return cleanedValues.map(function (value, colIndex) {
|
|
927
|
-
var _a, _b, _c;
|
|
929
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
928
930
|
var fontColorRaw = (_a = header === null || header === void 0 ? void 0 : header.font) === null || _a === void 0 ? void 0 : _a.color;
|
|
929
931
|
var fontColor;
|
|
930
932
|
if (Array.isArray(fontColorRaw)) {
|
|
931
|
-
var colorEntry = fontColorRaw[colIndex];
|
|
933
|
+
var colorEntry = (_b = fontColorRaw[colIndex]) !== null && _b !== void 0 ? _b : fontColorRaw[0];
|
|
932
934
|
if (Array.isArray(colorEntry)) {
|
|
933
935
|
fontColor = typeof colorEntry[0] === 'string' ? colorEntry[0] : undefined;
|
|
934
936
|
}
|
|
@@ -939,28 +941,37 @@ var transformPlotlyJsonToChartTableProps = function (input, isMultiPlot, colorMa
|
|
|
939
941
|
else if (typeof fontColorRaw === 'string') {
|
|
940
942
|
fontColor = fontColorRaw;
|
|
941
943
|
}
|
|
942
|
-
var fontSizeRaw = (
|
|
944
|
+
var fontSizeRaw = (_c = header === null || header === void 0 ? void 0 : header.font) === null || _c === void 0 ? void 0 : _c.size;
|
|
943
945
|
var fontSize;
|
|
944
946
|
if (Array.isArray(fontSizeRaw)) {
|
|
945
|
-
|
|
947
|
+
var fontSizeEntry = (_d = fontSizeRaw[colIndex]) !== null && _d !== void 0 ? _d : fontSizeRaw[0];
|
|
948
|
+
fontSize = Array.isArray(fontSizeRaw[0])
|
|
949
|
+
? (_e = fontSizeRaw[0][colIndex]) !== null && _e !== void 0 ? _e : fontSizeRaw[0][0]
|
|
950
|
+
: typeof fontSizeEntry === 'number'
|
|
951
|
+
? fontSizeEntry
|
|
952
|
+
: undefined;
|
|
946
953
|
}
|
|
947
954
|
else if (typeof fontSizeRaw === 'number') {
|
|
948
955
|
fontSize = fontSizeRaw;
|
|
949
956
|
}
|
|
950
957
|
var updatedColIndex = colIndex >= 1 ? 1 : 0;
|
|
951
|
-
var fillColorRaw = (
|
|
952
|
-
var backgroundColor = Array.isArray(fillColorRaw)
|
|
958
|
+
var fillColorRaw = (_f = header === null || header === void 0 ? void 0 : header.fill) === null || _f === void 0 ? void 0 : _f.color;
|
|
959
|
+
var backgroundColor = Array.isArray(fillColorRaw)
|
|
960
|
+
? (_g = fillColorRaw[updatedColIndex]) !== null && _g !== void 0 ? _g : fillColorRaw[0]
|
|
961
|
+
: fillColorRaw;
|
|
953
962
|
var textAlignRaw = header === null || header === void 0 ? void 0 : header.align;
|
|
954
|
-
var textAlign = Array.isArray(textAlignRaw) ? textAlignRaw[colIndex] : textAlignRaw;
|
|
963
|
+
var textAlign = Array.isArray(textAlignRaw) ? (_h = textAlignRaw[colIndex]) !== null && _h !== void 0 ? _h : textAlignRaw[0] : textAlignRaw;
|
|
955
964
|
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 } : {}));
|
|
956
965
|
return { value: value, style: style };
|
|
957
966
|
});
|
|
958
967
|
};
|
|
959
968
|
var columns = (_b = (_a = tableData.cells) === null || _a === void 0 ? void 0 : _a.values) !== null && _b !== void 0 ? _b : [];
|
|
960
|
-
var cells = tableData.cells
|
|
969
|
+
var cells = tableData.cells && Object.keys(tableData.cells).length > 0
|
|
970
|
+
? tableData.cells
|
|
971
|
+
: (_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;
|
|
961
972
|
var rows = columns[0].map(function (_, rowIndex) {
|
|
962
973
|
return columns.map(function (col, colIndex) {
|
|
963
|
-
var _a, _b, _c;
|
|
974
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
964
975
|
var cellValue = col[rowIndex];
|
|
965
976
|
var cleanValue = typeof cellValue === 'string' ? cleanText(cellValue) : cellValue;
|
|
966
977
|
var formattedValue = typeof cleanValue === 'string' || typeof cleanValue === 'number'
|
|
@@ -969,17 +980,17 @@ var transformPlotlyJsonToChartTableProps = function (input, isMultiPlot, colorMa
|
|
|
969
980
|
var rawFontColor = (_a = cells === null || cells === void 0 ? void 0 : cells.font) === null || _a === void 0 ? void 0 : _a.color;
|
|
970
981
|
var fontColor;
|
|
971
982
|
if (Array.isArray(rawFontColor)) {
|
|
972
|
-
var entry = rawFontColor[colIndex];
|
|
983
|
+
var entry = (_b = rawFontColor[colIndex]) !== null && _b !== void 0 ? _b : rawFontColor[0];
|
|
973
984
|
var colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
974
985
|
fontColor = typeof colorValue === 'string' ? colorValue : undefined;
|
|
975
986
|
}
|
|
976
987
|
else if (typeof rawFontColor === 'string') {
|
|
977
988
|
fontColor = rawFontColor;
|
|
978
989
|
}
|
|
979
|
-
var rawFontSize = (
|
|
990
|
+
var rawFontSize = (_c = cells === null || cells === void 0 ? void 0 : cells.font) === null || _c === void 0 ? void 0 : _c.size;
|
|
980
991
|
var fontSize;
|
|
981
992
|
if (Array.isArray(rawFontSize)) {
|
|
982
|
-
var entry = rawFontSize[colIndex];
|
|
993
|
+
var entry = (_d = rawFontSize[colIndex]) !== null && _d !== void 0 ? _d : rawFontSize[0];
|
|
983
994
|
var fontSizeValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
984
995
|
fontSize = typeof fontSizeValue === 'number' ? fontSizeValue : undefined;
|
|
985
996
|
}
|
|
@@ -987,17 +998,17 @@ var transformPlotlyJsonToChartTableProps = function (input, isMultiPlot, colorMa
|
|
|
987
998
|
fontSize = rawFontSize;
|
|
988
999
|
}
|
|
989
1000
|
var updatedColIndex = colIndex >= 1 ? 1 : 0;
|
|
990
|
-
var rawBackgroundColor = (
|
|
1001
|
+
var rawBackgroundColor = (_e = cells === null || cells === void 0 ? void 0 : cells.fill) === null || _e === void 0 ? void 0 : _e.color;
|
|
991
1002
|
var backgroundColor;
|
|
992
1003
|
if (Array.isArray(rawBackgroundColor)) {
|
|
993
|
-
var entry = rawBackgroundColor[updatedColIndex];
|
|
1004
|
+
var entry = (_f = rawBackgroundColor[updatedColIndex]) !== null && _f !== void 0 ? _f : rawBackgroundColor[0];
|
|
994
1005
|
var colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
995
1006
|
backgroundColor = typeof colorValue === 'string' ? colorValue : undefined;
|
|
996
1007
|
}
|
|
997
1008
|
else if (typeof rawBackgroundColor === 'string') {
|
|
998
1009
|
backgroundColor = rawBackgroundColor;
|
|
999
1010
|
}
|
|
1000
|
-
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;
|
|
1011
|
+
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;
|
|
1001
1012
|
var textAlign = rawTextAlign;
|
|
1002
1013
|
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 } : {}));
|
|
1003
1014
|
return {
|
|
@@ -1007,13 +1018,15 @@ var transformPlotlyJsonToChartTableProps = function (input, isMultiPlot, colorMa
|
|
|
1007
1018
|
});
|
|
1008
1019
|
});
|
|
1009
1020
|
var styles = {
|
|
1010
|
-
root: tslib_1.__assign({}, (((
|
|
1021
|
+
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 } : {})),
|
|
1011
1022
|
};
|
|
1012
1023
|
return {
|
|
1013
|
-
headers: normalizeHeaders((
|
|
1024
|
+
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
|
|
1025
|
+
? tableData.header
|
|
1026
|
+
: (_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),
|
|
1014
1027
|
rows: rows,
|
|
1015
|
-
width: (
|
|
1016
|
-
height: (
|
|
1028
|
+
width: (_q = input.layout) === null || _q === void 0 ? void 0 : _q.width,
|
|
1029
|
+
height: (_r = input.layout) === null || _r === void 0 ? void 0 : _r.height,
|
|
1017
1030
|
styles: styles,
|
|
1018
1031
|
};
|
|
1019
1032
|
};
|
|
@@ -1771,4 +1784,38 @@ var parseLocalDate = function (value) {
|
|
|
1771
1784
|
}
|
|
1772
1785
|
return new Date(value);
|
|
1773
1786
|
};
|
|
1787
|
+
var getBarProps = function (data, layout, isHorizontal) {
|
|
1788
|
+
var padding;
|
|
1789
|
+
if (typeof (layout === null || layout === void 0 ? void 0 : layout.bargap) === 'number') {
|
|
1790
|
+
padding = layout.bargap;
|
|
1791
|
+
}
|
|
1792
|
+
var plotlyBarWidths = data
|
|
1793
|
+
.map(function (series) {
|
|
1794
|
+
if (series.type === 'bar' && ((0, chart_utilities_1.isArrayOrTypedArray)(series.width) || typeof series.width === 'number')) {
|
|
1795
|
+
return series.width;
|
|
1796
|
+
}
|
|
1797
|
+
return [];
|
|
1798
|
+
})
|
|
1799
|
+
.flat();
|
|
1800
|
+
var maxPlotlyBarWidth = (0, d3_array_1.max)(plotlyBarWidths);
|
|
1801
|
+
if (typeof maxPlotlyBarWidth === 'number') {
|
|
1802
|
+
padding = 1 - maxPlotlyBarWidth;
|
|
1803
|
+
padding = Math.max(0, Math.min(padding, 1));
|
|
1804
|
+
}
|
|
1805
|
+
if (typeof padding === 'undefined') {
|
|
1806
|
+
return {};
|
|
1807
|
+
}
|
|
1808
|
+
if (isHorizontal) {
|
|
1809
|
+
return {
|
|
1810
|
+
maxBarHeight: 1000,
|
|
1811
|
+
yAxisPadding: padding,
|
|
1812
|
+
};
|
|
1813
|
+
}
|
|
1814
|
+
return {
|
|
1815
|
+
barWidth: 'auto',
|
|
1816
|
+
maxBarWidth: 1000,
|
|
1817
|
+
xAxisInnerPadding: padding,
|
|
1818
|
+
xAxisOuterPadding: padding / 2,
|
|
1819
|
+
};
|
|
1820
|
+
};
|
|
1774
1821
|
//# sourceMappingURL=PlotlySchemaAdapter.js.map
|