@fluentui/react-charting 5.24.11 → 5.24.13

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 (157) hide show
  1. package/CHANGELOG.json +61 -1
  2. package/CHANGELOG.md +25 -2
  3. package/bundle-size/GanttChart.fixture.js +7 -0
  4. package/dist/react-charting.d.ts +128 -3
  5. package/dist/react-charting.js +1 -1
  6. package/dist/react-charting.min.js +1 -1
  7. package/etc/react-charting.api.md +44 -2
  8. package/lib/GanttChart.d.ts +1 -0
  9. package/lib/GanttChart.js +2 -0
  10. package/lib/GanttChart.js.map +1 -0
  11. package/lib/components/CommonComponents/CartesianChart.base.js +2 -1
  12. package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
  13. package/lib/components/CommonComponents/CartesianChart.types.d.ts +3 -3
  14. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  15. package/lib/components/DeclarativeChart/DeclarativeChart.js +22 -4
  16. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  17. package/lib/components/DeclarativeChart/PlotlyColorAdapter.d.ts +2 -1
  18. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +23 -0
  19. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  20. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +2 -0
  21. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +173 -63
  22. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  23. package/lib/components/GanttChart/GanttChart.base.d.ts +3 -0
  24. package/lib/components/GanttChart/GanttChart.base.js +329 -0
  25. package/lib/components/GanttChart/GanttChart.base.js.map +1 -0
  26. package/lib/components/GanttChart/GanttChart.d.ts +7 -0
  27. package/lib/components/GanttChart/GanttChart.js +10 -0
  28. package/lib/components/GanttChart/GanttChart.js.map +1 -0
  29. package/lib/components/GanttChart/GanttChart.styles.d.ts +2 -0
  30. package/lib/components/GanttChart/GanttChart.styles.js +4 -0
  31. package/lib/components/GanttChart/GanttChart.styles.js.map +1 -0
  32. package/lib/components/GanttChart/GanttChart.types.d.ts +67 -0
  33. package/lib/components/GanttChart/GanttChart.types.js +2 -0
  34. package/lib/components/GanttChart/GanttChart.types.js.map +1 -0
  35. package/lib/components/GanttChart/index.d.ts +2 -0
  36. package/lib/components/GanttChart/index.js +3 -0
  37. package/lib/components/GanttChart/index.js.map +1 -0
  38. package/lib/components/LineChart/LineChart.base.d.ts +1 -0
  39. package/lib/components/LineChart/LineChart.base.js +34 -11
  40. package/lib/components/LineChart/LineChart.base.js.map +1 -1
  41. package/lib/components/ScatterChart/ScatterChart.base.js +37 -23
  42. package/lib/components/ScatterChart/ScatterChart.base.js.map +1 -1
  43. package/lib/index.d.ts +3 -1
  44. package/lib/index.js +1 -0
  45. package/lib/index.js.map +1 -1
  46. package/lib/types/IDataPoint.d.ts +49 -0
  47. package/lib/types/IDataPoint.js.map +1 -1
  48. package/lib/utilities/scatterpolar-utils.d.ts +22 -0
  49. package/lib/utilities/scatterpolar-utils.js +38 -0
  50. package/lib/utilities/scatterpolar-utils.js.map +1 -0
  51. package/lib/utilities/test-data.d.ts +4 -1
  52. package/lib/utilities/test-data.js +213 -0
  53. package/lib/utilities/test-data.js.map +1 -1
  54. package/lib/utilities/utilities.d.ts +14 -6
  55. package/lib/utilities/utilities.js +25 -9
  56. package/lib/utilities/utilities.js.map +1 -1
  57. package/lib-amd/GanttChart.d.ts +1 -0
  58. package/lib-amd/GanttChart.js +6 -0
  59. package/lib-amd/GanttChart.js.map +1 -0
  60. package/lib-amd/components/CommonComponents/CartesianChart.base.js +2 -1
  61. package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
  62. package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +3 -3
  63. package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
  64. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +22 -5
  65. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  66. package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.d.ts +2 -1
  67. package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.js +25 -2
  68. package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  69. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +2 -0
  70. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +173 -62
  71. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  72. package/lib-amd/components/GanttChart/GanttChart.base.d.ts +3 -0
  73. package/lib-amd/components/GanttChart/GanttChart.base.js +325 -0
  74. package/lib-amd/components/GanttChart/GanttChart.base.js.map +1 -0
  75. package/lib-amd/components/GanttChart/GanttChart.d.ts +7 -0
  76. package/lib-amd/components/GanttChart/GanttChart.js +12 -0
  77. package/lib-amd/components/GanttChart/GanttChart.js.map +1 -0
  78. package/lib-amd/components/GanttChart/GanttChart.styles.d.ts +2 -0
  79. package/lib-amd/components/GanttChart/GanttChart.styles.js +10 -0
  80. package/lib-amd/components/GanttChart/GanttChart.styles.js.map +1 -0
  81. package/lib-amd/components/GanttChart/GanttChart.types.d.ts +67 -0
  82. package/lib-amd/components/GanttChart/GanttChart.types.js +5 -0
  83. package/lib-amd/components/GanttChart/GanttChart.types.js.map +1 -0
  84. package/lib-amd/components/GanttChart/index.d.ts +2 -0
  85. package/lib-amd/components/GanttChart/index.js +7 -0
  86. package/lib-amd/components/GanttChart/index.js.map +1 -0
  87. package/lib-amd/components/LineChart/LineChart.base.d.ts +1 -0
  88. package/lib-amd/components/LineChart/LineChart.base.js +33 -11
  89. package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
  90. package/lib-amd/components/ScatterChart/ScatterChart.base.js +36 -23
  91. package/lib-amd/components/ScatterChart/ScatterChart.base.js.map +1 -1
  92. package/lib-amd/index.d.ts +3 -1
  93. package/lib-amd/index.js +3 -2
  94. package/lib-amd/index.js.map +1 -1
  95. package/lib-amd/types/IDataPoint.d.ts +49 -0
  96. package/lib-amd/types/IDataPoint.js.map +1 -1
  97. package/lib-amd/utilities/scatterpolar-utils.d.ts +22 -0
  98. package/lib-amd/utilities/scatterpolar-utils.js +43 -0
  99. package/lib-amd/utilities/scatterpolar-utils.js.map +1 -0
  100. package/lib-amd/utilities/test-data.d.ts +4 -1
  101. package/lib-amd/utilities/test-data.js +214 -2
  102. package/lib-amd/utilities/test-data.js.map +1 -1
  103. package/lib-amd/utilities/utilities.d.ts +14 -6
  104. package/lib-amd/utilities/utilities.js +27 -9
  105. package/lib-amd/utilities/utilities.js.map +1 -1
  106. package/lib-commonjs/GanttChart.d.ts +1 -0
  107. package/lib-commonjs/GanttChart.js +5 -0
  108. package/lib-commonjs/GanttChart.js.map +1 -0
  109. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +2 -1
  110. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
  111. package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +3 -3
  112. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  113. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +23 -5
  114. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  115. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.d.ts +2 -1
  116. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +25 -1
  117. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  118. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +2 -0
  119. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +173 -62
  120. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  121. package/lib-commonjs/components/GanttChart/GanttChart.base.d.ts +3 -0
  122. package/lib-commonjs/components/GanttChart/GanttChart.base.js +332 -0
  123. package/lib-commonjs/components/GanttChart/GanttChart.base.js.map +1 -0
  124. package/lib-commonjs/components/GanttChart/GanttChart.d.ts +7 -0
  125. package/lib-commonjs/components/GanttChart/GanttChart.js +13 -0
  126. package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -0
  127. package/lib-commonjs/components/GanttChart/GanttChart.styles.d.ts +2 -0
  128. package/lib-commonjs/components/GanttChart/GanttChart.styles.js +8 -0
  129. package/lib-commonjs/components/GanttChart/GanttChart.styles.js.map +1 -0
  130. package/lib-commonjs/components/GanttChart/GanttChart.types.d.ts +67 -0
  131. package/lib-commonjs/components/GanttChart/GanttChart.types.js +3 -0
  132. package/lib-commonjs/components/GanttChart/GanttChart.types.js.map +1 -0
  133. package/lib-commonjs/components/GanttChart/index.d.ts +2 -0
  134. package/lib-commonjs/components/GanttChart/index.js +6 -0
  135. package/lib-commonjs/components/GanttChart/index.js.map +1 -0
  136. package/lib-commonjs/components/LineChart/LineChart.base.d.ts +1 -0
  137. package/lib-commonjs/components/LineChart/LineChart.base.js +33 -10
  138. package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
  139. package/lib-commonjs/components/ScatterChart/ScatterChart.base.js +36 -22
  140. package/lib-commonjs/components/ScatterChart/ScatterChart.base.js.map +1 -1
  141. package/lib-commonjs/index.d.ts +3 -1
  142. package/lib-commonjs/index.js +3 -1
  143. package/lib-commonjs/index.js.map +1 -1
  144. package/lib-commonjs/types/IDataPoint.d.ts +49 -0
  145. package/lib-commonjs/types/IDataPoint.js.map +1 -1
  146. package/lib-commonjs/utilities/scatterpolar-utils.d.ts +22 -0
  147. package/lib-commonjs/utilities/scatterpolar-utils.js +42 -0
  148. package/lib-commonjs/utilities/scatterpolar-utils.js.map +1 -0
  149. package/lib-commonjs/utilities/test-data.d.ts +4 -1
  150. package/lib-commonjs/utilities/test-data.js +214 -1
  151. package/lib-commonjs/utilities/test-data.js.map +1 -1
  152. package/lib-commonjs/utilities/utilities.d.ts +14 -6
  153. package/lib-commonjs/utilities/utilities.js +28 -10
  154. package/lib-commonjs/utilities/utilities.js.map +1 -1
  155. package/package.json +2 -2
  156. package/src/components/CommonComponents/CartesianChart.types.ts +5 -2
  157. package/src/components/GanttChart/GanttChart.types.ts +83 -0
