@fluentui/react-charts 0.0.0-nightly-20251106-0410.1 → 0.0.0-nightly-20251110-0407.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 +31 -13
- package/dist/index.d.ts +213 -2
- package/lib/AnnotationOnlyChart.js +1 -0
- package/lib/AnnotationOnlyChart.js.map +1 -0
- package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.js +208 -0
- package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.js.map +1 -0
- package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js +1 -0
- package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js.map +1 -0
- package/lib/components/AnnotationOnlyChart/index.js +2 -0
- package/lib/components/AnnotationOnlyChart/index.js.map +1 -0
- package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js +31 -0
- package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js.map +1 -0
- package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js +23 -0
- package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js.map +1 -0
- package/lib/components/AreaChart/useAreaChartStyles.styles.js +3 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +3 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.js +3 -1
- package/lib/components/ChartTable/ChartTable.js.map +1 -1
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js +617 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +1 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
- package/lib/components/CommonComponents/Annotations/index.js +2 -0
- package/lib/components/CommonComponents/Annotations/index.js.map +1 -0
- package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js +173 -0
- package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js.map +1 -0
- package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js +126 -0
- package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js.map +1 -0
- package/lib/components/CommonComponents/CartesianChart.js +56 -27
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/index.js +2 -0
- package/lib/components/CommonComponents/index.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +17 -4
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +14 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +39 -19
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +571 -6
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +12 -7
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.js +5 -5
- package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.js +3 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js +3 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.js +3 -1
- package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +3 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +3 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js +5 -5
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +3 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +3 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.js +3 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +3 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +3 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
- package/lib/components/Legends/Legends.js +3 -1
- package/lib/components/Legends/Legends.js.map +1 -1
- package/lib/components/Legends/Legends.types.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +5 -4
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/LineChart/eventAnnotation/Textbox.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.js +3 -1
- package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js +3 -1
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ResponsiveContainer/ResponsiveContainer.js +1 -1
- package/lib/components/ResponsiveContainer/ResponsiveContainer.js.map +1 -1
- package/lib/components/SankeyChart/SankeyChart.js +1 -1
- package/lib/components/SankeyChart/SankeyChart.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js +3 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +3 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +3 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +3 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +3 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +12 -4
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +3 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +3 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/types/ChartAnnotation.js +1 -0
- package/lib/types/ChartAnnotation.js.map +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/index.js.map +1 -1
- package/lib/utilities/FocusableTooltipText.js +1 -1
- package/lib/utilities/FocusableTooltipText.js.map +1 -1
- package/lib/utilities/SVGTooltipText.js +8 -8
- package/lib/utilities/SVGTooltipText.js.map +1 -1
- package/lib/utilities/image-export-utils.js +108 -0
- package/lib/utilities/image-export-utils.js.map +1 -1
- package/lib-commonjs/AnnotationOnlyChart.js +6 -0
- package/lib-commonjs/AnnotationOnlyChart.js.map +1 -0
- package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.js +219 -0
- package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.js.map +1 -0
- package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js +6 -0
- package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js.map +1 -0
- package/lib-commonjs/components/AnnotationOnlyChart/index.js +7 -0
- package/lib-commonjs/components/AnnotationOnlyChart/index.js.map +1 -0
- package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js +56 -0
- package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js.map +1 -0
- package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js +33 -0
- package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +3 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +3 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.js +3 -1
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js +628 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +4 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/Annotations/index.js +7 -0
- package/lib-commonjs/components/CommonComponents/Annotations/index.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js +265 -0
- package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js +161 -0
- package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +56 -27
- package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/index.js +2 -0
- package/lib-commonjs/components/CommonComponents/index.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +16 -2
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +14 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +38 -18
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +574 -6
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +12 -7
- package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.js +5 -5
- package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js +3 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js +3 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.js +3 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +3 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +3 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +5 -5
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +3 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +3 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js +3 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +3 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +3 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.js +3 -1
- package/lib-commonjs/components/Legends/Legends.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.types.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +5 -4
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/LineChart/eventAnnotation/Textbox.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +3 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +3 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.js +1 -1
- package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.js +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +3 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +3 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +3 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +3 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +3 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +12 -4
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +3 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +3 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/index.js +1 -0
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types/ChartAnnotation.js +6 -0
- package/lib-commonjs/types/ChartAnnotation.js.map +1 -0
- package/lib-commonjs/types/index.js +1 -0
- package/lib-commonjs/types/index.js.map +1 -1
- package/lib-commonjs/utilities/FocusableTooltipText.js +1 -1
- package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/SVGTooltipText.js +8 -8
- package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/image-export-utils.js +108 -0
- package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
- package/package.json +12 -12
|
@@ -243,6 +243,526 @@ export const resolveXAxisPoint = (x, isXYearCategory, isXString, isXDate, isXNum
|
|
|
243
243
|
}
|
|
244
244
|
return flattened;
|
|
245
245
|
};
|
|
246
|
+
const encodeHtmlEntities = (value)=>value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
|
247
|
+
const toFiniteNumber = (value)=>{
|
|
248
|
+
if (value === undefined || value === null) {
|
|
249
|
+
return undefined;
|
|
250
|
+
}
|
|
251
|
+
const numeric = typeof value === 'number' ? value : Number(value);
|
|
252
|
+
return Number.isFinite(numeric) ? numeric : undefined;
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* Normalizes Plotly axis reference strings so equivalent aliases (e.g. `xaxis1`, `x1`) collapse to the base axis id.
|
|
256
|
+
*/ const normalizeAxisRef = (ref, axis)=>{
|
|
257
|
+
if (!ref) {
|
|
258
|
+
return axis;
|
|
259
|
+
}
|
|
260
|
+
const normalized = ref.toLowerCase();
|
|
261
|
+
if (normalized === axis || normalized === `${axis}axis` || normalized === `${axis}axis1` || normalized === `${axis}1`) {
|
|
262
|
+
return axis;
|
|
263
|
+
}
|
|
264
|
+
const match = normalized.match(/^([xy])(axis)?(\d+)$/);
|
|
265
|
+
if (match && match[1] === axis && match[3]) {
|
|
266
|
+
return match[3] === '1' ? axis : `${axis}${match[3]}`;
|
|
267
|
+
}
|
|
268
|
+
return normalized;
|
|
269
|
+
};
|
|
270
|
+
/**
|
|
271
|
+
* Scans the data traces bound to a given axis and returns the numeric min/max values plotted on that axis.
|
|
272
|
+
*/ const getAxisNumericRangeFromData = (axis, ref, layout, data)=>{
|
|
273
|
+
if (!data || data.length === 0) {
|
|
274
|
+
return undefined;
|
|
275
|
+
}
|
|
276
|
+
const axisLayout = getAxisLayoutByRef(layout, ref, axis);
|
|
277
|
+
const targetRef = normalizeAxisRef(ref, axis);
|
|
278
|
+
const traceAxisKey = axis === 'x' ? 'xaxis' : 'yaxis';
|
|
279
|
+
let minValue;
|
|
280
|
+
let maxValue;
|
|
281
|
+
data.forEach((trace)=>{
|
|
282
|
+
const plotTrace = trace;
|
|
283
|
+
const traceAxisRef = normalizeAxisRef(plotTrace[traceAxisKey], axis);
|
|
284
|
+
if (traceAxisRef !== targetRef) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
const values = axis === 'x' ? plotTrace.x : plotTrace.y;
|
|
288
|
+
if (!isArrayOrTypedArray(values)) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
const arrayLike = values;
|
|
292
|
+
for(let index = 0; index < arrayLike.length; index++){
|
|
293
|
+
const value = arrayLike[index];
|
|
294
|
+
const numeric = toNumericValue(convertDataValue(value, axisLayout));
|
|
295
|
+
if (numeric === undefined || Number.isNaN(numeric)) {
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
minValue = minValue === undefined ? numeric : Math.min(minValue, numeric);
|
|
299
|
+
maxValue = maxValue === undefined ? numeric : Math.max(maxValue, numeric);
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
if (minValue === undefined || maxValue === undefined || minValue === maxValue) {
|
|
303
|
+
return undefined;
|
|
304
|
+
}
|
|
305
|
+
return [
|
|
306
|
+
minValue,
|
|
307
|
+
maxValue
|
|
308
|
+
];
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* Converts Plotly's bottom-origin relative Y coordinate into the SVG top-origin space used by our overlay.
|
|
312
|
+
*/ const transformRelativeYForChart = (value)=>{
|
|
313
|
+
if (value === undefined) {
|
|
314
|
+
return undefined;
|
|
315
|
+
}
|
|
316
|
+
if (!Number.isFinite(value)) {
|
|
317
|
+
return undefined;
|
|
318
|
+
}
|
|
319
|
+
return 1 - value;
|
|
320
|
+
};
|
|
321
|
+
const mapHorizontalAlign = (anchor)=>{
|
|
322
|
+
switch((anchor !== null && anchor !== void 0 ? anchor : '').toLowerCase()){
|
|
323
|
+
case 'left':
|
|
324
|
+
return 'start';
|
|
325
|
+
case 'center':
|
|
326
|
+
return 'center';
|
|
327
|
+
case 'right':
|
|
328
|
+
return 'end';
|
|
329
|
+
default:
|
|
330
|
+
return undefined;
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
const mapVerticalAlign = (anchor)=>{
|
|
334
|
+
switch((anchor !== null && anchor !== void 0 ? anchor : '').toLowerCase()){
|
|
335
|
+
case 'top':
|
|
336
|
+
return 'top';
|
|
337
|
+
case 'middle':
|
|
338
|
+
return 'middle';
|
|
339
|
+
case 'bottom':
|
|
340
|
+
return 'bottom';
|
|
341
|
+
default:
|
|
342
|
+
return undefined;
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
const appendPx = (value)=>{
|
|
346
|
+
if (value === undefined || value === null) {
|
|
347
|
+
return undefined;
|
|
348
|
+
}
|
|
349
|
+
if (typeof value === 'string') {
|
|
350
|
+
return value;
|
|
351
|
+
}
|
|
352
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
353
|
+
return `${value}px`;
|
|
354
|
+
}
|
|
355
|
+
return undefined;
|
|
356
|
+
};
|
|
357
|
+
/**
|
|
358
|
+
* Maps Plotly's axis reference string to one of our coordinate interpretation modes (axis, relative, or pixel).
|
|
359
|
+
*/ const resolveRefType = (ref, axis)=>{
|
|
360
|
+
if (!ref) {
|
|
361
|
+
return 'axis';
|
|
362
|
+
}
|
|
363
|
+
const normalized = ref.toLowerCase();
|
|
364
|
+
if (normalized === 'pixel') {
|
|
365
|
+
return 'pixel';
|
|
366
|
+
}
|
|
367
|
+
if (normalized === 'paper') {
|
|
368
|
+
return 'relative';
|
|
369
|
+
}
|
|
370
|
+
if (normalized.endsWith(' domain')) {
|
|
371
|
+
return normalized.startsWith(axis) ? 'relative' : undefined;
|
|
372
|
+
}
|
|
373
|
+
const match = normalized.match(/^([xy])(\d*)$/);
|
|
374
|
+
if (match && match[1] === axis) {
|
|
375
|
+
return 'axis';
|
|
376
|
+
}
|
|
377
|
+
return undefined;
|
|
378
|
+
};
|
|
379
|
+
/**
|
|
380
|
+
* Retrieves the appropriate axis layout section from Plotly's layout given an axis reference alias.
|
|
381
|
+
*/ const getAxisLayoutByRef = (layout, ref, axis)=>{
|
|
382
|
+
if (!layout) {
|
|
383
|
+
return undefined;
|
|
384
|
+
}
|
|
385
|
+
const defaultAxisKey = `${axis}axis`;
|
|
386
|
+
if (!ref) {
|
|
387
|
+
return layout[defaultAxisKey];
|
|
388
|
+
}
|
|
389
|
+
const normalized = ref.toLowerCase();
|
|
390
|
+
if (normalized === 'paper' || normalized === 'pixel' || normalized.endsWith(' domain')) {
|
|
391
|
+
return layout[defaultAxisKey];
|
|
392
|
+
}
|
|
393
|
+
const match = normalized.match(/^([xy])(\d*)$/);
|
|
394
|
+
if (match && match[1] === axis) {
|
|
395
|
+
const index = match[2];
|
|
396
|
+
if (index && index !== '' && index !== '1') {
|
|
397
|
+
const axisKey = `${axis}axis${index}`;
|
|
398
|
+
return layout[axisKey];
|
|
399
|
+
}
|
|
400
|
+
return layout[defaultAxisKey];
|
|
401
|
+
}
|
|
402
|
+
return layout[defaultAxisKey];
|
|
403
|
+
};
|
|
404
|
+
/**
|
|
405
|
+
* Normalizes raw Plotly data values into canonical number/date/string types based on axis configuration.
|
|
406
|
+
*/ const convertDataValue = (value, axisLayout)=>{
|
|
407
|
+
if (value === undefined || value === null) {
|
|
408
|
+
return undefined;
|
|
409
|
+
}
|
|
410
|
+
if ((axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) === 'date' || isDate(value)) {
|
|
411
|
+
const dateValue = value instanceof Date ? value : new Date(value);
|
|
412
|
+
return Number.isNaN(dateValue.getTime()) ? undefined : dateValue;
|
|
413
|
+
}
|
|
414
|
+
if (typeof value === 'number') {
|
|
415
|
+
return value;
|
|
416
|
+
}
|
|
417
|
+
if ((axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) === 'linear' || (axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) === 'log') {
|
|
418
|
+
const numeric = Number(value);
|
|
419
|
+
return Number.isFinite(numeric) ? numeric : undefined;
|
|
420
|
+
}
|
|
421
|
+
if (value instanceof Date) {
|
|
422
|
+
return value;
|
|
423
|
+
}
|
|
424
|
+
return value;
|
|
425
|
+
};
|
|
426
|
+
const toNumericValue = (value)=>{
|
|
427
|
+
if (value instanceof Date) {
|
|
428
|
+
const timestamp = value.getTime();
|
|
429
|
+
return Number.isFinite(timestamp) ? timestamp : undefined;
|
|
430
|
+
}
|
|
431
|
+
if (typeof value === 'number') {
|
|
432
|
+
return Number.isFinite(value) ? value : undefined;
|
|
433
|
+
}
|
|
434
|
+
if (typeof value === 'string') {
|
|
435
|
+
const numeric = Number(value);
|
|
436
|
+
return Number.isFinite(numeric) ? numeric : undefined;
|
|
437
|
+
}
|
|
438
|
+
return undefined;
|
|
439
|
+
};
|
|
440
|
+
const toRelativeCoordinate = (value, axisLayout, fallbackRange)=>{
|
|
441
|
+
const range = Array.isArray(axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.range) ? axisLayout.range : undefined;
|
|
442
|
+
let start = range && range.length >= 2 ? toNumericValue(convertDataValue(range[0], axisLayout)) : undefined;
|
|
443
|
+
let end = range && range.length >= 2 ? toNumericValue(convertDataValue(range[1], axisLayout)) : undefined;
|
|
444
|
+
if ((start === undefined || end === undefined || start === end) && fallbackRange) {
|
|
445
|
+
[start, end] = fallbackRange;
|
|
446
|
+
}
|
|
447
|
+
const current = toNumericValue(convertDataValue(value, axisLayout));
|
|
448
|
+
if (start === undefined || end === undefined || current === undefined || start === end) {
|
|
449
|
+
return undefined;
|
|
450
|
+
}
|
|
451
|
+
const relative = (current - start) / (end - start);
|
|
452
|
+
return Number.isFinite(relative) ? relative : undefined;
|
|
453
|
+
};
|
|
454
|
+
const createAnnotationId = (text, index)=>{
|
|
455
|
+
const normalized = text.replace(/\s+/g, ' ').trim();
|
|
456
|
+
if (normalized) {
|
|
457
|
+
const slug = normalized.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 32);
|
|
458
|
+
if (slug) {
|
|
459
|
+
return `annotation-${index}-${slug}`;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
return `annotation-${index}`;
|
|
463
|
+
};
|
|
464
|
+
const DEFAULT_ARROW_OFFSET = -40;
|
|
465
|
+
const mapArrowsideToArrow = (annotation)=>{
|
|
466
|
+
let includeStart = false;
|
|
467
|
+
let includeEnd = false;
|
|
468
|
+
const arrowSide = typeof (annotation === null || annotation === void 0 ? void 0 : annotation.arrowside) === 'string' ? annotation === null || annotation === void 0 ? void 0 : annotation.arrowside.toLowerCase() : undefined;
|
|
469
|
+
if (arrowSide) {
|
|
470
|
+
includeStart = arrowSide.includes('start');
|
|
471
|
+
includeEnd = arrowSide.includes('end');
|
|
472
|
+
}
|
|
473
|
+
const endHead = toFiniteNumber(annotation === null || annotation === void 0 ? void 0 : annotation.arrowhead);
|
|
474
|
+
const startHead = toFiniteNumber(annotation.startarrowhead);
|
|
475
|
+
if (endHead !== undefined && endHead > 0) {
|
|
476
|
+
includeEnd = true;
|
|
477
|
+
}
|
|
478
|
+
if (startHead !== undefined && startHead > 0) {
|
|
479
|
+
includeStart = true;
|
|
480
|
+
}
|
|
481
|
+
if (includeStart && includeEnd) {
|
|
482
|
+
return 'both';
|
|
483
|
+
}
|
|
484
|
+
if (includeStart) {
|
|
485
|
+
return 'start';
|
|
486
|
+
}
|
|
487
|
+
if (includeEnd) {
|
|
488
|
+
return 'end';
|
|
489
|
+
}
|
|
490
|
+
return 'none';
|
|
491
|
+
};
|
|
492
|
+
const mapArrowDashToPattern = (value)=>{
|
|
493
|
+
if (!value) {
|
|
494
|
+
return undefined;
|
|
495
|
+
}
|
|
496
|
+
const normalized = value.trim().toLowerCase();
|
|
497
|
+
switch(normalized){
|
|
498
|
+
case 'solid':
|
|
499
|
+
return undefined;
|
|
500
|
+
case 'dot':
|
|
501
|
+
return '1, 5';
|
|
502
|
+
case 'dash':
|
|
503
|
+
return '5, 5';
|
|
504
|
+
case 'longdash':
|
|
505
|
+
return '10, 5';
|
|
506
|
+
case 'dashdot':
|
|
507
|
+
return '5, 5, 1, 5';
|
|
508
|
+
case 'longdashdot':
|
|
509
|
+
return '10, 5, 1, 5';
|
|
510
|
+
default:
|
|
511
|
+
if (/^\d+(\s|,)*\d*$/.test(normalized.replace(/\s+/g, ' '))) {
|
|
512
|
+
return normalized.replace(/\s+/g, ' ');
|
|
513
|
+
}
|
|
514
|
+
return value;
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
/**
|
|
518
|
+
* Converts a Plotly annotation definition into the internal `ChartAnnotation` format, translating coordinates,
|
|
519
|
+
* layout alignment, styling, and connector metadata while skipping unsupported configurations.
|
|
520
|
+
*/ const convertPlotlyAnnotation = (annotation, layout, data, index)=>{
|
|
521
|
+
if (!annotation || annotation.visible === false) {
|
|
522
|
+
return undefined;
|
|
523
|
+
}
|
|
524
|
+
const xRefType = resolveRefType(annotation.xref, 'x');
|
|
525
|
+
const yRefType = resolveRefType(annotation.yref, 'y');
|
|
526
|
+
if (!xRefType || !yRefType) {
|
|
527
|
+
return undefined;
|
|
528
|
+
}
|
|
529
|
+
let coordinates;
|
|
530
|
+
if (xRefType === 'axis' && yRefType === 'axis') {
|
|
531
|
+
const xAxisLayout = getAxisLayoutByRef(layout, annotation.xref, 'x');
|
|
532
|
+
const yAxisLayout = getAxisLayoutByRef(layout, annotation.yref, 'y');
|
|
533
|
+
const xValue = convertDataValue(annotation.x, xAxisLayout);
|
|
534
|
+
const yValue = convertDataValue(annotation.y, yAxisLayout);
|
|
535
|
+
if (xValue === undefined || yValue === undefined) {
|
|
536
|
+
return undefined;
|
|
537
|
+
}
|
|
538
|
+
const yRefNormalized = typeof annotation.yref === 'string' ? annotation.yref.toLowerCase() : undefined;
|
|
539
|
+
coordinates = {
|
|
540
|
+
type: 'data',
|
|
541
|
+
x: xValue,
|
|
542
|
+
y: yValue,
|
|
543
|
+
...yRefNormalized === 'y2' ? {
|
|
544
|
+
yAxis: 'secondary'
|
|
545
|
+
} : {}
|
|
546
|
+
};
|
|
547
|
+
} else if (xRefType === 'relative' && yRefType === 'relative') {
|
|
548
|
+
const xValue = toFiniteNumber(annotation.x);
|
|
549
|
+
const yValue = toFiniteNumber(annotation.y);
|
|
550
|
+
const chartRelativeY = transformRelativeYForChart(yValue);
|
|
551
|
+
if (xValue === undefined || chartRelativeY === undefined) {
|
|
552
|
+
return undefined;
|
|
553
|
+
}
|
|
554
|
+
coordinates = {
|
|
555
|
+
type: 'relative',
|
|
556
|
+
x: xValue,
|
|
557
|
+
y: chartRelativeY
|
|
558
|
+
};
|
|
559
|
+
} else if (xRefType === 'relative' && yRefType === 'axis') {
|
|
560
|
+
const xValue = toFiniteNumber(annotation.x);
|
|
561
|
+
const yAxisLayout = getAxisLayoutByRef(layout, annotation.yref, 'y');
|
|
562
|
+
const yFallbackRange = getAxisNumericRangeFromData('y', annotation.yref, layout, data);
|
|
563
|
+
const yRelative = toRelativeCoordinate(annotation.y, yAxisLayout, yFallbackRange);
|
|
564
|
+
const chartRelativeY = transformRelativeYForChart(yRelative);
|
|
565
|
+
if (xValue === undefined || chartRelativeY === undefined) {
|
|
566
|
+
return undefined;
|
|
567
|
+
}
|
|
568
|
+
coordinates = {
|
|
569
|
+
type: 'relative',
|
|
570
|
+
x: xValue,
|
|
571
|
+
y: chartRelativeY
|
|
572
|
+
};
|
|
573
|
+
} else if (xRefType === 'axis' && yRefType === 'relative') {
|
|
574
|
+
const yValue = toFiniteNumber(annotation.y);
|
|
575
|
+
const xAxisLayout = getAxisLayoutByRef(layout, annotation.xref, 'x');
|
|
576
|
+
const xFallbackRange = getAxisNumericRangeFromData('x', annotation.xref, layout, data);
|
|
577
|
+
const xRelative = toRelativeCoordinate(annotation.x, xAxisLayout, xFallbackRange);
|
|
578
|
+
const chartRelativeY = transformRelativeYForChart(yValue);
|
|
579
|
+
if (xRelative === undefined || chartRelativeY === undefined) {
|
|
580
|
+
return undefined;
|
|
581
|
+
}
|
|
582
|
+
coordinates = {
|
|
583
|
+
type: 'relative',
|
|
584
|
+
x: xRelative,
|
|
585
|
+
y: chartRelativeY
|
|
586
|
+
};
|
|
587
|
+
} else if (xRefType === 'pixel' && yRefType === 'pixel') {
|
|
588
|
+
const xValue = toFiniteNumber(annotation.x);
|
|
589
|
+
const yValue = toFiniteNumber(annotation.y);
|
|
590
|
+
if (xValue === undefined || yValue === undefined) {
|
|
591
|
+
return undefined;
|
|
592
|
+
}
|
|
593
|
+
coordinates = {
|
|
594
|
+
type: 'pixel',
|
|
595
|
+
x: xValue,
|
|
596
|
+
y: yValue
|
|
597
|
+
};
|
|
598
|
+
} else {
|
|
599
|
+
return undefined;
|
|
600
|
+
}
|
|
601
|
+
const textValue = annotation.text;
|
|
602
|
+
const rawText = textValue === undefined || textValue === null ? '' : String(textValue);
|
|
603
|
+
const encodedText = encodeHtmlEntities(rawText);
|
|
604
|
+
const chartAnnotation = {
|
|
605
|
+
id: createAnnotationId(encodedText, index),
|
|
606
|
+
text: encodedText,
|
|
607
|
+
coordinates
|
|
608
|
+
};
|
|
609
|
+
const layoutProps = {};
|
|
610
|
+
const styleProps = {};
|
|
611
|
+
const showArrow = annotation.showarrow === undefined ? false : !!annotation.showarrow;
|
|
612
|
+
const clipOnAxis = annotation.cliponaxis;
|
|
613
|
+
if (clipOnAxis !== undefined) {
|
|
614
|
+
layoutProps.clipToBounds = !!clipOnAxis;
|
|
615
|
+
} else if (coordinates.type === 'data') {
|
|
616
|
+
layoutProps.clipToBounds = true;
|
|
617
|
+
}
|
|
618
|
+
const horizontalAlign = mapHorizontalAlign(annotation.xanchor);
|
|
619
|
+
if (horizontalAlign) {
|
|
620
|
+
layoutProps.align = horizontalAlign;
|
|
621
|
+
}
|
|
622
|
+
if (!layoutProps.align) {
|
|
623
|
+
const alignProp = mapHorizontalAlign(annotation.align);
|
|
624
|
+
if (alignProp) {
|
|
625
|
+
layoutProps.align = alignProp;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
const verticalAlign = mapVerticalAlign(annotation.yanchor);
|
|
629
|
+
if (verticalAlign) {
|
|
630
|
+
layoutProps.verticalAlign = verticalAlign;
|
|
631
|
+
}
|
|
632
|
+
if (!layoutProps.verticalAlign) {
|
|
633
|
+
const valignProp = mapVerticalAlign(annotation.valign);
|
|
634
|
+
if (valignProp) {
|
|
635
|
+
layoutProps.verticalAlign = valignProp;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
const offsetXComponents = [];
|
|
639
|
+
let hasExplicitOffset = false;
|
|
640
|
+
const ax = toFiniteNumber(annotation.ax);
|
|
641
|
+
const axRef = typeof annotation.axref === 'string' ? annotation.axref.toLowerCase() : undefined;
|
|
642
|
+
if (ax !== undefined && (axRef === undefined || axRef === 'pixel')) {
|
|
643
|
+
offsetXComponents.push(ax);
|
|
644
|
+
hasExplicitOffset = true;
|
|
645
|
+
}
|
|
646
|
+
const xShift = toFiniteNumber(annotation.xshift);
|
|
647
|
+
if (xShift !== undefined) {
|
|
648
|
+
offsetXComponents.push(xShift);
|
|
649
|
+
hasExplicitOffset = true;
|
|
650
|
+
}
|
|
651
|
+
if (offsetXComponents.length > 0) {
|
|
652
|
+
const offsetX = offsetXComponents.reduce((sum, value)=>sum + value, 0);
|
|
653
|
+
if (offsetX !== 0) {
|
|
654
|
+
layoutProps.offsetX = offsetX;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
const offsetYComponents = [];
|
|
658
|
+
const ay = toFiniteNumber(annotation.ay);
|
|
659
|
+
const ayRef = typeof annotation.ayref === 'string' ? annotation.ayref.toLowerCase() : undefined;
|
|
660
|
+
if (ay !== undefined && (ayRef === undefined || ayRef === 'pixel')) {
|
|
661
|
+
offsetYComponents.push(ay);
|
|
662
|
+
hasExplicitOffset = true;
|
|
663
|
+
}
|
|
664
|
+
const yShift = toFiniteNumber(annotation.yshift);
|
|
665
|
+
if (yShift !== undefined) {
|
|
666
|
+
offsetYComponents.push(yShift);
|
|
667
|
+
hasExplicitOffset = true;
|
|
668
|
+
}
|
|
669
|
+
if (offsetYComponents.length > 0) {
|
|
670
|
+
const offsetY = offsetYComponents.reduce((sum, value)=>sum + value, 0);
|
|
671
|
+
if (offsetY !== 0) {
|
|
672
|
+
layoutProps.offsetY = offsetY;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
if (showArrow && !hasExplicitOffset && layoutProps.offsetY === undefined) {
|
|
676
|
+
layoutProps.offsetY = DEFAULT_ARROW_OFFSET;
|
|
677
|
+
}
|
|
678
|
+
const maxWidth = toFiniteNumber(annotation.width);
|
|
679
|
+
if (maxWidth !== undefined) {
|
|
680
|
+
layoutProps.maxWidth = maxWidth;
|
|
681
|
+
}
|
|
682
|
+
if (annotation.bgcolor) {
|
|
683
|
+
styleProps.backgroundColor = annotation.bgcolor;
|
|
684
|
+
}
|
|
685
|
+
if (annotation.bordercolor) {
|
|
686
|
+
styleProps.borderColor = annotation.bordercolor;
|
|
687
|
+
}
|
|
688
|
+
const borderWidth = toFiniteNumber(annotation.borderwidth);
|
|
689
|
+
if (borderWidth !== undefined) {
|
|
690
|
+
styleProps.borderWidth = borderWidth;
|
|
691
|
+
}
|
|
692
|
+
const borderPad = appendPx(annotation.borderpad);
|
|
693
|
+
if (borderPad) {
|
|
694
|
+
styleProps.padding = borderPad;
|
|
695
|
+
}
|
|
696
|
+
const opacity = toFiniteNumber(annotation.opacity);
|
|
697
|
+
if (opacity !== undefined) {
|
|
698
|
+
styleProps.opacity = opacity;
|
|
699
|
+
}
|
|
700
|
+
if (annotation.font) {
|
|
701
|
+
const font = annotation.font;
|
|
702
|
+
if (font === null || font === void 0 ? void 0 : font.color) {
|
|
703
|
+
styleProps.textColor = font.color;
|
|
704
|
+
}
|
|
705
|
+
const fontSize = appendPx(font === null || font === void 0 ? void 0 : font.size);
|
|
706
|
+
if (fontSize) {
|
|
707
|
+
styleProps.fontSize = fontSize;
|
|
708
|
+
}
|
|
709
|
+
if (font === null || font === void 0 ? void 0 : font.weight) {
|
|
710
|
+
styleProps.fontWeight = font.weight;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
const textAngle = annotation === null || annotation === void 0 ? void 0 : annotation.textangle;
|
|
714
|
+
if (typeof textAngle === 'number' && !Number.isNaN(textAngle)) {
|
|
715
|
+
styleProps.rotation = textAngle;
|
|
716
|
+
} else if (typeof textAngle === 'string' && textAngle.toLowerCase() !== 'auto') {
|
|
717
|
+
const parsedAngle = Number(textAngle);
|
|
718
|
+
if (!Number.isNaN(parsedAngle)) {
|
|
719
|
+
styleProps.rotation = parsedAngle;
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
if (Object.keys(layoutProps).length > 0) {
|
|
723
|
+
chartAnnotation.layout = layoutProps;
|
|
724
|
+
}
|
|
725
|
+
if (Object.keys(styleProps).length > 0) {
|
|
726
|
+
chartAnnotation.style = styleProps;
|
|
727
|
+
}
|
|
728
|
+
if (showArrow) {
|
|
729
|
+
var _annotation_arrowcolor;
|
|
730
|
+
const arrowColor = (_annotation_arrowcolor = annotation.arrowcolor) !== null && _annotation_arrowcolor !== void 0 ? _annotation_arrowcolor : styleProps.textColor;
|
|
731
|
+
const arrowWidth = toFiniteNumber(annotation.arrowwidth);
|
|
732
|
+
const endPadding = toFiniteNumber(annotation.standoff);
|
|
733
|
+
const startPadding = toFiniteNumber(annotation.startstandoff);
|
|
734
|
+
const dashPattern = mapArrowDashToPattern(annotation.arrowdash);
|
|
735
|
+
chartAnnotation.connector = {
|
|
736
|
+
...arrowColor ? {
|
|
737
|
+
strokeColor: arrowColor
|
|
738
|
+
} : {},
|
|
739
|
+
...arrowWidth !== undefined ? {
|
|
740
|
+
strokeWidth: arrowWidth
|
|
741
|
+
} : {},
|
|
742
|
+
...endPadding !== undefined ? {
|
|
743
|
+
endPadding: Math.max(endPadding, 0)
|
|
744
|
+
} : {},
|
|
745
|
+
...startPadding !== undefined ? {
|
|
746
|
+
startPadding: Math.max(startPadding, 0)
|
|
747
|
+
} : {},
|
|
748
|
+
...dashPattern ? {
|
|
749
|
+
dashArray: dashPattern
|
|
750
|
+
} : {},
|
|
751
|
+
arrow: mapArrowsideToArrow(annotation)
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
return chartAnnotation;
|
|
755
|
+
};
|
|
756
|
+
const getChartAnnotationsFromLayout = (layout, data, isMultiPlot)=>{
|
|
757
|
+
if (isMultiPlot || !(layout === null || layout === void 0 ? void 0 : layout.annotations)) {
|
|
758
|
+
return undefined;
|
|
759
|
+
}
|
|
760
|
+
const annotationsArray = Array.isArray(layout.annotations) ? layout.annotations : [
|
|
761
|
+
layout.annotations
|
|
762
|
+
];
|
|
763
|
+
const converted = annotationsArray.map((annotation, index)=>convertPlotlyAnnotation(annotation, layout, data, index)).filter((annotation)=>annotation !== undefined);
|
|
764
|
+
return converted.length > 0 ? converted : undefined;
|
|
765
|
+
};
|
|
246
766
|
/**
|
|
247
767
|
* Normalizes an array of objects by flattening nested structures and creating grouped data
|
|
248
768
|
* Uses json_normalize approach with D3 color detection and filtering
|
|
@@ -319,6 +839,34 @@ export const resolveXAxisPoint = (x, isXYearCategory, isXString, isXDate, isXNum
|
|
|
319
839
|
x
|
|
320
840
|
};
|
|
321
841
|
};
|
|
842
|
+
export const transformPlotlyJsonToAnnotationChartProps = (input, isMultiPlot, _colorMap, _colorwayType, _isDarkTheme)=>{
|
|
843
|
+
var _layoutWithMeta_meta, _input_layout, _input_layout1, _input_layout2, _input_layout3, _input_layout_font, _input_layout4, _input_layout_font1, _input_layout5, _input_layout6;
|
|
844
|
+
var _getChartAnnotationsFromLayout;
|
|
845
|
+
const annotations = (_getChartAnnotationsFromLayout = getChartAnnotationsFromLayout(input.layout, input.data, isMultiPlot)) !== null && _getChartAnnotationsFromLayout !== void 0 ? _getChartAnnotationsFromLayout : [];
|
|
846
|
+
const titles = getTitles(input.layout);
|
|
847
|
+
const layoutTitle = titles.chartTitle || undefined;
|
|
848
|
+
const layoutWithMeta = input.layout;
|
|
849
|
+
const description = typeof (layoutWithMeta === null || layoutWithMeta === void 0 ? void 0 : (_layoutWithMeta_meta = layoutWithMeta.meta) === null || _layoutWithMeta_meta === void 0 ? void 0 : _layoutWithMeta_meta.description) === 'string' ? layoutWithMeta.meta.description : undefined;
|
|
850
|
+
const width = typeof ((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width) === 'number' ? input.layout.width : undefined;
|
|
851
|
+
const height = typeof ((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) === 'number' ? input.layout.height : undefined;
|
|
852
|
+
const paperBackgroundColor = typeof ((_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.paper_bgcolor) === 'string' ? input.layout.paper_bgcolor : undefined;
|
|
853
|
+
const plotBackgroundColor = typeof ((_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.plot_bgcolor) === 'string' ? input.layout.plot_bgcolor : undefined;
|
|
854
|
+
const fontColor = typeof ((_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : (_input_layout_font = _input_layout4.font) === null || _input_layout_font === void 0 ? void 0 : _input_layout_font.color) === 'string' ? input.layout.font.color : undefined;
|
|
855
|
+
const fontFamily = typeof ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : (_input_layout_font1 = _input_layout5.font) === null || _input_layout_font1 === void 0 ? void 0 : _input_layout_font1.family) === 'string' ? input.layout.font.family : undefined;
|
|
856
|
+
const margin = (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.margin;
|
|
857
|
+
return {
|
|
858
|
+
annotations,
|
|
859
|
+
chartTitle: layoutTitle,
|
|
860
|
+
description,
|
|
861
|
+
width,
|
|
862
|
+
height,
|
|
863
|
+
paperBackgroundColor,
|
|
864
|
+
plotBackgroundColor,
|
|
865
|
+
fontColor,
|
|
866
|
+
fontFamily,
|
|
867
|
+
margin
|
|
868
|
+
};
|
|
869
|
+
};
|
|
322
870
|
export const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
323
871
|
var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _firstData_marker, _input_layout3, _input_layout4, _input_layout5, _input_layout6;
|
|
324
872
|
const firstData = input.data[0];
|
|
@@ -558,6 +1106,7 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
558
1106
|
});
|
|
559
1107
|
});
|
|
560
1108
|
const vsbcData = Object.values(mapXToDataPoints);
|
|
1109
|
+
const annotations = getChartAnnotationsFromLayout(input.layout, input.data, isMultiPlot);
|
|
561
1110
|
var _input_layout_height;
|
|
562
1111
|
return {
|
|
563
1112
|
data: vsbcData,
|
|
@@ -582,7 +1131,10 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
582
1131
|
...getAxisCategoryOrderProps(input.data, input.layout),
|
|
583
1132
|
...getBarProps(input.data, input.layout),
|
|
584
1133
|
...getYMinMaxValues(input.data[0], input.layout),
|
|
585
|
-
...getAxisTickProps(input.data, input.layout)
|
|
1134
|
+
...getAxisTickProps(input.data, input.layout),
|
|
1135
|
+
...annotations ? {
|
|
1136
|
+
annotations
|
|
1137
|
+
} : {}
|
|
586
1138
|
};
|
|
587
1139
|
};
|
|
588
1140
|
export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
@@ -689,6 +1241,7 @@ export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, col
|
|
|
689
1241
|
});
|
|
690
1242
|
}
|
|
691
1243
|
});
|
|
1244
|
+
const annotations = getChartAnnotationsFromLayout(processedInput.layout, processedInput.data, isMultiPlot);
|
|
692
1245
|
var _processedInput_layout_height;
|
|
693
1246
|
return {
|
|
694
1247
|
dataV2: gvbcDataV2,
|
|
@@ -707,7 +1260,10 @@ export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, col
|
|
|
707
1260
|
...getXAxisTickFormat(processedInput.data[0], processedInput.layout),
|
|
708
1261
|
...yAxisTickFormat,
|
|
709
1262
|
...getBarProps(processedInput.data, processedInput.layout),
|
|
710
|
-
...getAxisTickProps(processedInput.data, processedInput.layout)
|
|
1263
|
+
...getAxisTickProps(processedInput.data, processedInput.layout),
|
|
1264
|
+
...annotations ? {
|
|
1265
|
+
annotations
|
|
1266
|
+
} : {}
|
|
711
1267
|
};
|
|
712
1268
|
};
|
|
713
1269
|
export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
@@ -772,6 +1328,7 @@ export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colo
|
|
|
772
1328
|
});
|
|
773
1329
|
});
|
|
774
1330
|
});
|
|
1331
|
+
const annotations = getChartAnnotationsFromLayout(input.layout, input.data, isMultiPlot);
|
|
775
1332
|
var _input_layout_height;
|
|
776
1333
|
return {
|
|
777
1334
|
data: vbcData,
|
|
@@ -785,7 +1342,10 @@ export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colo
|
|
|
785
1342
|
roundCorners: true,
|
|
786
1343
|
...getTitles(input.layout),
|
|
787
1344
|
...getYMinMaxValues(input.data[0], input.layout),
|
|
788
|
-
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
1345
|
+
...getAxisCategoryOrderProps(input.data, input.layout),
|
|
1346
|
+
...annotations ? {
|
|
1347
|
+
annotations
|
|
1348
|
+
} : {}
|
|
789
1349
|
};
|
|
790
1350
|
};
|
|
791
1351
|
export const transformPlotlyJsonToAreaChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
@@ -976,6 +1536,7 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
976
1536
|
const scatterChartProps = {
|
|
977
1537
|
scatterChartData: chartData
|
|
978
1538
|
};
|
|
1539
|
+
const annotations = getChartAnnotationsFromLayout(input.layout, input.data, isMultiPlot);
|
|
979
1540
|
var _input_layout_height;
|
|
980
1541
|
const commonProps = {
|
|
981
1542
|
supportNegativeData: true,
|
|
@@ -985,13 +1546,16 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
985
1546
|
hideTickOverlap: true,
|
|
986
1547
|
hideLegend,
|
|
987
1548
|
useUTC: false,
|
|
988
|
-
|
|
1549
|
+
wrapXAxisLabels: shouldWrapLabels,
|
|
989
1550
|
optimizeLargeData: numDataPoints > 1000,
|
|
990
1551
|
...getTitles(input.layout),
|
|
991
1552
|
...getXAxisTickFormat(input.data[0], input.layout),
|
|
992
1553
|
...yAxisTickFormat,
|
|
993
1554
|
...getAxisScaleTypeProps(input.data, input.layout),
|
|
994
|
-
...getAxisTickProps(input.data, input.layout)
|
|
1555
|
+
...getAxisTickProps(input.data, input.layout),
|
|
1556
|
+
...annotations ? {
|
|
1557
|
+
annotations
|
|
1558
|
+
} : {}
|
|
995
1559
|
};
|
|
996
1560
|
if (isAreaChart) {
|
|
997
1561
|
return {
|
|
@@ -2128,7 +2692,8 @@ export const isNonPlotType = (chartType)=>{
|
|
|
2128
2692
|
return [
|
|
2129
2693
|
'donut',
|
|
2130
2694
|
'sankey',
|
|
2131
|
-
'pie'
|
|
2695
|
+
'pie',
|
|
2696
|
+
'annotation'
|
|
2132
2697
|
].includes(chartType);
|
|
2133
2698
|
};
|
|
2134
2699
|
export const getGridProperties = (schema, isMultiPlot, validTracesInfo)=>{
|