@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
@@ -1,4 +1,4 @@
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) {
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", "@fluentui/react"], 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, react_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.getGridProperties = exports.isNonPlotType = exports.getValidXYRanges = exports.getNumberAtIndexOrDefault = exports.getAllupLegendsProps = 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;
@@ -450,7 +450,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
450
450
  });
451
451
  });
452
452
  var vsbcData = Object.values(mapXToDataPoints);
453
- return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: vsbcData, width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barWidth: 'auto', yMaxValue: yMaxValue, yMinValue: yMinValue, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, supportNegativeData: true, barGapMax: 2, showYAxisLables: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, wrapXAxisLables: typeof ((_d = vsbcData[0]) === null || _d === void 0 ? void 0 : _d.xAxisPoint) === 'string' }), getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getYMinMaxValues(input.data[0], input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getBarProps(input.data, input.layout));
453
+ 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(tslib_1.__assign({ data: vsbcData, width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barWidth: 'auto', yMaxValue: yMaxValue, yMinValue: yMinValue, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, supportNegativeData: true, barGapMax: 2, showYAxisLables: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, wrapXAxisLables: typeof ((_d = vsbcData[0]) === null || _d === void 0 ? void 0 : _d.xAxisPoint) === 'string' }), getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getYMinMaxValues(input.data[0], input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getBarProps(input.data, input.layout)), getAxisTickProps(input.data, input.layout));
454
454
  };
455
455
  exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
456
456
  var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -517,7 +517,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
517
517
  });
518
518
  });
519
519
  var gvbcData = Object.values(mapXToDataPoints);
520
- 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));
520
+ 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(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)), getAxisTickProps(processedInput.data, processedInput.layout));
521
521
  };
522
522
  exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
523
523
  var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -682,7 +682,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
682
682
  var scatterChartProps = {
683
683
  scatterChartData: chartData,
684
684
  };
685
- 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));
685
+ var commonProps = tslib_1.__assign(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)), getAxisTickProps(input.data, input.layout));
686
686
  if (isAreaChart) {
687
687
  return tslib_1.__assign({ data: chartProps, mode: mode }, commonProps);
688
688
  }
@@ -733,9 +733,9 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
733
733
  var scalingFactor = 0.01;
734
734
  var gapFactor = 1 / (1 + scalingFactor * numberOfRows);
735
735
  var barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
736
- return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: chartData, secondaryYAxistitle: typeof ((_k = (_j = input.layout) === null || _j === void 0 ? void 0 : _j.yaxis2) === null || _k === void 0 ? void 0 : _k.title) === 'string'
736
+ return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: chartData, secondaryYAxistitle: typeof ((_k = (_j = input.layout) === null || _j === void 0 ? void 0 : _j.yaxis2) === null || _k === void 0 ? void 0 : _k.title) === 'string'
737
737
  ? (_m = (_l = input.layout) === null || _l === void 0 ? void 0 : _l.yaxis2) === null || _m === void 0 ? void 0 : _m.title
738
- : ((_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));
738
+ : ((_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));
739
739
  };
740
740
  exports.transformPlotlyJsonToHorizontalBarWithAxisProps = transformPlotlyJsonToHorizontalBarWithAxisProps;
741
741
  var transformPlotlyJsonToGanttChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -782,7 +782,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
782
782
  .filter(function (point) { return point !== null; });
783
783
  })
784
784
  .flat();
785
- return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: chartData, showYAxisLables: true, height: (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 350, width: (_c = input.layout) === null || _c === void 0 ? void 0 : _c.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true, useUTC: false }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getBarProps(input.data, input.layout, true));
785
+ return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: chartData, showYAxisLables: true, height: (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 350, width: (_c = input.layout) === null || _c === void 0 ? void 0 : _c.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true, useUTC: false }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getBarProps(input.data, input.layout, true)), getAxisTickProps(input.data, input.layout));
786
786
  };
787
787
  exports.transformPlotlyJsonToGanttChartProps = transformPlotlyJsonToGanttChartProps;
