@fluentui/react-charting 5.24.21 → 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.
Files changed (84) hide show
  1. package/CHANGELOG.json +40 -1
  2. package/CHANGELOG.md +15 -2
  3. package/bundle-size/ScatterChart.fixture.js +7 -0
  4. package/dist/react-charting.d.ts +27 -2
  5. package/dist/react-charting.js +1 -1
  6. package/dist/react-charting.min.js +1 -1
  7. package/etc/react-charting.api.md +8 -2
  8. package/lib/components/AreaChart/AreaChart.base.js +3 -3
  9. package/lib/components/AreaChart/AreaChart.base.js.map +1 -1
  10. package/lib/components/CommonComponents/CartesianChart.base.js +4 -4
  11. package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
  12. package/lib/components/CommonComponents/CartesianChart.types.d.ts +18 -3
  13. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  14. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +10 -0
  15. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +187 -11
  16. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  17. package/lib/components/LineChart/LineChart.base.d.ts +0 -9
  18. package/lib/components/LineChart/LineChart.base.js +82 -138
  19. package/lib/components/LineChart/LineChart.base.js.map +1 -1
  20. package/lib/components/ScatterChart/ScatterChart.base.js +37 -62
  21. package/lib/components/ScatterChart/ScatterChart.base.js.map +1 -1
  22. package/lib/components/VerticalBarChart/VerticalBarChart.base.js +2 -2
  23. package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  24. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +2 -2
  25. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  26. package/lib/index.d.ts +1 -1
  27. package/lib/index.js.map +1 -1
  28. package/lib/types/IDataPoint.d.ts +9 -0
  29. package/lib/types/IDataPoint.js.map +1 -1
  30. package/lib/utilities/utilities.d.ts +29 -28
  31. package/lib/utilities/utilities.js +127 -110
  32. package/lib/utilities/utilities.js.map +1 -1
  33. package/lib-amd/components/AreaChart/AreaChart.base.js +2 -2
  34. package/lib-amd/components/AreaChart/AreaChart.base.js.map +1 -1
  35. package/lib-amd/components/CommonComponents/CartesianChart.base.js +4 -4
  36. package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
  37. package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +18 -3
  38. package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
  39. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +10 -0
  40. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +188 -11
  41. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  42. package/lib-amd/components/LineChart/LineChart.base.d.ts +0 -9
  43. package/lib-amd/components/LineChart/LineChart.base.js +80 -136
  44. package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
  45. package/lib-amd/components/ScatterChart/ScatterChart.base.js +35 -60
  46. package/lib-amd/components/ScatterChart/ScatterChart.base.js.map +1 -1
  47. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +1 -1
  48. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  49. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +1 -1
  50. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  51. package/lib-amd/index.d.ts +1 -1
  52. package/lib-amd/index.js.map +1 -1
  53. package/lib-amd/types/IDataPoint.d.ts +9 -0
  54. package/lib-amd/types/IDataPoint.js.map +1 -1
  55. package/lib-amd/utilities/utilities.d.ts +29 -28
  56. package/lib-amd/utilities/utilities.js +133 -113
  57. package/lib-amd/utilities/utilities.js.map +1 -1
  58. package/lib-commonjs/components/AreaChart/AreaChart.base.js +2 -2
  59. package/lib-commonjs/components/AreaChart/AreaChart.base.js.map +1 -1
  60. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +4 -4
  61. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
  62. package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +18 -3
  63. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  64. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +10 -0
  65. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +188 -11
  66. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  67. package/lib-commonjs/components/LineChart/LineChart.base.d.ts +0 -9
  68. package/lib-commonjs/components/LineChart/LineChart.base.js +80 -136
  69. package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
  70. package/lib-commonjs/components/ScatterChart/ScatterChart.base.js +35 -60
  71. package/lib-commonjs/components/ScatterChart/ScatterChart.base.js.map +1 -1
  72. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +1 -1
  73. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  74. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +1 -1
  75. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  76. package/lib-commonjs/index.d.ts +1 -1
  77. package/lib-commonjs/index.js.map +1 -1
  78. package/lib-commonjs/types/IDataPoint.d.ts +9 -0
  79. package/lib-commonjs/types/IDataPoint.js.map +1 -1
  80. package/lib-commonjs/utilities/utilities.d.ts +29 -28
  81. package/lib-commonjs/utilities/utilities.js +134 -114
  82. package/lib-commonjs/utilities/utilities.js.map +1 -1
  83. package/package.json +4 -4
  84. package/src/components/CommonComponents/CartesianChart.types.ts +22 -2
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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;
3
+ 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;
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");
@@ -209,6 +209,125 @@ var resolveXAxisPoint = function (x, isXYearCategory, isXString, isXDate, isXNum
209
209
  return x;
210
210
  };
