@fluentui/react-charting 5.24.24 → 5.24.25

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 (47) hide show
  1. package/CHANGELOG.json +16 -1
  2. package/CHANGELOG.md +11 -2
  3. package/dist/react-charting.d.ts +55 -1
  4. package/dist/react-charting.js +1 -1
  5. package/dist/react-charting.min.js +1 -1
  6. package/etc/react-charting.api.md +9 -0
  7. package/lib/components/CommonComponents/CartesianChart.base.js +10 -5
  8. package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
  9. package/lib/components/CommonComponents/CartesianChart.types.d.ts +16 -1
  10. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  11. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +165 -29
  12. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  13. package/lib/index.d.ts +1 -1
  14. package/lib/index.js.map +1 -1
  15. package/lib/types/IDataPoint.d.ts +37 -0
  16. package/lib/types/IDataPoint.js.map +1 -1
  17. package/lib/utilities/utilities.d.ts +7 -3
  18. package/lib/utilities/utilities.js +131 -17
  19. package/lib/utilities/utilities.js.map +1 -1
  20. package/lib-amd/components/CommonComponents/CartesianChart.base.js +10 -5
  21. package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
  22. package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +16 -1
  23. package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
  24. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +167 -32
  25. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  26. package/lib-amd/index.d.ts +1 -1
  27. package/lib-amd/index.js.map +1 -1
  28. package/lib-amd/types/IDataPoint.d.ts +37 -0
  29. package/lib-amd/types/IDataPoint.js.map +1 -1
  30. package/lib-amd/utilities/utilities.d.ts +7 -3
  31. package/lib-amd/utilities/utilities.js +132 -16
  32. package/lib-amd/utilities/utilities.js.map +1 -1
  33. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +10 -5
  34. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
  35. package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +16 -1
  36. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  37. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +167 -31
  38. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  39. package/lib-commonjs/index.d.ts +1 -1
  40. package/lib-commonjs/index.js.map +1 -1
  41. package/lib-commonjs/types/IDataPoint.d.ts +37 -0
  42. package/lib-commonjs/types/IDataPoint.js.map +1 -1
  43. package/lib-commonjs/utilities/utilities.d.ts +7 -3
  44. package/lib-commonjs/utilities/utilities.js +132 -16
  45. package/lib-commonjs/utilities/utilities.js.map +1 -1
  46. package/package.json +1 -1
  47. package/src/components/CommonComponents/CartesianChart.types.ts +19 -0
@@ -4,11 +4,12 @@ import { scaleLinear as d3ScaleLinear } from 'd3-scale';
4
4
  import { format as d3Format } from 'd3-format';
5
5
  import { DataVizPalette, getColorFromToken } from '../../utilities/colors';
6
6
  import { GaugeChartVariant } from '../GaugeChart/index';
7
- import { findNumericMinMaxOfY, formatScientificLimitWidth, MIN_DONUT_RADIUS } from '../../utilities/utilities';
7
+ import { DEFAULT_DATE_STRING, findNumericMinMaxOfY, formatScientificLimitWidth, MIN_DONUT_RADIUS, } from '../../utilities/utilities';
8
8
  import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue, formatToLocaleString, isNumber, isObjectArray, getAxisIds, getAxisKey, } from '@fluentui/chart-utilities';
9
9
  import { curveCardinal as d3CurveCardinal } from 'd3-shape';
10
10
  import { getOpacity, extractColor, resolveColor, createColorScale } from './PlotlyColorAdapter';
11
11
  import { rgb } from 'd3-color';
12
+ import { calculatePrecision, precisionRound } from '@fluentui/react';
12
13
  export var NON_PLOT_KEY_PREFIX = 'nonplot_';
13
14
  export var SINGLE_REPEAT = 'repeat(1, 1fr)';
14
15
  var dashOptions = {
@@ -451,7 +452,7 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
451
452
  });
452
453
  });
453
454
  var vsbcData = Object.values(mapXToDataPoints);
454
- return __assign(__assign(__assign(__assign(__assign(__assign(__assign(__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));
455
+ return __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__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)), getAxisTickProps(input.data, input.layout));
455
456
  };
456
457
  export var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
457
458
  var _a, _b, _c, _d;
@@ -517,7 +518,7 @@ export var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorM
517
518
  });
518
519
  });
519
520
  var gvbcData = Object.values(mapXToDataPoints);