@@ -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.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.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 = {
@@ -262,18 +262,13 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
262
262
  var colorScale = undefined;
263
263
  var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
264
264
  input.data.forEach(function (series, index1) {
265
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
266
- if (((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.coloraxis) === null || _b === void 0 ? void 0 : _b.colorscale) === null || _c === void 0 ? void 0 : _c.length) &&
267
- (0, chart_utilities_1.isArrayOrTypedArray)((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color) &&
268
- ((_e = series.marker) === null || _e === void 0 ? void 0 : _e.color).length > 0 &&
269
- typeof ((_g = (_f = series.marker) === null || _f === void 0 ? void 0 : _f.color) === null || _g === void 0 ? void 0 : _g[0]) === 'number') {
270
- colorScale = createColorScale(input.layout, series);
271
- }
265
+ var _a, _b, _c, _d, _e, _f, _g, _h;
266
+ colorScale = (0, PlotlyColorAdapter_1.createColorScale)(input.layout, series, colorScale);
272
267
  var isXYearCategory = (0, chart_utilities_1.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
273
268
  // extract bar colors for each series only once
274
- var extractedBarColors = (0, PlotlyColorAdapter_1.extractColor)((_k = (_j = (_h = input.layout) === null || _h === void 0 ? void 0 : _h.template) === null || _j === void 0 ? void 0 : _j.layout) === null || _k === void 0 ? void 0 : _k.colorway, colorwayType, (_l = series.marker) === null || _l === void 0 ? void 0 : _l.color, colorMap, isDarkTheme);
269
+ var extractedBarColors = (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);
275
270
  // extract line colors for each series only once
276
- var extractedLineColors = (0, PlotlyColorAdapter_1.extractColor)((_p = (_o = (_m = input.layout) === null || _m === void 0 ? void 0 : _m.template) === null || _o === void 0 ? void 0 : _o.layout) === null || _p === void 0 ? void 0 : _p.colorway, colorwayType, (_q = series.line) === null || _q === void 0 ? void 0 : _q.color, colorMap, isDarkTheme);
271
+ var extractedLineColors = (0, PlotlyColorAdapter_1.extractColor)((_g = (_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.template) === null || _f === void 0 ? void 0 : _f.layout) === null || _g === void 0 ? void 0 : _g.colorway, colorwayType, (_h = series.line) === null || _h === void 0 ? void 0 : _h.color, colorMap, isDarkTheme);
277
272
  var xValues = series.x;
278
273
  var isXDate = (0, chart_utilities_1.isDateArray)(xValues);
279
274
  var isXString = (0, chart_utilities_1.isStringArray)(xValues);
@@ -338,22 +333,6 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
338
333
  return 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)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat);
339
334
  };
340
335
  exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
341
- var createColorScale = function (layout, series) {
342
- var _a, _b, _c, _d, _e, _f;
343
- var scale = (_a = layout === null || layout === void 0 ? void 0 : layout.coloraxis) === null || _a === void 0 ? void 0 : _a.colorscale;
344
- var colorValues = (_b = series.marker) === null || _b === void 0 ? void 0 : _b.color;
345
- var _g = [
346
- (_d = (_c = layout === null || layout === void 0 ? void 0 : layout.coloraxis) === null || _c === void 0 ? void 0 : _c.cmin) !== null && _d !== void 0 ? _d : Math.min.apply(Math, colorValues),
347
- (_f = (_e = layout === null || layout === void 0 ? void 0 : layout.coloraxis) === null || _e === void 0 ? void 0 : _e.cmax) !== null && _f !== void 0 ? _f : Math.max.apply(Math, colorValues),
348
- ], dMin = _g[0], dMax = _g[1];
349
- // Normalize colorscale domain to actual data domain
350
- var scaleDomain = scale.map(function (_a) {
351
- var pos = _a[0];
352
- return dMin + pos * (dMax - dMin);
353
- });
354
- var scaleColors = scale.map(function (item) { return item[1]; });
355
- return (0, d3_scale_1.scaleLinear)().domain(scaleDomain).range(scaleColors);
356
- };
357
336
  var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
358
337
  var _a, _b, _c, _d;
359
338
  var mapXToDataPoints = {};
@@ -362,16 +341,11 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
362
341
  var colorScale = undefined;
363
342
  var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
364
343
  input.data.forEach(function (series, index1) {
365
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
366
- if (((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.coloraxis) === null || _b === void 0 ? void 0 : _b.colorscale) === null || _c === void 0 ? void 0 : _c.length) &&
367
- (0, chart_utilities_1.isArrayOrTypedArray)((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color) &&
368
- ((_e = series.marker) === null || _e === void 0 ? void 0 : _e.color).length > 0 &&
369
- typeof ((_g = (_f = series.marker) === null || _f === void 0 ? void 0 : _f.color) === null || _g === void 0 ? void 0 : _g[0]) === 'number') {
370
- colorScale = createColorScale(input.layout, series);
371
- }
344
+ var _a, _b, _c, _d, _e;
345
+ colorScale = (0, PlotlyColorAdapter_1.createColorScale)(input.layout, series, colorScale);
372
346
  // extract colors for each series only once
373
- var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_k = (_j = (_h = input.layout) === null || _h === void 0 ? void 0 : _h.template) === null || _j === void 0 ? void 0 : _j.layout) === null || _k === void 0 ? void 0 : _k.colorway, colorwayType, (_l = series.marker) === null || _l === void 0 ? void 0 : _l.color, colorMap, isDarkTheme);
374
- (_m = series.x) === null || _m === void 0 ? void 0 : _m.forEach(function (x, xIndex) {
347
+ 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);
348
+ (_e = series.x) === null || _e === void 0 ? void 0 : _e.forEach(function (x, xIndex) {
375
349
  var _a, _b, _c, _d, _e, _f;
376
350
  if ((0, chart_utilities_1.isInvalidValue)(x) || (0, chart_utilities_1.isInvalidValue)((_a = series.y) === null || _a === void 0 ? void 0 : _a[xIndex])) {
377
351
  return;
@@ -411,18 +385,13 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
411
385
  var _e = getLegendProps(input.data, input.layout, isMultiPlot), legends = _e.legends, hideLegend = _e.hideLegend;
412
386
  var colorScale = undefined;
413
387
  input.data.forEach(function (series, seriesIdx) {
414
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
388
+ var _a, _b, _c, _d, _e, _f, _g;
415
389
  if (!series.x) {
416
390
  return;
417
391
  }
418
- if (((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.coloraxis) === null || _b === void 0 ? void 0 : _b.colorscale) === null || _c === void 0 ? void 0 : _c.length) &&
419
- (0, chart_utilities_1.isArrayOrTypedArray)((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color) &&
420
- ((_e = series.marker) === null || _e === void 0 ? void 0 : _e.color).length > 0 &&
421
- typeof ((_g = (_f = series.marker) === null || _f === void 0 ? void 0 : _f.color) === null || _g === void 0 ? void 0 : _g[0]) === 'number') {
422
- colorScale = createColorScale(input.layout, series);
423
- }
392
+ colorScale = (0, PlotlyColorAdapter_1.createColorScale)(input.layout, series, colorScale);
424
393
  // extract colors for each series only once
425
- var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_k = (_j = (_h = input.layout) === null || _h === void 0 ? void 0 : _h.template) === null || _j === void 0 ? void 0 : _j.layout) === null || _k === void 0 ? void 0 : _k.colorway, colorwayType, (_l = series.marker) === null || _l === void 0 ? void 0 : _l.color, colorMap, isDarkTheme);
394
+ 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);
426
395
  var xValues = [];
427
396
  var yValues = [];
428
397
  series.x.forEach(function (xVal, index) {
@@ -436,7 +405,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
436
405
  var isXString = (0, chart_utilities_1.isStringArray)(xValues);
437
406
  // TODO: In case of a single bin, add an empty bin of the same size to prevent the
438
407
  // default bar width from being used and ensure the bar spans the full intended range.
439
- var xBins = createBins(xValues, (_m = series.xbins) === null || _m === void 0 ? void 0 : _m.start, (_o = series.xbins) === null || _o === void 0 ? void 0 : _o.end, (_p = series.xbins) === null || _p === void 0 ? void 0 : _p.size);
408
+ var xBins = createBins(xValues, (_e = series.xbins) === null || _e === void 0 ? void 0 : _e.start, (_f = series.xbins) === null || _f === void 0 ? void 0 : _f.end, (_g = series.xbins) === null || _g === void 0 ? void 0 : _g.size);
440
409
  var yBins = xBins.map(function () { return []; });
441
410
  var total = 0;
442
411
  xValues.forEach(function (xVal, index) {
@@ -518,11 +487,11 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
518
487
  var seriesOpacity = (0, PlotlyColorAdapter_1.getOpacity)(series, index);
519
488
  mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
520
489
  // if mode contains 'text', we prioritize showing the text over curving the line
521
- var lineOptions = !((_h = series.mode) === null || _h === void 0 ? void 0 : _h.includes('text')) ? getLineOptions(series.line) : undefined;
490
+ var lineOptions = !((_h = series.mode) === null || _h === void 0 ? void 0 : _h.includes('text')) && series.type !== 'scatterpolar' ? getLineOptions(series.line) : undefined;
522
491
  var legendShape = getLegendShape(series);
523
492
  var validXYRanges = (0, exports.getValidXYRanges)(series);
524
493
  return validXYRanges.map(function (_a, rangeIdx) {
525
- var _b, _c;
494
+ var _b, _c, _d;
526
495
  var rangeStart = _a[0], rangeEnd = _a[1];
527
496
  var rangeXValues = xValues.slice(rangeStart, rangeEnd);
528
497
  var rangeYValues = series.y.slice(rangeStart, rangeEnd);
@@ -542,7 +511,10 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
542
511
  : {})), (textValues ? { text: textValues[i] } : {})), { yAxisCalloutData: getFormattedCalloutYData(rangeYValues[i], yAxisTickFormat) }));
543
512
  }),
544
513
  color: (_c = (0, d3_color_1.rgb)(seriesColor).copy({ opacity: seriesOpacity }).formatHex8()) !== null && _c !== void 0 ? _c : seriesColor,
545
- lineOptions: tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
514
+ lineOptions: tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.type !== 'scatterpolar' ? series.mode : 'scatterpolar',
515
+ // originXOffset is not typed on Layout, but may be present in input.layout as a part of projection of
516
+ // scatter polar coordingates to cartesian coordinates
517
+ originXOffset: (_d = input.layout) === null || _d === void 0 ? void 0 : _d.__polarOriginX }),
546
518
  useSecondaryYScale: usesSecondaryYScale(series, input.layout),
547
519
  };