211
211
  exports.resolveXAxisPoint = resolveXAxisPoint;
212
+ /**
213
+ * Checks if a key should be ignored during normalization
214
+ * @param key The key to check
215
+ * @returns true if the key should be ignored
216
+ */
217
+ var shouldIgnoreKey = function (key) {
218
+ var lowerKey = key.toLowerCase();
219
+ if (lowerKey.includes('style') || lowerKey === 'style') {
220
+ return true;
221
+ }
222
+ // Use regex to match common CSS property patterns
223
+ // (color, fill, stroke, border, background, font, shadow, outline, etc.)
224
+ var cssKeyRegex = new RegExp('^(color|fill|stroke|border|background|font|shadow|outline|margin|padding|gap|align|justify|display|flex|grid|' +
225
+ 'text|line|letter|word|vertical|horizontal|overflow|position|top|right|bottom|left|zindex|z-index|opacity|' +
226
+ 'filter|clip|cursor|resize|transition|animation|transform|box|column|row|direction|visibility|' +
227
+ 'content|width|height|aspect|image|user|pointer|caret|scroll|%)|(-webkit-|-moz-|-ms-|-o-)', 'i');
228
+ if (cssKeyRegex.test(lowerKey)) {
229
+ return true;
230
+ }
231
+ return false;
232
+ };
233
+ /**
234
+ * Flattens a nested object into a single level object with dot notation keys
235
+ * @param obj Object to flatten
236
+ * @param prefix Optional prefix for keys
237
+ * @returns Flattened object
238
+ */
239
+ var flattenObject = function (obj, prefix) {
240
+ if (prefix === void 0) { prefix = ''; }
241
+ var flattened = {};
242
+ for (var key in obj) {
243
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
244
+ var newKey = prefix ? "".concat(prefix, ".").concat(key) : key;
245
+ var value = obj[key];
246
+ if (typeof value === 'object' && value !== null && !Array.isArray(value) && !(value instanceof Date)) {
247
+ // Recursively flatten nested objects
248
+ Object.assign(flattened, flattenObject(value, newKey));
249
+ }
250
+ else {
251
+ flattened[newKey] = value;
252
+ }
253
+ }
254
+ }
255
+ return flattened;
256
+ };
257
+ /**
258
+ * Normalizes an array of objects by flattening nested structures and creating grouped data
259
+ * Uses json_normalize approach with D3 color detection and filtering
260
+ * @param data Array of objects to normalize
261
+ * @returns Object containing traces for grouped vertical bar chart
262
+ */
263
+ var normalizeObjectArrayForGVBC = function (data, xLabels) {
264
+ if (!data || data.length === 0) {
265
+ return { traces: [], x: [] };
266
+ }
267
+ // Use provided xLabels if available, otherwise default to Item 1, Item 2, ...
268
+ var x = xLabels && xLabels.length === data.length ? xLabels : data.map(function (_, index) { return "Item ".concat(index + 1); });
269
+ // First, flatten all objects and collect all unique keys, excluding style keys
270
+ var flattenedObjects = data.map(function (item, index) {
271
+ var _a;
272
+ if (typeof item === 'object' && item !== null) {
273
+ var flattened_1 = flattenObject(item);
274
+ // Only keep keys where the value is numeric (number or numeric string) and not a style key
275
+ var filtered_1 = {};
276
+ Object.keys(flattened_1).forEach(function (key) {
277
+ var value = flattened_1[key];
278
+ if (!shouldIgnoreKey(key) && (typeof value === 'number' || (typeof value === 'string' && (0, chart_utilities_1.isNumber)(value)))) {
279
+ filtered_1[key] = value;
280
+ }
281
+ });
282
+ return filtered_1;
283
+ }
284
+ else if (typeof item === 'number' || (typeof item === 'string' && (0, chart_utilities_1.isNumber)(item))) {
285
+ // Only keep primitive numeric values
286
+ return _a = {}, _a[x[index] || "item_".concat(index)] = item, _a;
287
+ }
288
+ else {
289
+ // Non-numeric primitive, ignore by returning empty object
290
+ return {};
291
+ }
292
+ });
293
+ // Collect all unique keys across all objects
294
+ var allKeys = new Set();
295
+ flattenedObjects.forEach(function (obj) {
296
+ Object.keys(obj).forEach(function (key) { return allKeys.add(key); });
297
+ });
298
+ // Create traces for each key (property)
299
+ var traces = [];
300
+ allKeys.forEach(function (key) {
301
+ var yValues = [];
302
+ var hasValidData = false;
303
+ var isNumericData = false;
304
+ flattenedObjects.forEach(function (obj, index) {
305
+ var value = obj[key];
306
+ if (typeof value === 'number') {
307
+ yValues.push(value);
308
+ hasValidData = true;
309
+ isNumericData = true;
310
+ }
311
+ else if (typeof value === 'string' && (0, chart_utilities_1.isNumber)(value)) {
312
+ yValues.push(parseFloat(value));
313
+ hasValidData = true;
314
+ isNumericData = true;
315
+ }
316
+ });
317
+ // Only create trace if we have valid numeric data
318
+ if (hasValidData && isNumericData) {
319
+ var trace = {
320
+ type: 'bar',
321
+ name: key,
322
+ x: x,
323
+ y: yValues,
324
+ };
325
+ traces.push(trace);
326
+ }
327
+ });
328
+ return { traces: traces, x: x };
329
+ };
330
+ exports.normalizeObjectArrayForGVBC = normalizeObjectArrayForGVBC;
212
331
  var transformPlotlyJsonToDonutProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