520
- return __assign(__assign(__assign(__assign(__assign(__assign(__assign(__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));
521
+ return __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__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)), getAxisTickProps(processedInput.data, processedInput.layout));
521
522
  };
522
523
  export var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
523
524
  var _a, _b, _c, _d;
@@ -677,7 +678,7 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
677
678
  var scatterChartProps = {
678
679
  scatterChartData: chartData,
679
680
  };
680
- var commonProps = __assign(__assign(__assign(__assign(__assign(__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));
681
+ var commonProps = __assign(__assign(__assign(__assign(__assign(__assign(__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)), getAxisTickProps(input.data, input.layout));
681
682
  if (isAreaChart) {
682
683
  return __assign({ data: chartProps, mode: mode }, commonProps);
683
684
  }
@@ -728,9 +729,9 @@ export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, is
728
729
  var scalingFactor = 0.01;
729
730
  var gapFactor = 1 / (1 + scalingFactor * numberOfRows);
730
731
  var barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
731
- return __assign(__assign(__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'
732
+ return __assign(__assign(__assign(__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'
732
733
  ? (_m = (_l = input.layout) === null || _l === void 0 ? void 0 : _l.yaxis2) === null || _m === void 0 ? void 0 : _m.title
733
- : ((_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));
734
+ : ((_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)), getAxisTickProps(input.data, input.layout));
734
735
  };
735
736
  export var transformPlotlyJsonToGanttChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
736
737
  var _a, _b, _c;
@@ -776,7 +777,7 @@ export var transformPlotlyJsonToGanttChartProps = function (input, isMultiPlot,
776
777
  .filter(function (point) { return point !== null; });
777
778
  })
778
779
  .flat();
779
- return __assign(__assign(__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));
780
+ return __assign(__assign(__assign(__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)), getAxisTickProps(input.data, input.layout));
780
781
  };
781
782
  export var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
782
783
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
@@ -890,7 +891,7 @@ export var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, col
890
891
  var rangeValuesForColorScale = Array.isArray(colorscale)
891
892
  ? colorscale.map(function (arr) { return arr[1]; })
892
893
  : defaultRange;
893
- return __assign(__assign({ data: [heatmapData], domainValuesForColorScale: domainValuesForColorScale, rangeValuesForColorScale: rangeValuesForColorScale, hideLegend: true, showYAxisLables: true, sortOrder: 'none', width: (_6 = input.layout) === null || _6 === void 0 ? void 0 : _6.width, height: (_8 = (_7 = input.layout) === null || _7 === void 0 ? void 0 : _7.height) !== null && _8 !== void 0 ? _8 : 350, hideTickOverlap: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, wrapXAxisLables: true }, getTitles(input.layout)), getAxisCategoryOrderProps([firstData], input.layout));
894
+ return __assign(__assign(__assign({ data: [heatmapData], domainValuesForColorScale: domainValuesForColorScale, rangeValuesForColorScale: rangeValuesForColorScale, hideLegend: true, showYAxisLables: true, sortOrder: 'none', width: (_6 = input.layout) === null || _6 === void 0 ? void 0 : _6.width, height: (_8 = (_7 = input.layout) === null || _7 === void 0 ? void 0 : _7.height) !== null && _8 !== void 0 ? _8 : 350, hideTickOverlap: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, wrapXAxisLables: true }, getTitles(input.layout)), getAxisCategoryOrderProps([firstData], input.layout)), getAxisTickProps(input.data, input.layout));
894
895
  };
895
896
  export var transformPlotlyJsonToSankeyProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
896
897
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
@@ -1519,7 +1520,7 @@ var createBins = function (data, binStart, binEnd, binSize) {
1519
1520
  var binGenerator = d3Bin().domain([minVal, maxVal]);
1520
1521
  if (typeof binSize === 'number' && binSize > 0) {
1521
1522
  var thresholds = [];
1522
- var precision = Math.max(getPrecision(minVal), getPrecision(binSize));
1523
+ var precision = Math.max(calculatePrecision(minVal), calculatePrecision(binSize));
1523
1524
  var th = precisionRound(minVal, precision);
1524
1525
  while (th < precisionRound(maxVal + binSize, precision)) {
1525
1526
  thresholds.push(th);
@@ -1566,14 +1567,6 @@ var calculateHistNorm = function (histnorm, value, total, dx, dy) {
1566
1567
  return value;
1567
1568
  }
1568
1569
  };
1569
- var getPrecision = function (value) {
1570
- var _a, _b;
1571
- return (_b = (_a = value.toString().split('.')[1]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
1572
- };
1573
- var precisionRound = function (value, precision) {
1574
- var factor = Math.pow(10, precision);
1575
- return Math.round(value * factor) / factor;
1576
- };
1577
1570
  var getLegendShape = function (series) {
1578
1571
  var _a, _b;
1579
1572
  var dashType = ((_a = series.line) === null || _a === void 0 ? void 0 : _a.dash) || 'solid';
@@ -1951,7 +1944,128 @@ var getBarProps = function (data, layout, isHorizontal) {
1951
1944
  };
1952
1945
  };
1953
1946
  var getAxisScaleTypeProps = function (data, layout) {
1947
+ var _a, _b, _c;
1954
1948
  var result = {};
1949
+ var axisObjects = getAxisObjects(data, layout);
1950
+ if (((_a = axisObjects.x) === null || _a === void 0 ? void 0 : _a.type) === 'log') {
1951
+ result.xScaleType = 'log';
1952
+ }
1953
+ if (((_b = axisObjects.y) === null || _b === void 0 ? void 0 : _b.type) === 'log') {
1954
+ result.yScaleType = 'log';
1955
+ }
1956
+ if (((_c = axisObjects.y2) === null || _c === void 0 ? void 0 : _c.type) === 'log') {
1957
+ result.secondaryYScaleType = 'log';
1958
+ }
1959
+ return result;
1960
+ };
1961
+ /**
1962
+ * @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/tick_value_defaults.js#L8}
1963
+ */
1964
+ var getAxisTickProps = function (data, layout) {
1965
+ var props = {};
1966
+ var axisObjects = getAxisObjects(data, layout);
1967
+ Object.keys(axisObjects).forEach(function (axId) {
1968
+ var ax = axisObjects[axId];
1969
+ if (!ax) {
1970
+ return;
1971
+ }
1972
+ var axType = getAxisType(data, axId[0], ax);
1973
+ if ((!ax.tickmode || ax.tickmode === 'array') && isArrayOrTypedArray(ax.tickvals)) {
1974
+ var tickValues = axType === 'date' ? ax.tickvals.map(function (v) { return new Date(v); }) : ax.tickvals;
1975
+ if (axId === 'x') {
1976
+ props.tickValues = tickValues;
1977
+ }
1978
+ else if (axId === 'y') {
1979
+ props.yAxisTickValues = tickValues;
1980
+ }
1981
+ return;
1982
+ }
1983
+ if ((!ax.tickmode || ax.tickmode === 'linear') && ax.dtick) {
1984
+ var dtick = plotlyDtick(ax.dtick, axType);
1985
+ var tick0 = plotlyTick0(ax.tick0, axType, dtick);
1986
+ if (axId === 'x') {
1987
+ props.xAxis = {
1988
+ tickStep: dtick,
1989
+ tick0: tick0,
1990
+ };
1991
+ }
1992
+ else if (axId === 'y') {
1993
+ props.yAxis = {
1994
+ tickStep: dtick,
1995
+ tick0: tick0,
1996
+ };
1997
+ }
1998
+ return;
1999
+ }
2000
+ if ((!ax.tickmode || ax.tickmode === 'auto') && typeof ax.nticks === 'number' && ax.nticks >= 0) {
2001
+ if (axId === 'x') {
2002
+ props.xAxisTickCount = ax.nticks;
2003
+ }
2004
+ else if (axId === 'y') {
2005
+ props.yAxisTickCount = ax.nticks;
2006
+ }
2007
+ }
2008
+ });
2009
+ return props;
2010
+ };
2011
+ /**
2012
+ * @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/clean_ticks.js#L16}
2013
+ */
2014
+ var plotlyDtick = function (dtick, axType) {
2015
+ var isLogAx = axType === 'log';
2016
+ var isDateAx = axType === 'date';
2017
+ var isCatAx = axType === 'category';
2018
+ var dtickDflt = isDateAx ? 86400000 : 1;
2019
+ if (!dtick) {
2020
+ return dtickDflt;
2021
+ }
2022
+ if (isNumber(dtick)) {
2023
+ dtick = Number(dtick);
2024
+ if (dtick <= 0) {
2025
+ return dtickDflt;
2026
+ }
2027
+ if (isCatAx) {
2028
+ // category dtick must be positive integers
2029
+ return Math.max(1, Math.round(dtick));
2030
+ }
2031
+ if (isDateAx) {
2032
+ // date dtick must be at least 0.1ms (our current precision)
2033
+ return Math.max(0.1, dtick);
2034
+ }
2035
+ return dtick;
2036
+ }
2037
+ if (typeof dtick !== 'string' || !(isDateAx || isLogAx)) {
2038
+ return dtickDflt;
2039
+ }
2040
+ var prefix = dtick.charAt(0);
2041
+ var dtickNum = isNumber(dtick.slice(1)) ? Number(dtick.slice(1)) : 0;
2042
+ if (dtickNum <= 0 ||
2043
+ !(
2044
+ // "M<n>" gives ticks every (integer) n months
2045
+ ((isDateAx && prefix === 'M' && dtickNum === Math.round(dtickNum)) ||
2046
+ // "L<f>" gives ticks linearly spaced in data (not in position) every (float) f
2047
+ (isLogAx && prefix === 'L') ||
2048
+ // "D1" gives powers of 10 with all small digits between, "D2" gives only 2 and 5
2049
+ (isLogAx && prefix === 'D' && (dtickNum === 1 || dtickNum === 2))))) {
2050
+ return dtickDflt;
2051
+ }
2052
+ return dtick;
2053
+ };
2054
+ /**
2055
+ * @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/clean_ticks.js#L70}
2056
+ */
2057
+ var plotlyTick0 = function (tick0, axType, dtick) {
2058
+ if (axType === 'date') {
2059
+ return isDate(tick0) ? new Date(tick0) : new Date(DEFAULT_DATE_STRING);
2060
+ }
2061
+ if (dtick === 'D1' || dtick === 'D2') {
2062
+ // D1 and D2 modes ignore tick0 entirely
2063
+ return undefined;
2064
+ }
2065
+ // Aside from date axes, tick0 must be numeric
2066
+ return isNumber(tick0) ? Number(tick0) : 0;
2067
+ };
2068
+ var getAxisObjects = function (data, layout) {
1955
2069
  // Traces are grouped by their xaxis property, and for each group/subplot, the adapter functions
1956
2070
  // are called with the corresponding filtered data. As a result, all traces passed to an adapter
1957
2071
  // function share the same xaxis.
@@ -1962,21 +2076,43 @@ var getAxisScaleTypeProps = function (data, layout) {
1962
2076
  xAxisId = axisIds.x;
1963
2077
  yAxisIds.add(axisIds.y);
1964
2078
  });
1965
- var isLogAxis = function (axLetter, axId) {
1966
- var _a;
1967
- var axisKey = getAxisKey(axLetter, axId);
1968
- return ((_a = layout === null || layout === void 0 ? void 0 : layout[axisKey]) === null || _a === void 0 ? void 0 : _a.type) === 'log';
1969
- };
1970
- if (typeof xAxisId === 'number' && isLogAxis('x', xAxisId)) {
1971
- result.xScaleType = 'log';
2079
+ var axisObjects = {};
2080
+ if (typeof xAxisId === 'number') {
2081
+ axisObjects.x = layout === null || layout === void 0 ? void 0 : layout[getAxisKey('x', xAxisId)];
1972
2082
  }
1973
2083
  var sortedYAxisIds = Array.from(yAxisIds).sort();
1974
- if (sortedYAxisIds.length > 0 && isLogAxis('y', sortedYAxisIds[0])) {
1975
- result.yScaleType = 'log';
2084
+ if (sortedYAxisIds.length > 0) {
2085
+ axisObjects.y = layout === null || layout === void 0 ? void 0 : layout[getAxisKey('y', sortedYAxisIds[0])];
1976
2086
  }
1977
- if (sortedYAxisIds.length > 1 && isLogAxis('y', sortedYAxisIds[1])) {
1978
- result.secondaryYScaleType = 'log';
2087
+ if (sortedYAxisIds.length > 1) {
2088
+ axisObjects.y2 = layout === null || layout === void 0 ? void 0 : layout[getAxisKey('y', sortedYAxisIds[1])];
2089
+ }
2090
+ return axisObjects;
2091
+ };
2092
+ var getAxisType = function (data, axLetter, ax) {
2093
+ var values = [];
2094
+ data.forEach(function (series) {
2095
+ var _a;
2096
+ (_a = series[axLetter]) === null || _a === void 0 ? void 0 : _a.forEach(function (val) {
2097
+ if (!isInvalidValue(val)) {
2098
+ values.push(val);
2099
+ }
2100
+ });
2101
+ });
2102
+ // Note: When ax.type is explicitly specified, Plotly casts the values to match that type.
2103
+ // Therefore, simply checking the type of the values may not be sufficient. At the moment,
2104
+ // we don’t always perform this casting ourselves and instead use the values as provided.
2105
+ if (isNumberArray(values)) {
2106
+ if ((ax === null || ax === void 0 ? void 0 : ax.type) === 'log') {
2107
+ return 'log';
2108
+ }
2109
+ return 'linear';
2110
+ }
2111
+ if (isDateArray(values)) {
2112
+ return 'date';
2113
+ }
2114
+ if (isStringArray(values)) {
2115
+ return 'category';
1979
2116
  }
1980
- return result;
1981
2117
  };
1982
2118
  //# sourceMappingURL=PlotlySchemaAdapter.js.map