@fluentui/react-charts 0.0.0-nightly-20251210-0407.1 → 0.0.0-nightly-20251211-0406.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.md +13 -13
- package/dist/index.d.ts +25 -5
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js +87 -49
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +81 -155
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +54 -38
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/types/ChartAnnotation.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js +87 -49
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +81 -155
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +54 -38
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/types/ChartAnnotation.js.map +1 -1
- package/package.json +13 -13
|
@@ -281,62 +281,6 @@ const toFiniteNumber = (value)=>{
|
|
|
281
281
|
const numeric = typeof value === 'number' ? value : Number(value);
|
|
282
282
|
return Number.isFinite(numeric) ? numeric : undefined;
|
|
283
283
|
};
|
|
284
|
-
/**
|
|
285
|
-
* Normalizes Plotly axis reference strings so equivalent aliases (e.g. `xaxis1`, `x1`) collapse to the base axis id.
|
|
286
|
-
*/ const normalizeAxisRef = (ref, axis)=>{
|
|
287
|
-
if (!ref) {
|
|
288
|
-
return axis;
|
|
289
|
-
}
|
|
290
|
-
const normalized = ref.toLowerCase();
|
|
291
|
-
if (normalized === axis || normalized === `${axis}axis` || normalized === `${axis}axis1` || normalized === `${axis}1`) {
|
|
292
|
-
return axis;
|
|
293
|
-
}
|
|
294
|
-
const match = normalized.match(/^([xy])(axis)?(\d+)$/);
|
|
295
|
-
if (match && match[1] === axis && match[3]) {
|
|
296
|
-
return match[3] === '1' ? axis : `${axis}${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
|
-
*/ const getAxisNumericRangeFromData = (axis, ref, layout, data)=>{
|
|
303
|
-
if (!data || data.length === 0) {
|
|
304
|
-
return undefined;
|
|
305
|
-
}
|
|
306
|
-
const axisLayout = getAxisLayoutByRef(layout, ref, axis);
|
|
307
|
-
const targetRef = normalizeAxisRef(ref, axis);
|
|
308
|
-
const traceAxisKey = axis === 'x' ? 'xaxis' : 'yaxis';
|
|
309
|
-
let minValue;
|
|
310
|
-
let maxValue;
|
|
311
|
-
data.forEach((trace)=>{
|
|
312
|
-
const plotTrace = trace;
|
|
313
|
-
const traceAxisRef = normalizeAxisRef(plotTrace[traceAxisKey], axis);
|
|
314
|
-
if (traceAxisRef !== targetRef) {
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
const values = axis === 'x' ? plotTrace.x : plotTrace.y;
|
|
318
|
-
if (!isArrayOrTypedArray(values)) {
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
const arrayLike = values;
|
|
322
|
-
for(let index = 0; index < arrayLike.length; index++){
|
|
323
|
-
const value = arrayLike[index];
|
|
324
|
-
const numeric = toNumericValue(convertDataValue(value, axisLayout));
|
|
325
|
-
if (numeric === undefined || Number.isNaN(numeric)) {
|
|
326
|
-
continue;
|
|
327
|
-
}
|
|
328
|
-
minValue = minValue === undefined ? numeric : Math.min(minValue, numeric);
|
|
329
|
-
maxValue = maxValue === undefined ? numeric : Math.max(maxValue, numeric);
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
if (minValue === undefined || maxValue === undefined || minValue === maxValue) {
|
|
333
|
-
return undefined;
|
|
334
|
-
}
|
|
335
|
-
return [
|
|
336
|
-
minValue,
|
|
337
|
-
maxValue
|
|
338
|
-
];
|
|
339
|
-
};
|
|
340
284
|
/**
|
|
341
285
|
* Converts Plotly's bottom-origin relative Y coordinate into the SVG top-origin space used by our overlay.
|
|
342
286
|
*/ const transformRelativeYForChart = (value)=>{
|
|
@@ -437,49 +381,32 @@ const appendPx = (value)=>{
|
|
|
437
381
|
if (value === undefined || value === null) {
|
|
438
382
|
return undefined;
|
|
439
383
|
}
|
|
440
|
-
|
|
384
|
+
const axisType = axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type;
|
|
385
|
+
if (axisType === 'date') {
|
|
441
386
|
const dateValue = value instanceof Date ? value : new Date(value);
|
|
442
387
|
return Number.isNaN(dateValue.getTime()) ? undefined : dateValue;
|
|
443
388
|
}
|
|
444
|
-
if (typeof value === 'number') {
|
|
445
|
-
return value;
|
|
446
|
-
}
|
|
447
|
-
if ((axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) === 'linear' || (axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) === 'log') {
|
|
448
|
-
const numeric = Number(value);
|
|
449
|
-
return Number.isFinite(numeric) ? numeric : undefined;
|
|
450
|
-
}
|
|
451
389
|
if (value instanceof Date) {
|
|
452
|
-
return value;
|
|
453
|
-
}
|
|
454
|
-
return value;
|
|
455
|
-
};
|
|
456
|
-
const toNumericValue = (value)=>{
|
|
457
|
-
if (value instanceof Date) {
|
|
458
|
-
const timestamp = value.getTime();
|
|
459
|
-
return Number.isFinite(timestamp) ? timestamp : undefined;
|
|
390
|
+
return Number.isNaN(value.getTime()) ? undefined : value;
|
|
460
391
|
}
|
|
461
392
|
if (typeof value === 'number') {
|
|
462
393
|
return Number.isFinite(value) ? value : undefined;
|
|
463
394
|
}
|
|
464
|
-
if (
|
|
395
|
+
if (axisType === 'linear' || axisType === 'log') {
|
|
465
396
|
const numeric = Number(value);
|
|
466
397
|
return Number.isFinite(numeric) ? numeric : undefined;
|
|
467
398
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
const current = toNumericValue(convertDataValue(value, axisLayout));
|
|
478
|
-
if (start === undefined || end === undefined || current === undefined || start === end) {
|
|
479
|
-
return undefined;
|
|
399
|
+
if (typeof value === 'string') {
|
|
400
|
+
const shouldTryParseDate = axisType === undefined || axisType === '-' || axisType === null;
|
|
401
|
+
if (shouldTryParseDate && isDate(value)) {
|
|
402
|
+
const parsedDate = new Date(value);
|
|
403
|
+
if (!Number.isNaN(parsedDate.getTime()) && parsedDate.getFullYear() >= 1900) {
|
|
404
|
+
return parsedDate;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
return value;
|
|
480
408
|
}
|
|
481
|
-
|
|
482
|
-
return Number.isFinite(relative) ? relative : undefined;
|
|
409
|
+
return value;
|
|
483
410
|
};
|
|
484
411
|
const createAnnotationId = (text, index)=>{
|
|
485
412
|
const normalized = text.replace(/\s+/g, ' ').trim();
|
|
@@ -544,10 +471,35 @@ const mapArrowDashToPattern = (value)=>{
|
|
|
544
471
|
return value;
|
|
545
472
|
}
|
|
546
473
|
};
|
|
474
|
+
const mapRefTypeToCoordinateType = (refType)=>{
|
|
475
|
+
return refType === 'axis' ? 'data' : refType;
|
|
476
|
+
};
|
|
477
|
+
const normalizeCoordinateValueForType = (coordinateType, value)=>{
|
|
478
|
+
if (coordinateType === 'data') {
|
|
479
|
+
return value;
|
|
480
|
+
}
|
|
481
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
482
|
+
};
|
|
483
|
+
const getAnnotationCoordinateValue = (axis, refType, annotation, layout)=>{
|
|
484
|
+
if (refType === 'axis') {
|
|
485
|
+
const axisRef = axis === 'x' ? annotation === null || annotation === void 0 ? void 0 : annotation.xref : annotation === null || annotation === void 0 ? void 0 : annotation.yref;
|
|
486
|
+
const axisLayout = getAxisLayoutByRef(layout, axisRef, axis);
|
|
487
|
+
const rawValue = axis === 'x' ? annotation === null || annotation === void 0 ? void 0 : annotation.x : annotation === null || annotation === void 0 ? void 0 : annotation.y;
|
|
488
|
+
return convertDataValue(rawValue, axisLayout);
|
|
489
|
+
}
|
|
490
|
+
const numericValue = toFiniteNumber(axis === 'x' ? annotation === null || annotation === void 0 ? void 0 : annotation.x : annotation === null || annotation === void 0 ? void 0 : annotation.y);
|
|
491
|
+
if (numericValue === undefined) {
|
|
492
|
+
return undefined;
|
|
493
|
+
}
|
|
494
|
+
if (refType === 'relative') {
|
|
495
|
+
return axis === 'y' ? transformRelativeYForChart(numericValue) : numericValue;
|
|
496
|
+
}
|
|
497
|
+
return numericValue;
|
|
498
|
+
};
|
|
547
499
|
/**
|
|
548
500
|
* Converts a Plotly annotation definition into the internal `ChartAnnotation` format, translating coordinates,
|
|
549
501
|
* layout alignment, styling, and connector metadata while skipping unsupported configurations.
|
|
550
|
-
*/ const convertPlotlyAnnotation = (annotation, layout,
|
|
502
|
+
*/ const convertPlotlyAnnotation = (annotation, layout, index)=>{
|
|
551
503
|
if (!annotation || annotation.visible === false) {
|
|
552
504
|
return undefined;
|
|
553
505
|
}
|
|
@@ -556,77 +508,51 @@ const mapArrowDashToPattern = (value)=>{
|
|
|
556
508
|
if (!xRefType || !yRefType) {
|
|
557
509
|
return undefined;
|
|
558
510
|
}
|
|
511
|
+
const xValue = getAnnotationCoordinateValue('x', xRefType, annotation, layout);
|
|
512
|
+
const yValue = getAnnotationCoordinateValue('y', yRefType, annotation, layout);
|
|
513
|
+
if (xValue === undefined || yValue === undefined) {
|
|
514
|
+
return undefined;
|
|
515
|
+
}
|
|
516
|
+
const xCoordinateType = mapRefTypeToCoordinateType(xRefType);
|
|
517
|
+
const yCoordinateType = mapRefTypeToCoordinateType(yRefType);
|
|
518
|
+
const normalizedX = normalizeCoordinateValueForType(xCoordinateType, xValue);
|
|
519
|
+
const normalizedY = normalizeCoordinateValueForType(yCoordinateType, yValue);
|
|
520
|
+
if (normalizedX === undefined || normalizedY === undefined) {
|
|
521
|
+
return undefined;
|
|
522
|
+
}
|
|
523
|
+
const yRefNormalized = typeof annotation.yref === 'string' ? annotation.yref.toLowerCase() : undefined;
|
|
524
|
+
const yAxisProps = yCoordinateType === 'data' && yRefNormalized === 'y2' ? {
|
|
525
|
+
yAxis: 'secondary'
|
|
526
|
+
} : undefined;
|
|
559
527
|
let coordinates;
|
|
560
|
-
if (
|
|
561
|
-
const xAxisLayout = getAxisLayoutByRef(layout, annotation.xref, 'x');
|
|
562
|
-
const yAxisLayout = getAxisLayoutByRef(layout, annotation.yref, 'y');
|
|
563
|
-
const xValue = convertDataValue(annotation.x, xAxisLayout);
|
|
564
|
-
const yValue = convertDataValue(annotation.y, yAxisLayout);
|
|
565
|
-
if (xValue === undefined || yValue === undefined) {
|
|
566
|
-
return undefined;
|
|
567
|
-
}
|
|
568
|
-
const yRefNormalized = typeof annotation.yref === 'string' ? annotation.yref.toLowerCase() : undefined;
|
|
528
|
+
if (xCoordinateType === 'data' && yCoordinateType === 'data') {
|
|
569
529
|
coordinates = {
|
|
570
530
|
type: 'data',
|
|
571
|
-
x:
|
|
572
|
-
y:
|
|
573
|
-
...
|
|
574
|
-
yAxis: 'secondary'
|
|
575
|
-
} : {}
|
|
531
|
+
x: normalizedX,
|
|
532
|
+
y: normalizedY,
|
|
533
|
+
...yAxisProps !== null && yAxisProps !== void 0 ? yAxisProps : {}
|
|
576
534
|
};
|
|
577
|
-
} else if (
|
|
578
|
-
const xValue = toFiniteNumber(annotation.x);
|
|
579
|
-
const yValue = toFiniteNumber(annotation.y);
|
|
580
|
-
const chartRelativeY = transformRelativeYForChart(yValue);
|
|
581
|
-
if (xValue === undefined || chartRelativeY === undefined) {
|
|
582
|
-
return undefined;
|
|
583
|
-
}
|
|
535
|
+
} else if (xCoordinateType === 'relative' && yCoordinateType === 'relative') {
|
|
584
536
|
coordinates = {
|
|
585
537
|
type: 'relative',
|
|
586
|
-
x:
|
|
587
|
-
y:
|
|
538
|
+
x: normalizedX,
|
|
539
|
+
y: normalizedY
|
|
588
540
|
};
|
|
589
|
-
} else if (
|
|
590
|
-
const xValue = toFiniteNumber(annotation.x);
|
|
591
|
-
const yAxisLayout = getAxisLayoutByRef(layout, annotation.yref, 'y');
|
|
592
|
-
const yFallbackRange = getAxisNumericRangeFromData('y', annotation.yref, layout, data);
|
|
593
|
-
const yRelative = toRelativeCoordinate(annotation.y, yAxisLayout, yFallbackRange);
|
|
594
|
-
const chartRelativeY = transformRelativeYForChart(yRelative);
|
|
595
|
-
if (xValue === undefined || chartRelativeY === undefined) {
|
|
596
|
-
return undefined;
|
|
597
|
-
}
|
|
598
|
-
coordinates = {
|
|
599
|
-
type: 'relative',
|
|
600
|
-
x: xValue,
|
|
601
|
-
y: chartRelativeY
|
|
602
|
-
};
|
|
603
|
-
} else if (xRefType === 'axis' && yRefType === 'relative') {
|
|
604
|
-
const yValue = toFiniteNumber(annotation.y);
|
|
605
|
-
const xAxisLayout = getAxisLayoutByRef(layout, annotation.xref, 'x');
|
|
606
|
-
const xFallbackRange = getAxisNumericRangeFromData('x', annotation.xref, layout, data);
|
|
607
|
-
const xRelative = toRelativeCoordinate(annotation.x, xAxisLayout, xFallbackRange);
|
|
608
|
-
const chartRelativeY = transformRelativeYForChart(yValue);
|
|
609
|
-
if (xRelative === undefined || chartRelativeY === undefined) {
|
|
610
|
-
return undefined;
|
|
611
|
-
}
|
|
612
|
-
coordinates = {
|
|
613
|
-
type: 'relative',
|
|
614
|
-
x: xRelative,
|
|
615
|
-
y: chartRelativeY
|
|
616
|
-
};
|
|
617
|
-
} else if (xRefType === 'pixel' && yRefType === 'pixel') {
|
|
618
|
-
const xValue = toFiniteNumber(annotation.x);
|
|
619
|
-
const yValue = toFiniteNumber(annotation.y);
|
|
620
|
-
if (xValue === undefined || yValue === undefined) {
|
|
621
|
-
return undefined;
|
|
622
|
-
}
|
|
541
|
+
} else if (xCoordinateType === 'pixel' && yCoordinateType === 'pixel') {
|
|
623
542
|
coordinates = {
|
|
624
543
|
type: 'pixel',
|
|
625
|
-
x:
|
|
626
|
-
y:
|
|
544
|
+
x: normalizedX,
|
|
545
|
+
y: normalizedY
|
|
627
546
|
};
|
|
628
547
|
} else {
|
|
629
|
-
|
|
548
|
+
coordinates = {
|
|
549
|
+
type: 'mixed',
|
|
550
|
+
xCoordinateType,
|
|
551
|
+
yCoordinateType,
|
|
552
|
+
x: normalizedX,
|
|
553
|
+
y: normalizedY,
|
|
554
|
+
...yAxisProps !== null && yAxisProps !== void 0 ? yAxisProps : {}
|
|
555
|
+
};
|
|
630
556
|
}
|
|
631
557
|
const textValue = annotation.text;
|
|
632
558
|
const rawText = textValue === undefined || textValue === null ? '' : String(textValue);
|
|
@@ -783,14 +709,14 @@ const mapArrowDashToPattern = (value)=>{
|
|
|
783
709
|
}
|
|
784
710
|
return chartAnnotation;
|
|
785
711
|
};
|
|
786
|
-
const getChartAnnotationsFromLayout = (layout,
|
|
712
|
+
const getChartAnnotationsFromLayout = (layout, isMultiPlot)=>{
|
|
787
713
|
if (isMultiPlot || !(layout === null || layout === void 0 ? void 0 : layout.annotations)) {
|
|
788
714
|
return undefined;
|
|
789
715
|
}
|
|
790
716
|
const annotationsArray = Array.isArray(layout.annotations) ? layout.annotations : [
|
|
791
717
|
layout.annotations
|
|
792
718
|
];
|
|
793
|
-
const converted = annotationsArray.map((annotation, index)=>convertPlotlyAnnotation(annotation, layout,
|
|
719
|
+
const converted = annotationsArray.map((annotation, index)=>convertPlotlyAnnotation(annotation, layout, index)).filter((annotation)=>annotation !== undefined);
|
|
794
720
|
return converted.length > 0 ? converted : undefined;
|
|
795
721
|
};
|
|
796
722
|
/**
|
|
@@ -872,7 +798,7 @@ const getChartAnnotationsFromLayout = (layout, data, isMultiPlot)=>{
|
|
|
872
798
|
export const transformPlotlyJsonToAnnotationChartProps = (input, isMultiPlot, _colorMap, _colorwayType, _isDarkTheme)=>{
|
|
873
799
|
var _layoutWithMeta_meta, _input_layout, _input_layout1, _input_layout2, _input_layout3, _input_layout_font, _input_layout4, _input_layout_font1, _input_layout5, _input_layout6;
|
|
874
800
|
var _getChartAnnotationsFromLayout;
|
|
875
|
-
const annotations = (_getChartAnnotationsFromLayout = getChartAnnotationsFromLayout(input.layout,
|
|
801
|
+
const annotations = (_getChartAnnotationsFromLayout = getChartAnnotationsFromLayout(input.layout, isMultiPlot)) !== null && _getChartAnnotationsFromLayout !== void 0 ? _getChartAnnotationsFromLayout : [];
|
|
876
802
|
const titles = getTitles(input.layout);
|
|
877
803
|
const layoutTitle = titles.chartTitle || undefined;
|
|
878
804
|
const layoutWithMeta = input.layout;
|
|
@@ -1128,7 +1054,7 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
1128
1054
|
}
|
|
1129
1055
|
});
|
|
1130
1056
|
const vsbcData = Object.values(mapXToDataPoints);
|
|
1131
|
-
const annotations = getChartAnnotationsFromLayout(input.layout,
|
|
1057
|
+
const annotations = getChartAnnotationsFromLayout(input.layout, isMultiPlot);
|
|
1132
1058
|
var _input_layout_height;
|
|
1133
1059
|
return {
|
|
1134
1060
|
data: vsbcData,
|
|
@@ -1265,7 +1191,7 @@ export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, col
|
|
|
1265
1191
|
});
|
|
1266
1192
|
}
|
|
1267
1193
|
});
|
|
1268
|
-
const annotations = getChartAnnotationsFromLayout(processedInput.layout,
|
|
1194
|
+
const annotations = getChartAnnotationsFromLayout(processedInput.layout, isMultiPlot);
|
|
1269
1195
|
var _processedInput_layout_height;
|
|
1270
1196
|
return {
|
|
1271
1197
|
dataV2: gvbcDataV2,
|
|
@@ -1355,7 +1281,7 @@ export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colo
|
|
|
1355
1281
|
});
|
|
1356
1282
|
});
|
|
1357
1283
|
});
|
|
1358
|
-
const annotations = getChartAnnotationsFromLayout(input.layout,
|
|
1284
|
+
const annotations = getChartAnnotationsFromLayout(input.layout, isMultiPlot);
|
|
1359
1285
|
var _input_layout_height;
|
|
1360
1286
|
return {
|
|
1361
1287
|
data: vbcData,
|
|
@@ -1577,7 +1503,7 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
1577
1503
|
...lineShape
|
|
1578
1504
|
]
|
|
1579
1505
|
};
|
|
1580
|
-
const annotations = getChartAnnotationsFromLayout(input.layout,
|
|
1506
|
+
const annotations = getChartAnnotationsFromLayout(input.layout, isMultiPlot);
|
|
1581
1507
|
var _input_layout_height;
|
|
1582
1508
|
const commonProps = {
|
|
1583
1509
|
supportNegativeData: true,
|