213
332
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
214
333
  var firstData = input.data[0];
@@ -345,16 +464,37 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
345
464
  exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
346
465
  var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
347
466
  var _a, _b, _c, _d;
467
+ // Handle object arrays in y values by normalizing the data first
468
+ var processedInput = tslib_1.__assign({}, input);
469
+ // Check if any bar traces have object arrays as y values
470
+ var hasObjectArrayData = input.data.some(function (series) { return series.type === 'bar' && (0, chart_utilities_1.isObjectArray)(series.y); });
471
+ if (hasObjectArrayData) {
472
+ // Process each trace that has object array y values
473
+ var processedData = input.data
474
+ .map(function (series, index) {
475
+ if (series.type === 'bar' && (0, chart_utilities_1.isObjectArray)(series.y)) {
476
+ // Normalize the object array to create multiple traces for GVBC
477
+ var traces = (0, exports.normalizeObjectArrayForGVBC)(series.y, Array.isArray(series.x) ? series.x : undefined).traces;
478
+ // Return all the new traces, each representing a property from the objects
479
+ return traces.map(function (trace) { return (tslib_1.__assign(tslib_1.__assign({}, trace), {
480
+ // Copy other properties from the original series if needed
481
+ marker: series.marker })); });
482
+ }
483
+ return [series];
484
+ })
485
+ .flat();
486
+ processedInput = tslib_1.__assign(tslib_1.__assign({}, input), { data: processedData });
487
+ }
348
488
  var mapXToDataPoints = {};
349
- var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
350
- var _e = getLegendProps(input.data, input.layout, isMultiPlot), legends = _e.legends, hideLegend = _e.hideLegend;
489
+ var secondaryYAxisValues = getSecondaryYAxisValues(processedInput.data, processedInput.layout, 0, 0);
490
+ var _e = getLegendProps(processedInput.data, processedInput.layout, isMultiPlot), legends = _e.legends, hideLegend = _e.hideLegend;
351
491
  var colorScale = undefined;