788
788
  var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -897,7 +897,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
897
897
  var rangeValuesForColorScale = Array.isArray(colorscale)
898
898
  ? colorscale.map(function (arr) { return arr[1]; })
899
899
  : defaultRange;
900
- return tslib_1.__assign(tslib_1.__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));
900
+ return tslib_1.__assign(tslib_1.__assign(tslib_1.__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));
901
901
  };
902
902
  exports.transformPlotlyJsonToHeatmapProps = transformPlotlyJsonToHeatmapProps;
903
903
  var transformPlotlyJsonToSankeyProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -1532,11 +1532,11 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
1532
1532
  var binGenerator = (0, d3_array_1.bin)().domain([minVal, maxVal]);
1533
1533
  if (typeof binSize === 'number' && binSize > 0) {
1534
1534
  var thresholds = [];
1535
- var precision = Math.max(getPrecision(minVal), getPrecision(binSize));
1536
- var th = precisionRound(minVal, precision);
1537
- while (th < precisionRound(maxVal + binSize, precision)) {
1535
+ var precision = Math.max((0, react_1.calculatePrecision)(minVal), (0, react_1.calculatePrecision)(binSize));
1536
+ var th = (0, react_1.precisionRound)(minVal, precision);
1537
+ while (th < (0, react_1.precisionRound)(maxVal + binSize, precision)) {
1538
1538
  thresholds.push(th);
1539
- th = precisionRound(th + binSize, precision);
1539
+ th = (0, react_1.precisionRound)(th + binSize, precision);
1540
1540
  }
1541
1541
  minVal = thresholds[0];
1542
1542
  maxVal = thresholds[thresholds.length - 1];
@@ -1579,14 +1579,6 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
1579
1579
  return value;
1580
1580
  }
1581
1581
  };
