@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
@@ -262,6 +262,517 @@ var flattenObject = function (obj, prefix) {
262
262
  }
263
263
  return flattened;
264
264
  };
265
+ var encodeHtmlEntities = function (value) {
266
+ return value
267
+ .replace(/&/g, '&')
268
+ .replace(/</g, '&lt;')
269
+ .replace(/>/g, '&gt;')
270
+ .replace(/"/g, '&quot;')
271
+ .replace(/'/g, '&#39;');
272
+ };
273
+ var toFiniteNumber = function (value) {
274
+ if (value === undefined || value === null) {
275
+ return undefined;
276
+ }
277
+ var numeric = typeof value === 'number' ? value : Number(value);
278
+ return Number.isFinite(numeric) ? numeric : undefined;
279
+ };
280
+ /**
281
+ * Normalizes Plotly axis reference strings so equivalent aliases (e.g. `xaxis1`, `x1`) collapse to the base axis id.
282
+ */
283
+ var normalizeAxisRef = function (ref, axis) {
284
+ if (!ref) {
285
+ return axis;
286
+ }
287
+ var normalized = ref.toLowerCase();
288
+ if (normalized === axis ||
289
+ normalized === "".concat(axis, "axis") ||
290
+ normalized === "".concat(axis, "axis1") ||
291
+ normalized === "".concat(axis, "1")) {
292
+ return axis;
293
+ }
294
+ var match = normalized.match(/^([xy])(axis)?(\d+)$/);
295
+ if (match && match[1] === axis && match[3]) {
296
+ return match[3] === '1' ? axis : "".concat(axis).concat(match[3]);
297
+ }
298
+ return normalized;
299
+ };
300
+ /**
301
+ * Scans the data traces bound to a given axis and returns the numeric min/max values plotted on that axis.
302
+ */
303
+ var getAxisNumericRangeFromData = function (axis, ref, layout, data) {
304
+ if (!data || data.length === 0) {
305
+ return undefined;
306
+ }
307
+ var axisLayout = getAxisLayoutByRef(layout, ref, axis);
308
+ var targetRef = normalizeAxisRef(ref, axis);
309
+ var traceAxisKey = axis === 'x' ? 'xaxis' : 'yaxis';
310
+ var minValue;
311
+ var maxValue;
312
+ data.forEach(function (trace) {
313
+ var plotTrace = trace;
314
+ var traceAxisRef = normalizeAxisRef(plotTrace[traceAxisKey], axis);
315
+ if (traceAxisRef !== targetRef) {
316
+ return;
317
+ }
318
+ var values = (axis === 'x' ? plotTrace.x : plotTrace.y);
319
+ if (!(0, chart_utilities_1.isArrayOrTypedArray)(values)) {
320
+ return;
321
+ }
322
+ var arrayLike = values;
323
+ for (var index = 0; index < arrayLike.length; index++) {
324
+ var value = arrayLike[index];
325
+ var numeric = toNumericValue(convertDataValue(value, axisLayout));
326
+ if (numeric === undefined || Number.isNaN(numeric)) {
327
+ continue;
328
+ }
329
+ minValue = minValue === undefined ? numeric : Math.min(minValue, numeric);
330
+ maxValue = maxValue === undefined ? numeric : Math.max(maxValue, numeric);
331
+ }
332
+ });
333
+ if (minValue === undefined || maxValue === undefined || minValue === maxValue) {
334
+ return undefined;
335
+ }
336
+ return [minValue, maxValue];
337
+ };
338
+ /**
339
+ * Converts Plotly's bottom-origin relative Y coordinate into the SVG top-origin space used by our overlay.
340
+ */
341
+ var transformRelativeYForChart = function (value) {
342
+ if (value === undefined) {
343
+ return undefined;
344
+ }
345
+ if (!Number.isFinite(value)) {
346
+ return undefined;
347
+ }
348
+ return 1 - value;
349
+ };
350
+ var mapHorizontalAlign = function (anchor) {
351
+ switch ((anchor !== null && anchor !== void 0 ? anchor : '').toLowerCase()) {
352
+ case 'left':
353
+ return 'start';
354
+ case 'center':
355
+ return 'center';
356
+ case 'right':
357
+ return 'end';
358
+ default:
359
+ return undefined;
360
+ }
361
+ };
362
+ var mapVerticalAlign = function (anchor) {
363
+ switch ((anchor !== null && anchor !== void 0 ? anchor : '').toLowerCase()) {
364
+ case 'top':
365
+ return 'top';
366
+ case 'middle':
367
+ return 'middle';
368
+ case 'bottom':
369
+ return 'bottom';
370
+ default:
371
+ return undefined;
372
+ }
373
+ };
374
+ var appendPx = function (value) {
375
+ if (value === undefined || value === null) {
376
+ return undefined;
377
+ }
378
+ if (typeof value === 'string') {
379
+ return value;
380
+ }
381
+ if (typeof value === 'number' && Number.isFinite(value)) {
382
+ return "".concat(value, "px");
383
+ }
384
+ return undefined;
385
+ };
386
+ /**
387
+ * Maps Plotly's axis reference string to one of our coordinate interpretation modes (axis, relative, or pixel).
388
+ */
389
+ var resolveRefType = function (ref, axis) {
390
+ if (!ref) {
391
+ return 'axis';
392
+ }
393
+ var normalized = ref.toLowerCase();
394
+ if (normalized === 'pixel') {
395
+ return 'pixel';
396
+ }
397
+ if (normalized === 'paper') {
398
+ return 'relative';
399
+ }
400
+ if (normalized.endsWith(' domain')) {
401
+ return normalized.startsWith(axis) ? 'relative' : undefined;
402
+ }
403
+ var match = normalized.match(/^([xy])(\d*)$/);
404
+ if (match && match[1] === axis) {
405
+ return 'axis';
406
+ }
407
+ return undefined;
408
+ };
409
+ /**
410
+ * Retrieves the appropriate axis layout section from Plotly's layout given an axis reference alias.
411
+ */
412
+ var getAxisLayoutByRef = function (layout, ref, axis) {
413
+ if (!layout) {
414
+ return undefined;
415
+ }
416
+ var defaultAxisKey = "".concat(axis, "axis");
417
+ if (!ref) {
418
+ return layout[defaultAxisKey];
419
+ }
420
+ var normalized = ref.toLowerCase();
421
+ if (normalized === 'paper' || normalized === 'pixel' || normalized.endsWith(' domain')) {
422
+ return layout[defaultAxisKey];
423
+ }
424
+ var match = normalized.match(/^([xy])(\d*)$/);
425
+ if (match && match[1] === axis) {
426
+ var index = match[2];
427
+ if (index && index !== '' && index !== '1') {
428
+ var axisKey = "".concat(axis, "axis").concat(index);
429
+ return layout[axisKey];
430
+ }
431
+ return layout[defaultAxisKey];
432
+ }
433
+ return layout[defaultAxisKey];
434
+ };
435
+ /**
436
+ * Normalizes raw Plotly data values into canonical number/date/string types based on axis configuration.
437
+ */
438
+ var convertDataValue = function (value, axisLayout) {
439
+ if (value === undefined || value === null) {
440
+ return undefined;
441
+ }
442
+ if ((axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) === 'date' || (0, chart_utilities_1.isDate)(value)) {
443
+ var dateValue = value instanceof Date ? value : new Date(value);
444
+ return Number.isNaN(dateValue.getTime()) ? undefined : dateValue;
445
+ }
446
+ if (typeof value === 'number') {
447
+ return value;
448
+ }
449
+ if ((axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) === 'linear' || (axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) === 'log') {
450
+ var numeric = Number(value);
451
+ return Number.isFinite(numeric) ? numeric : undefined;
452
+ }
453
+ if (value instanceof Date) {
454
+ return value;
455
+ }
456
+ return value;
457
+ };
458
+ var toNumericValue = function (value) {
459
+ if (value instanceof Date) {
460
+ var timestamp = value.getTime();
461
+ return Number.isFinite(timestamp) ? timestamp : undefined;
462
+ }
463
+ if (typeof value === 'number') {
464
+ return Number.isFinite(value) ? value : undefined;
465
+ }
466
+ if (typeof value === 'string') {
467
+ var numeric = Number(value);
468
+ return Number.isFinite(numeric) ? numeric : undefined;
469
+ }
470
+ return undefined;
471
+ };
472
+ var toRelativeCoordinate = function (value, axisLayout, fallbackRange) {
473
+ var range = Array.isArray(axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.range) ? axisLayout.range : undefined;
474
+ var start = range && range.length >= 2 ? toNumericValue(convertDataValue(range[0], axisLayout)) : undefined;
475
+ var end = range && range.length >= 2 ? toNumericValue(convertDataValue(range[1], axisLayout)) : undefined;
476
+ if ((start === undefined || end === undefined || start === end) && fallbackRange) {
477
+ start = fallbackRange[0], end = fallbackRange[1];
478
+ }
479
+ var current = toNumericValue(convertDataValue(value, axisLayout));
480
+ if (start === undefined || end === undefined || current === undefined || start === end) {
481
+ return undefined;
482
+ }
483
+ var relative = (current - start) / (end - start);
484
+ return Number.isFinite(relative) ? relative : undefined;
485
+ };
486
+ var createAnnotationId = function (text, index) {
487
+ var normalized = text.replace(/\s+/g, ' ').trim();
488
+ if (normalized) {
489
+ var slug = normalized
490
+ .toLowerCase()
491
+ .replace(/[^a-z0-9]+/g, '-')
492
+ .replace(/^-+|-+$/g, '')
493
+ .slice(0, 32);
494
+ if (slug) {
495
+ return "annotation-".concat(index, "-").concat(slug);
496
+ }
497
+ }
498
+ return "annotation-".concat(index);
499
+ };
500
+ var DEFAULT_ARROW_OFFSET = -40;
501
+ var mapArrowsideToArrow = function (annotation) {
502
+ var includeStart = false;
503
+ var includeEnd = false;
504
+ var arrowSide = typeof (annotation === null || annotation === void 0 ? void 0 : annotation.arrowside) === 'string' ? annotation === null || annotation === void 0 ? void 0 : annotation.arrowside.toLowerCase() : undefined;
505
+ if (arrowSide) {
506
+ includeStart = arrowSide.includes('start');
507
+ includeEnd = arrowSide.includes('end');
508
+ }
509
+ var endHead = toFiniteNumber(annotation === null || annotation === void 0 ? void 0 : annotation.arrowhead);
510
+ var startHead = toFiniteNumber(annotation.startarrowhead);
511
+ if (endHead !== undefined && endHead > 0) {
512
+ includeEnd = true;
513
+ }
514
+ if (startHead !== undefined && startHead > 0) {
515
+ includeStart = true;
516
+ }
517
+ if (includeStart && includeEnd) {
518
+ return 'both';
519
+ }
520
+ if (includeStart) {
521
+ return 'start';
522
+ }
523
+ if (includeEnd) {
524
+ return 'end';
525
+ }
526
+ return 'none';
527
+ };
528
+ var mapArrowDashToPattern = function (value) {
529
+ if (!value) {
530
+ return undefined;
531
+ }
532
+ var normalized = value.trim().toLowerCase();
533
+ switch (normalized) {
534
+ case 'solid':
535
+ return undefined;
536
+ case 'dot':
537
+ return '1, 5';
538
+ case 'dash':
539
+ return '5, 5';
540
+ case 'longdash':
541
+ return '10, 5';
542
+ case 'dashdot':
543
+ return '5, 5, 1, 5';
544
+ case 'longdashdot':
545
+ return '10, 5, 1, 5';
546
+ default:
547
+ if (/^\d+(\s|,)*\d*$/.test(normalized.replace(/\s+/g, ' '))) {
548
+ return normalized.replace(/\s+/g, ' ');
549
+ }
550
+ return value;
551
+ }
552
+ };
553
+ /**
554
+ * Converts a Plotly annotation definition into the internal `ChartAnnotation` format, translating coordinates,
555
+ * layout alignment, styling, and connector metadata while skipping unsupported configurations.
556
+ */
557
+ var convertPlotlyAnnotation = function (annotation, layout, data, index) {
558
+ var _a;
559
+ if (!annotation || annotation.visible === false) {
560
+ return undefined;
561
+ }
562
+ var xRefType = resolveRefType(annotation.xref, 'x');
563
+ var yRefType = resolveRefType(annotation.yref, 'y');
564
+ if (!xRefType || !yRefType) {
565
+ return undefined;
566
+ }
567
+ var coordinates;
568
+ if (xRefType === 'axis' && yRefType === 'axis') {
569
+ var xAxisLayout = getAxisLayoutByRef(layout, annotation.xref, 'x');
570
+ var yAxisLayout = getAxisLayoutByRef(layout, annotation.yref, 'y');
571
+ var xValue = convertDataValue(annotation.x, xAxisLayout);
572
+ var yValue = convertDataValue(annotation.y, yAxisLayout);
573
+ if (xValue === undefined || yValue === undefined) {
574
+ return undefined;
575
+ }
576
+ var yRefNormalized = typeof annotation.yref === 'string' ? annotation.yref.toLowerCase() : undefined;
577
+ coordinates = tslib_1.__assign({ type: 'data', x: xValue, y: yValue }, (yRefNormalized === 'y2' ? { yAxis: 'secondary' } : {}));
578
+ }
579
+ else if (xRefType === 'relative' && yRefType === 'relative') {
580
+ var xValue = toFiniteNumber(annotation.x);
581
+ var yValue = toFiniteNumber(annotation.y);
582
+ var chartRelativeY = transformRelativeYForChart(yValue);
583
+ if (xValue === undefined || chartRelativeY === undefined) {
584
+ return undefined;
585
+ }
586
+ coordinates = {
587
+ type: 'relative',
588
+ x: xValue,
589
+ y: chartRelativeY,
590
+ };
591
+ }
592
+ else if (xRefType === 'relative' && yRefType === 'axis') {
593
+ var xValue = toFiniteNumber(annotation.x);
594
+ var yAxisLayout = getAxisLayoutByRef(layout, annotation.yref, 'y');
595
+ var yFallbackRange = getAxisNumericRangeFromData('y', annotation.yref, layout, data);
596
+ var yRelative = toRelativeCoordinate(annotation.y, yAxisLayout, yFallbackRange);
597
+ var chartRelativeY = transformRelativeYForChart(yRelative);
598
+ if (xValue === undefined || chartRelativeY === undefined) {
599
+ return undefined;
600
+ }
601
+ coordinates = {
602
+ type: 'relative',
603
+ x: xValue,
604
+ y: chartRelativeY,
605
+ };
606
+ }
607
+ else if (xRefType === 'axis' && yRefType === 'relative') {
608
+ var yValue = toFiniteNumber(annotation.y);
609
+ var xAxisLayout = getAxisLayoutByRef(layout, annotation.xref, 'x');
610
+ var xFallbackRange = getAxisNumericRangeFromData('x', annotation.xref, layout, data);
611
+ var xRelative = toRelativeCoordinate(annotation.x, xAxisLayout, xFallbackRange);
612
+ var chartRelativeY = transformRelativeYForChart(yValue);
613
+ if (xRelative === undefined || chartRelativeY === undefined) {
614
+ return undefined;
615
+ }
616
+ coordinates = {
617
+ type: 'relative',
618
+ x: xRelative,
619
+ y: chartRelativeY,
620
+ };
621
+ }
622
+ else if (xRefType === 'pixel' && yRefType === 'pixel') {
623
+ var xValue = toFiniteNumber(annotation.x);
624
+ var yValue = toFiniteNumber(annotation.y);
625
+ if (xValue === undefined || yValue === undefined) {
626
+ return undefined;
627
+ }
628
+ coordinates = {
629
+ type: 'pixel',
630
+ x: xValue,
631
+ y: yValue,
632
+ };
633
+ }
634
+ else {
635
+ return undefined;
636
+ }
637
+ var textValue = annotation.text;
638
+ var rawText = textValue === undefined || textValue === null ? '' : String(textValue);
639
+ var encodedText = encodeHtmlEntities(rawText);
640
+ var chartAnnotation = {
641
+ id: createAnnotationId(encodedText, index),
642
+ text: encodedText,
643
+ coordinates: coordinates,
644
+ };
645
+ var layoutProps = {};
646
+ var styleProps = {};
647
+ var showArrow = annotation.showarrow === undefined ? false : !!annotation.showarrow;
648
+ var clipOnAxis = annotation.cliponaxis;
649
+ if (clipOnAxis !== undefined) {
650
+ layoutProps.clipToBounds = !!clipOnAxis;
651
+ }
652
+ else if (coordinates.type === 'data') {
653
+ layoutProps.clipToBounds = true;
654
+ }
655
+ var horizontalAlign = mapHorizontalAlign(annotation.xanchor);
656
+ if (horizontalAlign) {
657
+ layoutProps.align = horizontalAlign;
658
+ }
659
+ if (!layoutProps.align) {
660
+ var alignProp = mapHorizontalAlign(annotation.align);
661
+ if (alignProp) {
662
+ layoutProps.align = alignProp;
663
+ }
664
+ }
665
+ var verticalAlign = mapVerticalAlign(annotation.yanchor);
666
+ if (verticalAlign) {
667
+ layoutProps.verticalAlign = verticalAlign;
668
+ }
669
+ if (!layoutProps.verticalAlign) {
670
+ var valignProp = mapVerticalAlign(annotation.valign);
671
+ if (valignProp) {
672
+ layoutProps.verticalAlign = valignProp;
673
+ }
674
+ }
675
+ var offsetXComponents = [];
676
+ var hasExplicitOffset = false;
677
+ var ax = toFiniteNumber(annotation.ax);
678
+ var axRef = typeof annotation.axref === 'string' ? annotation.axref.toLowerCase() : undefined;
679
+ if (ax !== undefined && (axRef === undefined || axRef === 'pixel')) {
680
+ offsetXComponents.push(ax);
681
+ hasExplicitOffset = true;
682
+ }
683
+ var xShift = toFiniteNumber(annotation.xshift);
684
+ if (xShift !== undefined) {
685
+ offsetXComponents.push(xShift);
686
+ hasExplicitOffset = true;
687
+ }
688
+ if (offsetXComponents.length > 0) {
689
+ var offsetX = offsetXComponents.reduce(function (sum, value) { return sum + value; }, 0);
690
+ if (offsetX !== 0) {
691
+ layoutProps.offsetX = offsetX;
692
+ }
693
+ }
694
+ var offsetYComponents = [];
695
+ var ay = toFiniteNumber(annotation.ay);
696
+ var ayRef = typeof annotation.ayref === 'string' ? annotation.ayref.toLowerCase() : undefined;
697
+ if (ay !== undefined && (ayRef === undefined || ayRef === 'pixel')) {
698
+ offsetYComponents.push(ay);
699
+ hasExplicitOffset = true;
700
+ }
701
+ var yShift = toFiniteNumber(annotation.yshift);
702
+ if (yShift !== undefined) {
703
+ offsetYComponents.push(yShift);
704
+ hasExplicitOffset = true;
705
+ }
706
+ if (offsetYComponents.length > 0) {
707
+ var offsetY = offsetYComponents.reduce(function (sum, value) { return sum + value; }, 0);
708
+ if (offsetY !== 0) {
709
+ layoutProps.offsetY = offsetY;
710
+ }
711
+ }
712
+ if (showArrow && !hasExplicitOffset && layoutProps.offsetY === undefined) {
713
+ layoutProps.offsetY = DEFAULT_ARROW_OFFSET;
714
+ }
715
+ var maxWidth = toFiniteNumber(annotation.width);
716
+ if (maxWidth !== undefined) {
717
+ layoutProps.maxWidth = maxWidth;
718
+ }
719
+ if (annotation.bgcolor) {
720
+ styleProps.backgroundColor = annotation.bgcolor;
721
+ }
722
+ if (annotation.bordercolor) {
723
+ styleProps.borderColor = annotation.bordercolor;
724
+ }
725
+ var borderWidth = toFiniteNumber(annotation.borderwidth);
726
+ if (borderWidth !== undefined) {
727
+ styleProps.borderWidth = borderWidth;
728
+ }
729
+ var borderPad = appendPx(annotation.borderpad);
730
+ if (borderPad) {
731
+ styleProps.padding = borderPad;
732
+ }
733
+ var opacity = toFiniteNumber(annotation.opacity);
734
+ if (opacity !== undefined) {
735
+ styleProps.opacity = opacity;
736
+ }
737
+ if (annotation.font) {
738
+ var font = annotation.font;
739
+ if (font === null || font === void 0 ? void 0 : font.color) {
740
+ styleProps.textColor = font.color;
741
+ }
742
+ var fontSize = appendPx(font === null || font === void 0 ? void 0 : font.size);
743
+ if (fontSize) {
744
+ styleProps.fontSize = fontSize;
745
+ }
746
+ if (font === null || font === void 0 ? void 0 : font.weight) {
747
+ styleProps.fontWeight = font.weight;
748
+ }
749
+ }
750
+ if (Object.keys(layoutProps).length > 0) {
751
+ chartAnnotation.layout = layoutProps;
752
+ }
753
+ if (Object.keys(styleProps).length > 0) {
754
+ chartAnnotation.style = styleProps;
755
+ }
756
+ if (showArrow) {
757
+ var arrowColor = (_a = annotation.arrowcolor) !== null && _a !== void 0 ? _a : styleProps.textColor;
758
+ var arrowWidth = toFiniteNumber(annotation.arrowwidth);
759
+ var endPadding = toFiniteNumber(annotation.standoff);
760
+ var startPadding = toFiniteNumber(annotation.startstandoff);
761
+ var dashPattern = mapArrowDashToPattern(annotation.arrowdash);
762
+ 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) });
763
+ }
764
+ return chartAnnotation;
765
+ };
766
+ var getChartAnnotationsFromLayout = function (layout, data, isMultiPlot) {
767
+ if (isMultiPlot || !(layout === null || layout === void 0 ? void 0 : layout.annotations)) {
768
+ return undefined;
769
+ }
770
+ var annotationsArray = Array.isArray(layout.annotations) ? layout.annotations : [layout.annotations];
771
+ var converted = annotationsArray
772
+ .map(function (annotation, index) { return convertPlotlyAnnotation(annotation, layout, data, index); })
773
+ .filter(function (annotation) { return annotation !== undefined; });
774
+ return converted.length > 0 ? converted : undefined;
775
+ };
265
776
  /**
266
777
  * Normalizes an array of objects by flattening nested structures and creating grouped data
267
778
  * Uses json_normalize approach with D3 color detection and filtering
@@ -426,7 +937,7 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
426
937
  var _j = getLegendProps(input.data, input.layout, isMultiPlot), legends = _j.legends, hideLegend = _j.hideLegend;
427
938
  var colorScale = undefined;
428
939
  var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
429
- var resolveXAxisValue = getAxisValueResolver(input.data, input.layout, 'x');
940
+ var resolveXValue = getAxisValueResolver(getAxisType(input.data, getAxisObjects(input.data, input.layout).x));
430
941
  input.data.forEach(function (series, index1) {
431
942
  var _a, _b, _c, _d, _e, _f, _g, _h;
432
943
  colorScale = (0, PlotlyColorAdapter_1.createColorScale)(input.layout, series, colorScale);
@@ -434,7 +945,7 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
434
945
  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);
435
946
  // extract line colors for each series only once
436
947
  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);
437
- var validXYRanges = (0, exports.getValidXYRanges)(series, resolveXAxisValue);
948
+ var validXYRanges = (0, exports.getValidXYRanges)(series, resolveXValue);
438
949
  validXYRanges.forEach(function (_a, rangeIdx) {
439
950
  var rangeStart = _a[0], rangeEnd = _a[1];
440
951
  var rangeXValues = series.x.slice(rangeStart, rangeEnd);
@@ -443,7 +954,7 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
443
954
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
444
955
  if (!mapXToDataPoints[x]) {
445
956
  mapXToDataPoints[x] = {
446
- xAxisPoint: resolveXAxisValue(x),
957
+ xAxisPoint: resolveXValue(x),
447
958
  chartData: [],
448
959
  lineData: [],
449
960
  };
@@ -496,7 +1007,6 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
496
1007
  .forEach(function (shape, shapeIdx) {
497
1008
  var _a, _b, _c;
498
1009
  var lineColor = (_a = shape.line) === null || _a === void 0 ? void 0 : _a.color;
499
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
500
1010
  var resolveX = function (val) {
501
1011
  if (typeof val === 'number' && Array.isArray(xCategories) && xCategories[val] !== undefined) {
502
1012
  return xCategories[val];
@@ -505,7 +1015,6 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
505
1015
  };
506
1016
  var x0Key = resolveX(shape.x0);
507
1017
  var x1Key = resolveX(shape.x1);
508
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
509
1018
  var resolveY = function (val) {
510
1019
  if (shape.yref === 'paper') {
511
1020
  if (val === 0) {
@@ -514,7 +1023,10 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
514
1023
  if (val === 1) {
515
1024
  return yMaxValue;
516
1025
  }
517
- return yMinValue + val * (yMaxValue - yMinValue);
1026
+ if (typeof val === 'number') {
1027
+ return yMinValue + val * (yMaxValue - yMinValue);
1028
+ }
1029
+ return val;
518
1030
  }
519
1031
  return val;
520
1032
  };
@@ -536,7 +1048,8 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
536
1048
  });
537
1049
  });
538
1050
  var vsbcData = Object.values(mapXToDataPoints);
539
- 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));
1051
+ var annotations = getChartAnnotationsFromLayout(input.layout, input.data, isMultiPlot);
1052
+ 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 } : {}));
540
1053
  };
541
1054
  exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
542
1055
  var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -635,7 +1148,8 @@ var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, col
635
1148
  });
636
1149
  }
637
1150
  });
638
- 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));
1151
+ var annotations = getChartAnnotationsFromLayout(processedInput.layout, processedInput.data, isMultiPlot);
1152
+ 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 } : {}));
639
1153
  };
640
1154
  exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
641
1155
  var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -695,7 +1209,8 @@ var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colo
695
1209
  : { xAxisCalloutData: "[".concat(bin.x0, " - ").concat(bin.x1, ")") })));
696
1210
  });
697
1211
  });
698
- 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));
1212
+ var annotations = getChartAnnotationsFromLayout(input.layout, input.data, isMultiPlot);
1213
+ 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 } : {}));
699
1214
  };
700
1215
  exports.transformPlotlyJsonToVBCProps = transformPlotlyJsonToVBCProps;
701
1216
  var transformPlotlyJsonToAreaChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -710,7 +1225,6 @@ var transformPlotlyJsonToScatterChartProps = function (input, isMultiPlot, color
710
1225
  return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
711
1226
  };
712
1227
  exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterChartProps;
713
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
714
1228
  var mapColorFillBars = function (layout) {
715
1229
  if (!Array.isArray(layout === null || layout === void 0 ? void 0 : layout.shapes)) {
716
1230
  return [];
@@ -730,7 +1244,7 @@ var mapColorFillBars = function (layout) {
730
1244
  });
731
1245
  };
732
1246
  var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme) {
733
- var _a, _b, _c, _d, _e, _f, _g;
1247
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
734
1248
  var isScatterMarkers = [
735
1249
  'text',
736
1250
  'markers',
@@ -745,10 +1259,11 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
745
1259
  var isScatterChart = chartType === 'scatter';
746
1260
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
747
1261
  var mode = 'tonexty';
748
- var _h = getLegendProps(input.data, input.layout, isMultiPlot), legends = _h.legends, hideLegend = _h.hideLegend;
1262
+ var _q = getLegendProps(input.data, input.layout, isMultiPlot), legends = _q.legends, hideLegend = _q.hideLegend;
749
1263
  var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
750
- var resolveXAxisValue = getAxisValueResolver(input.data, input.layout, 'x');
751
- var shouldWrapLabels = getAxisType(input.data, input.layout, 'x') === 'category';
1264
+ var xAxisType = getAxisType(input.data, getAxisObjects(input.data, input.layout).x);
1265
+ var resolveXValue = getAxisValueResolver(xAxisType);
1266
+ var shouldWrapLabels = xAxisType === 'category';
752
1267
  var chartData = input.data
753
1268
  .map(function (series, index) {
754
1269
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
@@ -768,7 +1283,7 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
768
1283
  // if mode contains 'text', we prioritize showing the text over curving the line
769
1284
  var lineOptions = !((_l = series.mode) === null || _l === void 0 ? void 0 : _l.includes('text')) && series.type !== 'scatterpolar' ? getLineOptions(series.line) : undefined;
770
1285
  var legendShape = getLegendShape(series);
771
- var validXYRanges = (0, exports.getValidXYRanges)(series, resolveXAxisValue);
1286
+ var validXYRanges = (0, exports.getValidXYRanges)(series, resolveXValue);
772
1287
  return validXYRanges.map(function (_a, rangeIdx) {
773
1288
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
774
1289
  var rangeStart = _a[0], rangeEnd = _a[1];
@@ -788,7 +1303,7 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
788
1303
  legendShape: legendShape,
789
1304
  data: rangeXValues.map(function (x, i) {
790
1305
  var _a, _b;
791
- 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)
1306
+ 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)
792
1307
  ? { markerSize: markerSizes[i] }
793
1308
  : typeof ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size) === 'number'
794
1309
  ? { markerSize: series.marker.size }
@@ -811,16 +1326,49 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
811
1326
  });
812
1327
  })
813
1328
  .flat();
814
- var lineShape = ((_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.shapes) !== null && _c !== void 0 ? _c : [])
1329
+ var xMinValue = (_c = (_b = chartData[0]) === null || _b === void 0 ? void 0 : _b.data[0]) === null || _c === void 0 ? void 0 : _c.x;
1330
+ 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;
1331
+ var yMinValue = (_g = (_f = chartData[0]) === null || _f === void 0 ? void 0 : _f.data[0]) === null || _g === void 0 ? void 0 : _g.y;
1332
+ 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;
1333
+ var lineShape = ((_l = (_k = input.layout) === null || _k === void 0 ? void 0 : _k.shapes) !== null && _l !== void 0 ? _l : [])
815
1334
  .filter(function (shape) { return shape.type === 'line'; })
816
1335
  .map(function (shape, shapeIdx) {
817
1336
  var _a, _b;
818
1337
  var lineColor = (_a = shape.line) === null || _a === void 0 ? void 0 : _a.color;
1338
+ var resolveX = function (val) {
1339
+ if (shape.xref === 'paper') {
1340
+ if (val === 0) {
1341
+ return xMinValue;
1342
+ }
1343
+ if (val === 1) {
1344
+ return xMaxValue;
1345
+ }
1346
+ return typeof xMinValue === 'number' && typeof xMaxValue === 'number' && typeof val === 'number'
1347
+ ? xMinValue + val * (xMaxValue - xMinValue)
1348
+ : val;
1349
+ }
1350
+ return val;
1351
+ };
1352
+ var resolveY = function (val) {
1353
+ if (shape.yref === 'paper') {
1354
+ if (val === 0) {
1355
+ return yMinValue;
1356
+ }
1357
+ if (val === 1) {
1358
+ return yMaxValue;
1359
+ }
1360
+ if (typeof val === 'number') {
1361
+ return yMinValue + val * (yMaxValue - yMinValue);
1362
+ }
1363
+ return val;
1364
+ }
1365
+ return val;
1366
+ };
819
1367
  return {
820
1368
  legend: "Reference_".concat(shapeIdx),
821
1369
  data: [
822
- { x: shape.x0, y: shape.y0 },
823
- { x: shape.x1, y: shape.y1 },
1370
+ { x: resolveX(shape.x0), y: resolveY(shape.y0) },
1371
+ { x: resolveX(shape.x1), y: resolveY(shape.y1) },
824
1372
  ],
825
1373
  color: (_b = (0, d3_color_1.rgb)(lineColor).formatHex8()) !== null && _b !== void 0 ? _b : lineColor,
826
1374
  lineOptions: getLineOptions(shape.line),
@@ -840,15 +1388,18 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
840
1388
  var scatterChartProps = {
841
1389
  scatterChartData: chartData,
842
1390
  };
843
- 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));
1391
+ var annotations = getChartAnnotationsFromLayout(input.layout, input.data, isMultiPlot);
1392
+ 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 } : {}));
844
1393
  if (isAreaChart) {
845
1394
  return tslib_1.__assign({ data: chartProps, mode: mode }, commonProps);
846
1395
  }
847
1396
  else {
848
1397
  return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: isScatterChart ? scatterChartProps : chartProps, roundedTicks: true, enableReflow: false }, commonProps), yMinMax), (isScatterChart
849
- ? tslib_1.__assign({ showYAxisLablesTooltip: true }, getAxisCategoryOrderProps(input.data, input.layout)) : {})), (!isScatterChart && ((_g = mapColorFillBars(input.layout)) === null || _g === void 0 ? void 0 : _g.length)
850
- ? { colorFillBars: mapColorFillBars(input.layout) }
851
- : {}));
1398
+ ? tslib_1.__assign({ showYAxisLablesTooltip: true }, getAxisCategoryOrderProps(input.data, input.layout)) : {})), (!isScatterChart &&
1399
+ (function () {
1400
+ var bars = mapColorFillBars(input.layout);
1401
+ return bars && !bars.includes(null) ? { colorFillBars: bars } : {};
1402
+ })()));
852
1403
  }
853
1404
  };
854
1405
  var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -900,49 +1451,71 @@ var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPl
900
1451
  exports.transformPlotlyJsonToHorizontalBarWithAxisProps = transformPlotlyJsonToHorizontalBarWithAxisProps;
901
1452
  var transformPlotlyJsonToGanttChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
902
1453
  var _a, _b, _c;
903
- var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
1454
+ var data = input.data.filter(function (series) { return series.type !== 'scatter' || series.mode !== 'markers'; });
1455
+ var _d = getLegendProps(data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
904
1456
  var colorScale = undefined;
905
- var isXDate = getAxisType(input.data, input.layout, 'x') === 'date';
906
- var chartData = input.data
907
- .map(function (series, index) {
1457
+ var xAxisType = getAxisType(data, getAxisObjects(data, input.layout).x);
1458
+ var resolveXValue = getAxisValueResolver(xAxisType, parseLocalDate);
1459
+ var resolveGanttXValue = function (value) {
1460
+ var resolvedValue = resolveXValue(value);
1461
+ return typeof resolvedValue === 'string' ? 0 : resolvedValue !== null && resolvedValue !== void 0 ? resolvedValue : 0;
1462
+ };
1463
+ var isXDate = xAxisType === 'date';
1464
+ var ganttData = [];
1465
+ data.forEach(function (series, index) {
908
1466
  var _a, _b, _c, _d;
909
- colorScale = (0, PlotlyColorAdapter_1.createColorScale)(input.layout, series, colorScale);
910
- // extract colors for each series only once
911
- 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);
912
1467
  var legend = legends[index];
913
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
914
- var convertXValueToNumber = function (value) {
915
- return (0, chart_utilities_1.isInvalidValue)(value) ? 0 : isXDate ? +parseLocalDate(value) : +value;
916
- };
917
- return series.y
918
- .map(function (yVal, i) {
919
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
920
- if ((0, chart_utilities_1.isInvalidValue)(yVal)) {
921
- return null;
1468
+ if (series.type === 'bar') {
1469
+ colorScale = (0, PlotlyColorAdapter_1.createColorScale)(input.layout, series, colorScale);
1470
+ // extract colors for each series only once
1471
+ 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);
1472
+ series.y.forEach(function (yVal, i) {
1473
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1474
+ if ((0, chart_utilities_1.isInvalidValue)(yVal)) {
1475
+ return;
1476
+ }
1477
+ // resolve color for each legend's bars from the colorscale or extracted colors
1478
+ var color = colorScale
1479
+ ? colorScale((0, chart_utilities_1.isArrayOrTypedArray)((_a = series.marker) === null || _a === void 0 ? void 0 : _a.color)
1480
+ ? (_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]
1481
+ : 0)
1482
+ : (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);
1483
+ var opacity = (0, PlotlyColorAdapter_1.getOpacity)(series, i);
1484
+ var base = +resolveGanttXValue((_h = series.base) === null || _h === void 0 ? void 0 : _h[i]);
1485
+ var xVal = +resolveGanttXValue((_j = series.x) === null || _j === void 0 ? void 0 : _j[i]);
1486
+ ganttData.push({
1487
+ x: {
1488
+ start: isXDate ? new Date(base) : base,
1489
+ end: isXDate ? new Date(base + xVal) : base + xVal,
1490
+ },
1491
+ y: yVal,
1492
+ legend: legend,
1493
+ color: (_k = (0, d3_color_1.rgb)(color).copy({ opacity: opacity }).formatHex8()) !== null && _k !== void 0 ? _k : color,
1494
+ });
1495
+ });
1496
+ }
1497
+ else if (series.type === 'scatter' && series.mode === 'none' && series.fill === 'toself') {
1498
+ for (var i = 0; i < series.y.length; i += 5) {
1499
+ if ((0, chart_utilities_1.isInvalidValue)(series.y[i]) || (0, chart_utilities_1.isInvalidValue)(series.y[i + 3])) {
1500
+ continue;
1501
+ }
1502
+ var x0 = resolveGanttXValue(series.x[i]);
1503
+ var x1 = resolveGanttXValue(series.x[i + 1]);
1504
+ var y0 = series.y[i];
1505
+ var y1 = series.y[i + 3];
1506
+ ganttData.push({
1507
+ x: {
1508
+ start: x0,
1509
+ end: x1,
1510
+ },
1511
+ y: Math.round((y0 + y1) / 2),
1512
+ legend: legend,
1513
+ color: series.fillcolor,
1514
+ });
922
1515
  }
923
- // resolve color for each legend's bars from the colorscale or extracted colors
924
- var color = colorScale
925
- ? colorScale((0, chart_utilities_1.isArrayOrTypedArray)((_a = series.marker) === null || _a === void 0 ? void 0 : _a.color)
926
- ? (_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]
927
- : 0)
928
- : (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);
929
- var opacity = (0, PlotlyColorAdapter_1.getOpacity)(series, i);
930
- var base = convertXValueToNumber((_h = series.base) === null || _h === void 0 ? void 0 : _h[i]);
931
- var xVal = convertXValueToNumber((_j = series.x) === null || _j === void 0 ? void 0 : _j[i]);
932
- return {
933
- x: {
934
- start: isXDate ? new Date(base) : base,
935
- end: isXDate ? new Date(base + xVal) : base + xVal,
936
- },
937
- y: yVal,
938
- legend: legend,
939
- color: (_k = (0, d3_color_1.rgb)(color).copy({ opacity: opacity }).formatHex8()) !== null && _k !== void 0 ? _k : color,
940
- };
941
- })
942
- .filter(function (point) { return point !== null; });
943
- })
944
- .flat();
945
- 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));
1516
+ }
1517
+ });
1518
+ 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));
946
1519
  };
947
1520
  exports.transformPlotlyJsonToGanttChartProps = transformPlotlyJsonToGanttChartProps;
948
1521
  var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -2127,9 +2700,15 @@ var getAxisTickProps = function (data, layout) {
2127
2700
  var tickValues = axType === 'date' ? ax.tickvals.map(function (v) { return new Date(v); }) : ax.tickvals;
2128
2701
  if (axId === 'x') {
2129
2702
  props.tickValues = tickValues;
2703
+ props.xAxis = {
2704
+ tickText: ax.ticktext,
2705
+ };
2130
2706
  }
2131
2707
  else if (axId === 'y') {
2132
2708
  props.yAxisTickValues = tickValues;
2709
+ props.yAxis = {
2710
+ tickText: ax.ticktext,
2711
+ };
2133
2712
  }
2134
2713
  return;
2135
2714
  }
@@ -2243,16 +2822,8 @@ var getAxisObjects = function (data, layout) {
2243
2822
  }
2244
2823
  return axisObjects;
2245
2824
  };
2246
- function getAxisType(data, arg2, arg3) {
2825
+ var getAxisType = function (data, ax) {
2247
2826
  var _a;
2248
- var ax;
2249
- if (arg2 && typeof arg2 === 'object' && '_id' in arg2) {
2250
- ax = arg2;
2251
- }
2252
- else if (typeof arg3 === 'string') {
2253
- var layout = arg2;
2254
- ax = getAxisObjects(data, layout)[arg3];
2255
- }
2256
2827
  if (!ax) {
2257
2828
  return 'category';
2258
2829
  }
@@ -2279,9 +2850,12 @@ function getAxisType(data, arg2, arg3) {
2279
2850
  return 'date';
2280
2851
  }
2281
2852
  return 'category';
2282
- }
2283
- var getAxisValueResolver = function (data, layout, axisId) {
2284
- var axType = getAxisType(data, layout, axisId);
2853
+ };
2854
+ var getAxisValueResolver = function (axType, dateParser) {
2855
+ var toDate = function (value) {
2856
+ var date = dateParser ? dateParser(value) : new Date(value);
2857
+ return isNaN(date.getTime()) ? null : date;
2858
+ };
2285
2859
  return function (value) {
2286
2860
  if ((0, chart_utilities_1.isInvalidValue)(value)) {
2287
2861
  return null;
@@ -2292,10 +2866,10 @@ var getAxisValueResolver = function (data, layout, axisId) {
2292
2866
  return (0, chart_utilities_1.isNumber)(value) ? +value : null;
2293
2867
  case 'date':
2294
2868
  if ((0, chart_utilities_1.isNumber)(value)) {
2295
- return new Date(+value);
2869
+ return toDate(+value);
2296
2870
  }
2297
2871
  if (typeof value === 'string') {
2298
- return new Date(value);
2872
+ return toDate(value);
2299
2873
  }
2300
2874
  return null;
2301
2875
  case 'category':