548
520
  });
@@ -575,15 +547,10 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
575
547
  var colorScale = undefined;
576
548
  var chartData = input.data
577
549
  .map(function (series, index) {
578
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
579
- if (((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.coloraxis) === null || _b === void 0 ? void 0 : _b.colorscale) === null || _c === void 0 ? void 0 : _c.length) &&
580
- (0, chart_utilities_1.isArrayOrTypedArray)((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color) &&
581
- ((_e = series.marker) === null || _e === void 0 ? void 0 : _e.color).length > 0 &&
582
- typeof ((_g = (_f = series.marker) === null || _f === void 0 ? void 0 : _f.color) === null || _g === void 0 ? void 0 : _g[0]) === 'number') {
583
- colorScale = createColorScale(input.layout, series);
584
- }
550
+ var _a, _b, _c, _d;
551
+ colorScale = (0, PlotlyColorAdapter_1.createColorScale)(input.layout, series, colorScale);
585
552
  // extract colors for each series only once
586
- var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_k = (_j = (_h = input.layout) === null || _h === void 0 ? void 0 : _h.template) === null || _j === void 0 ? void 0 : _j.layout) === null || _k === void 0 ? void 0 : _k.colorway, colorwayType, (_l = series.marker) === null || _l === void 0 ? void 0 : _l.color, colorMap, isDarkTheme);
553
+ 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);
587
554
  var legend = legends[index];