1582
- var getPrecision = function (value) {
1583
- var _a, _b;
1584
- return (_b = (_a = value.toString().split('.')[1]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
1585
- };
1586
- var precisionRound = function (value, precision) {
1587
- var factor = Math.pow(10, precision);
1588
- return Math.round(value * factor) / factor;
1589
- };
1590
1582
  var getLegendShape = function (series) {
1591
1583
  var _a, _b;
1592
1584
  var dashType = ((_a = series.line) === null || _a === void 0 ? void 0 : _a.dash) || 'solid';
@@ -1969,7 +1961,128 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
1969
1961
  };
1970
1962
  };
1971
1963
  var getAxisScaleTypeProps = function (data, layout) {
1964
+ var _a, _b, _c;
1972
1965
  var result = {};
1966
+ var axisObjects = getAxisObjects(data, layout);
1967
+ if (((_a = axisObjects.x) === null || _a === void 0 ? void 0 : _a.type) === 'log') {
1968
+ result.xScaleType = 'log';
1969
+ }
1970
+ if (((_b = axisObjects.y) === null || _b === void 0 ? void 0 : _b.type) === 'log') {
1971
+ result.yScaleType = 'log';
1972
+ }
1973
+ if (((_c = axisObjects.y2) === null || _c === void 0 ? void 0 : _c.type) === 'log') {
1974
+ result.secondaryYScaleType = 'log';
1975
+ }
1976
+ return result;
1977
+ };
1978
+ /**
1979
+ * @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/tick_value_defaults.js#L8}
1980
+ */
1981
+ var getAxisTickProps = function (data, layout) {
1982
+ var props = {};
1983
+ var axisObjects = getAxisObjects(data, layout);
1984
+ Object.keys(axisObjects).forEach(function (axId) {
1985
+ var ax = axisObjects[axId];
1986
+ if (!ax) {
1987
+ return;
1988
+ }
1989
+ var axType = getAxisType(data, axId[0], ax);
1990
+ if ((!ax.tickmode || ax.tickmode === 'array') && (0, chart_utilities_1.isArrayOrTypedArray)(ax.tickvals)) {
1991
+ var tickValues = axType === 'date' ? ax.tickvals.map(function (v) { return new Date(v); }) : ax.tickvals;
1992
+ if (axId === 'x') {
1993
+ props.tickValues = tickValues;
1994
+ }
1995
+ else if (axId === 'y') {
1996
+ props.yAxisTickValues = tickValues;
1997
+ }
1998
+ return;
1999
+ }
2000
+ if ((!ax.tickmode || ax.tickmode === 'linear') && ax.dtick) {
2001
+ var dtick = plotlyDtick(ax.dtick, axType);
2002
+ var tick0 = plotlyTick0(ax.tick0, axType, dtick);
2003
+ if (axId === 'x') {
2004
+ props.xAxis = {
2005
+ tickStep: dtick,
2006
+ tick0: tick0,
2007
+ };
2008
+ }
2009
+ else if (axId === 'y') {
2010
+ props.yAxis = {
2011
+ tickStep: dtick,
2012
+ tick0: tick0,
2013
+ };
2014
+ }
2015
+ return;
2016
+ }
2017
+ if ((!ax.tickmode || ax.tickmode === 'auto') && typeof ax.nticks === 'number' && ax.nticks >= 0) {
2018
+ if (axId === 'x') {
2019
+ props.xAxisTickCount = ax.nticks;
2020
+ }
2021
+ else if (axId === 'y') {
2022
+ props.yAxisTickCount = ax.nticks;
2023
+ }
2024
+ }
2025
+ });
2026
+ return props;
2027
+ };
2028
+ /**
2029
+ * @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/clean_ticks.js#L16}
2030
+ */
2031
+ var plotlyDtick = function (dtick, axType) {
2032
+ var isLogAx = axType === 'log';
2033
+ var isDateAx = axType === 'date';
2034
+ var isCatAx = axType === 'category';
2035
+ var dtickDflt = isDateAx ? 86400000 : 1;
2036
+ if (!dtick) {
2037
+ return dtickDflt;
2038
+ }
2039
+ if ((0, chart_utilities_1.isNumber)(dtick)) {
2040
+ dtick = Number(dtick);
2041
+ if (dtick <= 0) {
2042
+ return dtickDflt;
2043
+ }
2044
+ if (isCatAx) {
2045
+ // category dtick must be positive integers
2046
+ return Math.max(1, Math.round(dtick));
2047
+ }
2048
+ if (isDateAx) {
2049
+ // date dtick must be at least 0.1ms (our current precision)
2050
+ return Math.max(0.1, dtick);
2051
+ }
2052
+ return dtick;
2053
+ }
2054
+ if (typeof dtick !== 'string' || !(isDateAx || isLogAx)) {
2055
+ return dtickDflt;
2056
+ }
2057
+ var prefix = dtick.charAt(0);
2058
+ var dtickNum = (0, chart_utilities_1.isNumber)(dtick.slice(1)) ? Number(dtick.slice(1)) : 0;
2059
+ if (dtickNum <= 0 ||
2060
+ !(
2061
+ // "M<n>" gives ticks every (integer) n months
2062
+ ((isDateAx && prefix === 'M' && dtickNum === Math.round(dtickNum)) ||
2063
+ // "L<f>" gives ticks linearly spaced in data (not in position) every (float) f
2064
+ (isLogAx && prefix === 'L') ||
2065
+ // "D1" gives powers of 10 with all small digits between, "D2" gives only 2 and 5
2066
+ (isLogAx && prefix === 'D' && (dtickNum === 1 || dtickNum === 2))))) {
2067
+ return dtickDflt;
2068
+ }
2069
+ return dtick;
2070
+ };
2071
+ /**
2072
+ * @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/clean_ticks.js#L70}
2073
+ */
2074
+ var plotlyTick0 = function (tick0, axType, dtick) {
2075
+ if (axType === 'date') {
2076
+ return (0, chart_utilities_1.isDate)(tick0) ? new Date(tick0) : new Date(utilities_1.DEFAULT_DATE_STRING);
2077
+ }
2078
+ if (dtick === 'D1' || dtick === 'D2') {
2079
+ // D1 and D2 modes ignore tick0 entirely
2080
+ return undefined;
2081
+ }
2082
+ // Aside from date axes, tick0 must be numeric
2083
+ return (0, chart_utilities_1.isNumber)(tick0) ? Number(tick0) : 0;
2084
+ };
2085
+ var getAxisObjects = function (data, layout) {
1973
2086
  // Traces are grouped by their xaxis property, and for each group/subplot, the adapter functions
1974
2087
  // are called with the corresponding filtered data. As a result, all traces passed to an adapter
1975
2088
  // function share the same xaxis.
@@ -1980,22 +2093,44 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
1980
2093
  xAxisId = axisIds.x;
1981
2094
  yAxisIds.add(axisIds.y);
1982
2095
  });
