@fluentui/react-charting 5.24.20 → 5.24.22
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 +61 -1
- package/CHANGELOG.md +25 -2
- package/bundle-size/ScatterChart.fixture.js +7 -0
- package/dist/react-charting.d.ts +27 -2
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +8 -2
- 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.js +4 -4
- package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.d.ts +18 -3
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +10 -0
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +187 -11
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/LineChart/LineChart.base.d.ts +0 -9
- package/lib/components/LineChart/LineChart.base.js +82 -138
- package/lib/components/LineChart/LineChart.base.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.base.js +37 -62
- package/lib/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js +2 -2
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +2 -2
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js.map +1 -1
- package/lib/types/IDataPoint.d.ts +9 -0
- package/lib/types/IDataPoint.js.map +1 -1
- package/lib/utilities/utilities.d.ts +29 -28
- package/lib/utilities/utilities.js +127 -110
- 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.js +4 -4
- package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +18 -3
- package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +10 -0
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +188 -11
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/LineChart/LineChart.base.d.ts +0 -9
- package/lib-amd/components/LineChart/LineChart.base.js +80 -136
- package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-amd/components/ScatterChart/ScatterChart.base.js +35 -60
- package/lib-amd/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +1 -1
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +1 -1
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-amd/index.d.ts +1 -1
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/types/IDataPoint.d.ts +9 -0
- package/lib-amd/types/IDataPoint.js.map +1 -1
- package/lib-amd/utilities/utilities.d.ts +29 -28
- package/lib-amd/utilities/utilities.js +133 -113
- 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.js +4 -4
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +18 -3
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +10 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +188 -11
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.base.d.ts +0 -9
- package/lib-commonjs/components/LineChart/LineChart.base.js +80 -136
- package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js +35 -60
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-commonjs/index.d.ts +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types/IDataPoint.d.ts +9 -0
- package/lib-commonjs/types/IDataPoint.js.map +1 -1
- package/lib-commonjs/utilities/utilities.d.ts +29 -28
- package/lib-commonjs/utilities/utilities.js +134 -114
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +4 -4
- package/src/components/CommonComponents/CartesianChart.types.ts +22 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../../utilities/colors", "../GaugeChart/index", "../../utilities/utilities", "@fluentui/chart-utilities", "d3-shape", "./PlotlyColorAdapter", "d3-color"], function (require, exports, tslib_1, d3_array_1, d3_scale_1, d3_format_1, colors_1, index_1, utilities_1, chart_utilities_1, d3_shape_1, PlotlyColorAdapter_1, d3_color_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.getGridProperties = exports.isNonPlotType = exports.getValidXYRanges = exports.getNumberAtIndexOrDefault = exports.getAllupLegendsProps = exports.findArrayAttributes = exports.projectPolarToCartesian = exports.transformPlotlyJsonToFunnelChartProps = exports.transformPlotlyJsonToChartTableProps = exports.transformPlotlyJsonToGaugeProps = exports.transformPlotlyJsonToSankeyProps = exports.transformPlotlyJsonToHeatmapProps = exports.transformPlotlyJsonToGanttChartProps = exports.transformPlotlyJsonToHorizontalBarWithAxisProps = exports.transformPlotlyJsonToScatterChartProps = exports.transformPlotlyJsonToLineChartProps = exports.transformPlotlyJsonToAreaChartProps = exports.transformPlotlyJsonToVBCProps = exports.transformPlotlyJsonToGVBCProps = exports.transformPlotlyJsonToVSBCProps = exports.transformPlotlyJsonToDonutProps = exports.resolveXAxisPoint = exports._getGaugeAxisColor = exports.correctYearMonth = exports.SINGLE_REPEAT = exports.NON_PLOT_KEY_PREFIX = void 0;
|
|
4
|
+
exports.getGridProperties = exports.isNonPlotType = exports.getValidXYRanges = exports.getNumberAtIndexOrDefault = exports.getAllupLegendsProps = exports.findArrayAttributes = exports.projectPolarToCartesian = exports.transformPlotlyJsonToFunnelChartProps = exports.transformPlotlyJsonToChartTableProps = exports.transformPlotlyJsonToGaugeProps = exports.transformPlotlyJsonToSankeyProps = exports.transformPlotlyJsonToHeatmapProps = exports.transformPlotlyJsonToGanttChartProps = exports.transformPlotlyJsonToHorizontalBarWithAxisProps = exports.transformPlotlyJsonToScatterChartProps = exports.transformPlotlyJsonToLineChartProps = exports.transformPlotlyJsonToAreaChartProps = exports.transformPlotlyJsonToVBCProps = exports.transformPlotlyJsonToGVBCProps = exports.transformPlotlyJsonToVSBCProps = exports.transformPlotlyJsonToDonutProps = exports.normalizeObjectArrayForGVBC = exports.resolveXAxisPoint = exports._getGaugeAxisColor = exports.correctYearMonth = exports.SINGLE_REPEAT = exports.NON_PLOT_KEY_PREFIX = void 0;
|
|
5
5
|
exports.NON_PLOT_KEY_PREFIX = 'nonplot_';
|
|
6
6
|
exports.SINGLE_REPEAT = 'repeat(1, 1fr)';
|
|
7
7
|
var dashOptions = {
|
|
@@ -199,6 +199,125 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
199
199
|
return x;
|
|
200
200
|
};
|
|
201
201
|
exports.resolveXAxisPoint = resolveXAxisPoint;
|
|
202
|
+
/**
|
|
203
|
+
* Checks if a key should be ignored during normalization
|
|
204
|
+
* @param key The key to check
|
|
205
|
+
* @returns true if the key should be ignored
|
|
206
|
+
*/
|
|
207
|
+
var shouldIgnoreKey = function (key) {
|
|
208
|
+
var lowerKey = key.toLowerCase();
|
|
209
|
+
if (lowerKey.includes('style') || lowerKey === 'style') {
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
// Use regex to match common CSS property patterns
|
|
213
|
+
// (color, fill, stroke, border, background, font, shadow, outline, etc.)
|
|
214
|
+
var cssKeyRegex = new RegExp('^(color|fill|stroke|border|background|font|shadow|outline|margin|padding|gap|align|justify|display|flex|grid|' +
|
|
215
|
+
'text|line|letter|word|vertical|horizontal|overflow|position|top|right|bottom|left|zindex|z-index|opacity|' +
|
|
216
|
+
'filter|clip|cursor|resize|transition|animation|transform|box|column|row|direction|visibility|' +
|
|
217
|
+
'content|width|height|aspect|image|user|pointer|caret|scroll|%)|(-webkit-|-moz-|-ms-|-o-)', 'i');
|
|
218
|
+
if (cssKeyRegex.test(lowerKey)) {
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
return false;
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* Flattens a nested object into a single level object with dot notation keys
|
|
225
|
+
* @param obj Object to flatten
|
|
226
|
+
* @param prefix Optional prefix for keys
|
|
227
|
+
* @returns Flattened object
|
|
228
|
+
*/
|
|
229
|
+
var flattenObject = function (obj, prefix) {
|
|
230
|
+
if (prefix === void 0) { prefix = ''; }
|
|
231
|
+
var flattened = {};
|
|
232
|
+
for (var key in obj) {
|
|
233
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
234
|
+
var newKey = prefix ? "".concat(prefix, ".").concat(key) : key;
|
|
235
|
+
var value = obj[key];
|
|
236
|
+
if (typeof value === 'object' && value !== null && !Array.isArray(value) && !(value instanceof Date)) {
|
|
237
|
+
// Recursively flatten nested objects
|
|
238
|
+
Object.assign(flattened, flattenObject(value, newKey));
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
flattened[newKey] = value;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return flattened;
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* Normalizes an array of objects by flattening nested structures and creating grouped data
|
|
249
|
+
* Uses json_normalize approach with D3 color detection and filtering
|
|
250
|
+
* @param data Array of objects to normalize
|
|
251
|
+
* @returns Object containing traces for grouped vertical bar chart
|
|
252
|
+
*/
|
|
253
|
+
var normalizeObjectArrayForGVBC = function (data, xLabels) {
|
|
254
|
+
if (!data || data.length === 0) {
|
|
255
|
+
return { traces: [], x: [] };
|
|
256
|
+
}
|
|
257
|
+
// Use provided xLabels if available, otherwise default to Item 1, Item 2, ...
|
|
258
|
+
var x = xLabels && xLabels.length === data.length ? xLabels : data.map(function (_, index) { return "Item ".concat(index + 1); });
|
|
259
|
+
// First, flatten all objects and collect all unique keys, excluding style keys
|
|
260
|
+
var flattenedObjects = data.map(function (item, index) {
|
|
261
|
+
var _a;
|
|
262
|
+
if (typeof item === 'object' && item !== null) {
|
|
263
|
+
var flattened_1 = flattenObject(item);
|
|
264
|
+
// Only keep keys where the value is numeric (number or numeric string) and not a style key
|
|
265
|
+
var filtered_1 = {};
|
|
266
|
+
Object.keys(flattened_1).forEach(function (key) {
|
|
267
|
+
var value = flattened_1[key];
|
|
268
|
+
if (!shouldIgnoreKey(key) && (typeof value === 'number' || (typeof value === 'string' && (0, chart_utilities_1.isNumber)(value)))) {
|
|
269
|
+
filtered_1[key] = value;
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
return filtered_1;
|
|
273
|
+
}
|
|
274
|
+
else if (typeof item === 'number' || (typeof item === 'string' && (0, chart_utilities_1.isNumber)(item))) {
|
|
275
|
+
// Only keep primitive numeric values
|
|
276
|
+
return _a = {}, _a[x[index] || "item_".concat(index)] = item, _a;
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
// Non-numeric primitive, ignore by returning empty object
|
|
280
|
+
return {};
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
// Collect all unique keys across all objects
|
|
284
|
+
var allKeys = new Set();
|
|
285
|
+
flattenedObjects.forEach(function (obj) {
|
|
286
|
+
Object.keys(obj).forEach(function (key) { return allKeys.add(key); });
|
|
287
|
+
});
|
|
288
|
+
// Create traces for each key (property)
|
|
289
|
+
var traces = [];
|
|
290
|
+
allKeys.forEach(function (key) {
|
|
291
|
+
var yValues = [];
|
|
292
|
+
var hasValidData = false;
|
|
293
|
+
var isNumericData = false;
|
|
294
|
+
flattenedObjects.forEach(function (obj, index) {
|
|
295
|
+
var value = obj[key];
|
|
296
|
+
if (typeof value === 'number') {
|
|
297
|
+
yValues.push(value);
|
|
298
|
+
hasValidData = true;
|
|
299
|
+
isNumericData = true;
|
|
300
|
+
}
|
|
301
|
+
else if (typeof value === 'string' && (0, chart_utilities_1.isNumber)(value)) {
|
|
302
|
+
yValues.push(parseFloat(value));
|
|
303
|
+
hasValidData = true;
|
|
304
|
+
isNumericData = true;
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
// Only create trace if we have valid numeric data
|
|
308
|
+
if (hasValidData && isNumericData) {
|
|
309
|
+
var trace = {
|
|
310
|
+
type: 'bar',
|
|
311
|
+
name: key,
|
|
312
|
+
x: x,
|
|
313
|
+
y: yValues,
|
|
314
|
+
};
|
|
315
|
+
traces.push(trace);
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
return { traces: traces, x: x };
|
|
319
|
+
};
|
|
320
|
+
exports.normalizeObjectArrayForGVBC = normalizeObjectArrayForGVBC;
|
|
202
321
|
var transformPlotlyJsonToDonutProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
203
322
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
204
323
|
var firstData = input.data[0];
|
|
@@ -335,16 +454,37 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
335
454
|
exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
|
|
336
455
|
var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
337
456
|
var _a, _b, _c, _d;
|
|
457
|
+
// Handle object arrays in y values by normalizing the data first
|
|
458
|
+
var processedInput = tslib_1.__assign({}, input);
|
|
459
|
+
// Check if any bar traces have object arrays as y values
|
|
460
|
+
var hasObjectArrayData = input.data.some(function (series) { return series.type === 'bar' && (0, chart_utilities_1.isObjectArray)(series.y); });
|
|
461
|
+
if (hasObjectArrayData) {
|
|
462
|
+
// Process each trace that has object array y values
|
|
463
|
+
var processedData = input.data
|
|
464
|
+
.map(function (series, index) {
|
|
465
|
+
if (series.type === 'bar' && (0, chart_utilities_1.isObjectArray)(series.y)) {
|
|
466
|
+
// Normalize the object array to create multiple traces for GVBC
|
|
467
|
+
var traces = (0, exports.normalizeObjectArrayForGVBC)(series.y, Array.isArray(series.x) ? series.x : undefined).traces;
|
|
468
|
+
// Return all the new traces, each representing a property from the objects
|
|
469
|
+
return traces.map(function (trace) { return (tslib_1.__assign(tslib_1.__assign({}, trace), {
|
|
470
|
+
// Copy other properties from the original series if needed
|
|
471
|
+
marker: series.marker })); });
|
|
472
|
+
}
|
|
473
|
+
return [series];
|
|
474
|
+
})
|
|
475
|
+
.flat();
|
|
476
|
+
processedInput = tslib_1.__assign(tslib_1.__assign({}, input), { data: processedData });
|
|
477
|
+
}
|
|
338
478
|
var mapXToDataPoints = {};
|
|
339
|
-
var secondaryYAxisValues = getSecondaryYAxisValues(
|
|
340
|
-
var _e = getLegendProps(
|
|
479
|
+
var secondaryYAxisValues = getSecondaryYAxisValues(processedInput.data, processedInput.layout, 0, 0);
|
|
480
|
+
var _e = getLegendProps(processedInput.data, processedInput.layout, isMultiPlot), legends = _e.legends, hideLegend = _e.hideLegend;
|
|
341
481
|
var colorScale = undefined;
|
|
342
|
-
var yAxisTickFormat = getYAxisTickFormat(
|
|
343
|
-
|
|
482
|
+
var yAxisTickFormat = getYAxisTickFormat(processedInput.data[0], processedInput.layout);
|
|
483
|
+
processedInput.data.forEach(function (series, index1) {
|
|
344
484
|
var _a, _b, _c, _d, _e;
|
|
345
|
-
colorScale = (0, PlotlyColorAdapter_1.createColorScale)(
|
|
485
|
+
colorScale = (0, PlotlyColorAdapter_1.createColorScale)(processedInput.layout, series, colorScale);
|
|
346
486
|
// extract colors for each series only once
|
|
347
|
-
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_c = (_b = (_a =
|
|
487
|
+
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_c = (_b = (_a = processedInput.layout) === null || _a === void 0 ? void 0 : _a.template) === null || _b === void 0 ? void 0 : _b.layout) === null || _c === void 0 ? void 0 : _c.colorway, colorwayType, (_d = series.marker) === null || _d === void 0 ? void 0 : _d.color, colorMap, isDarkTheme);
|
|
348
488
|
(_e = series.x) === null || _e === void 0 ? void 0 : _e.forEach(function (x, xIndex) {
|
|
349
489
|
var _a, _b, _c, _d, _e, _f;
|
|
350
490
|
if ((0, chart_utilities_1.isInvalidValue)(x) || (0, chart_utilities_1.isInvalidValue)((_a = series.y) === null || _a === void 0 ? void 0 : _a[xIndex])) {
|
|
@@ -369,14 +509,14 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
369
509
|
xAxisCalloutData: x,
|
|
370
510
|
color: (_f = (0, d3_color_1.rgb)(color).copy({ opacity: opacity }).formatHex8()) !== null && _f !== void 0 ? _f : color,
|
|
371
511
|
legend: legend,
|
|
372
|
-
useSecondaryYScale: usesSecondaryYScale(series,
|
|
512
|
+
useSecondaryYScale: usesSecondaryYScale(series, processedInput.layout),
|
|
373
513
|
yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat),
|
|
374
514
|
});
|
|
375
515
|
}
|
|
376
516
|
});
|
|
377
517
|
});
|
|
378
518
|
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(tslib_1.__assign({ data: gvbcData, width: (_a =
|
|
519
|
+
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 = processedInput.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = processedInput.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(processedInput.layout)), getAxisCategoryOrderProps(processedInput.data, processedInput.layout)), getYMinMaxValues(processedInput.data[0], processedInput.layout)), getXAxisTickFormat(processedInput.data[0], processedInput.layout)), yAxisTickFormat), getBarProps(processedInput.data, processedInput.layout));
|
|
380
520
|
};
|
|
381
521
|
exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
|
|
382
522
|
var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -541,7 +681,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
541
681
|
var scatterChartProps = {
|
|
542
682
|
scatterChartData: chartData,
|
|
543
683
|
};
|
|
544
|
-
var commonProps = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ supportNegativeData: true }, secondaryYAxisValues), { width: (_b = input.layout) === null || _b === void 0 ? void 0 : _b.width, height: (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : 350, hideTickOverlap: true, hideLegend: hideLegend, useUTC: false, optimizeLargeData: numDataPoints > 1000 }), getTitles(input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat);
|
|
684
|
+
var commonProps = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ supportNegativeData: true }, secondaryYAxisValues), { width: (_b = input.layout) === null || _b === void 0 ? void 0 : _b.width, height: (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : 350, hideTickOverlap: true, hideLegend: hideLegend, useUTC: false, optimizeLargeData: numDataPoints > 1000 }), getTitles(input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getAxisScaleTypeProps(input.data, input.layout));
|
|
545
685
|
if (isAreaChart) {
|
|
546
686
|
return tslib_1.__assign({ data: chartProps, mode: mode }, commonProps);
|
|
547
687
|
}
|
|
@@ -1788,7 +1928,15 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
1788
1928
|
var getBarProps = function (data, layout, isHorizontal) {
|
|
1789
1929
|
var padding;
|
|
1790
1930
|
if (typeof (layout === null || layout === void 0 ? void 0 : layout.bargap) === 'number') {
|
|
1791
|
-
|
|
1931
|
+
if (layout.bargap >= 0 && layout.bargap <= 1) {
|
|
1932
|
+
padding = layout.bargap;
|
|
1933
|
+
}
|
|
1934
|
+
else {
|
|
1935
|
+
// Plotly uses a default bargap of 0.2, as noted here: https://github.com/plotly/plotly.js/blob/1d5a249e43dd31ae50acf02117a19e5ac97387e9/src/traces/bar/layout_defaults.js#L58.
|
|
1936
|
+
// However, we don't use this value as our default padding because it causes the bars to
|
|
1937
|
+
// appear disproportionately wide in large containers.
|
|
1938
|
+
padding = 0.2;
|
|
1939
|
+
}
|
|
1792
1940
|
}
|
|
1793
1941
|
var plotlyBarWidths = data
|
|
1794
1942
|
.map(function (series) {
|
|
@@ -1819,5 +1967,34 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
1819
1967
|
xAxisOuterPadding: padding / 2,
|
|
1820
1968
|
};
|
|
1821
1969
|
};
|
|
1970
|
+
var getAxisScaleTypeProps = function (data, layout) {
|
|
1971
|
+
var result = {};
|
|
1972
|
+
// Traces are grouped by their xaxis property, and for each group/subplot, the adapter functions
|
|
1973
|
+
// are called with the corresponding filtered data. As a result, all traces passed to an adapter
|
|
1974
|
+
// function share the same xaxis.
|
|
1975
|
+
var xAxisId;
|
|
1976
|
+
var yAxisIds = new Set();
|
|
1977
|
+
data.forEach(function (series) {
|
|
1978
|
+
var axisIds = (0, chart_utilities_1.getAxisIds)(series);
|
|
1979
|
+
xAxisId = axisIds.x;
|
|
1980
|
+
yAxisIds.add(axisIds.y);
|
|
1981
|
+
});
|
|
1982
|
+
var isLogAxis = function (axLetter, axId) {
|
|
1983
|
+
var _a;
|
|
1984
|
+
var axisKey = (0, chart_utilities_1.getAxisKey)(axLetter, axId);
|
|
1985
|
+
return ((_a = layout === null || layout === void 0 ? void 0 : layout[axisKey]) === null || _a === void 0 ? void 0 : _a.type) === 'log';
|
|
1986
|
+
};
|
|
1987
|
+
if (typeof xAxisId === 'number' && isLogAxis('x', xAxisId)) {
|
|
1988
|
+
result.xScaleType = 'log';
|
|
1989
|
+
}
|
|
1990
|
+
var sortedYAxisIds = Array.from(yAxisIds).sort();
|
|
1991
|
+
if (sortedYAxisIds.length > 0 && isLogAxis('y', sortedYAxisIds[0])) {
|
|
1992
|
+
result.yScaleType = 'log';
|
|
1993
|
+
}
|
|
1994
|
+
if (sortedYAxisIds.length > 1 && isLogAxis('y', sortedYAxisIds[1])) {
|
|
1995
|
+
result.secondaryYScaleType = 'log';
|
|
1996
|
+
}
|
|
1997
|
+
return result;
|
|
1998
|
+
};
|
|
1822
1999
|
});
|
|
1823
2000
|
//# sourceMappingURL=PlotlySchemaAdapter.js.map
|