@fluentui/react-charting 5.24.39 → 5.25.1

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 (111) hide show
  1. package/CHANGELOG.json +75 -1
  2. package/CHANGELOG.md +30 -2
  3. package/dist/react-charting.d.ts +127 -0
  4. package/dist/react-charting.js +1 -1
  5. package/dist/react-charting.min.js +1 -1
  6. package/etc/react-charting.api.md +74 -0
  7. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.d.ts +3 -0
  8. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js +496 -0
  9. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
  10. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.d.ts +28 -0
  11. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js +111 -0
  12. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js.map +1 -0
  13. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.d.ts +52 -0
  14. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +2 -0
  15. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
  16. package/lib/components/CommonComponents/CartesianChart.base.js +38 -46
  17. package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
  18. package/lib/components/CommonComponents/CartesianChart.styles.js +9 -1
  19. package/lib/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  20. package/lib/components/CommonComponents/CartesianChart.types.d.ts +17 -1
  21. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  22. package/lib/components/CommonComponents/index.d.ts +2 -0
  23. package/lib/components/CommonComponents/index.js +2 -0
  24. package/lib/components/CommonComponents/index.js.map +1 -1
  25. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +650 -76
  26. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  27. package/lib/index.d.ts +1 -1
  28. package/lib/index.js.map +1 -1
  29. package/lib/types/IChartAnnotation.d.ts +99 -0
  30. package/lib/types/IChartAnnotation.js +2 -0
  31. package/lib/types/IChartAnnotation.js.map +1 -0
  32. package/lib/types/IDataPoint.d.ts +4 -0
  33. package/lib/types/IDataPoint.js.map +1 -1
  34. package/lib/types/index.d.ts +1 -0
  35. package/lib/types/index.js +1 -0
  36. package/lib/types/index.js.map +1 -1
  37. package/lib/utilities/image-export-utils.js +55 -0
  38. package/lib/utilities/image-export-utils.js.map +1 -1
  39. package/lib/utilities/utilities.js +72 -20
  40. package/lib/utilities/utilities.js.map +1 -1
  41. package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.d.ts +3 -0
  42. package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.js +497 -0
  43. package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
  44. package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.d.ts +28 -0
  45. package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js +119 -0
  46. package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js.map +1 -0
  47. package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.types.d.ts +52 -0
  48. package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +5 -0
  49. package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
  50. package/lib-amd/components/CommonComponents/CartesianChart.base.js +38 -47
  51. package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
  52. package/lib-amd/components/CommonComponents/CartesianChart.styles.js +9 -1
  53. package/lib-amd/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  54. package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +17 -1
  55. package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
  56. package/lib-amd/components/CommonComponents/index.d.ts +2 -0
  57. package/lib-amd/components/CommonComponents/index.js +3 -1
  58. package/lib-amd/components/CommonComponents/index.js.map +1 -1
  59. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +650 -76
  60. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  61. package/lib-amd/index.d.ts +1 -1
  62. package/lib-amd/index.js.map +1 -1
  63. package/lib-amd/types/IChartAnnotation.d.ts +99 -0
  64. package/lib-amd/types/IChartAnnotation.js +5 -0
  65. package/lib-amd/types/IChartAnnotation.js.map +1 -0
  66. package/lib-amd/types/IDataPoint.d.ts +4 -0
  67. package/lib-amd/types/IDataPoint.js.map +1 -1
  68. package/lib-amd/types/index.d.ts +1 -0
  69. package/lib-amd/types/index.js +2 -1
  70. package/lib-amd/types/index.js.map +1 -1
  71. package/lib-amd/utilities/image-export-utils.js +55 -0
  72. package/lib-amd/utilities/image-export-utils.js.map +1 -1
  73. package/lib-amd/utilities/utilities.js +72 -20
  74. package/lib-amd/utilities/utilities.js.map +1 -1
  75. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.d.ts +3 -0
  76. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js +499 -0
  77. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
  78. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.d.ts +28 -0
  79. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js +118 -0
  80. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js.map +1 -0
  81. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.d.ts +52 -0
  82. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +3 -0
  83. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
  84. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +38 -46
  85. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
  86. package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js +9 -1
  87. package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  88. package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +17 -1
  89. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  90. package/lib-commonjs/components/CommonComponents/index.d.ts +2 -0
  91. package/lib-commonjs/components/CommonComponents/index.js +2 -0
  92. package/lib-commonjs/components/CommonComponents/index.js.map +1 -1
  93. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +650 -76
  94. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  95. package/lib-commonjs/index.d.ts +1 -1
  96. package/lib-commonjs/index.js.map +1 -1
  97. package/lib-commonjs/types/IChartAnnotation.d.ts +99 -0
  98. package/lib-commonjs/types/IChartAnnotation.js +3 -0
  99. package/lib-commonjs/types/IChartAnnotation.js.map +1 -0
  100. package/lib-commonjs/types/IDataPoint.d.ts +4 -0
  101. package/lib-commonjs/types/IDataPoint.js.map +1 -1
  102. package/lib-commonjs/types/index.d.ts +1 -0
  103. package/lib-commonjs/types/index.js +1 -0
  104. package/lib-commonjs/types/index.js.map +1 -1
  105. package/lib-commonjs/utilities/image-export-utils.js +55 -0
  106. package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
  107. package/lib-commonjs/utilities/utilities.js +72 -20
  108. package/lib-commonjs/utilities/utilities.js.map +1 -1
  109. package/package.json +9 -9
  110. package/src/components/CommonComponents/Annotations/ChartAnnotationLayer.types.ts +58 -0
  111. package/src/components/CommonComponents/CartesianChart.types.ts +21 -0
@@ -251,6 +251,517 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
251
251
  }
252
252
  return flattened;
253
253
  };