352
- var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
353
- input.data.forEach(function (series, index1) {
492
+ var yAxisTickFormat = getYAxisTickFormat(processedInput.data[0], processedInput.layout);
493
+ processedInput.data.forEach(function (series, index1) {
354
494
  var _a, _b, _c, _d, _e;
355
- colorScale = (0, PlotlyColorAdapter_1.createColorScale)(input.layout, series, colorScale);
495
+ colorScale = (0, PlotlyColorAdapter_1.createColorScale)(processedInput.layout, series, colorScale);
356
496
  // extract colors for each series only once
357
- var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_c = (_b = (_a = input.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);
497
+ 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);
358
498
  (_e = series.x) === null || _e === void 0 ? void 0 : _e.forEach(function (x, xIndex) {
359
499
  var _a, _b, _c, _d, _e, _f;
360
500
  if ((0, chart_utilities_1.isInvalidValue)(x) || (0, chart_utilities_1.isInvalidValue)((_a = series.y) === null || _a === void 0 ? void 0 : _a[xIndex])) {
@@ -379,14 +519,14 @@ var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, col
379
519
  xAxisCalloutData: x,
380
520
  color: (_f = (0, d3_color_1.rgb)(color).copy({ opacity: opacity }).formatHex8()) !== null && _f !== void 0 ? _f : color,
381
521
  legend: legend,
382
- useSecondaryYScale: usesSecondaryYScale(series, input.layout),
522
+ useSecondaryYScale: usesSecondaryYScale(series, processedInput.layout),
383
523
  yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat),
384
524
  });
385
525
  }
386
526
  });
387
527
  });
388
528
  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(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));
529
+ 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));
390
530
  };
391
531
  exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
392
532
  var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -551,7 +691,7 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
551
691
  var scatterChartProps = {
552
692
  scatterChartData: chartData,
553
693
  };
554
- 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);
694
+ 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));
555
695
  if (isAreaChart) {
556
696
  return tslib_1.__assign({ data: chartProps, mode: mode }, commonProps);
557
697
  }
@@ -1798,7 +1938,15 @@ var parseLocalDate = function (value) {
1798
1938
  var getBarProps = function (data, layout, isHorizontal) {
1799
1939
  var padding;
1800
1940
  if (typeof (layout === null || layout === void 0 ? void 0 : layout.bargap) === 'number') {
1801
- padding = layout.bargap;
1941
+ if (layout.bargap >= 0 && layout.bargap <= 1) {
1942
+ padding = layout.bargap;
1943
+ }
1944
+ else {
1945
+ // 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.
1946
+ // However, we don't use this value as our default padding because it causes the bars to
1947
+ // appear disproportionately wide in large containers.
1948
+ padding = 0.2;
1949
+ }
1802
1950
  }
1803
1951
  var plotlyBarWidths = data
1804
1952
  .map(function (series) {
@@ -1829,4 +1977,33 @@ var getBarProps = function (data, layout, isHorizontal) {
1829
1977
  xAxisOuterPadding: padding / 2,
1830
1978
  };
1831
1979
  };
1980
+ var getAxisScaleTypeProps = function (data, layout) {
1981
+ var result = {};
1982
+ // Traces are grouped by their xaxis property, and for each group/subplot, the adapter functions
1983
+ // are called with the corresponding filtered data. As a result, all traces passed to an adapter
1984
+ // function share the same xaxis.
1985
+ var xAxisId;
1986
+ var yAxisIds = new Set();
1987
+ data.forEach(function (series) {
1988
+ var axisIds = (0, chart_utilities_1.getAxisIds)(series);
1989
+ xAxisId = axisIds.x;
1990
+ yAxisIds.add(axisIds.y);
1991
+ });
1992
+ var isLogAxis = function (axLetter, axId) {
1993
+ var _a;
1994
+ var axisKey = (0, chart_utilities_1.getAxisKey)(axLetter, axId);
1995
+ return ((_a = layout === null || layout === void 0 ? void 0 : layout[axisKey]) === null || _a === void 0 ? void 0 : _a.type) === 'log';
1996
+ };
1997
+ if (typeof xAxisId === 'number' && isLogAxis('x', xAxisId)) {
1998
+ result.xScaleType = 'log';
1999
+ }
2000
+ var sortedYAxisIds = Array.from(yAxisIds).sort();
2001
+ if (sortedYAxisIds.length > 0 && isLogAxis('y', sortedYAxisIds[0])) {
2002
+ result.yScaleType = 'log';
2003
+ }
2004
+ if (sortedYAxisIds.length > 1 && isLogAxis('y', sortedYAxisIds[1])) {
2005
+ result.secondaryYScaleType = 'log';
2006
+ }
2007
+ return result;
2008
+ };
1832
2009
  //# sourceMappingURL=PlotlySchemaAdapter.js.map