@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.
- package/CHANGELOG.json +75 -1
- package/CHANGELOG.md +30 -2
- package/dist/react-charting.d.ts +127 -0
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +74 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.d.ts +3 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js +496 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.d.ts +28 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js +111 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js.map +1 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.d.ts +52 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +2 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
- package/lib/components/CommonComponents/CartesianChart.base.js +38 -46
- package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.styles.js +9 -1
- package/lib/components/CommonComponents/CartesianChart.styles.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.d.ts +17 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/index.d.ts +2 -0
- package/lib/components/CommonComponents/index.js +2 -0
- package/lib/components/CommonComponents/index.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +650 -76
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js.map +1 -1
- package/lib/types/IChartAnnotation.d.ts +99 -0
- package/lib/types/IChartAnnotation.js +2 -0
- package/lib/types/IChartAnnotation.js.map +1 -0
- package/lib/types/IDataPoint.d.ts +4 -0
- package/lib/types/IDataPoint.js.map +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/index.js.map +1 -1
- package/lib/utilities/image-export-utils.js +55 -0
- package/lib/utilities/image-export-utils.js.map +1 -1
- package/lib/utilities/utilities.js +72 -20
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.d.ts +3 -0
- package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.js +497 -0
- package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
- package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.d.ts +28 -0
- package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js +119 -0
- package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js.map +1 -0
- package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.types.d.ts +52 -0
- package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +5 -0
- package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
- package/lib-amd/components/CommonComponents/CartesianChart.base.js +38 -47
- package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.styles.js +9 -1
- package/lib-amd/components/CommonComponents/CartesianChart.styles.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +17 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-amd/components/CommonComponents/index.d.ts +2 -0
- package/lib-amd/components/CommonComponents/index.js +3 -1
- package/lib-amd/components/CommonComponents/index.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +650 -76
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/index.d.ts +1 -1
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/types/IChartAnnotation.d.ts +99 -0
- package/lib-amd/types/IChartAnnotation.js +5 -0
- package/lib-amd/types/IChartAnnotation.js.map +1 -0
- package/lib-amd/types/IDataPoint.d.ts +4 -0
- package/lib-amd/types/IDataPoint.js.map +1 -1
- package/lib-amd/types/index.d.ts +1 -0
- package/lib-amd/types/index.js +2 -1
- package/lib-amd/types/index.js.map +1 -1
- package/lib-amd/utilities/image-export-utils.js +55 -0
- package/lib-amd/utilities/image-export-utils.js.map +1 -1
- package/lib-amd/utilities/utilities.js +72 -20
- package/lib-amd/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.d.ts +3 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js +499 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.d.ts +28 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js +118 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.styles.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.d.ts +52 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +3 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +38 -46
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js +9 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +17 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/index.d.ts +2 -0
- package/lib-commonjs/components/CommonComponents/index.js +2 -0
- package/lib-commonjs/components/CommonComponents/index.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +650 -76
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/index.d.ts +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types/IChartAnnotation.d.ts +99 -0
- package/lib-commonjs/types/IChartAnnotation.js +3 -0
- package/lib-commonjs/types/IChartAnnotation.js.map +1 -0
- package/lib-commonjs/types/IDataPoint.d.ts +4 -0
- package/lib-commonjs/types/IDataPoint.js.map +1 -1
- package/lib-commonjs/types/index.d.ts +1 -0
- package/lib-commonjs/types/index.js +1 -0
- package/lib-commonjs/types/index.js.map +1 -1
- package/lib-commonjs/utilities/image-export-utils.js +55 -0
- package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +72 -20
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +9 -9
- package/src/components/CommonComponents/Annotations/ChartAnnotationLayer.types.ts +58 -0
- package/src/components/CommonComponents/CartesianChart.types.ts +21 -0
|
@@ -255,6 +255,517 @@ var flattenObject = function (obj, prefix) {
|
|
|
255
255
|
}
|
|
256
256
|
return flattened;
|
|
257
257
|
};
|
|
258
|
+
var encodeHtmlEntities = function (value) {
|
|
259
|
+
return value
|
|
260
|
+
.replace(/&/g, '&')
|
|
261
|
+
.replace(/</g, '<')
|
|
262
|
+
.replace(/>/g, '>')
|
|
263
|
+
.replace(/"/g, '"')
|
|
264
|
+
.replace(/'/g, ''');
|
|
265
|
+
};
|
|
266
|
+
var toFiniteNumber = function (value) {
|
|
267
|
+
if (value === undefined || value === null) {
|
|
268
|
+
return undefined;
|
|
269
|
+
}
|
|
270
|
+
var numeric = typeof value === 'number' ? value : Number(value);
|
|
271
|
+
return Number.isFinite(numeric) ? numeric : undefined;
|
|
272
|
+
};
|
|
273
|
+
/**
|
|
274
|
+
* Normalizes Plotly axis reference strings so equivalent aliases (e.g. `xaxis1`, `x1`) collapse to the base axis id.
|
|
275
|
+
*/
|
|
276
|
+
var normalizeAxisRef = function (ref, axis) {
|
|
277
|
+
if (!ref) {
|
|
278
|
+
return axis;
|
|
279
|
+
}
|
|
280
|
+
var normalized = ref.toLowerCase();
|
|
281
|
+
if (normalized === axis ||
|
|
282
|
+
normalized === "".concat(axis, "axis") ||
|
|
283
|
+
normalized === "".concat(axis, "axis1") ||
|
|
284
|
+
normalized === "".concat(axis, "1")) {
|
|
285
|
+
return axis;
|
|
286
|
+
}
|
|
287
|
+
var match = normalized.match(/^([xy])(axis)?(\d+)$/);
|
|
288
|
+
if (match && match[1] === axis && match[3]) {
|
|
289
|
+
return match[3] === '1' ? axis : "".concat(axis).concat(match[3]);
|
|
290
|
+
}
|
|
291
|
+
return normalized;
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* Scans the data traces bound to a given axis and returns the numeric min/max values plotted on that axis.
|
|
295
|
+
*/
|
|
296
|
+
var getAxisNumericRangeFromData = function (axis, ref, layout, data) {
|
|
297
|
+
if (!data || data.length === 0) {
|
|
298
|
+
return undefined;
|
|
299
|
+
}
|
|
300
|
+
var axisLayout = getAxisLayoutByRef(layout, ref, axis);
|
|
301
|
+
var targetRef = normalizeAxisRef(ref, axis);
|
|
302
|
+
var traceAxisKey = axis === 'x' ? 'xaxis' : 'yaxis';
|
|
303
|
+
var minValue;
|
|
304
|
+
var maxValue;
|
|
305
|
+
data.forEach(function (trace) {
|
|
306
|
+
var plotTrace = trace;
|
|
307
|
+
var traceAxisRef = normalizeAxisRef(plotTrace[traceAxisKey], axis);
|
|
308
|
+
if (traceAxisRef !== targetRef) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
var values = (axis === 'x' ? plotTrace.x : plotTrace.y);
|
|
312
|
+
if (!isArrayOrTypedArray(values)) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
var arrayLike = values;
|
|
316
|
+
for (var index = 0; index < arrayLike.length; index++) {
|
|
317
|
+
var value = arrayLike[index];
|
|
318
|
+
var numeric = toNumericValue(convertDataValue(value, axisLayout));
|
|
319
|
+
if (numeric === undefined || Number.isNaN(numeric)) {
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
minValue = minValue === undefined ? numeric : Math.min(minValue, numeric);
|
|
323
|
+
maxValue = maxValue === undefined ? numeric : Math.max(maxValue, numeric);
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
if (minValue === undefined || maxValue === undefined || minValue === maxValue) {
|
|
327
|
+
return undefined;
|
|
328
|
+
}
|
|
329
|
+
return [minValue, maxValue];
|
|
330
|
+
};
|
|
331
|
+
/**
|
|
332
|
+
* Converts Plotly's bottom-origin relative Y coordinate into the SVG top-origin space used by our overlay.
|
|
333
|
+
*/
|
|
334
|
+
var transformRelativeYForChart = function (value) {
|
|
335
|
+
if (value === undefined) {
|
|
336
|
+
return undefined;
|
|
337
|
+
}
|
|
338
|
+
if (!Number.isFinite(value)) {
|
|
339
|
+
return undefined;
|
|
340
|
+
}
|
|
341
|
+
return 1 - value;
|
|
342
|
+
};
|
|
343
|
+
var mapHorizontalAlign = function (anchor) {
|
|
344
|
+
switch ((anchor !== null && anchor !== void 0 ? anchor : '').toLowerCase()) {
|
|
345
|
+
case 'left':
|
|
346
|
+
return 'start';
|
|
347
|
+
case 'center':
|
|
348
|
+
return 'center';
|
|
349
|
+
case 'right':
|
|
350
|
+
return 'end';
|
|
351
|
+
default:
|
|
352
|
+
return undefined;
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
var mapVerticalAlign = function (anchor) {
|
|
356
|
+
switch ((anchor !== null && anchor !== void 0 ? anchor : '').toLowerCase()) {
|
|
357
|
+
case 'top':
|
|
358
|
+
return 'top';
|
|
359
|
+
case 'middle':
|
|
360
|
+
return 'middle';
|
|
361
|
+
case 'bottom':
|
|
362
|
+
return 'bottom';
|
|
363
|
+
default:
|
|
364
|
+
return undefined;
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
var appendPx = function (value) {
|
|
368
|
+
if (value === undefined || value === null) {
|
|
369
|
+
return undefined;
|
|
370
|
+
}
|
|
371
|
+
if (typeof value === 'string') {
|
|
372
|
+
return value;
|
|
373
|
+
}
|
|
374
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
375
|
+
return "".concat(value, "px");
|
|
376
|
+
}
|
|
377
|
+
return undefined;
|
|
378
|
+
};
|
|
379
|
+
/**
|
|
380
|
+
* Maps Plotly's axis reference string to one of our coordinate interpretation modes (axis, relative, or pixel).
|
|
381
|
+
*/
|
|
382
|
+
var resolveRefType = function (ref, axis) {
|
|
383
|
+
if (!ref) {
|
|
384
|
+
return 'axis';
|
|
385
|
+
}
|
|
386
|
+
var normalized = ref.toLowerCase();
|
|
387
|
+
if (normalized === 'pixel') {
|
|
388
|
+
return 'pixel';
|
|
389
|
+
}
|
|
390
|
+
if (normalized === 'paper') {
|
|
391
|
+
return 'relative';
|
|
392
|
+
}
|
|
393
|
+
if (normalized.endsWith(' domain')) {
|
|
394
|
+
return normalized.startsWith(axis) ? 'relative' : undefined;
|
|
395
|
+
}
|
|
396
|
+
var match = normalized.match(/^([xy])(\d*)$/);
|
|
397
|
+
if (match && match[1] === axis) {
|
|
398
|
+
return 'axis';
|
|
399
|
+
}
|
|
400
|
+
return undefined;
|
|
401
|
+
};
|
|
402
|
+
/**
|
|
403
|
+
* Retrieves the appropriate axis layout section from Plotly's layout given an axis reference alias.
|
|
404
|
+
*/
|
|
405
|
+
var getAxisLayoutByRef = function (layout, ref, axis) {
|
|
406
|
+
if (!layout) {
|
|
407
|
+
return undefined;
|
|
408
|
+
}
|
|
409
|
+
var defaultAxisKey = "".concat(axis, "axis");
|
|
410
|
+
if (!ref) {
|
|
411
|
+
return layout[defaultAxisKey];
|
|
412
|
+
}
|
|
413
|
+
var normalized = ref.toLowerCase();
|
|
414
|
+
if (normalized === 'paper' || normalized === 'pixel' || normalized.endsWith(' domain')) {
|
|
415
|
+
return layout[defaultAxisKey];
|
|
416
|
+
}
|
|
417
|
+
var match = normalized.match(/^([xy])(\d*)$/);
|
|
418
|
+
if (match && match[1] === axis) {
|
|
419
|
+
var index = match[2];
|
|
420
|
+
if (index && index !== '' && index !== '1') {
|
|
421
|
+
var axisKey = "".concat(axis, "axis").concat(index);
|
|
422
|
+
return layout[axisKey];
|
|
423
|
+
}
|
|
424
|
+
return layout[defaultAxisKey];
|
|
425
|
+
}
|
|
426
|
+
return layout[defaultAxisKey];
|
|
427
|
+
};
|
|
428
|
+
/**
|
|
429
|
+
* Normalizes raw Plotly data values into canonical number/date/string types based on axis configuration.
|
|
430
|
+
*/
|
|
431
|
+
var convertDataValue = function (value, axisLayout) {
|
|
432
|
+
if (value === undefined || value === null) {
|
|
433
|
+
return undefined;
|
|
434
|
+
}
|
|
435
|
+
if ((axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) === 'date' || isDate(value)) {
|
|
436
|
+
var dateValue = value instanceof Date ? value : new Date(value);
|
|
437
|
+
return Number.isNaN(dateValue.getTime()) ? undefined : dateValue;
|
|
438
|
+
}
|
|
439
|
+
if (typeof value === 'number') {
|
|
440
|
+
return value;
|
|
441
|
+
}
|
|
442
|
+
if ((axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) === 'linear' || (axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) === 'log') {
|
|
443
|
+
var numeric = Number(value);
|
|
444
|
+
return Number.isFinite(numeric) ? numeric : undefined;
|
|
445
|
+
}
|
|
446
|
+
if (value instanceof Date) {
|
|
447
|
+
return value;
|
|
448
|
+
}
|
|
449
|
+
return value;
|
|
450
|
+
};
|
|
451
|
+
var toNumericValue = function (value) {
|
|
452
|
+
if (value instanceof Date) {
|
|
453
|
+
var timestamp = value.getTime();
|
|
454
|
+
return Number.isFinite(timestamp) ? timestamp : undefined;
|
|
455
|
+
}
|
|
456
|
+
if (typeof value === 'number') {
|
|
457
|
+
return Number.isFinite(value) ? value : undefined;
|
|
458
|
+
}
|
|
459
|
+
if (typeof value === 'string') {
|
|
460
|
+
var numeric = Number(value);
|
|
461
|
+
return Number.isFinite(numeric) ? numeric : undefined;
|
|
462
|
+
}
|
|
463
|
+
return undefined;
|
|
464
|
+
};
|
|
465
|
+
var toRelativeCoordinate = function (value, axisLayout, fallbackRange) {
|
|
466
|
+
var range = Array.isArray(axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.range) ? axisLayout.range : undefined;
|
|
467
|
+
var start = range && range.length >= 2 ? toNumericValue(convertDataValue(range[0], axisLayout)) : undefined;
|
|
468
|
+
var end = range && range.length >= 2 ? toNumericValue(convertDataValue(range[1], axisLayout)) : undefined;
|
|
469
|
+
if ((start === undefined || end === undefined || start === end) && fallbackRange) {
|
|
470
|
+
start = fallbackRange[0], end = fallbackRange[1];
|
|
471
|
+
}
|
|
472
|
+
var current = toNumericValue(convertDataValue(value, axisLayout));
|
|
473
|
+
if (start === undefined || end === undefined || current === undefined || start === end) {
|
|
474
|
+
return undefined;
|
|
475
|
+
}
|
|
476
|
+
var relative = (current - start) / (end - start);
|
|
477
|
+
return Number.isFinite(relative) ? relative : undefined;
|
|
478
|
+
};
|
|
479
|
+
var createAnnotationId = function (text, index) {
|
|
480
|
+
var normalized = text.replace(/\s+/g, ' ').trim();
|
|
481
|
+
if (normalized) {
|
|
482
|
+
var slug = normalized
|
|
483
|
+
.toLowerCase()
|
|
484
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
485
|
+
.replace(/^-+|-+$/g, '')
|
|
486
|
+
.slice(0, 32);
|
|
487
|
+
if (slug) {
|
|
488
|
+
return "annotation-".concat(index, "-").concat(slug);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
return "annotation-".concat(index);
|
|
492
|
+
};
|
|
493
|
+
var DEFAULT_ARROW_OFFSET = -40;
|
|
494
|
+
var mapArrowsideToArrow = function (annotation) {
|
|
495
|
+
var includeStart = false;
|
|
496
|
+
var includeEnd = false;
|
|
497
|
+
var arrowSide = typeof (annotation === null || annotation === void 0 ? void 0 : annotation.arrowside) === 'string' ? annotation === null || annotation === void 0 ? void 0 : annotation.arrowside.toLowerCase() : undefined;
|
|
498
|
+
if (arrowSide) {
|
|
499
|
+
includeStart = arrowSide.includes('start');
|
|
500
|
+
includeEnd = arrowSide.includes('end');
|
|
501
|
+
}
|
|
502
|
+
var endHead = toFiniteNumber(annotation === null || annotation === void 0 ? void 0 : annotation.arrowhead);
|
|
503
|
+
var startHead = toFiniteNumber(annotation.startarrowhead);
|
|
504
|
+
if (endHead !== undefined && endHead > 0) {
|
|
505
|
+
includeEnd = true;
|
|
506
|
+
}
|
|
507
|
+
if (startHead !== undefined && startHead > 0) {
|
|
508
|
+
includeStart = true;
|
|
509
|
+
}
|
|
510
|
+
if (includeStart && includeEnd) {
|
|
511
|
+
return 'both';
|
|
512
|
+
}
|
|
513
|
+
if (includeStart) {
|
|
514
|
+
return 'start';
|
|
515
|
+
}
|
|
516
|
+
if (includeEnd) {
|
|
517
|
+
return 'end';
|
|
518
|
+
}
|
|
519
|
+
return 'none';
|
|
520
|
+
};
|
|
521
|
+
var mapArrowDashToPattern = function (value) {
|
|
522
|
+
if (!value) {
|
|
523
|
+
return undefined;
|
|
524
|
+
}
|
|
525
|
+
var normalized = value.trim().toLowerCase();
|
|
526
|
+
switch (normalized) {
|
|
527
|
+
case 'solid':
|
|
528
|
+
return undefined;
|
|
529
|
+
case 'dot':
|
|
530
|
+
return '1, 5';
|
|
531
|
+
case 'dash':
|
|
532
|
+
return '5, 5';
|
|
533
|
+
case 'longdash':
|
|
534
|
+
return '10, 5';
|
|
535
|
+
case 'dashdot':
|
|
536
|
+
return '5, 5, 1, 5';
|
|
537
|
+
case 'longdashdot':
|
|
538
|
+
return '10, 5, 1, 5';
|
|
539
|
+
default:
|
|
540
|
+
if (/^\d+(\s|,)*\d*$/.test(normalized.replace(/\s+/g, ' '))) {
|
|
541
|
+
return normalized.replace(/\s+/g, ' ');
|
|
542
|
+
}
|
|
543
|
+
return value;
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
/**
|
|
547
|
+
* Converts a Plotly annotation definition into the internal `ChartAnnotation` format, translating coordinates,
|
|
548
|
+
* layout alignment, styling, and connector metadata while skipping unsupported configurations.
|
|
549
|
+
*/
|
|
550
|
+
var convertPlotlyAnnotation = function (annotation, layout, data, index) {
|
|
551
|
+
var _a;
|
|
552
|
+
if (!annotation || annotation.visible === false) {
|
|
553
|
+
return undefined;
|
|
554
|
+
}
|
|
555
|
+
var xRefType = resolveRefType(annotation.xref, 'x');
|
|
556
|
+
var yRefType = resolveRefType(annotation.yref, 'y');
|
|
557
|
+
if (!xRefType || !yRefType) {
|
|
558
|
+
return undefined;
|
|
559
|
+
}
|
|
560
|
+
var coordinates;
|
|
561
|
+
if (xRefType === 'axis' && yRefType === 'axis') {
|
|
562
|
+
var xAxisLayout = getAxisLayoutByRef(layout, annotation.xref, 'x');
|
|
563
|
+
var yAxisLayout = getAxisLayoutByRef(layout, annotation.yref, 'y');
|
|
564
|
+
var xValue = convertDataValue(annotation.x, xAxisLayout);
|
|
565
|
+
var yValue = convertDataValue(annotation.y, yAxisLayout);
|
|
566
|
+
if (xValue === undefined || yValue === undefined) {
|
|
567
|
+
return undefined;
|
|
568
|
+
}
|
|
569
|
+
var yRefNormalized = typeof annotation.yref === 'string' ? annotation.yref.toLowerCase() : undefined;
|
|
570
|
+
coordinates = __assign({ type: 'data', x: xValue, y: yValue }, (yRefNormalized === 'y2' ? { yAxis: 'secondary' } : {}));
|
|
571
|
+
}
|
|
572
|
+
else if (xRefType === 'relative' && yRefType === 'relative') {
|
|
573
|
+
var xValue = toFiniteNumber(annotation.x);
|
|
574
|
+
var yValue = toFiniteNumber(annotation.y);
|
|
575
|
+
var chartRelativeY = transformRelativeYForChart(yValue);
|
|
576
|
+
if (xValue === undefined || chartRelativeY === undefined) {
|
|
577
|
+
return undefined;
|
|
578
|
+
}
|
|
579
|
+
coordinates = {
|
|
580
|
+
type: 'relative',
|
|
581
|
+
x: xValue,
|
|
582
|
+
y: chartRelativeY,
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
else if (xRefType === 'relative' && yRefType === 'axis') {
|
|
586
|
+
var xValue = toFiniteNumber(annotation.x);
|
|
587
|
+
var yAxisLayout = getAxisLayoutByRef(layout, annotation.yref, 'y');
|
|
588
|
+
var yFallbackRange = getAxisNumericRangeFromData('y', annotation.yref, layout, data);
|
|
589
|
+
var yRelative = toRelativeCoordinate(annotation.y, yAxisLayout, yFallbackRange);
|
|
590
|
+
var chartRelativeY = transformRelativeYForChart(yRelative);
|
|
591
|
+
if (xValue === undefined || chartRelativeY === undefined) {
|
|
592
|
+
return undefined;
|
|
593
|
+
}
|
|
594
|
+
coordinates = {
|
|
595
|
+
type: 'relative',
|
|
596
|
+
x: xValue,
|
|
597
|
+
y: chartRelativeY,
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
else if (xRefType === 'axis' && yRefType === 'relative') {
|
|
601
|
+
var yValue = toFiniteNumber(annotation.y);
|
|
602
|
+
var xAxisLayout = getAxisLayoutByRef(layout, annotation.xref, 'x');
|
|
603
|
+
var xFallbackRange = getAxisNumericRangeFromData('x', annotation.xref, layout, data);
|
|
604
|
+
var xRelative = toRelativeCoordinate(annotation.x, xAxisLayout, xFallbackRange);
|
|
605
|
+
var chartRelativeY = transformRelativeYForChart(yValue);
|
|
606
|
+
if (xRelative === undefined || chartRelativeY === undefined) {
|
|
607
|
+
return undefined;
|
|
608
|
+
}
|
|
609
|
+
coordinates = {
|
|
610
|
+
type: 'relative',
|
|
611
|
+
x: xRelative,
|
|
612
|
+
y: chartRelativeY,
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
else if (xRefType === 'pixel' && yRefType === 'pixel') {
|
|
616
|
+
var xValue = toFiniteNumber(annotation.x);
|
|
617
|
+
var yValue = toFiniteNumber(annotation.y);
|
|
618
|
+
if (xValue === undefined || yValue === undefined) {
|
|
619
|
+
return undefined;
|
|
620
|
+
}
|
|
621
|
+
coordinates = {
|
|
622
|
+
type: 'pixel',
|
|
623
|
+
x: xValue,
|
|
624
|
+
y: yValue,
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
else {
|
|
628
|
+
return undefined;
|
|
629
|
+
}
|
|
630
|
+
var textValue = annotation.text;
|
|
631
|
+
var rawText = textValue === undefined || textValue === null ? '' : String(textValue);
|
|
632
|
+
var encodedText = encodeHtmlEntities(rawText);
|
|
633
|
+
var chartAnnotation = {
|
|
634
|
+
id: createAnnotationId(encodedText, index),
|
|
635
|
+
text: encodedText,
|
|
636
|
+
coordinates: coordinates,
|
|
637
|
+
};
|
|
638
|
+
var layoutProps = {};
|
|
639
|
+
var styleProps = {};
|
|
640
|
+
var showArrow = annotation.showarrow === undefined ? false : !!annotation.showarrow;
|
|
641
|
+
var clipOnAxis = annotation.cliponaxis;
|
|
642
|
+
if (clipOnAxis !== undefined) {
|
|
643
|
+
layoutProps.clipToBounds = !!clipOnAxis;
|
|
644
|
+
}
|
|
645
|
+
else if (coordinates.type === 'data') {
|
|
646
|
+
layoutProps.clipToBounds = true;
|
|
647
|
+
}
|
|
648
|
+
var horizontalAlign = mapHorizontalAlign(annotation.xanchor);
|
|
649
|
+
if (horizontalAlign) {
|
|
650
|
+
layoutProps.align = horizontalAlign;
|
|
651
|
+
}
|
|
652
|
+
if (!layoutProps.align) {
|
|
653
|
+
var alignProp = mapHorizontalAlign(annotation.align);
|
|
654
|
+
if (alignProp) {
|
|
655
|
+
layoutProps.align = alignProp;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
var verticalAlign = mapVerticalAlign(annotation.yanchor);
|
|
659
|
+
if (verticalAlign) {
|
|
660
|
+
layoutProps.verticalAlign = verticalAlign;
|
|
661
|
+
}
|
|
662
|
+
if (!layoutProps.verticalAlign) {
|
|
663
|
+
var valignProp = mapVerticalAlign(annotation.valign);
|
|
664
|
+
if (valignProp) {
|
|
665
|
+
layoutProps.verticalAlign = valignProp;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
var offsetXComponents = [];
|
|
669
|
+
var hasExplicitOffset = false;
|
|
670
|
+
var ax = toFiniteNumber(annotation.ax);
|
|
671
|
+
var axRef = typeof annotation.axref === 'string' ? annotation.axref.toLowerCase() : undefined;
|
|
672
|
+
if (ax !== undefined && (axRef === undefined || axRef === 'pixel')) {
|
|
673
|
+
offsetXComponents.push(ax);
|
|
674
|
+
hasExplicitOffset = true;
|
|
675
|
+
}
|
|
676
|
+
var xShift = toFiniteNumber(annotation.xshift);
|
|
677
|
+
if (xShift !== undefined) {
|
|
678
|
+
offsetXComponents.push(xShift);
|
|
679
|
+
hasExplicitOffset = true;
|
|
680
|
+
}
|
|
681
|
+
if (offsetXComponents.length > 0) {
|
|
682
|
+
var offsetX = offsetXComponents.reduce(function (sum, value) { return sum + value; }, 0);
|
|
683
|
+
if (offsetX !== 0) {
|
|
684
|
+
layoutProps.offsetX = offsetX;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
var offsetYComponents = [];
|
|
688
|
+
var ay = toFiniteNumber(annotation.ay);
|
|
689
|
+
var ayRef = typeof annotation.ayref === 'string' ? annotation.ayref.toLowerCase() : undefined;
|
|
690
|
+
if (ay !== undefined && (ayRef === undefined || ayRef === 'pixel')) {
|
|
691
|
+
offsetYComponents.push(ay);
|
|
692
|
+
hasExplicitOffset = true;
|
|
693
|
+
}
|
|
694
|
+
var yShift = toFiniteNumber(annotation.yshift);
|
|
695
|
+
if (yShift !== undefined) {
|
|
696
|
+
offsetYComponents.push(yShift);
|
|
697
|
+
hasExplicitOffset = true;
|
|
698
|
+
}
|
|
699
|
+
if (offsetYComponents.length > 0) {
|
|
700
|
+
var offsetY = offsetYComponents.reduce(function (sum, value) { return sum + value; }, 0);
|
|
701
|
+
if (offsetY !== 0) {
|
|
702
|
+
layoutProps.offsetY = offsetY;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
if (showArrow && !hasExplicitOffset && layoutProps.offsetY === undefined) {
|
|
706
|
+
layoutProps.offsetY = DEFAULT_ARROW_OFFSET;
|
|
707
|
+
}
|
|
708
|
+
var maxWidth = toFiniteNumber(annotation.width);
|
|
709
|
+
if (maxWidth !== undefined) {
|
|
710
|
+
layoutProps.maxWidth = maxWidth;
|
|
711
|
+
}
|
|
712
|
+
if (annotation.bgcolor) {
|
|
713
|
+
styleProps.backgroundColor = annotation.bgcolor;
|
|
714
|
+
}
|
|
715
|
+
if (annotation.bordercolor) {
|
|
716
|
+
styleProps.borderColor = annotation.bordercolor;
|
|
717
|
+
}
|
|
718
|
+
var borderWidth = toFiniteNumber(annotation.borderwidth);
|
|
719
|
+
if (borderWidth !== undefined) {
|
|
720
|
+
styleProps.borderWidth = borderWidth;
|
|
721
|
+
}
|
|
722
|
+
var borderPad = appendPx(annotation.borderpad);
|
|
723
|
+
if (borderPad) {
|
|
724
|
+
styleProps.padding = borderPad;
|
|
725
|
+
}
|
|
726
|
+
var opacity = toFiniteNumber(annotation.opacity);
|
|
727
|
+
if (opacity !== undefined) {
|
|
728
|
+
styleProps.opacity = opacity;
|
|
729
|
+
}
|
|
730
|
+
if (annotation.font) {
|
|
731
|
+
var font = annotation.font;
|
|
732
|
+
if (font === null || font === void 0 ? void 0 : font.color) {
|
|
733
|
+
styleProps.textColor = font.color;
|
|
734
|
+
}
|
|
735
|
+
var fontSize = appendPx(font === null || font === void 0 ? void 0 : font.size);
|
|
736
|
+
if (fontSize) {
|
|
737
|
+
styleProps.fontSize = fontSize;
|
|
738
|
+
}
|
|
739
|
+
if (font === null || font === void 0 ? void 0 : font.weight) {
|
|
740
|
+
styleProps.fontWeight = font.weight;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
if (Object.keys(layoutProps).length > 0) {
|
|
744
|
+
chartAnnotation.layout = layoutProps;
|
|
745
|
+
}
|
|
746
|
+
if (Object.keys(styleProps).length > 0) {
|
|
747
|
+
chartAnnotation.style = styleProps;
|
|
748
|
+
}
|
|
749
|
+
if (showArrow) {
|
|
750
|
+
var arrowColor = (_a = annotation.arrowcolor) !== null && _a !== void 0 ? _a : styleProps.textColor;
|
|
751
|
+
var arrowWidth = toFiniteNumber(annotation.arrowwidth);
|
|
752
|
+
var endPadding = toFiniteNumber(annotation.standoff);
|
|
753
|
+
var startPadding = toFiniteNumber(annotation.startstandoff);
|
|
754
|
+
var dashPattern = mapArrowDashToPattern(annotation.arrowdash);
|
|
755
|
+
chartAnnotation.connector = __assign(__assign(__assign(__assign(__assign(__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) });
|
|
756
|
+
}
|
|
757
|
+
return chartAnnotation;
|
|
758
|
+
};
|
|
759
|
+
var getChartAnnotationsFromLayout = function (layout, data, isMultiPlot) {
|
|
760
|
+
if (isMultiPlot || !(layout === null || layout === void 0 ? void 0 : layout.annotations)) {
|
|
761
|
+
return undefined;
|
|
762
|
+
}
|
|
763
|
+
var annotationsArray = Array.isArray(layout.annotations) ? layout.annotations : [layout.annotations];
|
|
764
|
+
var converted = annotationsArray
|
|
765
|
+
.map(function (annotation, index) { return convertPlotlyAnnotation(annotation, layout, data, index); })
|
|
766
|
+
.filter(function (annotation) { return annotation !== undefined; });
|
|
767
|
+
return converted.length > 0 ? converted : undefined;
|
|
768
|
+
};
|
|
258
769
|
/**
|
|
259
770
|
* Normalizes an array of objects by flattening nested structures and creating grouped data
|
|
260
771
|
* Uses json_normalize approach with D3 color detection and filtering
|
|
@@ -417,7 +928,7 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
|
|
|
417
928
|
var _j = getLegendProps(input.data, input.layout, isMultiPlot), legends = _j.legends, hideLegend = _j.hideLegend;
|
|
418
929
|
var colorScale = undefined;
|
|
419
930
|
var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
420
|
-
var
|
|
931
|
+
var resolveXValue = getAxisValueResolver(getAxisType(input.data, getAxisObjects(input.data, input.layout).x));
|
|
421
932
|
input.data.forEach(function (series, index1) {
|
|
422
933
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
423
934
|
colorScale = createColorScale(input.layout, series, colorScale);
|
|
@@ -425,7 +936,7 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
|
|
|
425
936
|
var extractedBarColors = extractColor((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.template) === null || _b === void 0 ? void 0 : _b.layout) === null || _c === void 0 ? void 0 : _c.colorway, colorwayType, (_d = series.marker) === null || _d === void 0 ? void 0 : _d.color, colorMap, isDarkTheme);
|
|
426
937
|
// extract line colors for each series only once
|
|
427
938
|
var extractedLineColors = 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);
|
|
428
|
-
var validXYRanges = getValidXYRanges(series,
|
|
939
|
+
var validXYRanges = getValidXYRanges(series, resolveXValue);
|
|
429
940
|
validXYRanges.forEach(function (_a, rangeIdx) {
|
|
430
941
|
var rangeStart = _a[0], rangeEnd = _a[1];
|
|
431
942
|
var rangeXValues = series.x.slice(rangeStart, rangeEnd);
|
|
@@ -434,7 +945,7 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
|
|
|
434
945
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
435
946
|
if (!mapXToDataPoints[x]) {
|
|
436
947
|
mapXToDataPoints[x] = {
|
|
437
|
-
xAxisPoint:
|
|
948
|
+
xAxisPoint: resolveXValue(x),
|
|
438
949
|
chartData: [],
|
|
439
950
|
lineData: [],
|
|
440
951
|
};
|
|
@@ -487,7 +998,6 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
|
|
|
487
998
|
.forEach(function (shape, shapeIdx) {
|
|
488
999
|
var _a, _b, _c;
|
|
489
1000
|
var lineColor = (_a = shape.line) === null || _a === void 0 ? void 0 : _a.color;
|
|
490
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
491
1001
|
var resolveX = function (val) {
|
|
492
1002
|
if (typeof val === 'number' && Array.isArray(xCategories) && xCategories[val] !== undefined) {
|
|
493
1003
|
return xCategories[val];
|
|
@@ -496,7 +1006,6 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
|
|
|
496
1006
|
};
|
|
497
1007
|
var x0Key = resolveX(shape.x0);
|
|
498
1008
|
var x1Key = resolveX(shape.x1);
|
|
499
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
500
1009
|
var resolveY = function (val) {
|
|
501
1010
|
if (shape.yref === 'paper') {
|
|
502
1011
|
if (val === 0) {
|
|
@@ -505,7 +1014,10 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
|
|
|
505
1014
|
if (val === 1) {
|
|
506
1015
|
return yMaxValue;
|
|
507
1016
|
}
|
|
508
|
-
|
|
1017
|
+
if (typeof val === 'number') {
|
|
1018
|
+
return yMinValue + val * (yMaxValue - yMinValue);
|
|
1019
|
+
}
|
|
1020
|
+
return val;
|
|
509
1021
|
}
|
|
510
1022
|
return val;
|
|
511
1023
|
};
|
|
@@ -527,7 +1039,8 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
|
|
|
527
1039
|
});
|
|
528
1040
|
});
|
|
529
1041
|
var vsbcData = Object.values(mapXToDataPoints);
|
|
530
|
-
|
|
1042
|
+
var annotations = getChartAnnotationsFromLayout(input.layout, input.data, isMultiPlot);
|
|
1043
|
+
return __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__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 } : {}));
|
|
531
1044
|
};
|
|
532
1045
|
export var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
533
1046
|
var _a, _b, _c;
|
|
@@ -625,7 +1138,8 @@ export var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorM
|
|
|
625
1138
|
});
|
|
626
1139
|
}
|
|
627
1140
|
});
|
|
628
|
-
|
|
1141
|
+
var annotations = getChartAnnotationsFromLayout(processedInput.layout, processedInput.data, isMultiPlot);
|
|
1142
|
+
return __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__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 } : {}));
|
|
629
1143
|
};
|
|
630
1144
|
export var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
631
1145
|
var _a, _b, _c, _d;
|
|
@@ -684,7 +1198,8 @@ export var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMa
|
|
|
684
1198
|
: { xAxisCalloutData: "[".concat(bin.x0, " - ").concat(bin.x1, ")") })));
|
|
685
1199
|
});
|
|
686
1200
|
});
|
|
687
|
-
|
|
1201
|
+
var annotations = getChartAnnotationsFromLayout(input.layout, input.data, isMultiPlot);
|
|
1202
|
+
return __assign(__assign(__assign(__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
|
export var transformPlotlyJsonToAreaChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
690
1205
|
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'area', colorMap, colorwayType, isDarkTheme);
|
|
@@ -695,7 +1210,6 @@ export var transformPlotlyJsonToLineChartProps = function (input, isMultiPlot, c
|
|
|
695
1210
|
export var transformPlotlyJsonToScatterChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
696
1211
|
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
|
|
697
1212
|
};
|
|
698
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
699
1213
|
var mapColorFillBars = function (layout) {
|
|
700
1214
|
if (!Array.isArray(layout === null || layout === void 0 ? void 0 : layout.shapes)) {
|
|
701
1215
|
return [];
|
|
@@ -715,7 +1229,7 @@ var mapColorFillBars = function (layout) {
|
|
|
715
1229
|
});
|
|
716
1230
|
};
|
|
717
1231
|
var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme) {
|
|
718
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1232
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
719
1233
|
var isScatterMarkers = [
|
|
720
1234
|
'text',
|
|
721
1235
|
'markers',
|
|
@@ -730,10 +1244,11 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
|
|
|
730
1244
|
var isScatterChart = chartType === 'scatter';
|
|
731
1245
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
732
1246
|
var mode = 'tonexty';
|
|
733
|
-
var
|
|
1247
|
+
var _q = getLegendProps(input.data, input.layout, isMultiPlot), legends = _q.legends, hideLegend = _q.hideLegend;
|
|
734
1248
|
var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
735
|
-
var
|
|
736
|
-
var
|
|
1249
|
+
var xAxisType = getAxisType(input.data, getAxisObjects(input.data, input.layout).x);
|
|
1250
|
+
var resolveXValue = getAxisValueResolver(xAxisType);
|
|
1251
|
+
var shouldWrapLabels = xAxisType === 'category';
|
|
737
1252
|
var chartData = input.data
|
|
738
1253
|
.map(function (series, index) {
|
|
739
1254
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
@@ -753,7 +1268,7 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
|
|
|
753
1268
|
// if mode contains 'text', we prioritize showing the text over curving the line
|
|
754
1269
|
var lineOptions = !((_l = series.mode) === null || _l === void 0 ? void 0 : _l.includes('text')) && series.type !== 'scatterpolar' ? getLineOptions(series.line) : undefined;
|
|
755
1270
|
var legendShape = getLegendShape(series);
|
|
756
|
-
var validXYRanges = getValidXYRanges(series,
|
|
1271
|
+
var validXYRanges = getValidXYRanges(series, resolveXValue);
|
|
757
1272
|
return validXYRanges.map(function (_a, rangeIdx) {
|
|
758
1273
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
759
1274
|
var rangeStart = _a[0], rangeEnd = _a[1];
|
|
@@ -773,7 +1288,7 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
|
|
|
773
1288
|
legendShape: legendShape,
|
|
774
1289
|
data: rangeXValues.map(function (x, i) {
|
|
775
1290
|
var _a, _b;
|
|
776
|
-
return (__assign(__assign(__assign(__assign({ x:
|
|
1291
|
+
return (__assign(__assign(__assign(__assign({ x: resolveXValue(x), y: rangeYValues[i] }, (Array.isArray((_a = series.marker) === null || _a === void 0 ? void 0 : _a.size)
|
|
777
1292
|
? { markerSize: markerSizes[i] }
|
|
778
1293
|
: typeof ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size) === 'number'
|
|
779
1294
|
? { markerSize: series.marker.size }
|
|
@@ -796,16 +1311,49 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
|
|
|
796
1311
|
});
|
|
797
1312
|
})
|
|
798
1313
|
.flat();
|
|
799
|
-
var
|
|
1314
|
+
var xMinValue = (_c = (_b = chartData[0]) === null || _b === void 0 ? void 0 : _b.data[0]) === null || _c === void 0 ? void 0 : _c.x;
|
|
1315
|
+
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;
|
|
1316
|
+
var yMinValue = (_g = (_f = chartData[0]) === null || _f === void 0 ? void 0 : _f.data[0]) === null || _g === void 0 ? void 0 : _g.y;
|
|
1317
|
+
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;
|
|
1318
|
+
var lineShape = ((_l = (_k = input.layout) === null || _k === void 0 ? void 0 : _k.shapes) !== null && _l !== void 0 ? _l : [])
|
|
800
1319
|
.filter(function (shape) { return shape.type === 'line'; })
|
|
801
1320
|
.map(function (shape, shapeIdx) {
|
|
802
1321
|
var _a, _b;
|
|
803
1322
|
var lineColor = (_a = shape.line) === null || _a === void 0 ? void 0 : _a.color;
|
|
1323
|
+
var resolveX = function (val) {
|
|
1324
|
+
if (shape.xref === 'paper') {
|
|
1325
|
+
if (val === 0) {
|
|
1326
|
+
return xMinValue;
|
|
1327
|
+
}
|
|
1328
|
+
if (val === 1) {
|
|
1329
|
+
return xMaxValue;
|
|
1330
|
+
}
|
|
1331
|
+
return typeof xMinValue === 'number' && typeof xMaxValue === 'number' && typeof val === 'number'
|
|
1332
|
+
? xMinValue + val * (xMaxValue - xMinValue)
|
|
1333
|
+
: val;
|
|
1334
|
+
}
|
|
1335
|
+
return val;
|
|
1336
|
+
};
|
|
1337
|
+
var resolveY = function (val) {
|
|
1338
|
+
if (shape.yref === 'paper') {
|
|
1339
|
+
if (val === 0) {
|
|
1340
|
+
return yMinValue;
|
|
1341
|
+
}
|
|
1342
|
+
if (val === 1) {
|
|
1343
|
+
return yMaxValue;
|
|
1344
|
+
}
|
|
1345
|
+
if (typeof val === 'number') {
|
|
1346
|
+
return yMinValue + val * (yMaxValue - yMinValue);
|
|
1347
|
+
}
|
|
1348
|
+
return val;
|
|
1349
|
+
}
|
|
1350
|
+
return val;
|
|
1351
|
+
};
|
|
804
1352
|
return {
|
|
805
1353
|
legend: "Reference_".concat(shapeIdx),
|
|
806
1354
|
data: [
|
|
807
|
-
{ x: shape.x0, y: shape.y0 },
|
|
808
|
-
{ x: shape.x1, y: shape.y1 },
|
|
1355
|
+
{ x: resolveX(shape.x0), y: resolveY(shape.y0) },
|
|
1356
|
+
{ x: resolveX(shape.x1), y: resolveY(shape.y1) },
|
|
809
1357
|
],
|
|
810
1358
|
color: (_b = rgb(lineColor).formatHex8()) !== null && _b !== void 0 ? _b : lineColor,
|
|
811
1359
|
lineOptions: getLineOptions(shape.line),
|
|
@@ -825,15 +1373,18 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
|
|
|
825
1373
|
var scatterChartProps = {
|
|
826
1374
|
scatterChartData: chartData,
|
|
827
1375
|
};
|
|
828
|
-
var
|
|
1376
|
+
var annotations = getChartAnnotationsFromLayout(input.layout, input.data, isMultiPlot);
|
|
1377
|
+
var commonProps = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__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 } : {}));
|
|
829
1378
|
if (isAreaChart) {
|
|
830
1379
|
return __assign({ data: chartProps, mode: mode }, commonProps);
|
|
831
1380
|
}
|
|
832
1381
|
else {
|
|
833
1382
|
return __assign(__assign(__assign(__assign({ data: isScatterChart ? scatterChartProps : chartProps, roundedTicks: true, enableReflow: false }, commonProps), yMinMax), (isScatterChart
|
|
834
|
-
? __assign({ showYAxisLablesTooltip: true }, getAxisCategoryOrderProps(input.data, input.layout)) : {})), (!isScatterChart &&
|
|
835
|
-
|
|
836
|
-
|
|
1383
|
+
? __assign({ showYAxisLablesTooltip: true }, getAxisCategoryOrderProps(input.data, input.layout)) : {})), (!isScatterChart &&
|
|
1384
|
+
(function () {
|
|
1385
|
+
var bars = mapColorFillBars(input.layout);
|
|
1386
|
+
return bars && !bars.includes(null) ? { colorFillBars: bars } : {};
|
|
1387
|
+
})()));
|
|
837
1388
|
}
|
|
838
1389
|
};
|
|
839
1390
|
export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -884,49 +1435,71 @@ export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, is
|
|
|
884
1435
|
};
|
|
885
1436
|
export var transformPlotlyJsonToGanttChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
886
1437
|
var _a, _b, _c;
|
|
887
|
-
var
|
|
1438
|
+
var data = input.data.filter(function (series) { return series.type !== 'scatter' || series.mode !== 'markers'; });
|
|
1439
|
+
var _d = getLegendProps(data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
888
1440
|
var colorScale = undefined;
|
|
889
|
-
var
|
|
890
|
-
var
|
|
891
|
-
|
|
1441
|
+
var xAxisType = getAxisType(data, getAxisObjects(data, input.layout).x);
|
|
1442
|
+
var resolveXValue = getAxisValueResolver(xAxisType, parseLocalDate);
|
|
1443
|
+
var resolveGanttXValue = function (value) {
|
|
1444
|
+
var resolvedValue = resolveXValue(value);
|
|
1445
|
+
return typeof resolvedValue === 'string' ? 0 : resolvedValue !== null && resolvedValue !== void 0 ? resolvedValue : 0;
|
|
1446
|
+
};
|
|
1447
|
+
var isXDate = xAxisType === 'date';
|
|
1448
|
+
var ganttData = [];
|
|
1449
|
+
data.forEach(function (series, index) {
|
|
892
1450
|
var _a, _b, _c, _d;
|
|
893
|
-
colorScale = createColorScale(input.layout, series, colorScale);
|
|
894
|
-
// extract colors for each series only once
|
|
895
|
-
var extractedColors = 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);
|
|
896
1451
|
var legend = legends[index];
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
1452
|
+
if (series.type === 'bar') {
|
|
1453
|
+
colorScale = createColorScale(input.layout, series, colorScale);
|
|
1454
|
+
// extract colors for each series only once
|
|
1455
|
+
var extractedColors_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);
|
|
1456
|
+
series.y.forEach(function (yVal, i) {
|
|
1457
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1458
|
+
if (isInvalidValue(yVal)) {
|
|
1459
|
+
return;
|
|
1460
|
+
}
|
|
1461
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
1462
|
+
var color = colorScale
|
|
1463
|
+
? colorScale(isArrayOrTypedArray((_a = series.marker) === null || _a === void 0 ? void 0 : _a.color)
|
|
1464
|
+
? (_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]
|
|
1465
|
+
: 0)
|
|
1466
|
+
: 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);
|
|
1467
|
+
var opacity = getOpacity(series, i);
|
|
1468
|
+
var base = +resolveGanttXValue((_h = series.base) === null || _h === void 0 ? void 0 : _h[i]);
|
|
1469
|
+
var xVal = +resolveGanttXValue((_j = series.x) === null || _j === void 0 ? void 0 : _j[i]);
|
|
1470
|
+
ganttData.push({
|
|
1471
|
+
x: {
|
|
1472
|
+
start: isXDate ? new Date(base) : base,
|
|
1473
|
+
end: isXDate ? new Date(base + xVal) : base + xVal,
|
|
1474
|
+
},
|
|
1475
|
+
y: yVal,
|
|
1476
|
+
legend: legend,
|
|
1477
|
+
color: (_k = rgb(color).copy({ opacity: opacity }).formatHex8()) !== null && _k !== void 0 ? _k : color,
|
|
1478
|
+
});
|
|
1479
|
+
});
|
|
1480
|
+
}
|
|
1481
|
+
else if (series.type === 'scatter' && series.mode === 'none' && series.fill === 'toself') {
|
|
1482
|
+
for (var i = 0; i < series.y.length; i += 5) {
|
|
1483
|
+
if (isInvalidValue(series.y[i]) || isInvalidValue(series.y[i + 3])) {
|
|
1484
|
+
continue;
|
|
1485
|
+
}
|
|
1486
|
+
var x0 = resolveGanttXValue(series.x[i]);
|
|
1487
|
+
var x1 = resolveGanttXValue(series.x[i + 1]);
|
|
1488
|
+
var y0 = series.y[i];
|
|
1489
|
+
var y1 = series.y[i + 3];
|
|
1490
|
+
ganttData.push({
|
|
1491
|
+
x: {
|
|
1492
|
+
start: x0,
|
|
1493
|
+
end: x1,
|
|
1494
|
+
},
|
|
1495
|
+
y: Math.round((y0 + y1) / 2),
|
|
1496
|
+
legend: legend,
|
|
1497
|
+
color: series.fillcolor,
|
|
1498
|
+
});
|
|
906
1499
|
}
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
? (_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]
|
|
911
|
-
: 0)
|
|
912
|
-
: 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);
|
|
913
|
-
var opacity = getOpacity(series, i);
|
|
914
|
-
var base = convertXValueToNumber((_h = series.base) === null || _h === void 0 ? void 0 : _h[i]);
|
|
915
|
-
var xVal = convertXValueToNumber((_j = series.x) === null || _j === void 0 ? void 0 : _j[i]);
|
|
916
|
-
return {
|
|
917
|
-
x: {
|
|
918
|
-
start: isXDate ? new Date(base) : base,
|
|
919
|
-
end: isXDate ? new Date(base + xVal) : base + xVal,
|
|
920
|
-
},
|
|
921
|
-
y: yVal,
|
|
922
|
-
legend: legend,
|
|
923
|
-
color: (_k = rgb(color).copy({ opacity: opacity }).formatHex8()) !== null && _k !== void 0 ? _k : color,
|
|
924
|
-
};
|
|
925
|
-
})
|
|
926
|
-
.filter(function (point) { return point !== null; });
|
|
927
|
-
})
|
|
928
|
-
.flat();
|
|
929
|
-
return __assign(__assign(__assign(__assign({ data: chartData, showYAxisLables: true, height: (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 350, width: (_c = input.layout) === null || _c === void 0 ? void 0 : _c.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true, useUTC: false }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getBarProps(input.data, input.layout, true)), getAxisTickProps(input.data, input.layout));
|
|
1500
|
+
}
|
|
1501
|
+
});
|
|
1502
|
+
return __assign(__assign(__assign(__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));
|
|
930
1503
|
};
|
|
931
1504
|
export var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
932
1505
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
|
|
@@ -2099,9 +2672,15 @@ var getAxisTickProps = function (data, layout) {
|
|
|
2099
2672
|
var tickValues = axType === 'date' ? ax.tickvals.map(function (v) { return new Date(v); }) : ax.tickvals;
|
|
2100
2673
|
if (axId === 'x') {
|
|
2101
2674
|
props.tickValues = tickValues;
|
|
2675
|
+
props.xAxis = {
|
|
2676
|
+
tickText: ax.ticktext,
|
|
2677
|
+
};
|
|
2102
2678
|
}
|
|
2103
2679
|
else if (axId === 'y') {
|
|
2104
2680
|
props.yAxisTickValues = tickValues;
|
|
2681
|
+
props.yAxis = {
|
|
2682
|
+
tickText: ax.ticktext,
|
|
2683
|
+
};
|
|
2105
2684
|
}
|
|
2106
2685
|
return;
|
|
2107
2686
|
}
|
|
@@ -2215,16 +2794,8 @@ var getAxisObjects = function (data, layout) {
|
|
|
2215
2794
|
}
|
|
2216
2795
|
return axisObjects;
|
|
2217
2796
|
};
|
|
2218
|
-
function
|
|
2797
|
+
var getAxisType = function (data, ax) {
|
|
2219
2798
|
var _a;
|
|
2220
|
-
var ax;
|
|
2221
|
-
if (arg2 && typeof arg2 === 'object' && '_id' in arg2) {
|
|
2222
|
-
ax = arg2;
|
|
2223
|
-
}
|
|
2224
|
-
else if (typeof arg3 === 'string') {
|
|
2225
|
-
var layout = arg2;
|
|
2226
|
-
ax = getAxisObjects(data, layout)[arg3];
|
|
2227
|
-
}
|
|
2228
2799
|
if (!ax) {
|
|
2229
2800
|
return 'category';
|
|
2230
2801
|
}
|
|
@@ -2251,9 +2822,12 @@ function getAxisType(data, arg2, arg3) {
|
|
|
2251
2822
|
return 'date';
|
|
2252
2823
|
}
|
|
2253
2824
|
return 'category';
|
|
2254
|
-
}
|
|
2255
|
-
var getAxisValueResolver = function (
|
|
2256
|
-
var
|
|
2825
|
+
};
|
|
2826
|
+
var getAxisValueResolver = function (axType, dateParser) {
|
|
2827
|
+
var toDate = function (value) {
|
|
2828
|
+
var date = dateParser ? dateParser(value) : new Date(value);
|
|
2829
|
+
return isNaN(date.getTime()) ? null : date;
|
|
2830
|
+
};
|
|
2257
2831
|
return function (value) {
|
|
2258
2832
|
if (isInvalidValue(value)) {
|
|
2259
2833
|
return null;
|
|
@@ -2264,10 +2838,10 @@ var getAxisValueResolver = function (data, layout, axisId) {
|
|
|
2264
2838
|
return isNumber(value) ? +value : null;
|
|
2265
2839
|
case 'date':
|
|
2266
2840
|
if (isNumber(value)) {
|
|
2267
|
-
return
|
|
2841
|
+
return toDate(+value);
|
|
2268
2842
|
}
|
|
2269
2843
|
if (typeof value === 'string') {
|
|
2270
|
-
return
|
|
2844
|
+
return toDate(value);
|
|
2271
2845
|
}
|
|
2272
2846
|
return null;
|
|
2273
2847
|
case 'category':
|