254
+ var encodeHtmlEntities = function (value) {
255
+ return value
256
+ .replace(/&/g, '&')
257
+ .replace(/</g, '&lt;')
258
+ .replace(/>/g, '&gt;')
259
+ .replace(/"/g, '&quot;')
260
+ .replace(/'/g, '&#39;');
261
+ };
262
+ var toFiniteNumber = function (value) {
263
+ if (value === undefined || value === null) {
264
+ return undefined;
265
+ }
266
+ var numeric = typeof value === 'number' ? value : Number(value);
267
+ return Number.isFinite(numeric) ? numeric : undefined;
268
+ };
269
+ /**
270
+ * Normalizes Plotly axis reference strings so equivalent aliases (e.g. `xaxis1`, `x1`) collapse to the base axis id.
271
+ */
272
+ var normalizeAxisRef = function (ref, axis) {
273
+ if (!ref) {
274
+ return axis;
275
+ }
276
+ var normalized = ref.toLowerCase();
277
+ if (normalized === axis ||
278
+ normalized === "".concat(axis, "axis") ||
279
+ normalized === "".concat(axis, "axis1") ||
280
+ normalized === "".concat(axis, "1")) {
281
+ return axis;
282
+ }
283
+ var match = normalized.match(/^([xy])(axis)?(\d+)$/);
284
+ if (match && match[1] === axis && match[3]) {
285
+ return match[3] === '1' ? axis : "".concat(axis).concat(match[3]);
286
+ }
287
+ return normalized;
288
+ };
289
+ /**
290
+ * Scans the data traces bound to a given axis and returns the numeric min/max values plotted on that axis.
291
+ */
292
+ var getAxisNumericRangeFromData = function (axis, ref, layout, data) {
293
+ if (!data || data.length === 0) {
294
+ return undefined;
295
+ }
296
+ var axisLayout = getAxisLayoutByRef(layout, ref, axis);
297
+ var targetRef = normalizeAxisRef(ref, axis);
298
+ var traceAxisKey = axis === 'x' ? 'xaxis' : 'yaxis';
299
+ var minValue;
300
+ var maxValue;
301
+ data.forEach(function (trace) {
302
+ var plotTrace = trace;
303
+ var traceAxisRef = normalizeAxisRef(plotTrace[traceAxisKey], axis);
304
+ if (traceAxisRef !== targetRef) {
305
+ return;
306
+ }
307
+ var values = (axis === 'x' ? plotTrace.x : plotTrace.y);
308
+ if (!(0, chart_utilities_1.isArrayOrTypedArray)(values)) {
309
+ return;
310
+ }
311
+ var arrayLike = values;
312
+ for (var index = 0; index < arrayLike.length; index++) {
313
+ var value = arrayLike[index];
314
+ var numeric = toNumericValue(convertDataValue(value, axisLayout));
315
+ if (numeric === undefined || Number.isNaN(numeric)) {
316
+ continue;
317
+ }
318
+ minValue = minValue === undefined ? numeric : Math.min(minValue, numeric);
319
+ maxValue = maxValue === undefined ? numeric : Math.max(maxValue, numeric);
320
+ }
321
+ });
322
+ if (minValue === undefined || maxValue === undefined || minValue === maxValue) {
323
+ return undefined;
324
+ }
325
+ return [minValue, maxValue];
326
+ };
327
+ /**
328
+ * Converts Plotly's bottom-origin relative Y coordinate into the SVG top-origin space used by our overlay.
329
+ */
330
+ var transformRelativeYForChart = function (value) {
331
+ if (value === undefined) {
332
+ return undefined;
333
+ }
334
+ if (!Number.isFinite(value)) {
335
+ return undefined;
336
+ }
337
+ return 1 - value;
338
+ };
339
+ var mapHorizontalAlign = function (anchor) {
340
+ switch ((anchor !== null && anchor !== void 0 ? anchor : '').toLowerCase()) {
341
+ case 'left':
342
+ return 'start';
343
+ case 'center':
344
+ return 'center';
345
+ case 'right':
346
+ return 'end';
347
+ default:
348
+ return undefined;
349
+ }
350
+ };
351
+ var mapVerticalAlign = function (anchor) {
352
+ switch ((anchor !== null && anchor !== void 0 ? anchor : '').toLowerCase()) {
353
+ case 'top':
354
+ return 'top';
355
+ case 'middle':
356
+ return 'middle';
357
+ case 'bottom':
358
+ return 'bottom';
359
+ default:
360
+ return undefined;
361
+ }
362
+ };
363
+ var appendPx = function (value) {
364
+ if (value === undefined || value === null) {
365
+ return undefined;
366
+ }
367
+ if (typeof value === 'string') {
368
+ return value;
369
+ }
370
+ if (typeof value === 'number' && Number.isFinite(value)) {
371
+ return "".concat(value, "px");
372
+ }
373
+ return undefined;
374
+ };
375
+ /**
376
+ * Maps Plotly's axis reference string to one of our coordinate interpretation modes (axis, relative, or pixel).
377
+ */
378
+ var resolveRefType = function (ref, axis) {
379
+ if (!ref) {
380
+ return 'axis';
381
+ }
382
+ var normalized = ref.toLowerCase();
383
+ if (normalized === 'pixel') {
384
+ return 'pixel';
385
+ }
386
+ if (normalized === 'paper') {
387
+ return 'relative';
388
+ }
389
+ if (normalized.endsWith(' domain')) {
390
+ return normalized.startsWith(axis) ? 'relative' : undefined;
391
+ }
392
+ var match = normalized.match(/^([xy])(\d*)$/);
393
+ if (match && match[1] === axis) {
394
+ return 'axis';
395
+ }
396
+ return undefined;
397
+ };
398
+ /**
399
+ * Retrieves the appropriate axis layout section from Plotly's layout given an axis reference alias.
400
+ */
401
+ var getAxisLayoutByRef = function (layout, ref, axis) {
402
+ if (!layout) {
403
+ return undefined;
404
+ }
405
+ var defaultAxisKey = "".concat(axis, "axis");
406
+ if (!ref) {
407
+ return layout[defaultAxisKey];
408
+ }
409
+ var normalized = ref.toLowerCase();
410
+ if (normalized === 'paper' || normalized === 'pixel' || normalized.endsWith(' domain')) {
411
+ return layout[defaultAxisKey];
412
+ }
413
+ var match = normalized.match(/^([xy])(\d*)$/);
414
+ if (match && match[1] === axis) {
415
+ var index = match[2];
416
+ if (index && index !== '' && index !== '1') {
417
+ var axisKey = "".concat(axis, "axis").concat(index);
418
+ return layout[axisKey];
419
+ }
420
+ return layout[defaultAxisKey];
421
+ }
422
+ return layout[defaultAxisKey];
423
+ };
424
+ /**
425
+ * Normalizes raw Plotly data values into canonical number/date/string types based on axis configuration.
426
+ */
427
+ var convertDataValue = function (value, axisLayout) {
428
+ if (value === undefined || value === null) {
429
+ return undefined;
430
+ }
431
+ if ((axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) === 'date' || (0, chart_utilities_1.isDate)(value)) {
432
+ var dateValue = value instanceof Date ? value : new Date(value);
433
+ return Number.isNaN(dateValue.getTime()) ? undefined : dateValue;
434
+ }
435
+ if (typeof value === 'number') {
436
+ return value;
437
+ }
438
+ if ((axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) === 'linear' || (axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) === 'log') {
439
+ var numeric = Number(value);
440
+ return Number.isFinite(numeric) ? numeric : undefined;
441
+ }
442
+ if (value instanceof Date) {
443
+ return value;
444
+ }
445
+ return value;
446
+ };
447
+ var toNumericValue = function (value) {
448
+ if (value instanceof Date) {
449
+ var timestamp = value.getTime();
450
+ return Number.isFinite(timestamp) ? timestamp : undefined;
451
+ }
452
+ if (typeof value === 'number') {
453
+ return Number.isFinite(value) ? value : undefined;
454
+ }
455
+ if (typeof value === 'string') {
456
+ var numeric = Number(value);
457
+ return Number.isFinite(numeric) ? numeric : undefined;
458
+ }
459
+ return undefined;
460
+ };
461
+ var toRelativeCoordinate = function (value, axisLayout, fallbackRange) {
462
+ var range = Array.isArray(axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.range) ? axisLayout.range : undefined;
463
+ var start = range && range.length >= 2 ? toNumericValue(convertDataValue(range[0], axisLayout)) : undefined;
464
+ var end = range && range.length >= 2 ? toNumericValue(convertDataValue(range[1], axisLayout)) : undefined;
465
+ if ((start === undefined || end === undefined || start === end) && fallbackRange) {
466
+ start = fallbackRange[0], end = fallbackRange[1];
467
+ }
468
+ var current = toNumericValue(convertDataValue(value, axisLayout));
469
+ if (start === undefined || end === undefined || current === undefined || start === end) {
470
+ return undefined;
471
+ }
472
+ var relative = (current - start) / (end - start);
473
+ return Number.isFinite(relative) ? relative : undefined;
474
+ };
475
+ var createAnnotationId = function (text, index) {
476
+ var normalized = text.replace(/\s+/g, ' ').trim();
477
+ if (normalized) {
478
+ var slug = normalized
479
+ .toLowerCase()
480
+ .replace(/[^a-z0-9]+/g, '-')
481
+ .replace(/^-+|-+$/g, '')
482
+ .slice(0, 32);
483
+ if (slug) {
484
+ return "annotation-".concat(index, "-").concat(slug);
485
+ }
486
+ }
487
+ return "annotation-".concat(index);
488
+ };
489
+ var DEFAULT_ARROW_OFFSET = -40;
490
+ var mapArrowsideToArrow = function (annotation) {
491
+ var includeStart = false;
492
+ var includeEnd = false;
493
+ var arrowSide = typeof (annotation === null || annotation === void 0 ? void 0 : annotation.arrowside) === 'string' ? annotation === null || annotation === void 0 ? void 0 : annotation.arrowside.toLowerCase() : undefined;
494
+ if (arrowSide) {
495
+ includeStart = arrowSide.includes('start');
496
+ includeEnd = arrowSide.includes('end');
497
+ }
498
+ var endHead = toFiniteNumber(annotation === null || annotation === void 0 ? void 0 : annotation.arrowhead);
499
+ var startHead = toFiniteNumber(annotation.startarrowhead);
500
+ if (endHead !== undefined && endHead > 0) {
501
+ includeEnd = true;
502
+ }
503
+ if (startHead !== undefined && startHead > 0) {
504
+ includeStart = true;
505
+ }
506
+ if (includeStart && includeEnd) {
507
+ return 'both';
508
+ }
509
+ if (includeStart) {
510
+ return 'start';
511
+ }
512
+ if (includeEnd) {
513
+ return 'end';
514
+ }
515
+ return 'none';
516
+ };
517
+ var mapArrowDashToPattern = function (value) {
518
+ if (!value) {
519
+ return undefined;
520
+ }
521
+ var normalized = value.trim().toLowerCase();
522
+ switch (normalized) {
523
+ case 'solid':
524
+ return undefined;
525
+ case 'dot':
526
+ return '1, 5';
527
+ case 'dash':
528
+ return '5, 5';
529
+ case 'longdash':
530
+ return '10, 5';
531
+ case 'dashdot':
532
+ return '5, 5, 1, 5';
533
+ case 'longdashdot':
534
+ return '10, 5, 1, 5';
535
+ default:
536
+ if (/^\d+(\s|,)*\d*$/.test(normalized.replace(/\s+/g, ' '))) {
537
+ return normalized.replace(/\s+/g, ' ');
538
+ }
539
+ return value;
540
+ }
541
+ };
542
+ /**
543
+ * Converts a Plotly annotation definition into the internal `ChartAnnotation` format, translating coordinates,
544
+ * layout alignment, styling, and connector metadata while skipping unsupported configurations.
545
+ */
546
+ var convertPlotlyAnnotation = function (annotation, layout, data, index) {
547
+ var _a;
548
+ if (!annotation || annotation.visible === false) {
549
+ return undefined;
550
+ }
551
+ var xRefType = resolveRefType(annotation.xref, 'x');
552
+ var yRefType = resolveRefType(annotation.yref, 'y');
553
+ if (!xRefType || !yRefType) {
554
+ return undefined;
555
+ }
556
+ var coordinates;
557
+ if (xRefType === 'axis' && yRefType === 'axis') {
558
+ var xAxisLayout = getAxisLayoutByRef(layout, annotation.xref, 'x');
559
+ var yAxisLayout = getAxisLayoutByRef(layout, annotation.yref, 'y');
560
+ var xValue = convertDataValue(annotation.x, xAxisLayout);
561
+ var yValue = convertDataValue(annotation.y, yAxisLayout);
562
+ if (xValue === undefined || yValue === undefined) {
563
+ return undefined;
564
+ }
565
+ var yRefNormalized = typeof annotation.yref === 'string' ? annotation.yref.toLowerCase() : undefined;
566
+ coordinates = tslib_1.__assign({ type: 'data', x: xValue, y: yValue }, (yRefNormalized === 'y2' ? { yAxis: 'secondary' } : {}));
567
+ }
568
+ else if (xRefType === 'relative' && yRefType === 'relative') {
569
+ var xValue = toFiniteNumber(annotation.x);
570
+ var yValue = toFiniteNumber(annotation.y);
571
+ var chartRelativeY = transformRelativeYForChart(yValue);
572
+ if (xValue === undefined || chartRelativeY === undefined) {
573
+ return undefined;
574
+ }
575
+ coordinates = {
576
+ type: 'relative',
577
+ x: xValue,
578
+ y: chartRelativeY,
579
+ };
580
+ }
581
+ else if (xRefType === 'relative' && yRefType === 'axis') {
582
+ var xValue = toFiniteNumber(annotation.x);
583
+ var yAxisLayout = getAxisLayoutByRef(layout, annotation.yref, 'y');
584
+ var yFallbackRange = getAxisNumericRangeFromData('y', annotation.yref, layout, data);
585
+ var yRelative = toRelativeCoordinate(annotation.y, yAxisLayout, yFallbackRange);
586
+ var chartRelativeY = transformRelativeYForChart(yRelative);
587
+ if (xValue === undefined || chartRelativeY === undefined) {
588
+ return undefined;
589
+ }
590
+ coordinates = {
591
+ type: 'relative',
592
+ x: xValue,
593
+ y: chartRelativeY,
594
+ };
595
+ }
596
+ else if (xRefType === 'axis' && yRefType === 'relative') {
597
+ var yValue = toFiniteNumber(annotation.y);
598
+ var xAxisLayout = getAxisLayoutByRef(layout, annotation.xref, 'x');
599
+ var xFallbackRange = getAxisNumericRangeFromData('x', annotation.xref, layout, data);
600
+ var xRelative = toRelativeCoordinate(annotation.x, xAxisLayout, xFallbackRange);
601
+ var chartRelativeY = transformRelativeYForChart(yValue);
602
+ if (xRelative === undefined || chartRelativeY === undefined) {
603
+ return undefined;
604
+ }
605
+ coordinates = {
606
+ type: 'relative',
607
+ x: xRelative,
608
+ y: chartRelativeY,
609
+ };
610
+ }
611
+ else if (xRefType === 'pixel' && yRefType === 'pixel') {
612
+ var xValue = toFiniteNumber(annotation.x);
613
+ var yValue = toFiniteNumber(annotation.y);
614
+ if (xValue === undefined || yValue === undefined) {
615
+ return undefined;
616
+ }
617
+ coordinates = {
618
+ type: 'pixel',
619
+ x: xValue,
620
+ y: yValue,
621
+ };
622
+ }
623
+ else {
624
+ return undefined;
625
+ }
626
+ var textValue = annotation.text;
627
+ var rawText = textValue === undefined || textValue === null ? '' : String(textValue);
628
+ var encodedText = encodeHtmlEntities(rawText);
629
+ var chartAnnotation = {
630
+ id: createAnnotationId(encodedText, index),
631
+ text: encodedText,
632
+ coordinates: coordinates,
633
+ };
634
+ var layoutProps = {};
635
+ var styleProps = {};
636
+ var showArrow = annotation.showarrow === undefined ? false : !!annotation.showarrow;
637
+ var clipOnAxis = annotation.cliponaxis;
638
+ if (clipOnAxis !== undefined) {
639
+ layoutProps.clipToBounds = !!clipOnAxis;
640
+ }
641
+ else if (coordinates.type === 'data') {
642
+ layoutProps.clipToBounds = true;
643
+ }
644
+ var horizontalAlign = mapHorizontalAlign(annotation.xanchor);
645
+ if (horizontalAlign) {
646
+ layoutProps.align = horizontalAlign;
647
+ }
648
+ if (!layoutProps.align) {
649
+ var alignProp = mapHorizontalAlign(annotation.align);
650
+ if (alignProp) {
651
+ layoutProps.align = alignProp;
652
+ }
653
+ }
654
+ var verticalAlign = mapVerticalAlign(annotation.yanchor);
655
+ if (verticalAlign) {
656
+ layoutProps.verticalAlign = verticalAlign;
657
+ }
658
+ if (!layoutProps.verticalAlign) {
659
+ var valignProp = mapVerticalAlign(annotation.valign);
660
+ if (valignProp) {
661
+ layoutProps.verticalAlign = valignProp;
662
+ }
663
+ }
664
+ var offsetXComponents = [];
665
+ var hasExplicitOffset = false;
666
+ var ax = toFiniteNumber(annotation.ax);
667
+ var axRef = typeof annotation.axref === 'string' ? annotation.axref.toLowerCase() : undefined;
668
+ if (ax !== undefined && (axRef === undefined || axRef === 'pixel')) {
669
+ offsetXComponents.push(ax);
670
+ hasExplicitOffset = true;
671
+ }
672
+ var xShift = toFiniteNumber(annotation.xshift);
673
+ if (xShift !== undefined) {
674
+ offsetXComponents.push(xShift);
675
+ hasExplicitOffset = true;
676
+ }
677
+ if (offsetXComponents.length > 0) {
678
+ var offsetX = offsetXComponents.reduce(function (sum, value) { return sum + value; }, 0);
679
+ if (offsetX !== 0) {
680
+ layoutProps.offsetX = offsetX;
681
+ }
682
+ }
683
+ var offsetYComponents = [];
684
+ var ay = toFiniteNumber(annotation.ay);
685
+ var ayRef = typeof annotation.ayref === 'string' ? annotation.ayref.toLowerCase() : undefined;
686
+ if (ay !== undefined && (ayRef === undefined || ayRef === 'pixel')) {
687
+ offsetYComponents.push(ay);
688
+ hasExplicitOffset = true;
689
+ }
690
+ var yShift = toFiniteNumber(annotation.yshift);
691
+ if (yShift !== undefined) {
692
+ offsetYComponents.push(yShift);
693
+ hasExplicitOffset = true;
694
+ }
695
+ if (offsetYComponents.length > 0) {
696
+ var offsetY = offsetYComponents.reduce(function (sum, value) { return sum + value; }, 0);
697
+ if (offsetY !== 0) {
698
+ layoutProps.offsetY = offsetY;
699
+ }
700
+ }
701
+ if (showArrow && !hasExplicitOffset && layoutProps.offsetY === undefined) {
702
+ layoutProps.offsetY = DEFAULT_ARROW_OFFSET;
703
+ }
704
+ var maxWidth = toFiniteNumber(annotation.width);
705
+ if (maxWidth !== undefined) {
706
+ layoutProps.maxWidth = maxWidth;
707
+ }
708
+ if (annotation.bgcolor) {
709
+ styleProps.backgroundColor = annotation.bgcolor;
710
+ }
711
+ if (annotation.bordercolor) {
712
+ styleProps.borderColor = annotation.bordercolor;
713
+ }
714
+ var borderWidth = toFiniteNumber(annotation.borderwidth);
715
+ if (borderWidth !== undefined) {
716
+ styleProps.borderWidth = borderWidth;
717
+ }
718
+ var borderPad = appendPx(annotation.borderpad);
719
+ if (borderPad) {
720
+ styleProps.padding = borderPad;
721
+ }
722
+ var opacity = toFiniteNumber(annotation.opacity);
723
+ if (opacity !== undefined) {
724
+ styleProps.opacity = opacity;
725
+ }
726
+ if (annotation.font) {
727
+ var font = annotation.font;
728
+ if (font === null || font === void 0 ? void 0 : font.color) {
729
+ styleProps.textColor = font.color;
730
+ }
731
+ var fontSize = appendPx(font === null || font === void 0 ? void 0 : font.size);
732
+ if (fontSize) {
733
+ styleProps.fontSize = fontSize;
734
+ }
735
+ if (font === null || font === void 0 ? void 0 : font.weight) {
736
+ styleProps.fontWeight = font.weight;
737
+ }
738
+ }
739
+ if (Object.keys(layoutProps).length > 0) {
740
+ chartAnnotation.layout = layoutProps;
741
+ }
742
+ if (Object.keys(styleProps).length > 0) {
743
+ chartAnnotation.style = styleProps;
744
+ }
745
+ if (showArrow) {
746
+ var arrowColor = (_a = annotation.arrowcolor) !== null && _a !== void 0 ? _a : styleProps.textColor;
747
+ var arrowWidth = toFiniteNumber(annotation.arrowwidth);
748
+ var endPadding = toFiniteNumber(annotation.standoff);
749
+ var startPadding = toFiniteNumber(annotation.startstandoff);
750
+ var dashPattern = mapArrowDashToPattern(annotation.arrowdash);
751
+ chartAnnotation.connector = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, (arrowColor ? { strokeColor: arrowColor } : {})), (arrowWidth !== undefined ? { strokeWidth: arrowWidth } : {})), (endPadding !== undefined ? { endPadding: Math.max(endPadding, 0) } : {})), (startPadding !== undefined ? { startPadding: Math.max(startPadding, 0) } : {})), (dashPattern ? { dashArray: dashPattern } : {})), { arrow: mapArrowsideToArrow(annotation) });
752
+ }
753
+ return chartAnnotation;
754
+ };
755
+ var getChartAnnotationsFromLayout = function (layout, data, isMultiPlot) {
756
+ if (isMultiPlot || !(layout === null || layout === void 0 ? void 0 : layout.annotations)) {
757
+ return undefined;
758
+ }
759
+ var annotationsArray = Array.isArray(layout.annotations) ? layout.annotations : [layout.annotations];
760
+ var converted = annotationsArray
761
+ .map(function (annotation, index) { return convertPlotlyAnnotation(annotation, layout, data, index); })
762
+ .filter(function (annotation) { return annotation !== undefined; });
763
+ return converted.length > 0 ? converted : undefined;
764
+ };
254
765
  /**
255
766
  * Normalizes an array of objects by flattening nested structures and creating grouped data
256
767
  * Uses json_normalize approach with D3 color detection and filtering
@@ -415,7 +926,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
415
926
  var _j = getLegendProps(input.data, input.layout, isMultiPlot), legends = _j.legends, hideLegend = _j.hideLegend;
416
927
  var colorScale = undefined;
417
928
  var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
418
- var resolveXAxisValue = getAxisValueResolver(input.data, input.layout, 'x');
929
+ var resolveXValue = getAxisValueResolver(getAxisType(input.data, getAxisObjects(input.data, input.layout).x));
419
930
  input.data.forEach(function (series, index1) {
420
931
  var _a, _b, _c, _d, _e, _f, _g, _h;
421
932
  colorScale = (0, PlotlyColorAdapter_1.createColorScale)(input.layout, series, colorScale);
@@ -423,7 +934,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
423
934
  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);
424
935
  // extract line colors for each series only once
425
936
  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);
426
- var validXYRanges = (0, exports.getValidXYRanges)(series, resolveXAxisValue);
937
+ var validXYRanges = (0, exports.getValidXYRanges)(series, resolveXValue);
427
938
  validXYRanges.forEach(function (_a, rangeIdx) {
428
939
  var rangeStart = _a[0], rangeEnd = _a[1];
429
940
  var rangeXValues = series.x.slice(rangeStart, rangeEnd);
@@ -432,7 +943,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
432
943
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
433
944
  if (!mapXToDataPoints[x]) {
434
945
  mapXToDataPoints[x] = {
435
- xAxisPoint: resolveXAxisValue(x),
946
+ xAxisPoint: resolveXValue(x),
436
947
  chartData: [],
437
948
  lineData: [],
438
949
  };
@@ -485,7 +996,6 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
485
996
  .forEach(function (shape, shapeIdx) {
486
997
  var _a, _b, _c;
487
998
  var lineColor = (_a = shape.line) === null || _a === void 0 ? void 0 : _a.color;
488
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
489
999
  var resolveX = function (val) {
490
1000
  if (typeof val === 'number' && Array.isArray(xCategories) && xCategories[val] !== undefined) {
491
1001
  return xCategories[val];
@@ -494,7 +1004,6 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
494
1004
  };
495
1005
  var x0Key = resolveX(shape.x0);
496
1006
  var x1Key = resolveX(shape.x1);
497
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
498
1007
  var resolveY = function (val) {
499
1008
  if (shape.yref === 'paper') {
500
1009
  if (val === 0) {
@@ -503,7 +1012,10 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
503
1012
  if (val === 1) {
504
1013
  return yMaxValue;
505
1014
  }
506
- return yMinValue + val * (yMaxValue - yMinValue);
1015
+ if (typeof val === 'number') {
1016
+ return yMinValue + val * (yMaxValue - yMinValue);
1017
+ }
1018
+ return val;
507
1019
  }
508
1020
  return val;
509
1021
  };
@@ -525,7 +1037,8 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
525
1037
  });
526
1038
  });
527
1039
  var vsbcData = Object.values(mapXToDataPoints);
528
- 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: (_e = input.layout) === null || _e === void 0 ? void 0 : _e.width, height: (_g = (_f = input.layout) === null || _f === void 0 ? void 0 : _f.height) !== null && _g !== void 0 ? _g : 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 ((_h = vsbcData[0]) === null || _h === void 0 ? void 0 : _h.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));
1040
+ var annotations = getChartAnnotationsFromLayout(input.layout, input.data, isMultiPlot);
1041
+ 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(tslib_1.__assign({ data: vsbcData, width: (_e = input.layout) === null || _e === void 0 ? void 0 : _e.width, height: (_g = (_f = input.layout) === null || _f === void 0 ? void 0 : _f.height) !== null && _g !== void 0 ? _g : 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 ((_h = vsbcData[0]) === null || _h === void 0 ? void 0 : _h.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)), (annotations ? { annotations: annotations } : {}));
529
1042
  };
530
1043
  exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
531
1044
  var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -624,7 +1137,8 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
624
1137
  });
625
1138
  }
626
1139
  });
627
- 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({ dataV2: gvbcDataV2, 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: true }), 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));
1140
+ var annotations = getChartAnnotationsFromLayout(processedInput.layout, processedInput.data, isMultiPlot);
1141
+ 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(tslib_1.__assign({ dataV2: gvbcDataV2, 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: true }), 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)), (annotations ? { annotations: annotations } : {}));
628
1142
  };
629
1143
  exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
630
1144
  var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -684,7 +1198,8 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
684
1198
  : { xAxisCalloutData: "[".concat(bin.x0, " - ").concat(bin.x1, ")") })));
685
1199
  });
686
1200
  });
687
- return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: vbcData, 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, supportNegativeData: true, mode: 'histogram', hideTickOverlap: true, maxBarWidth: 50, hideLegend: hideLegend, roundCorners: true, wrapXAxisLables: typeof ((_d = vbcData[0]) === null || _d === void 0 ? void 0 : _d.x) === 'string' }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getYMinMaxValues(input.data[0], input.layout));
1201
+ var annotations = getChartAnnotationsFromLayout(input.layout, input.data, isMultiPlot);
1202
+ return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: vbcData, 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, supportNegativeData: true, mode: 'histogram', hideTickOverlap: true, maxBarWidth: 50, hideLegend: hideLegend, roundCorners: true, wrapXAxisLables: typeof ((_d = vbcData[0]) === null || _d === void 0 ? void 0 : _d.x) === 'string' }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getYMinMaxValues(input.data[0], input.layout)), (annotations ? { annotations: annotations } : {}));
688
1203
  };
689
1204
  exports.transformPlotlyJsonToVBCProps = transformPlotlyJsonToVBCProps;
690
1205
  var transformPlotlyJsonToAreaChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -699,7 +1214,6 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
699
1214
  return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
700
1215
  };
701
1216
  exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterChartProps;
702
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
703
1217
  var mapColorFillBars = function (layout) {
704
1218
  if (!Array.isArray(layout === null || layout === void 0 ? void 0 : layout.shapes)) {
705
1219
  return [];
@@ -719,7 +1233,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
719
1233
  });
720
1234
  };
721
1235
  var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme) {
722
- var _a, _b, _c, _d, _e, _f, _g;
1236
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
723
1237
  var isScatterMarkers = [
724
1238
  'text',
725
1239
  'markers',
@@ -734,10 +1248,11 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
734
1248
  var isScatterChart = chartType === 'scatter';
735
1249
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
736
1250
  var mode = 'tonexty';
737
- var _h = getLegendProps(input.data, input.layout, isMultiPlot), legends = _h.legends, hideLegend = _h.hideLegend;
1251
+ var _q = getLegendProps(input.data, input.layout, isMultiPlot), legends = _q.legends, hideLegend = _q.hideLegend;
738
1252
  var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
739
- var resolveXAxisValue = getAxisValueResolver(input.data, input.layout, 'x');
740
- var shouldWrapLabels = getAxisType(input.data, input.layout, 'x') === 'category';
1253
+ var xAxisType = getAxisType(input.data, getAxisObjects(input.data, input.layout).x);
1254
+ var resolveXValue = getAxisValueResolver(xAxisType);
1255
+ var shouldWrapLabels = xAxisType === 'category';
741
1256
  var chartData = input.data
742
1257
  .map(function (series, index) {
743
1258
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
@@ -757,7 +1272,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
757
1272
  // if mode contains 'text', we prioritize showing the text over curving the line
758
1273
  var lineOptions = !((_l = series.mode) === null || _l === void 0 ? void 0 : _l.includes('text')) && series.type !== 'scatterpolar' ? getLineOptions(series.line) : undefined;
759
1274
  var legendShape = getLegendShape(series);
760
- var validXYRanges = (0, exports.getValidXYRanges)(series, resolveXAxisValue);
1275
+ var validXYRanges = (0, exports.getValidXYRanges)(series, resolveXValue);
761
1276
  return validXYRanges.map(function (_a, rangeIdx) {
762
1277
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
763
1278
  var rangeStart = _a[0], rangeEnd = _a[1];
@@ -777,7 +1292,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
777
1292
  legendShape: legendShape,
778
1293
  data: rangeXValues.map(function (x, i) {
779
1294
  var _a, _b;
780
- return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ x: resolveXAxisValue(x), y: rangeYValues[i] }, (Array.isArray((_a = series.marker) === null || _a === void 0 ? void 0 : _a.size)
1295
+ return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ x: resolveXValue(x), y: rangeYValues[i] }, (Array.isArray((_a = series.marker) === null || _a === void 0 ? void 0 : _a.size)
781
1296
  ? { markerSize: markerSizes[i] }
782
1297
  : typeof ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size) === 'number'
783
1298
  ? { markerSize: series.marker.size }
@@ -800,16 +1315,49 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
800
1315
  });
801
1316
  })
802
1317
  .flat();
803
- var lineShape = ((_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.shapes) !== null && _c !== void 0 ? _c : [])
1318
+ var xMinValue = (_c = (_b = chartData[0]) === null || _b === void 0 ? void 0 : _b.data[0]) === null || _c === void 0 ? void 0 : _c.x;
1319
+ var xMaxValue = (_e = (_d = chartData[0]) === null || _d === void 0 ? void 0 : _d.data[chartData[0].data.length - 1]) === null || _e === void 0 ? void 0 : _e.x;
1320
+ var yMinValue = (_g = (_f = chartData[0]) === null || _f === void 0 ? void 0 : _f.data[0]) === null || _g === void 0 ? void 0 : _g.y;
1321
+ var yMaxValue = (_j = (_h = chartData[0]) === null || _h === void 0 ? void 0 : _h.data[chartData[0].data.length - 1]) === null || _j === void 0 ? void 0 : _j.y;
1322
+ var lineShape = ((_l = (_k = input.layout) === null || _k === void 0 ? void 0 : _k.shapes) !== null && _l !== void 0 ? _l : [])
804
1323
  .filter(function (shape) { return shape.type === 'line'; })
805
1324
  .map(function (shape, shapeIdx) {
806
1325
  var _a, _b;
807
1326
  var lineColor = (_a = shape.line) === null || _a === void 0 ? void 0 : _a.color;
1327
+ var resolveX = function (val) {
1328
+ if (shape.xref === 'paper') {
1329
+ if (val === 0) {
1330
+ return xMinValue;
1331
+ }
1332
+ if (val === 1) {
1333
+ return xMaxValue;
1334
+ }
1335
+ return typeof xMinValue === 'number' && typeof xMaxValue === 'number' && typeof val === 'number'
1336
+ ? xMinValue + val * (xMaxValue - xMinValue)
1337
+ : val;
1338
+ }
1339
+ return val;
1340
+ };
1341
+ var resolveY = function (val) {
1342
+ if (shape.yref === 'paper') {
1343
+ if (val === 0) {
1344
+ return yMinValue;
1345
+ }
1346
+ if (val === 1) {
1347
+ return yMaxValue;
1348
+ }
1349
+ if (typeof val === 'number') {
1350
+ return yMinValue + val * (yMaxValue - yMinValue);
1351
+ }
1352
+ return val;
1353
+ }
1354
+ return val;
1355
+ };
808
1356
  return {
809
1357
  legend: "Reference_".concat(shapeIdx),
810
1358
  data: [
811
- { x: shape.x0, y: shape.y0 },
812
- { x: shape.x1, y: shape.y1 },
1359
+ { x: resolveX(shape.x0), y: resolveY(shape.y0) },
1360
+ { x: resolveX(shape.x1), y: resolveY(shape.y1) },
813
1361
  ],
814
1362
  color: (_b = (0, d3_color_1.rgb)(lineColor).formatHex8()) !== null && _b !== void 0 ? _b : lineColor,
815
1363
  lineOptions: getLineOptions(shape.line),
@@ -829,15 +1377,18 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
829
1377
  var scatterChartProps = {
830
1378
  scatterChartData: chartData,
831
1379
  };
832
- 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: (_d = input.layout) === null || _d === void 0 ? void 0 : _d.width, height: (_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.height) !== null && _f !== void 0 ? _f : 350, hideTickOverlap: true, hideLegend: hideLegend, useUTC: false, optimizeLargeData: numDataPoints > 1000, shouldWrapLabels: shouldWrapLabels }), getTitles(input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getAxisScaleTypeProps(input.data, input.layout)), getAxisTickProps(input.data, input.layout));
1380
+ var annotations = getChartAnnotationsFromLayout(input.layout, input.data, isMultiPlot);
1381
+ var commonProps = tslib_1.__assign(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: (_m = input.layout) === null || _m === void 0 ? void 0 : _m.width, height: (_p = (_o = input.layout) === null || _o === void 0 ? void 0 : _o.height) !== null && _p !== void 0 ? _p : 350, hideTickOverlap: true, hideLegend: hideLegend, useUTC: false, optimizeLargeData: numDataPoints > 1000, shouldWrapLabels: shouldWrapLabels }), getTitles(input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getAxisScaleTypeProps(input.data, input.layout)), getAxisTickProps(input.data, input.layout)), (annotations ? { annotations: annotations } : {}));
833
1382
  if (isAreaChart) {
834
1383
  return tslib_1.__assign({ data: chartProps, mode: mode }, commonProps);
835
1384
  }
836
1385
  else {
837
1386
  return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: isScatterChart ? scatterChartProps : chartProps, roundedTicks: true, enableReflow: false }, commonProps), yMinMax), (isScatterChart
838
- ? tslib_1.__assign({ showYAxisLablesTooltip: true }, getAxisCategoryOrderProps(input.data, input.layout)) : {})), (!isScatterChart && ((_g = mapColorFillBars(input.layout)) === null || _g === void 0 ? void 0 : _g.length)
839
- ? { colorFillBars: mapColorFillBars(input.layout) }
840
- : {}));
1387
+ ? tslib_1.__assign({ showYAxisLablesTooltip: true }, getAxisCategoryOrderProps(input.data, input.layout)) : {})), (!isScatterChart &&
1388
+ (function () {
1389
+ var bars = mapColorFillBars(input.layout);
1390
+ return bars && !bars.includes(null) ? { colorFillBars: bars } : {};
1391
+ })()));
841
1392
  }
842
1393
  };
843
1394
  var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -889,49 +1440,71 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
889
1440
  exports.transformPlotlyJsonToHorizontalBarWithAxisProps = transformPlotlyJsonToHorizontalBarWithAxisProps;
890
1441
  var transformPlotlyJsonToGanttChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
891
1442
  var _a, _b, _c;
892
- var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
1443
+ var data = input.data.filter(function (series) { return series.type !== 'scatter' || series.mode !== 'markers'; });
1444
+ var _d = getLegendProps(data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
893
1445
  var colorScale = undefined;
894
- var isXDate = getAxisType(input.data, input.layout, 'x') === 'date';
895
- var chartData = input.data
896
- .map(function (series, index) {
1446
+ var xAxisType = getAxisType(data, getAxisObjects(data, input.layout).x);
1447
+ var resolveXValue = getAxisValueResolver(xAxisType, parseLocalDate);
1448
+ var resolveGanttXValue = function (value) {
1449
+ var resolvedValue = resolveXValue(value);
1450
+ return typeof resolvedValue === 'string' ? 0 : resolvedValue !== null && resolvedValue !== void 0 ? resolvedValue : 0;
1451
+ };
1452
+ var isXDate = xAxisType === 'date';
1453
+ var ganttData = [];
1454
+ data.forEach(function (series, index) {
897
1455
  var _a, _b, _c, _d;
898
- colorScale = (0, PlotlyColorAdapter_1.createColorScale)(input.layout, series, colorScale);
899
- // extract colors for each series only once
900
- 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);
901
1456
  var legend = legends[index];
902
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
903
- var convertXValueToNumber = function (value) {
904
- return (0, chart_utilities_1.isInvalidValue)(value) ? 0 : isXDate ? +parseLocalDate(value) : +value;
905
- };
906
- return series.y
907
- .map(function (yVal, i) {
908
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
909
- if ((0, chart_utilities_1.isInvalidValue)(yVal)) {
910
- return null;
1457
+ if (series.type === 'bar') {
1458
+ colorScale = (0, PlotlyColorAdapter_1.createColorScale)(input.layout, series, colorScale);
1459
+ // extract colors for each series only once
1460
+ var extractedColors_1 = (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);
1461
+ series.y.forEach(function (yVal, i) {
1462
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1463
+ if ((0, chart_utilities_1.isInvalidValue)(yVal)) {
1464
+ return;
1465
+ }
1466
+ // resolve color for each legend's bars from the colorscale or extracted colors
1467
+ var color = colorScale
1468
+ ? colorScale((0, chart_utilities_1.isArrayOrTypedArray)((_a = series.marker) === null || _a === void 0 ? void 0 : _a.color)
1469
+ ? (_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]
1470
+ : 0)
1471
+ : (0, PlotlyColorAdapter_1.resolveColor)(extractedColors_1, i, legend, colorMap, (_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, isDarkTheme);
1472
+ var opacity = (0, PlotlyColorAdapter_1.getOpacity)(series, i);
1473
+ var base = +resolveGanttXValue((_h = series.base) === null || _h === void 0 ? void 0 : _h[i]);
1474
+ var xVal = +resolveGanttXValue((_j = series.x) === null || _j === void 0 ? void 0 : _j[i]);
1475
+ ganttData.push({
1476
+ x: {
1477
+ start: isXDate ? new Date(base) : base,
1478
+ end: isXDate ? new Date(base + xVal) : base + xVal,
1479
+ },
1480
+ y: yVal,
1481
+ legend: legend,
1482
+ color: (_k = (0, d3_color_1.rgb)(color).copy({ opacity: opacity }).formatHex8()) !== null && _k !== void 0 ? _k : color,
1483
+ });
1484
+ });
1485
+ }
1486
+ else if (series.type === 'scatter' && series.mode === 'none' && series.fill === 'toself') {
1487
+ for (var i = 0; i < series.y.length; i += 5) {
1488
+ if ((0, chart_utilities_1.isInvalidValue)(series.y[i]) || (0, chart_utilities_1.isInvalidValue)(series.y[i + 3])) {
1489
+ continue;
1490
+ }
1491
+ var x0 = resolveGanttXValue(series.x[i]);
1492
+ var x1 = resolveGanttXValue(series.x[i + 1]);
1493
+ var y0 = series.y[i];
1494
+ var y1 = series.y[i + 3];
1495
+ ganttData.push({
1496
+ x: {
1497
+ start: x0,
1498
+ end: x1,
1499
+ },
1500
+ y: Math.round((y0 + y1) / 2),
1501
+ legend: legend,
1502
+ color: series.fillcolor,
1503
+ });
911
1504
  }
912
- // resolve color for each legend's bars from the colorscale or extracted colors
913
- var color = colorScale
914
- ? colorScale((0, chart_utilities_1.isArrayOrTypedArray)((_a = series.marker) === null || _a === void 0 ? void 0 : _a.color)
915
- ? (_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]
916
- : 0)
917
- : (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, i, legend, colorMap, (_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, isDarkTheme);
918
- var opacity = (0, PlotlyColorAdapter_1.getOpacity)(series, i);
919
- var base = convertXValueToNumber((_h = series.base) === null || _h === void 0 ? void 0 : _h[i]);
920
- var xVal = convertXValueToNumber((_j = series.x) === null || _j === void 0 ? void 0 : _j[i]);
921
- return {
922
- x: {
923
- start: isXDate ? new Date(base) : base,
924
- end: isXDate ? new Date(base + xVal) : base + xVal,
925
- },
926
- y: yVal,
927
- legend: legend,
928
- color: (_k = (0, d3_color_1.rgb)(color).copy({ opacity: opacity }).formatHex8()) !== null && _k !== void 0 ? _k : color,
929
- };
930
- })
931
- .filter(function (point) { return point !== null; });
932
- })
933
- .flat();
934
- 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));
1505
+ }
1506
+ });
1507
+ return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: ganttData, 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(data, input.layout)), getBarProps(data, input.layout, true)), getAxisTickProps(data, input.layout));
935
1508
  };
936
1509
  exports.transformPlotlyJsonToGanttChartProps = transformPlotlyJsonToGanttChartProps;
937
1510
  var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -2116,9 +2689,15 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
2116
2689
  var tickValues = axType === 'date' ? ax.tickvals.map(function (v) { return new Date(v); }) : ax.tickvals;
2117
2690
  if (axId === 'x') {
2118
2691
  props.tickValues = tickValues;
2692
+ props.xAxis = {
2693
+ tickText: ax.ticktext,
2694
+ };
2119
2695
  }
2120
2696
  else if (axId === 'y') {
2121
2697
  props.yAxisTickValues = tickValues;
2698
+ props.yAxis = {
2699
+ tickText: ax.ticktext,
2700
+ };
2122
2701
  }
2123
2702
  return;
2124
2703
  }
@@ -2232,16 +2811,8 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
2232
2811
  }
2233
2812
  return axisObjects;
2234
2813
  };
2235
- function getAxisType(data, arg2, arg3) {
2814
+ var getAxisType = function (data, ax) {
2236
2815
  var _a;
2237
- var ax;
2238
- if (arg2 && typeof arg2 === 'object' && '_id' in arg2) {
2239
- ax = arg2;
2240
- }
2241
- else if (typeof arg3 === 'string') {
2242
- var layout = arg2;
2243
- ax = getAxisObjects(data, layout)[arg3];
2244
- }
2245
2816
  if (!ax) {
2246
2817
  return 'category';
2247
2818
  }
@@ -2268,9 +2839,12 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
2268
2839
  return 'date';
2269
2840
  }
2270
2841
  return 'category';
2271
- }
2272
- var getAxisValueResolver = function (data, layout, axisId) {
2273
- var axType = getAxisType(data, layout, axisId);
2842
+ };
2843
+ var getAxisValueResolver = function (axType, dateParser) {
2844
+ var toDate = function (value) {
2845
+ var date = dateParser ? dateParser(value) : new Date(value);
2846
+ return isNaN(date.getTime()) ? null : date;
2847
+ };
2274
2848
  return function (value) {
2275
2849
  if ((0, chart_utilities_1.isInvalidValue)(value)) {
2276
2850
  return null;
@@ -2281,10 +2855,10 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
2281
2855
  return (0, chart_utilities_1.isNumber)(value) ? +value : null;
2282
2856
  case 'date':
2283
2857
  if ((0, chart_utilities_1.isNumber)(value)) {
2284
- return new Date(+value);
2858
+ return toDate(+value);
2285
2859
  }
2286
2860
  if (typeof value === 'string') {
2287
- return new Date(value);
2861
+ return toDate(value);
2288
2862
  }
2289
2863
  return null;
2290
2864
  case 'category':