588
555
  return series.y
589
556
  .map(function (yValue, i) {
@@ -621,6 +588,53 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
621
588
  : ((_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));
622
589
  };
623
590
  exports.transformPlotlyJsonToHorizontalBarWithAxisProps = transformPlotlyJsonToHorizontalBarWithAxisProps;
591
+ var transformPlotlyJsonToGanttChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
592
+ var _a, _b, _c;
593
+ var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
594
+ var colorScale = undefined;
595
+ var chartData = input.data
596
+ .map(function (series, index) {
597
+ var _a, _b, _c, _d, _e, _f;
598
+ colorScale = (0, PlotlyColorAdapter_1.createColorScale)(input.layout, series, colorScale);
599
+ // extract colors for each series only once
600
+ 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);
601
+ var legend = legends[index];
602
+ var isXDate = ((_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.xaxis) === null || _f === void 0 ? void 0 : _f.type) === 'date' || (0, chart_utilities_1.isDateArray)(series.x);
603
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
604
+ var convertXValueToNumber = function (value) {
605
+ return (0, chart_utilities_1.isInvalidValue)(value) ? 0 : isXDate ? new Date(value).getTime() : value;
606
+ };
607
+ return series.y
608
+ .map(function (yVal, i) {
609
+ var _a, _b, _c, _d, _e, _f, _g;
610
+ if ((0, chart_utilities_1.isInvalidValue)(yVal)) {
611
+ return null;
612
+ }
613
+ // resolve color for each legend's bars from the colorscale or extracted colors
614
+ var color = colorScale
615
+ ? colorScale((0, chart_utilities_1.isArrayOrTypedArray)((_a = series.marker) === null || _a === void 0 ? void 0 : _a.color)
616
+ ? (_c = (_b = series.marker) === null || _b === void 0 ? void 0 : _b.color) === null || _c === void 0 ? void 0 : _c[i % ((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color).length]
617
+ : 0)
618
+ : (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, i, legend, colorMap, isDarkTheme);
619
+ var opacity = (0, PlotlyColorAdapter_1.getOpacity)(series, i);
620
+ var base = convertXValueToNumber((_e = series.base) === null || _e === void 0 ? void 0 : _e[i]);
621
+ var xVal = convertXValueToNumber((_f = series.x) === null || _f === void 0 ? void 0 : _f[i]);
622
+ return {
623
+ x: {
624
+ start: isXDate ? new Date(base) : base,
625
+ end: isXDate ? new Date(base + xVal) : base + xVal,
626
+ },
627
+ y: yVal,
628
+ legend: legend,
629
+ color: (_g = (0, d3_color_1.rgb)(color).copy({ opacity: opacity }).formatHex8()) !== null && _g !== void 0 ? _g : color,
630
+ };
631
+ })
632
+ .filter(function (point) { return point !== null; });
633
+ })
634
+ .flat();
635
+ return 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));
636
+ };
637
+ exports.transformPlotlyJsonToGanttChartProps = transformPlotlyJsonToGanttChartProps;
624
638
  var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