1983
- var isLogAxis = function (axLetter, axId) {
1984
- var _a;
1985
- var axisKey = (0, chart_utilities_1.getAxisKey)(axLetter, axId);
1986
- return ((_a = layout === null || layout === void 0 ? void 0 : layout[axisKey]) === null || _a === void 0 ? void 0 : _a.type) === 'log';
1987
- };
1988
- if (typeof xAxisId === 'number' && isLogAxis('x', xAxisId)) {
1989
- result.xScaleType = 'log';
2096
+ var axisObjects = {};
2097
+ if (typeof xAxisId === 'number') {
2098
+ axisObjects.x = layout === null || layout === void 0 ? void 0 : layout[(0, chart_utilities_1.getAxisKey)('x', xAxisId)];
1990
2099
  }
1991
2100
  var sortedYAxisIds = Array.from(yAxisIds).sort();
1992
- if (sortedYAxisIds.length > 0 && isLogAxis('y', sortedYAxisIds[0])) {
1993
- result.yScaleType = 'log';
2101
+ if (sortedYAxisIds.length > 0) {
2102
+ axisObjects.y = layout === null || layout === void 0 ? void 0 : layout[(0, chart_utilities_1.getAxisKey)('y', sortedYAxisIds[0])];
1994
2103
  }
1995
- if (sortedYAxisIds.length > 1 && isLogAxis('y', sortedYAxisIds[1])) {
1996
- result.secondaryYScaleType = 'log';
2104
+ if (sortedYAxisIds.length > 1) {
2105
+ axisObjects.y2 = layout === null || layout === void 0 ? void 0 : layout[(0, chart_utilities_1.getAxisKey)('y', sortedYAxisIds[1])];
2106
+ }
2107
+ return axisObjects;
2108
+ };
2109
+ var getAxisType = function (data, axLetter, ax) {
2110
+ var values = [];
2111
+ data.forEach(function (series) {
2112
+ var _a;
2113
+ (_a = series[axLetter]) === null || _a === void 0 ? void 0 : _a.forEach(function (val) {
2114
+ if (!(0, chart_utilities_1.isInvalidValue)(val)) {
2115
+ values.push(val);
2116
+ }
2117
+ });
2118
+ });
2119
+ // Note: When ax.type is explicitly specified, Plotly casts the values to match that type.
2120
+ // Therefore, simply checking the type of the values may not be sufficient. At the moment,
2121
+ // we don’t always perform this casting ourselves and instead use the values as provided.
2122
+ if ((0, chart_utilities_1.isNumberArray)(values)) {
2123
+ if ((ax === null || ax === void 0 ? void 0 : ax.type) === 'log') {
2124
+ return 'log';
2125
+ }
2126
+ return 'linear';
2127
+ }
2128
+ if ((0, chart_utilities_1.isDateArray)(values)) {
2129
+ return 'date';
2130
+ }
2131
+ if ((0, chart_utilities_1.isStringArray)(values)) {
2132
+ return 'category';
1997
2133
  }
1998
- return result;
1999
2134
  };
2000
2135
  });
2001
2136
  //# sourceMappingURL=PlotlySchemaAdapter.js.map