@fluentui/react-charting 5.23.86 → 5.23.88
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 +13 -0
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +2 -0
- package/lib/components/AreaChart/AreaChart.base.js +3 -3
- package/lib/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.base.d.ts +1 -0
- package/lib/components/CommonComponents/CartesianChart.base.js +51 -20
- package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.styles.js +1 -0
- package/lib/components/CommonComponents/CartesianChart.styles.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.d.ts +8 -0
- package/lib/components/DeclarativeChart/DeclarativeChart.js +11 -7
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +10 -7
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +95 -30
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +3 -3
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.types.d.ts +5 -0
- package/lib/components/HeatMapChart/HeatMapChart.types.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +0 -2
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +0 -67
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.styles.js +1 -3
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.styles.js.map +1 -1
- package/lib/components/LineChart/LineChart.base.js +3 -3
- package/lib/components/LineChart/LineChart.base.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js +7 -7
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +3 -3
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib/utilities/SVGTooltipText.js +4 -5
- package/lib/utilities/SVGTooltipText.js.map +1 -1
- package/lib/utilities/utilities.d.ts +2 -1
- package/lib/utilities/utilities.js +12 -5
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-amd/components/AreaChart/AreaChart.base.js +2 -2
- package/lib-amd/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.base.d.ts +1 -0
- package/lib-amd/components/CommonComponents/CartesianChart.base.js +50 -20
- package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.styles.js +1 -0
- package/lib-amd/components/CommonComponents/CartesianChart.styles.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.d.ts +8 -0
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +11 -7
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +10 -7
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +99 -32
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +2 -2
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/HeatMapChart/HeatMapChart.types.d.ts +5 -0
- package/lib-amd/components/HeatMapChart/HeatMapChart.types.js.map +1 -1
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +0 -2
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +1 -67
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.styles.js +2 -3
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.styles.js.map +1 -1
- package/lib-amd/components/LineChart/LineChart.base.js +2 -2
- package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +6 -6
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +2 -2
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-amd/utilities/SVGTooltipText.js +5 -5
- package/lib-amd/utilities/SVGTooltipText.js.map +1 -1
- package/lib-amd/utilities/utilities.d.ts +2 -1
- package/lib-amd/utilities/utilities.js +15 -7
- package/lib-amd/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.base.js +2 -2
- package/lib-commonjs/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.d.ts +1 -0
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +50 -19
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js +1 -0
- package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.d.ts +8 -0
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +11 -7
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +10 -7
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +99 -31
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +2 -2
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.d.ts +5 -0
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +0 -2
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +0 -67
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.styles.js +1 -3
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.styles.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.base.js +2 -2
- package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +6 -6
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +2 -2
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-commonjs/utilities/SVGTooltipText.js +4 -5
- package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/utilities.d.ts +2 -1
- package/lib-commonjs/utilities/utilities.js +16 -8
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +5 -5
- package/src/components/HeatMapChart/HeatMapChart.types.ts +6 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findArrayAttributes = exports.projectPolarToCartesian = exports.transformPlotlyJsonToGaugeProps = exports.transformPlotlyJsonToSankeyProps = exports.transformPlotlyJsonToHeatmapProps = exports.transformPlotlyJsonToHorizontalBarWithAxisProps = exports.transformPlotlyJsonToScatterChartProps = exports.transformPlotlyJsonToVBCProps = exports.transformPlotlyJsonToGVBCProps = exports.transformPlotlyJsonToVSBCProps = exports.transformPlotlyJsonToDonutProps = exports.getColor = exports.correctYearMonth = exports.isMonthArray = void 0;
|
|
3
|
+
exports.findArrayAttributes = exports.projectPolarToCartesian = exports.transformPlotlyJsonToGaugeProps = exports.transformPlotlyJsonToSankeyProps = exports.transformPlotlyJsonToHeatmapProps = exports.transformPlotlyJsonToHorizontalBarWithAxisProps = exports.transformPlotlyJsonToScatterChartProps = exports.transformPlotlyJsonToVBCProps = exports.transformPlotlyJsonToGVBCProps = exports.transformPlotlyJsonToVSBCProps = exports.transformPlotlyJsonToDonutProps = exports._resolveColor = exports._extractColor = exports.getSchemaColors = exports.getColor = exports.correctYearMonth = exports.isMonthArray = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var d3_array_1 = require("d3-array");
|
|
6
6
|
var d3_scale_1 = require("d3-scale");
|
|
@@ -10,6 +10,7 @@ var utilities_1 = require("../../utilities/utilities");
|
|
|
10
10
|
var chart_utilities_1 = require("@fluentui/chart-utilities");
|
|
11
11
|
var d3_time_format_1 = require("d3-time-format");
|
|
12
12
|
var d3_shape_1 = require("d3-shape");
|
|
13
|
+
var d3_color_1 = require("d3-color");
|
|
13
14
|
var dashOptions = {
|
|
14
15
|
dot: {
|
|
15
16
|
strokeDasharray: '1, 5',
|
|
@@ -145,13 +146,59 @@ var getSecondaryYAxisValues = function (data, layout, maxAllowedMinY, minAllowed
|
|
|
145
146
|
},
|
|
146
147
|
};
|
|
147
148
|
};
|
|
148
|
-
var
|
|
149
|
-
var
|
|
149
|
+
var getSchemaColors = function (colors, colorMap, isDarkTheme) {
|
|
150
|
+
var hexColors = [];
|
|
151
|
+
if (!colors) {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
if ((0, chart_utilities_1.isArrayOrTypedArray)(colors)) {
|
|
155
|
+
colors.forEach(function (element, index) {
|
|
156
|
+
var colorString = element === null || element === void 0 ? void 0 : element.toString().trim();
|
|
157
|
+
var nextFluentColor = (0, exports.getColor)("Label_".concat(index), colorMap, isDarkTheme);
|
|
158
|
+
if (colorString) {
|
|
159
|
+
var parsedColor = (0, d3_color_1.color)(colorString);
|
|
160
|
+
hexColors.push(parsedColor ? parsedColor.formatHex() : nextFluentColor);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
hexColors.push(nextFluentColor);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
else if (typeof colors === 'string') {
|
|
168
|
+
var parsedColor = (0, d3_color_1.color)(colors);
|
|
169
|
+
return parsedColor ? parsedColor.formatHex() : (0, exports.getColor)('Label_0', colorMap, isDarkTheme);
|
|
170
|
+
}
|
|
171
|
+
return hexColors;
|
|
172
|
+
};
|
|
173
|
+
exports.getSchemaColors = getSchemaColors;
|
|
174
|
+
var _extractColor = function (useFluentVizColorPalette, colors, colorMap, isDarkTheme) {
|
|
175
|
+
return !useFluentVizColorPalette && colors ? (0, exports.getSchemaColors)(colors, colorMap, isDarkTheme) : undefined;
|
|
176
|
+
};
|
|
177
|
+
exports._extractColor = _extractColor;
|
|
178
|
+
var _resolveColor = function (extractedColors, index, legend, colorMap, isDarkTheme) {
|
|
179
|
+
var color = '';
|
|
180
|
+
if (extractedColors && (0, chart_utilities_1.isArrayOrTypedArray)(extractedColors) && extractedColors[index]) {
|
|
181
|
+
color = extractedColors[index % extractedColors.length];
|
|
182
|
+
}
|
|
183
|
+
else if (typeof extractedColors === 'string') {
|
|
184
|
+
color = extractedColors;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
color = (0, exports.getColor)(legend, colorMap, isDarkTheme);
|
|
188
|
+
}
|
|
189
|
+
return color;
|
|
190
|
+
};
|
|
191
|
+
exports._resolveColor = _resolveColor;
|
|
192
|
+
var transformPlotlyJsonToDonutProps = function (input, colorMap, useFluentVizColorPalette, isDarkTheme) {
|
|
193
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
150
194
|
var firstData = input.data[0];
|
|
195
|
+
// extract colors for each series only once
|
|
196
|
+
var colors = (0, exports._extractColor)(useFluentVizColorPalette, (_a = firstData === null || firstData === void 0 ? void 0 : firstData.marker) === null || _a === void 0 ? void 0 : _a.colors, colorMap, isDarkTheme);
|
|
151
197
|
var mapLegendToDataPoint = {};
|
|
152
|
-
(
|
|
198
|
+
(_b = firstData.labels) === null || _b === void 0 ? void 0 : _b.forEach(function (label, index) {
|
|
153
199
|
var _a;
|
|
154
|
-
|
|
200
|
+
// resolve color for each legend from the extracted colors
|
|
201
|
+
var color = (0, exports._resolveColor)(colors, index, label, colorMap, isDarkTheme);
|
|
155
202
|
//ToDo how to handle string data?
|
|
156
203
|
var value = typeof ((_a = firstData.values) === null || _a === void 0 ? void 0 : _a[index]) === 'number' ? firstData.values[index] : 1;
|
|
157
204
|
if (!mapLegendToDataPoint[label]) {
|
|
@@ -165,8 +212,8 @@ var transformPlotlyJsonToDonutProps = function (input, colorMap, isDarkTheme) {
|
|
|
165
212
|
mapLegendToDataPoint[label].data += value;
|
|
166
213
|
}
|
|
167
214
|
});
|
|
168
|
-
var width = (
|
|
169
|
-
var height = (
|
|
215
|
+
var width = (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.width) !== null && _d !== void 0 ? _d : 440;
|
|
216
|
+
var height = (_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.height) !== null && _f !== void 0 ? _f : 220;
|
|
170
217
|
var hideLabels = firstData.textinfo
|
|
171
218
|
? !['value', 'percent', 'label+percent'].includes(firstData.textinfo)
|
|
172
219
|
: false;
|
|
@@ -181,8 +228,8 @@ var transformPlotlyJsonToDonutProps = function (input, colorMap, isDarkTheme) {
|
|
|
181
228
|
chartTitle: chartTitle,
|
|
182
229
|
chartData: Object.values(mapLegendToDataPoint),
|
|
183
230
|
},
|
|
184
|
-
hideLegend: ((
|
|
185
|
-
width: (
|
|
231
|
+
hideLegend: ((_g = input.layout) === null || _g === void 0 ? void 0 : _g.showlegend) === false ? true : false,
|
|
232
|
+
width: (_h = input.layout) === null || _h === void 0 ? void 0 : _h.width,
|
|
186
233
|
height: height,
|
|
187
234
|
innerRadius: innerRadius,
|
|
188
235
|
hideLabels: hideLabels,
|
|
@@ -190,24 +237,29 @@ var transformPlotlyJsonToDonutProps = function (input, colorMap, isDarkTheme) {
|
|
|
190
237
|
};
|
|
191
238
|
};
|
|
192
239
|
exports.transformPlotlyJsonToDonutProps = transformPlotlyJsonToDonutProps;
|
|
193
|
-
var transformPlotlyJsonToVSBCProps = function (input, colorMap, isDarkTheme, fallbackVSBC) {
|
|
240
|
+
var transformPlotlyJsonToVSBCProps = function (input, colorMap, useFluentVizColorPalette, isDarkTheme, fallbackVSBC) {
|
|
194
241
|
var _a, _b, _c;
|
|
195
242
|
var mapXToDataPoints = {};
|
|
196
243
|
var yMaxValue = 0;
|
|
197
244
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
198
245
|
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
199
246
|
input.data.forEach(function (series, index1) {
|
|
200
|
-
var _a;
|
|
247
|
+
var _a, _b, _c;
|
|
201
248
|
var isXYearCategory = (0, chart_utilities_1.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
|
|
202
|
-
|
|
249
|
+
// extract bar colors for each series only once
|
|
250
|
+
var extractedBarColors = (0, exports._extractColor)(useFluentVizColorPalette, (_a = series.marker) === null || _a === void 0 ? void 0 : _a.color, colorMap, isDarkTheme);
|
|
251
|
+
// extract line colors for each series only once
|
|
252
|
+
var extractedLineColors = (0, exports._extractColor)(useFluentVizColorPalette, (_b = series.line) === null || _b === void 0 ? void 0 : _b.color, colorMap, isDarkTheme);
|
|
253
|
+
(_c = series.x) === null || _c === void 0 ? void 0 : _c.forEach(function (x, index2) {
|
|
203
254
|
var _a, _b, _c;
|
|
204
255
|
if (!mapXToDataPoints[x]) {
|
|
205
256
|
mapXToDataPoints[x] = { xAxisPoint: isXYearCategory ? x.toString() : x, chartData: [], lineData: [] };
|
|
206
257
|
}
|
|
207
258
|
var legend = legends[index1];
|
|
259
|
+
// resolve color for each legend's bars from the extracted colors
|
|
260
|
+
var color = (0, exports._resolveColor)(extractedBarColors, index1, legend, colorMap, isDarkTheme);
|
|
208
261
|
var yVal = (_b = (_a = series.y) === null || _a === void 0 ? void 0 : _a[index2]) !== null && _b !== void 0 ? _b : 0;
|
|
209
262
|
if (series.type === 'bar') {
|
|
210
|
-
var color = (0, exports.getColor)(legend, colorMap, isDarkTheme);
|
|
211
263
|
mapXToDataPoints[x].chartData.push({
|
|
212
264
|
legend: legend,
|
|
213
265
|
data: yVal,
|
|
@@ -216,11 +268,11 @@ var transformPlotlyJsonToVSBCProps = function (input, colorMap, isDarkTheme, fal
|
|
|
216
268
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
217
269
|
}
|
|
218
270
|
else if (series.type === 'scatter' || !!fallbackVSBC) {
|
|
219
|
-
var
|
|
271
|
+
var lineColor = (0, exports._resolveColor)(extractedLineColors, index1, legend, colorMap, isDarkTheme);
|
|
220
272
|
var lineOptions = getLineOptions(series.line);
|
|
221
273
|
var dashType = ((_c = series.line) === null || _c === void 0 ? void 0 : _c.dash) || 'solid';
|
|
222
274
|
var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
|
|
223
|
-
mapXToDataPoints[x].lineData.push(tslib_1.__assign(tslib_1.__assign({ legend: legend, legendShape: legendShape, y: yVal, color:
|
|
275
|
+
mapXToDataPoints[x].lineData.push(tslib_1.__assign(tslib_1.__assign({ legend: legend, legendShape: legendShape, y: yVal, color: lineColor }, (lineOptions ? { lineOptions: lineOptions } : {})), { useSecondaryYScale: usesSecondaryYScale(series) }));
|
|
224
276
|
if (!usesSecondaryYScale(series)) {
|
|
225
277
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
226
278
|
}
|
|
@@ -231,21 +283,24 @@ var transformPlotlyJsonToVSBCProps = function (input, colorMap, isDarkTheme, fal
|
|
|
231
283
|
return tslib_1.__assign(tslib_1.__assign({ data: Object.values(mapXToDataPoints), 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, chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend });
|
|
232
284
|
};
|
|
233
285
|
exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
|
|
234
|
-
var transformPlotlyJsonToGVBCProps = function (input, colorMap, isDarkTheme) {
|
|
286
|
+
var transformPlotlyJsonToGVBCProps = function (input, colorMap, useFluentVizColorPalette, isDarkTheme) {
|
|
235
287
|
var _a, _b, _c;
|
|
236
288
|
var mapXToDataPoints = {};
|
|
237
289
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
|
|
238
290
|
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
239
291
|
input.data.forEach(function (series, index1) {
|
|
240
|
-
var _a;
|
|
241
|
-
|
|
292
|
+
var _a, _b;
|
|
293
|
+
// extract colors for each series only once
|
|
294
|
+
var extractedColors = (0, exports._extractColor)(useFluentVizColorPalette, (_a = series.marker) === null || _a === void 0 ? void 0 : _a.color, colorMap, isDarkTheme);
|
|
295
|
+
(_b = series.x) === null || _b === void 0 ? void 0 : _b.forEach(function (x, xIndex) {
|
|
242
296
|
var _a, _b;
|
|
243
297
|
if (!mapXToDataPoints[x]) {
|
|
244
298
|
mapXToDataPoints[x] = { name: x.toString(), series: [] };
|
|
245
299
|
}
|
|
246
300
|
if (series.type === 'bar') {
|
|
247
301
|
var legend = legends[index1];
|
|
248
|
-
|
|
302
|
+
// resolve color for each legend's bars from the extracted colors
|
|
303
|
+
var color = (0, exports._resolveColor)(extractedColors, index1, legend, colorMap, isDarkTheme);
|
|
249
304
|
mapXToDataPoints[x].series.push({
|
|
250
305
|
key: legend,
|
|
251
306
|
data: (_b = (_a = series.y) === null || _a === void 0 ? void 0 : _a[xIndex]) !== null && _b !== void 0 ? _b : 0,
|
|
@@ -261,19 +316,21 @@ var transformPlotlyJsonToGVBCProps = function (input, colorMap, isDarkTheme) {
|
|
|
261
316
|
return tslib_1.__assign(tslib_1.__assign({ data: Object.values(mapXToDataPoints), 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', chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend });
|
|
262
317
|
};
|
|
263
318
|
exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
|
|
264
|
-
var transformPlotlyJsonToVBCProps = function (input, colorMap, isDarkTheme) {
|
|
319
|
+
var transformPlotlyJsonToVBCProps = function (input, colorMap, useFluentVizColorPalette, isDarkTheme) {
|
|
265
320
|
var _a, _b, _c;
|
|
266
321
|
var vbcData = [];
|
|
267
322
|
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
268
323
|
input.data.forEach(function (series, seriesIdx) {
|
|
269
|
-
var _a, _b, _c;
|
|
324
|
+
var _a, _b, _c, _d;
|
|
270
325
|
if (!series.x) {
|
|
271
326
|
return;
|
|
272
327
|
}
|
|
328
|
+
// extract colors for each series only once
|
|
329
|
+
var extractedColors = (0, exports._extractColor)(useFluentVizColorPalette, (_a = series.marker) === null || _a === void 0 ? void 0 : _a.color, colorMap, isDarkTheme);
|
|
273
330
|
var isXString = isStringArray(series.x);
|
|
274
331
|
// TODO: In case of a single bin, add an empty bin of the same size to prevent the
|
|
275
332
|
// default bar width from being used and ensure the bar spans the full intended range.
|
|
276
|
-
var xBins = createBins(series.x, (
|
|
333
|
+
var xBins = createBins(series.x, (_b = series.xbins) === null || _b === void 0 ? void 0 : _b.start, (_c = series.xbins) === null || _c === void 0 ? void 0 : _c.end, (_d = series.xbins) === null || _d === void 0 ? void 0 : _d.size);
|
|
277
334
|
var yBins = xBins.map(function () { return []; });
|
|
278
335
|
var total = 0;
|
|
279
336
|
series.x.forEach(function (xVal, index) {
|
|
@@ -290,7 +347,8 @@ var transformPlotlyJsonToVBCProps = function (input, colorMap, isDarkTheme) {
|
|
|
290
347
|
});
|
|
291
348
|
xBins.forEach(function (bin, index) {
|
|
292
349
|
var legend = legends[seriesIdx];
|
|
293
|
-
|
|
350
|
+
// resolve color for each legend's bars from the extracted colors
|
|
351
|
+
var color = (0, exports._resolveColor)(extractedColors, seriesIdx, legend, colorMap, isDarkTheme);
|
|
294
352
|
var yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
|
|
295
353
|
vbcData.push(tslib_1.__assign({ x: isXString ? bin.join(', ') : getBinCenter(bin), y: yVal, legend: legend, color: color }, (isXString
|
|
296
354
|
? {}
|
|
@@ -313,22 +371,25 @@ var transformPlotlyJsonToVBCProps = function (input, colorMap, isDarkTheme) {
|
|
|
313
371
|
};
|
|
314
372
|
};
|
|
315
373
|
exports.transformPlotlyJsonToVBCProps = transformPlotlyJsonToVBCProps;
|
|
316
|
-
var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart, colorMap, isDarkTheme) {
|
|
374
|
+
var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart, colorMap, useFluentVizColorPalette, isDarkTheme) {
|
|
317
375
|
var _a, _b, _c, _d, _e, _f;
|
|
318
376
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
319
377
|
var mode = 'tonexty';
|
|
320
378
|
var _g = getLegendProps(input.data, input.layout), legends = _g.legends, hideLegend = _g.hideLegend;
|
|
321
379
|
var chartData = input.data.map(function (series, index) {
|
|
322
|
-
var _a;
|
|
380
|
+
var _a, _b;
|
|
381
|
+
// extract colors for each series only once
|
|
382
|
+
var extractedColors = (0, exports._extractColor)(useFluentVizColorPalette, (_a = series.line) === null || _a === void 0 ? void 0 : _a.color, colorMap, isDarkTheme);
|
|
323
383
|
var xValues = series.x;
|
|
324
384
|
var isString = typeof xValues[0] === 'string';
|
|
325
385
|
var isXDate = (0, chart_utilities_1.isDateArray)(xValues);
|
|
326
386
|
var isXNumber = (0, chart_utilities_1.isNumberArray)(xValues);
|
|
327
387
|
var legend = legends[index];
|
|
328
|
-
|
|
388
|
+
// resolve color for each legend's lines from the extracted colors
|
|
389
|
+
var lineColor = (0, exports._resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
329
390
|
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
330
391
|
var lineOptions = getLineOptions(series.line);
|
|
331
|
-
var dashType = ((
|
|
392
|
+
var dashType = ((_b = series.line) === null || _b === void 0 ? void 0 : _b.dash) || 'solid';
|
|
332
393
|
var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
|
|
333
394
|
return tslib_1.__assign(tslib_1.__assign({ legend: legend, legendShape: legendShape, data: xValues.map(function (x, i) {
|
|
334
395
|
var _a, _b;
|
|
@@ -353,13 +414,17 @@ var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart, color
|
|
|
353
414
|
}
|
|
354
415
|
};
|
|
355
416
|
exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterChartProps;
|
|
356
|
-
var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, colorMap, isDarkTheme) {
|
|
417
|
+
var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, colorMap, useFluentVizColorPalette, isDarkTheme) {
|
|
357
418
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
358
419
|
var _s = getLegendProps(input.data, input.layout), legends = _s.legends, hideLegend = _s.hideLegend;
|
|
359
420
|
var chartData = input.data
|
|
360
421
|
.map(function (series, index) {
|
|
422
|
+
var _a;
|
|
423
|
+
// extract colors for each series only once
|
|
424
|
+
var extractedColors = (0, exports._extractColor)(useFluentVizColorPalette, (_a = series.marker) === null || _a === void 0 ? void 0 : _a.color, colorMap, isDarkTheme);
|
|
361
425
|
var legend = legends[index];
|
|
362
|
-
|
|
426
|
+
// resolve color for each legend's bars from the extracted colors
|
|
427
|
+
var color = (0, exports._resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
363
428
|
return series.y.map(function (yValue, i) {
|
|
364
429
|
return {
|
|
365
430
|
x: series.x[i],
|
|
@@ -399,6 +464,8 @@ var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, colorMap,
|
|
|
399
464
|
width: (_r = input.layout) === null || _r === void 0 ? void 0 : _r.width,
|
|
400
465
|
hideTickOverlap: true,
|
|
401
466
|
hideLegend: hideLegend,
|
|
467
|
+
noOfCharsToTruncate: 20,
|
|
468
|
+
showYAxisLablesTooltip: true,
|
|
402
469
|
};
|
|
403
470
|
};
|
|
404
471
|
exports.transformPlotlyJsonToHorizontalBarWithAxisProps = transformPlotlyJsonToHorizontalBarWithAxisProps;
|
|
@@ -497,6 +564,8 @@ var transformPlotlyJsonToHeatmapProps = function (input) {
|
|
|
497
564
|
width: (_k = input.layout) === null || _k === void 0 ? void 0 : _k.width,
|
|
498
565
|
height: (_m = (_l = input.layout) === null || _l === void 0 ? void 0 : _l.height) !== null && _m !== void 0 ? _m : 350,
|
|
499
566
|
hideTickOverlap: true,
|
|
567
|
+
noOfCharsToTruncate: 20,
|
|
568
|
+
showYAxisLablesTooltip: true,
|
|
500
569
|
};
|
|
501
570
|
};
|
|
502
571
|
exports.transformPlotlyJsonToHeatmapProps = transformPlotlyJsonToHeatmapProps;
|
|
@@ -509,7 +578,6 @@ var transformPlotlyJsonToSankeyProps = function (input, colorMap, isDarkTheme) {
|
|
|
509
578
|
source: link === null || link === void 0 ? void 0 : link.source[index],
|
|
510
579
|
target: link === null || link === void 0 ? void 0 : link.target[index],
|
|
511
580
|
}); })
|
|
512
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
513
581
|
// Filter out negative nodes, unequal nodes and self-references (circular links)
|
|
514
582
|
.filter(function (x) { return x.source >= 0 && x.target >= 0 && x.source !== x.target; });
|
|
515
583
|
var sankeyChartData = {
|
|
@@ -802,7 +870,7 @@ var getLegendProps = function (data, layout) {
|
|
|
802
870
|
var hideLegends = data.every(function (series) { return series.showlegend === false; });
|
|
803
871
|
return {
|
|
804
872
|
legends: legends,
|
|
805
|
-
hideLegend: (layout === null || layout === void 0 ? void 0 : layout.showlegend) === false ? true : hideLegends,
|
|
873
|
+
hideLegend: (layout === null || layout === void 0 ? void 0 : layout.showlegend) === false || ((layout === null || layout === void 0 ? void 0 : layout.showlegend) !== true && legends.length < 2) ? true : hideLegends,
|
|
806
874
|
};
|
|
807
875
|
};
|
|
808
876
|
//# sourceMappingURL=PlotlySchemaAdapter.js.map
|