625
639
  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;
626
640
  var firstData = input.data[0];
@@ -1113,23 +1127,120 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
1113
1127
  };
1114
1128
  exports.transformPlotlyJsonToFunnelChartProps = transformPlotlyJsonToFunnelChartProps;
1115
1129
  var projectPolarToCartesian = function (input) {
1116
- var _a, _b, _c, _d;
1130
+ var _a, _b;
1117
1131
  var projection = tslib_1.__assign({}, input);
1132
+ // 1. Find the global min and max radius across all series
1133
+ var minRadius = 0;
1134
+ var maxRadius = 0;
1118
1135
  for (var sindex = 0; sindex < input.data.length; sindex++) {
1136
+ var rVals = input.data[sindex].r;
1137
+ if (rVals && (0, chart_utilities_1.isArrayOrTypedArray)(rVals)) {
1138
+ for (var ptindex = 0; ptindex < rVals.length; ptindex++) {
1139
+ if (!(0, chart_utilities_1.isInvalidValue)(rVals[ptindex])) {
1140
+ minRadius = Math.min(minRadius, rVals[ptindex]);
1141
+ maxRadius = Math.max(maxRadius, rVals[ptindex]);
1142
+ }
1143
+ }
1144
+ }
1145
+ }
1146
+ // 2. If there are negative radii, compute the shift
1147
+ var radiusShift = minRadius < 0 ? -minRadius : 0;
1148
+ // 3. Project all points and create a perfect square domain
1149
+ var allX = [];
1150
+ var allY = [];
1151
+ var originX = null;
1152
+ var _loop_1 = function (sindex) {
1119
1153
  var series = input.data[sindex];
1154
+ // If scatterpolar, set text to theta values as strings
1155
+ if (series.type === 'scatterpolar' && Array.isArray(series.theta)) {
1156
+ series.text = series.theta.map(function (v) { return String(v); });
1157
+ }
1120
1158
  series.x = [];
1121
1159
  series.y = [];
1122
- for (var ptindex = 0; ptindex < ((_b = (_a = series.r) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0); ptindex++) {
1123
- if ((0, chart_utilities_1.isInvalidValue)((_c = series.theta) === null || _c === void 0 ? void 0 : _c[ptindex]) || (0, chart_utilities_1.isInvalidValue)((_d = series.r) === null || _d === void 0 ? void 0 : _d[ptindex])) {
1160
+ var thetas = series.theta;
1161
+ var rVals = series.r;
1162
+ // Skip if rVals or thetas are not arrays
1163
+ if (!(0, chart_utilities_1.isArrayOrTypedArray)(rVals) || !(0, chart_utilities_1.isArrayOrTypedArray)(thetas)) {
1164
+ projection.data[sindex] = series;
1165
+ return "continue";
1166
+ }
1167
+ // Compute tick positions if categorical
1168
+ var uniqueTheta = [];
1169
+ var categorical = false;
1170
+ if (!(0, chart_utilities_1.isNumberArray)(thetas)) {
1171
+ uniqueTheta = Array.from(new Set(thetas));
1172
+ categorical = true;
1173
+ }
1174
+ for (var ptindex = 0; ptindex < rVals.length; ptindex++) {
1175
+ if ((0, chart_utilities_1.isInvalidValue)(thetas === null || thetas === void 0 ? void 0 : thetas[ptindex]) || (0, chart_utilities_1.isInvalidValue)(rVals === null || rVals === void 0 ? void 0 : rVals[ptindex])) {
1124
1176
  continue;
1125
1177
  }
1126
- var thetaRad = (series.theta[ptindex] * Math.PI) / 180;
1127
- var radius = series.r[ptindex];
1128
- series.x.push(radius * Math.cos(thetaRad));
1129
- series.y.push(radius * Math.sin(thetaRad));
1178
+ // 4. Map theta to angle in radians
1179
+ var thetaRad = void 0;
1180
+ if (categorical) {
1181
+ var idx = uniqueTheta.indexOf(thetas[ptindex]);
1182
+ var step = (2 * Math.PI) / uniqueTheta.length;
1183
+ thetaRad = idx * step;
1184
+ }
1185
+ else {
1186
+ thetaRad = (thetas[ptindex] * Math.PI) / 180;
1187
+ }
1188
+ // 5. Shift only the polar origin (not the cartesian)
1189
+ var rawRadius = rVals[ptindex];
1190
+ var polarRadius = rawRadius + radiusShift; // Only for projection
1191
+ // 6. Calculate cartesian coordinates (with shifted polar origin)
1192
+ var x = polarRadius * Math.cos(thetaRad);
1193
+ var y = polarRadius * Math.sin(thetaRad);
1194
+ // Calculate the cartesian coordinates of the original polar origin (0,0)
1195
+ // This is the point that should be mapped to (0,0) in cartesian coordinates
1196
+ if (sindex === 0 && ptindex === 0) {
1197
+ // For polar origin (r=0, θ=0), cartesian coordinates are (0,0)
1198
+ // But since we shifted the radius by radiusShift, the cartesian origin is at (radiusShift, 0)
1199
+ originX = radiusShift;
1200
+ }
1201
+ series.x.push(x);
1202
+ series.y.push(y);
1203
+ allX.push(x);
1204
+ allY.push(y);
1205
+ }
1206
+ // Map text to each data point for downstream chart rendering
1207
+ if (series.x && series.y) {
1208
+ series.data = series.x.map(function (xVal, idx) { return (tslib_1.__assign({ x: xVal, y: series.y[idx] }, (series.text ? { text: series.text[idx] } : {}))); });
1130
1209
  }
1131
1210
  projection.data[sindex] = series;
1211
+ };
1212
+ for (var sindex = 0; sindex < input.data.length; sindex++) {
1213
+ _loop_1(sindex);
1214
+ }
1215
+ // 7. Recenter all cartesian coordinates
1216
+ if (originX !== null) {
1217
+ for (var sindex = 0; sindex < projection.data.length; sindex++) {
1218
+ var series = projection.data[sindex];
1219
+ if (series.x && series.y) {
1220
+ series.x = series.x.map(function (v) { return v - originX; });
1221
+ }
1222
+ }
1223
+ // Also recenter allX for normalization
1224
+ for (var i = 0; i < allX.length; i++) {
1225
+ allX[i] = allX[i] - originX;
1226
+ }
1227
+ }
1228
+ // 8. Find the maximum absolute value among all x and y
1229
+ var maxAbs = Math.max.apply(Math, tslib_1.__spreadArray(tslib_1.__spreadArray([], allX.map(Math.abs), false), allY.map(Math.abs), false));
1230
+ maxAbs = maxAbs === 0 ? 1 : maxAbs;
1231
+ // 9. Rescale all points so that the largest |x| or |y| is 0.5
1232
+ for (var sindex = 0; sindex < projection.data.length; sindex++) {
1233
+ var series = projection.data[sindex];
1234
+ if (series.x && series.y) {
1235
+ series.x = series.x.map(function (v) { return v / (2 * maxAbs); });
1236
+ series.y = series.y.map(function (v) { return v / (2 * maxAbs); });
1237
+ }
1132
1238
  }
1239
+ // 10. Customize layout for perfect square with absolute positioning
1240
+ var size = ((_a = input.layout) === null || _a === void 0 ? void 0 : _a.width) || ((_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) || 500;
1241
+ projection.layout = tslib_1.__assign(tslib_1.__assign({}, projection.layout), { width: size, height: size });
1242
+ // Attach originX as custom properties
1243
+ projection.layout.__polarOriginX = originX !== null && originX !== void 0 ? originX : undefined;
1133
1244
  return projection;
1134
1245
  };
1135
1246
  exports.projectPolarToCartesian = projectPolarToCartesian;