@fluentui/react-charts 0.0.0-nightly-20251224-0407.1 → 0.0.0-nightly-20251225-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/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +148 -55
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +4 -2
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +148 -55
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +4 -2
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/package.json +12 -12
|
@@ -433,6 +433,57 @@ const toFiniteNumber = (value)=>{
|
|
|
433
433
|
const numeric = typeof value === 'number' ? value : Number(value);
|
|
434
434
|
return Number.isFinite(numeric) ? numeric : undefined;
|
|
435
435
|
};
|
|
436
|
+
/**
|
|
437
|
+
* Parses Plotly axis references (e.g. `x`, `x2`, `xaxis2`, `paper`, `pixel`, `x domain`) into a ref type + axis id.
|
|
438
|
+
*/ const parseAxisRef = (ref, axis)=>{
|
|
439
|
+
if (!ref) {
|
|
440
|
+
return {
|
|
441
|
+
refType: 'axis',
|
|
442
|
+
axisId: 1
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
const normalized = ref.toLowerCase().trim();
|
|
446
|
+
if (normalized === 'pixel') {
|
|
447
|
+
return {
|
|
448
|
+
refType: 'pixel',
|
|
449
|
+
axisId: 1
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
if (normalized === 'paper') {
|
|
453
|
+
return {
|
|
454
|
+
refType: 'relative',
|
|
455
|
+
axisId: 1
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
if (normalized.endsWith(' domain')) {
|
|
459
|
+
return normalized.startsWith(axis) ? {
|
|
460
|
+
refType: 'relative',
|
|
461
|
+
axisId: 1
|
|
462
|
+
} : {
|
|
463
|
+
refType: undefined,
|
|
464
|
+
axisId: 1
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
const match = normalized.match(/^([xy])(axis)?(\d*)$/);
|
|
468
|
+
if (!match || match[1] !== axis) {
|
|
469
|
+
return {
|
|
470
|
+
refType: undefined,
|
|
471
|
+
axisId: 1
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
const suffix = match[3];
|
|
475
|
+
if (!suffix || suffix === '1') {
|
|
476
|
+
return {
|
|
477
|
+
refType: 'axis',
|
|
478
|
+
axisId: 1
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
const parsed = Number(suffix);
|
|
482
|
+
return {
|
|
483
|
+
refType: 'axis',
|
|
484
|
+
axisId: Number.isFinite(parsed) && parsed >= 1 ? parsed : 1
|
|
485
|
+
};
|
|
486
|
+
};
|
|
436
487
|
/**
|
|
437
488
|
* Converts Plotly's bottom-origin relative Y coordinate into the SVG top-origin space used by our overlay.
|
|
438
489
|
*/ const transformRelativeYForChart = (value)=>{
|
|
@@ -486,21 +537,13 @@ const appendPx = (value)=>{
|
|
|
486
537
|
if (!ref) {
|
|
487
538
|
return 'axis';
|
|
488
539
|
}
|
|
489
|
-
const
|
|
490
|
-
if (
|
|
491
|
-
return
|
|
492
|
-
}
|
|
493
|
-
if (normalized === 'paper') {
|
|
494
|
-
return 'relative';
|
|
495
|
-
}
|
|
496
|
-
if (normalized.endsWith(' domain')) {
|
|
497
|
-
return normalized.startsWith(axis) ? 'relative' : undefined;
|
|
540
|
+
const parsed = parseAxisRef(ref, axis);
|
|
541
|
+
if (parsed.refType !== 'axis') {
|
|
542
|
+
return parsed.refType;
|
|
498
543
|
}
|
|
544
|
+
const normalized = (ref !== null && ref !== void 0 ? ref : '').toLowerCase().trim();
|
|
499
545
|
const match = normalized.match(/^([xy])(\d*)$/);
|
|
500
|
-
|
|
501
|
-
return 'axis';
|
|
502
|
-
}
|
|
503
|
-
return undefined;
|
|
546
|
+
return match && match[1] === axis ? 'axis' : undefined;
|
|
504
547
|
};
|
|
505
548
|
/**
|
|
506
549
|
* Retrieves the appropriate axis layout section from Plotly's layout given an axis reference alias.
|
|
@@ -509,56 +552,36 @@ const appendPx = (value)=>{
|
|
|
509
552
|
return undefined;
|
|
510
553
|
}
|
|
511
554
|
const defaultAxisKey = `${axis}axis`;
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
}
|
|
515
|
-
const normalized = ref.toLowerCase();
|
|
516
|
-
if (normalized === 'paper' || normalized === 'pixel' || normalized.endsWith(' domain')) {
|
|
555
|
+
const { refType, axisId } = parseAxisRef(ref, axis);
|
|
556
|
+
if (refType !== 'axis' || axisId === 1) {
|
|
517
557
|
return layout[defaultAxisKey];
|
|
518
558
|
}
|
|
519
|
-
const
|
|
520
|
-
|
|
521
|
-
const index = match[2];
|
|
522
|
-
if (index && index !== '' && index !== '1') {
|
|
523
|
-
const axisKey = `${axis}axis${index}`;
|
|
524
|
-
return layout[axisKey];
|
|
525
|
-
}
|
|
526
|
-
return layout[defaultAxisKey];
|
|
527
|
-
}
|
|
528
|
-
return layout[defaultAxisKey];
|
|
559
|
+
const axisKey = `${axis}axis${axisId}`;
|
|
560
|
+
return layout[axisKey];
|
|
529
561
|
};
|
|
530
|
-
|
|
531
|
-
* Normalizes raw Plotly data values into canonical number/date/string types based on axis configuration.
|
|
532
|
-
*/ const convertDataValue = (value, axisLayout)=>{
|
|
562
|
+
const convertAnnotationDataValue = (value, axisType)=>{
|
|
533
563
|
if (value === undefined || value === null) {
|
|
534
564
|
return undefined;
|
|
535
565
|
}
|
|
536
|
-
const axisType = axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type;
|
|
537
566
|
if (axisType === 'date') {
|
|
538
567
|
const dateValue = value instanceof Date ? value : new Date(value);
|
|
539
568
|
return Number.isNaN(dateValue.getTime()) ? undefined : dateValue;
|
|
540
569
|
}
|
|
541
|
-
if (value instanceof Date) {
|
|
542
|
-
return Number.isNaN(value.getTime()) ? undefined : value;
|
|
543
|
-
}
|
|
544
|
-
if (typeof value === 'number') {
|
|
545
|
-
return Number.isFinite(value) ? value : undefined;
|
|
546
|
-
}
|
|
547
570
|
if (axisType === 'linear' || axisType === 'log') {
|
|
571
|
+
if (typeof value === 'number') {
|
|
572
|
+
return Number.isFinite(value) ? value : undefined;
|
|
573
|
+
}
|
|
548
574
|
const numeric = Number(value);
|
|
549
575
|
return Number.isFinite(numeric) ? numeric : undefined;
|
|
550
576
|
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
if (shouldTryParseDate && (0, _chartutilities.isDate)(value)) {
|
|
554
|
-
const parsedDate = new Date(value);
|
|
555
|
-
if (!Number.isNaN(parsedDate.getTime()) && parsedDate.getFullYear() >= 1900) {
|
|
556
|
-
return parsedDate;
|
|
557
|
-
}
|
|
558
|
-
}
|
|
577
|
+
// For category-like axes, preserve raw strings (and avoid date parsing heuristics).
|
|
578
|
+
if (value instanceof Date) {
|
|
559
579
|
return value;
|
|
560
580
|
}
|
|
561
|
-
|
|
581
|
+
if (typeof value === 'number' || typeof value === 'string') {
|
|
582
|
+
return value;
|
|
583
|
+
}
|
|
584
|
+
return undefined;
|
|
562
585
|
};
|
|
563
586
|
const createAnnotationId = (text, index)=>{
|
|
564
587
|
const normalized = text.replace(/\s+/g, ' ').trim();
|
|
@@ -637,7 +660,9 @@ const getAnnotationCoordinateValue = (axis, refType, annotation, layout)=>{
|
|
|
637
660
|
const axisRef = axis === 'x' ? annotation === null || annotation === void 0 ? void 0 : annotation.xref : annotation === null || annotation === void 0 ? void 0 : annotation.yref;
|
|
638
661
|
const axisLayout = getAxisLayoutByRef(layout, axisRef, axis);
|
|
639
662
|
const rawValue = axis === 'x' ? annotation === null || annotation === void 0 ? void 0 : annotation.x : annotation === null || annotation === void 0 ? void 0 : annotation.y;
|
|
640
|
-
|
|
663
|
+
var _axisLayout_type;
|
|
664
|
+
const axisType = (_axisLayout_type = axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) !== null && _axisLayout_type !== void 0 ? _axisLayout_type : 'category';
|
|
665
|
+
return convertAnnotationDataValue(rawValue, axisType);
|
|
641
666
|
}
|
|
642
667
|
const numericValue = toFiniteNumber(axis === 'x' ? annotation === null || annotation === void 0 ? void 0 : annotation.x : annotation === null || annotation === void 0 ? void 0 : annotation.y);
|
|
643
668
|
if (numericValue === undefined) {
|
|
@@ -861,14 +886,82 @@ const getAnnotationCoordinateValue = (axis, refType, annotation, layout)=>{
|
|
|
861
886
|
}
|
|
862
887
|
return chartAnnotation;
|
|
863
888
|
};
|
|
864
|
-
const getChartAnnotationsFromLayout = (layout, isMultiPlot)=>{
|
|
889
|
+
const getChartAnnotationsFromLayout = (data, layout, isMultiPlot)=>{
|
|
865
890
|
if (isMultiPlot || !(layout === null || layout === void 0 ? void 0 : layout.annotations)) {
|
|
866
891
|
return undefined;
|
|
867
892
|
}
|
|
893
|
+
// Infer axis types when they are not explicitly set.
|
|
894
|
+
// This is needed so annotation coordinate parsing can correctly treat values as 'date' vs 'category'
|
|
895
|
+
// (for example, bar chart category axes with date-like strings).
|
|
896
|
+
const inferredLayout = (()=>{
|
|
897
|
+
if (!data || !(0, _chartutilities.isArrayOrTypedArray)(data) || data.length === 0) {
|
|
898
|
+
return layout;
|
|
899
|
+
}
|
|
900
|
+
const valuesByAxisKey = new Map();
|
|
901
|
+
const axesExpectingCategories = new Set();
|
|
902
|
+
data.forEach((series)=>{
|
|
903
|
+
const trace = series;
|
|
904
|
+
const axisIds = (0, _chartutilities.getAxisIds)(trace);
|
|
905
|
+
if (trace.type === 'bar') {
|
|
906
|
+
const categoryAxisLetter = trace.orientation === 'h' ? 'y' : 'x';
|
|
907
|
+
axesExpectingCategories.add((0, _chartutilities.getAxisKey)(categoryAxisLetter, axisIds[categoryAxisLetter]));
|
|
908
|
+
}
|
|
909
|
+
[
|
|
910
|
+
'x',
|
|
911
|
+
'y'
|
|
912
|
+
].forEach((axLetter)=>{
|
|
913
|
+
const coords = trace[axLetter];
|
|
914
|
+
if (!coords || !(0, _chartutilities.isArrayOrTypedArray)(coords)) {
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
const axisKey = (0, _chartutilities.getAxisKey)(axLetter, axisIds[axLetter]);
|
|
918
|
+
var _valuesByAxisKey_get;
|
|
919
|
+
const existing = (_valuesByAxisKey_get = valuesByAxisKey.get(axisKey)) !== null && _valuesByAxisKey_get !== void 0 ? _valuesByAxisKey_get : [];
|
|
920
|
+
coords.forEach((val)=>{
|
|
921
|
+
if (!(0, _chartutilities.isInvalidValue)(val)) {
|
|
922
|
+
existing.push(val);
|
|
923
|
+
}
|
|
924
|
+
});
|
|
925
|
+
valuesByAxisKey.set(axisKey, existing);
|
|
926
|
+
});
|
|
927
|
+
});
|
|
928
|
+
let nextLayout;
|
|
929
|
+
valuesByAxisKey.forEach((values, axisKey)=>{
|
|
930
|
+
const currentAxis = layout === null || layout === void 0 ? void 0 : layout[axisKey];
|
|
931
|
+
const currentType = currentAxis === null || currentAxis === void 0 ? void 0 : currentAxis.type;
|
|
932
|
+
if ([
|
|
933
|
+
'linear',
|
|
934
|
+
'log',
|
|
935
|
+
'date',
|
|
936
|
+
'category'
|
|
937
|
+
].includes(currentType !== null && currentType !== void 0 ? currentType : '')) {
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
let inferredType;
|
|
941
|
+
if (axesExpectingCategories.has(axisKey) || (0, _chartutilities.isYearArray)(values)) {
|
|
942
|
+
inferredType = 'category';
|
|
943
|
+
} else if ((0, _chartutilities.isDateArray)(values)) {
|
|
944
|
+
inferredType = 'date';
|
|
945
|
+
}
|
|
946
|
+
if (!inferredType) {
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
if (!nextLayout) {
|
|
950
|
+
nextLayout = {
|
|
951
|
+
...layout
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
nextLayout[axisKey] = {
|
|
955
|
+
...currentAxis !== null && currentAxis !== void 0 ? currentAxis : {},
|
|
956
|
+
type: inferredType
|
|
957
|
+
};
|
|
958
|
+
});
|
|
959
|
+
return nextLayout !== null && nextLayout !== void 0 ? nextLayout : layout;
|
|
960
|
+
})();
|
|
868
961
|
const annotationsArray = Array.isArray(layout.annotations) ? layout.annotations : [
|
|
869
962
|
layout.annotations
|
|
870
963
|
];
|
|
871
|
-
const converted = annotationsArray.map((annotation, index)=>convertPlotlyAnnotation(annotation,
|
|
964
|
+
const converted = annotationsArray.map((annotation, index)=>convertPlotlyAnnotation(annotation, inferredLayout, index)).filter((annotation)=>annotation !== undefined);
|
|
872
965
|
return converted.length > 0 ? converted : undefined;
|
|
873
966
|
};
|
|
874
967
|
const normalizeObjectArrayForGVBC = (data, xLabels)=>{
|
|
@@ -945,7 +1038,7 @@ const normalizeObjectArrayForGVBC = (data, xLabels)=>{
|
|
|
945
1038
|
const transformPlotlyJsonToAnnotationChartProps = (input, isMultiPlot, _colorMap, _colorwayType, _isDarkTheme)=>{
|
|
946
1039
|
var _layoutWithMeta_meta, _input_layout, _input_layout1, _input_layout2, _input_layout3, _input_layout_font, _input_layout4, _input_layout_font1, _input_layout5, _input_layout6;
|
|
947
1040
|
var _getChartAnnotationsFromLayout;
|
|
948
|
-
const annotations = (_getChartAnnotationsFromLayout = getChartAnnotationsFromLayout(input.layout, isMultiPlot)) !== null && _getChartAnnotationsFromLayout !== void 0 ? _getChartAnnotationsFromLayout : [];
|
|
1041
|
+
const annotations = (_getChartAnnotationsFromLayout = getChartAnnotationsFromLayout(input.data, input.layout, isMultiPlot)) !== null && _getChartAnnotationsFromLayout !== void 0 ? _getChartAnnotationsFromLayout : [];
|
|
949
1042
|
const titles = getTitles(input.layout);
|
|
950
1043
|
const layoutTitle = titles.chartTitle || undefined;
|
|
951
1044
|
const layoutWithMeta = input.layout;
|
|
@@ -1212,7 +1305,7 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
1212
1305
|
}
|
|
1213
1306
|
});
|
|
1214
1307
|
const vsbcData = Object.values(mapXToDataPoints);
|
|
1215
|
-
const annotations = getChartAnnotationsFromLayout(input.layout, isMultiPlot);
|
|
1308
|
+
const annotations = getChartAnnotationsFromLayout(input.data, input.layout, isMultiPlot);
|
|
1216
1309
|
var _input_layout_height;
|
|
1217
1310
|
return {
|
|
1218
1311
|
data: vsbcData,
|
|
@@ -1357,7 +1450,7 @@ const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
1357
1450
|
});
|
|
1358
1451
|
}
|
|
1359
1452
|
});
|
|
1360
|
-
const annotations = getChartAnnotationsFromLayout(processedInput.layout, isMultiPlot);
|
|
1453
|
+
const annotations = getChartAnnotationsFromLayout(processedInput.data, processedInput.layout, isMultiPlot);
|
|
1361
1454
|
var _processedInput_layout_height;
|
|
1362
1455
|
return {
|
|
1363
1456
|
dataV2: gvbcDataV2,
|
|
@@ -1454,7 +1547,7 @@ const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayTyp
|
|
|
1454
1547
|
});
|
|
1455
1548
|
});
|
|
1456
1549
|
});
|
|
1457
|
-
const annotations = getChartAnnotationsFromLayout(input.layout, isMultiPlot);
|
|
1550
|
+
const annotations = getChartAnnotationsFromLayout(input.data, input.layout, isMultiPlot);
|
|
1458
1551
|
var _input_layout_height;
|
|
1459
1552
|
return {
|
|
1460
1553
|
data: vbcData,
|
|
@@ -1673,7 +1766,7 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
1673
1766
|
...lineShape
|
|
1674
1767
|
]
|
|
1675
1768
|
};
|
|
1676
|
-
const annotations = getChartAnnotationsFromLayout(input.layout, isMultiPlot);
|
|
1769
|
+
const annotations = getChartAnnotationsFromLayout(input.data, input.layout, isMultiPlot);
|
|
1677
1770
|
var _input_layout_height;
|
|
1678
1771
|
const commonProps = {
|
|
1679
1772
|
supportNegativeData: true,
|