@fluentui/react-charting 5.24.38 → 5.25.0
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 +99 -1
- package/CHANGELOG.md +34 -2
- package/dist/react-charting.d.ts +129 -1
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +76 -1
- package/lib/components/AreaChart/AreaChart.base.d.ts +2 -1
- package/lib/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.base.d.ts +2 -1
- package/lib/components/ChartTable/ChartTable.base.js.map +1 -1
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.d.ts +3 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js +343 -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.d.ts +2 -1
- 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 +19 -2
- 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/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +641 -76
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/Arc/Arc.d.ts +2 -1
- package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.base.d.ts +2 -1
- package/lib/components/DonutChart/DonutChart.base.js.map +1 -1
- package/lib/components/DonutChart/Pie/Pie.d.ts +3 -2
- package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.base.js.map +1 -1
- package/lib/components/FunnelChart/funnelGeometry.js.map +1 -1
- package/lib/components/GanttChart/GanttChart.base.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.base.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.base.d.ts +2 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +2 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib/components/Legends/Legends.base.d.ts +2 -1
- package/lib/components/Legends/Legends.base.js.map +1 -1
- package/lib/components/LineChart/LineChart.base.d.ts +2 -1
- package/lib/components/LineChart/LineChart.base.js.map +1 -1
- package/lib/components/PieChart/Arc/Arc.d.ts +3 -2
- package/lib/components/PieChart/Arc/Arc.js.map +1 -1
- package/lib/components/PieChart/Pie/Pie.d.ts +3 -2
- package/lib/components/PieChart/Pie/Pie.js.map +1 -1
- package/lib/components/PieChart/PieChart.base.d.ts +2 -1
- package/lib/components/PieChart/PieChart.base.js.map +1 -1
- package/lib/components/ResponsiveContainer/withResponsiveContainer.js.map +1 -1
- package/lib/components/SankeyChart/SankeyChart.base.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib/components/Sparkline/Sparkline.base.d.ts +3 -2
- package/lib/components/Sparkline/Sparkline.base.js.map +1 -1
- package/lib/components/StackedBarChart/MultiStackedBarChart.base.d.ts +2 -1
- package/lib/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
- package/lib/components/StackedBarChart/StackedBarChart.base.d.ts +2 -1
- package/lib/components/StackedBarChart/StackedBarChart.base.js.map +1 -1
- package/lib/components/TreeChart/TreeChart.base.d.ts +2 -1
- package/lib/components/TreeChart/TreeChart.base.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.base.d.ts +2 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.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/scatterpolar-utils.d.ts +2 -2
- package/lib/utilities/scatterpolar-utils.js.map +1 -1
- package/lib/utilities/utilities.d.ts +14 -14
- package/lib/utilities/utilities.js +72 -20
- package/lib/utilities/utilities.js.map +1 -1
- package/lib/utilities/vbc-utils.js.map +1 -1
- package/lib-amd/components/AreaChart/AreaChart.base.d.ts +2 -1
- package/lib-amd/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib-amd/components/ChartTable/ChartTable.base.d.ts +2 -1
- package/lib-amd/components/ChartTable/ChartTable.base.js.map +1 -1
- package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.d.ts +3 -0
- package/lib-amd/components/CommonComponents/Annotations/ChartAnnotationLayer.js +344 -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.d.ts +2 -1
- 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 +19 -2
- 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/DeclarativeChart.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +641 -76
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/DonutChart/Arc/Arc.d.ts +2 -1
- package/lib-amd/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib-amd/components/DonutChart/DonutChart.base.d.ts +2 -1
- package/lib-amd/components/DonutChart/DonutChart.base.js.map +1 -1
- package/lib-amd/components/DonutChart/Pie/Pie.d.ts +3 -2
- package/lib-amd/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib-amd/components/FunnelChart/FunnelChart.base.js.map +1 -1
- package/lib-amd/components/FunnelChart/funnelGeometry.js.map +1 -1
- package/lib-amd/components/GanttChart/GanttChart.base.js.map +1 -1
- package/lib-amd/components/GaugeChart/GaugeChart.base.js.map +1 -1
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
- package/lib-amd/components/HorizontalBarChart/HorizontalBarChart.base.d.ts +2 -1
- package/lib-amd/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +2 -1
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib-amd/components/Legends/Legends.base.d.ts +2 -1
- package/lib-amd/components/Legends/Legends.base.js.map +1 -1
- package/lib-amd/components/LineChart/LineChart.base.d.ts +2 -1
- package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-amd/components/PieChart/Arc/Arc.d.ts +3 -2
- package/lib-amd/components/PieChart/Arc/Arc.js.map +1 -1
- package/lib-amd/components/PieChart/Pie/Pie.d.ts +3 -2
- package/lib-amd/components/PieChart/Pie/Pie.js.map +1 -1
- package/lib-amd/components/PieChart/PieChart.base.d.ts +2 -1
- package/lib-amd/components/PieChart/PieChart.base.js.map +1 -1
- package/lib-amd/components/ResponsiveContainer/withResponsiveContainer.js.map +1 -1
- package/lib-amd/components/SankeyChart/SankeyChart.base.js.map +1 -1
- package/lib-amd/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib-amd/components/Sparkline/Sparkline.base.d.ts +3 -2
- package/lib-amd/components/Sparkline/Sparkline.base.js.map +1 -1
- package/lib-amd/components/StackedBarChart/MultiStackedBarChart.base.d.ts +2 -1
- package/lib-amd/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
- package/lib-amd/components/StackedBarChart/StackedBarChart.base.d.ts +2 -1
- package/lib-amd/components/StackedBarChart/StackedBarChart.base.js.map +1 -1
- package/lib-amd/components/TreeChart/TreeChart.base.d.ts +2 -1
- package/lib-amd/components/TreeChart/TreeChart.base.js.map +1 -1
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.d.ts +2 -1
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.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/scatterpolar-utils.d.ts +2 -2
- package/lib-amd/utilities/scatterpolar-utils.js.map +1 -1
- package/lib-amd/utilities/utilities.d.ts +14 -14
- package/lib-amd/utilities/utilities.js +72 -20
- package/lib-amd/utilities/utilities.js.map +1 -1
- package/lib-amd/utilities/vbc-utils.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.base.d.ts +2 -1
- package/lib-commonjs/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.base.d.ts +2 -1
- package/lib-commonjs/components/ChartTable/ChartTable.base.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.d.ts +3 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js +346 -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.d.ts +2 -1
- 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 +19 -2
- 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/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +641 -76
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.d.ts +2 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.base.d.ts +2 -1
- package/lib-commonjs/components/DonutChart/DonutChart.base.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Pie/Pie.d.ts +3 -2
- package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.base.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/funnelGeometry.js.map +1 -1
- package/lib-commonjs/components/GanttChart/GanttChart.base.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.base.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.base.d.ts +2 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +2 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.base.d.ts +2 -1
- package/lib-commonjs/components/Legends/Legends.base.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.base.d.ts +2 -1
- package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-commonjs/components/PieChart/Arc/Arc.d.ts +3 -2
- package/lib-commonjs/components/PieChart/Arc/Arc.js.map +1 -1
- package/lib-commonjs/components/PieChart/Pie/Pie.d.ts +3 -2
- package/lib-commonjs/components/PieChart/Pie/Pie.js.map +1 -1
- package/lib-commonjs/components/PieChart/PieChart.base.d.ts +2 -1
- package/lib-commonjs/components/PieChart/PieChart.base.js.map +1 -1
- package/lib-commonjs/components/ResponsiveContainer/withResponsiveContainer.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.base.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib-commonjs/components/Sparkline/Sparkline.base.d.ts +3 -2
- package/lib-commonjs/components/Sparkline/Sparkline.base.js.map +1 -1
- package/lib-commonjs/components/StackedBarChart/MultiStackedBarChart.base.d.ts +2 -1
- package/lib-commonjs/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
- package/lib-commonjs/components/StackedBarChart/StackedBarChart.base.d.ts +2 -1
- package/lib-commonjs/components/StackedBarChart/StackedBarChart.base.js.map +1 -1
- package/lib-commonjs/components/TreeChart/TreeChart.base.d.ts +2 -1
- package/lib-commonjs/components/TreeChart/TreeChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.d.ts +2 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.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/scatterpolar-utils.d.ts +2 -2
- package/lib-commonjs/utilities/scatterpolar-utils.js.map +1 -1
- package/lib-commonjs/utilities/utilities.d.ts +14 -14
- package/lib-commonjs/utilities/utilities.js +72 -20
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/lib-commonjs/utilities/vbc-utils.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 +23 -1
|
@@ -262,6 +262,508 @@ var flattenObject = function (obj, prefix) {
|
|
|
262
262
|
}
|
|
263
263
|
return flattened;
|
|
264
264
|
};
|
|
265
|
+
var toFiniteNumber = function (value) {
|
|
266
|
+
if (value === undefined || value === null) {
|
|
267
|
+
return undefined;
|
|
268
|
+
}
|
|
269
|
+
var numeric = typeof value === 'number' ? value : Number(value);
|
|
270
|
+
return Number.isFinite(numeric) ? numeric : undefined;
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* Normalizes Plotly axis reference strings so equivalent aliases (e.g. `xaxis1`, `x1`) collapse to the base axis id.
|
|
274
|
+
*/
|
|
275
|
+
var normalizeAxisRef = function (ref, axis) {
|
|
276
|
+
if (!ref) {
|
|
277
|
+
return axis;
|
|
278
|
+
}
|
|
279
|
+
var normalized = ref.toLowerCase();
|
|
280
|
+
if (normalized === axis ||
|
|
281
|
+
normalized === "".concat(axis, "axis") ||
|
|
282
|
+
normalized === "".concat(axis, "axis1") ||
|
|
283
|
+
normalized === "".concat(axis, "1")) {
|
|
284
|
+
return axis;
|
|
285
|
+
}
|
|
286
|
+
var match = normalized.match(/^([xy])(axis)?(\d+)$/);
|
|
287
|
+
if (match && match[1] === axis && match[3]) {
|
|
288
|
+
return match[3] === '1' ? axis : "".concat(axis).concat(match[3]);
|
|
289
|
+
}
|
|
290
|
+
return normalized;
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* Scans the data traces bound to a given axis and returns the numeric min/max values plotted on that axis.
|
|
294
|
+
*/
|
|
295
|
+
var getAxisNumericRangeFromData = function (axis, ref, layout, data) {
|
|
296
|
+
if (!data || data.length === 0) {
|
|
297
|
+
return undefined;
|
|
298
|
+
}
|
|
299
|
+
var axisLayout = getAxisLayoutByRef(layout, ref, axis);
|
|
300
|
+
var targetRef = normalizeAxisRef(ref, axis);
|
|
301
|
+
var traceAxisKey = axis === 'x' ? 'xaxis' : 'yaxis';
|
|
302
|
+
var minValue;
|
|
303
|
+
var maxValue;
|
|
304
|
+
data.forEach(function (trace) {
|
|
305
|
+
var plotTrace = trace;
|
|
306
|
+
var traceAxisRef = normalizeAxisRef(plotTrace[traceAxisKey], axis);
|
|
307
|
+
if (traceAxisRef !== targetRef) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
var values = (axis === 'x' ? plotTrace.x : plotTrace.y);
|
|
311
|
+
if (!(0, chart_utilities_1.isArrayOrTypedArray)(values)) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
var arrayLike = values;
|
|
315
|
+
for (var index = 0; index < arrayLike.length; index++) {
|
|
316
|
+
var value = arrayLike[index];
|
|
317
|
+
var numeric = toNumericValue(convertDataValue(value, axisLayout));
|
|
318
|
+
if (numeric === undefined || Number.isNaN(numeric)) {
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
minValue = minValue === undefined ? numeric : Math.min(minValue, numeric);
|
|
322
|
+
maxValue = maxValue === undefined ? numeric : Math.max(maxValue, numeric);
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
if (minValue === undefined || maxValue === undefined || minValue === maxValue) {
|
|
326
|
+
return undefined;
|
|
327
|
+
}
|
|
328
|
+
return [minValue, maxValue];
|
|
329
|
+
};
|
|
330
|
+
/**
|
|
331
|
+
* Converts Plotly's bottom-origin relative Y coordinate into the SVG top-origin space used by our overlay.
|
|
332
|
+
*/
|
|
333
|
+
var transformRelativeYForChart = function (value) {
|
|
334
|
+
if (value === undefined) {
|
|
335
|
+
return undefined;
|
|
336
|
+
}
|
|
337
|
+
if (!Number.isFinite(value)) {
|
|
338
|
+
return undefined;
|
|
339
|
+
}
|
|
340
|
+
return 1 - value;
|
|
341
|
+
};
|
|
342
|
+
var mapHorizontalAlign = function (anchor) {
|
|
343
|
+
switch ((anchor !== null && anchor !== void 0 ? anchor : '').toLowerCase()) {
|
|
344
|
+
case 'left':
|
|
345
|
+
return 'start';
|
|
346
|
+
case 'center':
|
|
347
|
+
return 'center';
|
|
348
|
+
case 'right':
|
|
349
|
+
return 'end';
|
|
350
|
+
default:
|
|
351
|
+
return undefined;
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
var mapVerticalAlign = function (anchor) {
|
|
355
|
+
switch ((anchor !== null && anchor !== void 0 ? anchor : '').toLowerCase()) {
|
|
356
|
+
case 'top':
|
|
357
|
+
return 'top';
|
|
358
|
+
case 'middle':
|
|
359
|
+
return 'middle';
|
|
360
|
+
case 'bottom':
|
|
361
|
+
return 'bottom';
|
|
362
|
+
default:
|
|
363
|
+
return undefined;
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
var appendPx = function (value) {
|
|
367
|
+
if (value === undefined || value === null) {
|
|
368
|
+
return undefined;
|
|
369
|
+
}
|
|
370
|
+
if (typeof value === 'string') {
|
|
371
|
+
return value;
|
|
372
|
+
}
|
|
373
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
374
|
+
return "".concat(value, "px");
|
|
375
|
+
}
|
|
376
|
+
return undefined;
|
|
377
|
+
};
|
|
378
|
+
/**
|
|
379
|
+
* Maps Plotly's axis reference string to one of our coordinate interpretation modes (axis, relative, or pixel).
|
|
380
|
+
*/
|
|
381
|
+
var resolveRefType = function (ref, axis) {
|
|
382
|
+
if (!ref) {
|
|
383
|
+
return 'axis';
|
|
384
|
+
}
|
|
385
|
+
var normalized = ref.toLowerCase();
|
|
386
|
+
if (normalized === 'pixel') {
|
|
387
|
+
return 'pixel';
|
|
388
|
+
}
|
|
389
|
+
if (normalized === 'paper') {
|
|
390
|
+
return 'relative';
|
|
391
|
+
}
|
|
392
|
+
if (normalized.endsWith(' domain')) {
|
|
393
|
+
return normalized.startsWith(axis) ? 'relative' : undefined;
|
|
394
|
+
}
|
|
395
|
+
var match = normalized.match(/^([xy])(\d*)$/);
|
|
396
|
+
if (match && match[1] === axis) {
|
|
397
|
+
return 'axis';
|
|
398
|
+
}
|
|
399
|
+
return undefined;
|
|
400
|
+
};
|
|
401
|
+
/**
|
|
402
|
+
* Retrieves the appropriate axis layout section from Plotly's layout given an axis reference alias.
|
|
403
|
+
*/
|
|
404
|
+
var getAxisLayoutByRef = function (layout, ref, axis) {
|
|
405
|
+
if (!layout) {
|
|
406
|
+
return undefined;
|
|
407
|
+
}
|
|
408
|
+
var defaultAxisKey = "".concat(axis, "axis");
|
|
409
|
+
if (!ref) {
|
|
410
|
+
return layout[defaultAxisKey];
|
|
411
|
+
}
|
|
412
|
+
var normalized = ref.toLowerCase();
|
|
413
|
+
if (normalized === 'paper' || normalized === 'pixel' || normalized.endsWith(' domain')) {
|
|
414
|
+
return layout[defaultAxisKey];
|
|
415
|
+
}
|
|
416
|
+
var match = normalized.match(/^([xy])(\d*)$/);
|
|
417
|
+
if (match && match[1] === axis) {
|
|
418
|
+
var index = match[2];
|
|
419
|
+
if (index && index !== '' && index !== '1') {
|
|
420
|
+
var axisKey = "".concat(axis, "axis").concat(index);
|
|
421
|
+
return layout[axisKey];
|
|
422
|
+
}
|
|
423
|
+
return layout[defaultAxisKey];
|
|
424
|
+
}
|
|
425
|
+
return layout[defaultAxisKey];
|
|
426
|
+
};
|
|
427
|
+
/**
|
|
428
|
+
* Normalizes raw Plotly data values into canonical number/date/string types based on axis configuration.
|
|
429
|
+
*/
|
|
430
|
+
var convertDataValue = function (value, axisLayout) {
|
|
431
|
+
if (value === undefined || value === null) {
|
|
432
|
+
return undefined;
|
|
433
|
+
}
|
|
434
|
+
if ((axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) === 'date' || (0, chart_utilities_1.isDate)(value)) {
|
|
435
|
+
var dateValue = value instanceof Date ? value : new Date(value);
|
|
436
|
+
return Number.isNaN(dateValue.getTime()) ? undefined : dateValue;
|
|
437
|
+
}
|
|
438
|
+
if (typeof value === 'number') {
|
|
439
|
+
return value;
|
|
440
|
+
}
|
|
441
|
+
if ((axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) === 'linear' || (axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) === 'log') {
|
|
442
|
+
var numeric = Number(value);
|
|
443
|
+
return Number.isFinite(numeric) ? numeric : undefined;
|
|
444
|
+
}
|
|
445
|
+
if (value instanceof Date) {
|
|
446
|
+
return value;
|
|
447
|
+
}
|
|
448
|
+
return value;
|
|
449
|
+
};
|
|
450
|
+
var toNumericValue = function (value) {
|
|
451
|
+
if (value instanceof Date) {
|
|
452
|
+
var timestamp = value.getTime();
|
|
453
|
+
return Number.isFinite(timestamp) ? timestamp : undefined;
|
|
454
|
+
}
|
|
455
|
+
if (typeof value === 'number') {
|
|
456
|
+
return Number.isFinite(value) ? value : undefined;
|
|
457
|
+
}
|
|
458
|
+
if (typeof value === 'string') {
|
|
459
|
+
var numeric = Number(value);
|
|
460
|
+
return Number.isFinite(numeric) ? numeric : undefined;
|
|
461
|
+
}
|
|
462
|
+
return undefined;
|
|
463
|
+
};
|
|
464
|
+
var toRelativeCoordinate = function (value, axisLayout, fallbackRange) {
|
|
465
|
+
var range = Array.isArray(axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.range) ? axisLayout.range : undefined;
|
|
466
|
+
var start = range && range.length >= 2 ? toNumericValue(convertDataValue(range[0], axisLayout)) : undefined;
|
|
467
|
+
var end = range && range.length >= 2 ? toNumericValue(convertDataValue(range[1], axisLayout)) : undefined;
|
|
468
|
+
if ((start === undefined || end === undefined || start === end) && fallbackRange) {
|
|
469
|
+
start = fallbackRange[0], end = fallbackRange[1];
|
|
470
|
+
}
|
|
471
|
+
var current = toNumericValue(convertDataValue(value, axisLayout));
|
|
472
|
+
if (start === undefined || end === undefined || current === undefined || start === end) {
|
|
473
|
+
return undefined;
|
|
474
|
+
}
|
|
475
|
+
var relative = (current - start) / (end - start);
|
|
476
|
+
return Number.isFinite(relative) ? relative : undefined;
|
|
477
|
+
};
|
|
478
|
+
var createAnnotationId = function (text, index) {
|
|
479
|
+
var normalized = text.replace(/\s+/g, ' ').trim();
|
|
480
|
+
if (normalized) {
|
|
481
|
+
var slug = normalized
|
|
482
|
+
.toLowerCase()
|
|
483
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
484
|
+
.replace(/^-+|-+$/g, '')
|
|
485
|
+
.slice(0, 32);
|
|
486
|
+
if (slug) {
|
|
487
|
+
return "annotation-".concat(index, "-").concat(slug);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
return "annotation-".concat(index);
|
|
491
|
+
};
|
|
492
|
+
var DEFAULT_ARROW_OFFSET = -40;
|
|
493
|
+
var mapArrowsideToArrow = function (annotation) {
|
|
494
|
+
var includeStart = false;
|
|
495
|
+
var includeEnd = false;
|
|
496
|
+
var arrowSide = typeof (annotation === null || annotation === void 0 ? void 0 : annotation.arrowside) === 'string' ? annotation === null || annotation === void 0 ? void 0 : annotation.arrowside.toLowerCase() : undefined;
|
|
497
|
+
if (arrowSide) {
|
|
498
|
+
includeStart = arrowSide.includes('start');
|
|
499
|
+
includeEnd = arrowSide.includes('end');
|
|
500
|
+
}
|
|
501
|
+
var endHead = toFiniteNumber(annotation === null || annotation === void 0 ? void 0 : annotation.arrowhead);
|
|
502
|
+
var startHead = toFiniteNumber(annotation.startarrowhead);
|
|
503
|
+
if (endHead !== undefined && endHead > 0) {
|
|
504
|
+
includeEnd = true;
|
|
505
|
+
}
|
|
506
|
+
if (startHead !== undefined && startHead > 0) {
|
|
507
|
+
includeStart = true;
|
|
508
|
+
}
|
|
509
|
+
if (includeStart && includeEnd) {
|
|
510
|
+
return 'both';
|
|
511
|
+
}
|
|
512
|
+
if (includeStart) {
|
|
513
|
+
return 'start';
|
|
514
|
+
}
|
|
515
|
+
if (includeEnd) {
|
|
516
|
+
return 'end';
|
|
517
|
+
}
|
|
518
|
+
return 'none';
|
|
519
|
+
};
|
|
520
|
+
var mapArrowDashToPattern = function (value) {
|
|
521
|
+
if (!value) {
|
|
522
|
+
return undefined;
|
|
523
|
+
}
|
|
524
|
+
var normalized = value.trim().toLowerCase();
|
|
525
|
+
switch (normalized) {
|
|
526
|
+
case 'solid':
|
|
527
|
+
return undefined;
|
|
528
|
+
case 'dot':
|
|
529
|
+
return '1, 5';
|
|
530
|
+
case 'dash':
|
|
531
|
+
return '5, 5';
|
|
532
|
+
case 'longdash':
|
|
533
|
+
return '10, 5';
|
|
534
|
+
case 'dashdot':
|
|
535
|
+
return '5, 5, 1, 5';
|
|
536
|
+
case 'longdashdot':
|
|
537
|
+
return '10, 5, 1, 5';
|
|
538
|
+
default:
|
|
539
|
+
if (/^\d+(\s|,)*\d*$/.test(normalized.replace(/\s+/g, ' '))) {
|
|
540
|
+
return normalized.replace(/\s+/g, ' ');
|
|
541
|
+
}
|
|
542
|
+
return value;
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
/**
|
|
546
|
+
* Converts a Plotly annotation definition into the internal `ChartAnnotation` format, translating coordinates,
|
|
547
|
+
* layout alignment, styling, and connector metadata while skipping unsupported configurations.
|
|
548
|
+
*/
|
|
549
|
+
var convertPlotlyAnnotation = function (annotation, layout, data, index) {
|
|
550
|
+
var _a;
|
|
551
|
+
if (!annotation || annotation.visible === false) {
|
|
552
|
+
return undefined;
|
|
553
|
+
}
|
|
554
|
+
var xRefType = resolveRefType(annotation.xref, 'x');
|
|
555
|
+
var yRefType = resolveRefType(annotation.yref, 'y');
|
|
556
|
+
if (!xRefType || !yRefType) {
|
|
557
|
+
return undefined;
|
|
558
|
+
}
|
|
559
|
+
var coordinates;
|
|
560
|
+
if (xRefType === 'axis' && yRefType === 'axis') {
|
|
561
|
+
var xAxisLayout = getAxisLayoutByRef(layout, annotation.xref, 'x');
|
|
562
|
+
var yAxisLayout = getAxisLayoutByRef(layout, annotation.yref, 'y');
|
|
563
|
+
var xValue = convertDataValue(annotation.x, xAxisLayout);
|
|
564
|
+
var yValue = convertDataValue(annotation.y, yAxisLayout);
|
|
565
|
+
if (xValue === undefined || yValue === undefined) {
|
|
566
|
+
return undefined;
|
|
567
|
+
}
|
|
568
|
+
var yRefNormalized = typeof annotation.yref === 'string' ? annotation.yref.toLowerCase() : undefined;
|
|
569
|
+
coordinates = tslib_1.__assign({ type: 'data', x: xValue, y: yValue }, (yRefNormalized === 'y2' ? { yAxis: 'secondary' } : {}));
|
|
570
|
+
}
|
|
571
|
+
else if (xRefType === 'relative' && yRefType === 'relative') {
|
|
572
|
+
var xValue = toFiniteNumber(annotation.x);
|
|
573
|
+
var yValue = toFiniteNumber(annotation.y);
|
|
574
|
+
var chartRelativeY = transformRelativeYForChart(yValue);
|
|
575
|
+
if (xValue === undefined || chartRelativeY === undefined) {
|
|
576
|
+
return undefined;
|
|
577
|
+
}
|
|
578
|
+
coordinates = {
|
|
579
|
+
type: 'relative',
|
|
580
|
+
x: xValue,
|
|
581
|
+
y: chartRelativeY,
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
else if (xRefType === 'relative' && yRefType === 'axis') {
|
|
585
|
+
var xValue = toFiniteNumber(annotation.x);
|
|
586
|
+
var yAxisLayout = getAxisLayoutByRef(layout, annotation.yref, 'y');
|
|
587
|
+
var yFallbackRange = getAxisNumericRangeFromData('y', annotation.yref, layout, data);
|
|
588
|
+
var yRelative = toRelativeCoordinate(annotation.y, yAxisLayout, yFallbackRange);
|
|
589
|
+
var chartRelativeY = transformRelativeYForChart(yRelative);
|
|
590
|
+
if (xValue === undefined || chartRelativeY === undefined) {
|
|
591
|
+
return undefined;
|
|
592
|
+
}
|
|
593
|
+
coordinates = {
|
|
594
|
+
type: 'relative',
|
|
595
|
+
x: xValue,
|
|
596
|
+
y: chartRelativeY,
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
else if (xRefType === 'axis' && yRefType === 'relative') {
|
|
600
|
+
var yValue = toFiniteNumber(annotation.y);
|
|
601
|
+
var xAxisLayout = getAxisLayoutByRef(layout, annotation.xref, 'x');
|
|
602
|
+
var xFallbackRange = getAxisNumericRangeFromData('x', annotation.xref, layout, data);
|
|
603
|
+
var xRelative = toRelativeCoordinate(annotation.x, xAxisLayout, xFallbackRange);
|
|
604
|
+
var chartRelativeY = transformRelativeYForChart(yValue);
|
|
605
|
+
if (xRelative === undefined || chartRelativeY === undefined) {
|
|
606
|
+
return undefined;
|
|
607
|
+
}
|
|
608
|
+
coordinates = {
|
|
609
|
+
type: 'relative',
|
|
610
|
+
x: xRelative,
|
|
611
|
+
y: chartRelativeY,
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
else if (xRefType === 'pixel' && yRefType === 'pixel') {
|
|
615
|
+
var xValue = toFiniteNumber(annotation.x);
|
|
616
|
+
var yValue = toFiniteNumber(annotation.y);
|
|
617
|
+
if (xValue === undefined || yValue === undefined) {
|
|
618
|
+
return undefined;
|
|
619
|
+
}
|
|
620
|
+
coordinates = {
|
|
621
|
+
type: 'pixel',
|
|
622
|
+
x: xValue,
|
|
623
|
+
y: yValue,
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
return undefined;
|
|
628
|
+
}
|
|
629
|
+
var textValue = annotation.text;
|
|
630
|
+
var text = textValue === undefined || textValue === null ? '' : String(textValue);
|
|
631
|
+
var chartAnnotation = {
|
|
632
|
+
id: createAnnotationId(text, index),
|
|
633
|
+
text: text,
|
|
634
|
+
coordinates: coordinates,
|
|
635
|
+
};
|
|
636
|
+
var layoutProps = {};
|
|
637
|
+
var styleProps = {};
|
|
638
|
+
var showArrow = annotation.showarrow === undefined ? false : !!annotation.showarrow;
|
|
639
|
+
var clipOnAxis = annotation.cliponaxis;
|
|
640
|
+
if (clipOnAxis !== undefined) {
|
|
641
|
+
layoutProps.clipToBounds = !!clipOnAxis;
|
|
642
|
+
}
|
|
643
|
+
else if (coordinates.type === 'data') {
|
|
644
|
+
layoutProps.clipToBounds = true;
|
|
645
|
+
}
|
|
646
|
+
var horizontalAlign = mapHorizontalAlign(annotation.xanchor);
|
|
647
|
+
if (horizontalAlign) {
|
|
648
|
+
layoutProps.align = horizontalAlign;
|
|
649
|
+
}
|
|
650
|
+
if (!layoutProps.align) {
|
|
651
|
+
var alignProp = mapHorizontalAlign(annotation.align);
|
|
652
|
+
if (alignProp) {
|
|
653
|
+
layoutProps.align = alignProp;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
var verticalAlign = mapVerticalAlign(annotation.yanchor);
|
|
657
|
+
if (verticalAlign) {
|
|
658
|
+
layoutProps.verticalAlign = verticalAlign;
|
|
659
|
+
}
|
|
660
|
+
if (!layoutProps.verticalAlign) {
|
|
661
|
+
var valignProp = mapVerticalAlign(annotation.valign);
|
|
662
|
+
if (valignProp) {
|
|
663
|
+
layoutProps.verticalAlign = valignProp;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
var offsetXComponents = [];
|
|
667
|
+
var hasExplicitOffset = false;
|
|
668
|
+
var ax = toFiniteNumber(annotation.ax);
|
|
669
|
+
var axRef = typeof annotation.axref === 'string' ? annotation.axref.toLowerCase() : undefined;
|
|
670
|
+
if (ax !== undefined && (axRef === undefined || axRef === 'pixel')) {
|
|
671
|
+
offsetXComponents.push(ax);
|
|
672
|
+
hasExplicitOffset = true;
|
|
673
|
+
}
|
|
674
|
+
var xShift = toFiniteNumber(annotation.xshift);
|
|
675
|
+
if (xShift !== undefined) {
|
|
676
|
+
offsetXComponents.push(xShift);
|
|
677
|
+
hasExplicitOffset = true;
|
|
678
|
+
}
|
|
679
|
+
if (offsetXComponents.length > 0) {
|
|
680
|
+
var offsetX = offsetXComponents.reduce(function (sum, value) { return sum + value; }, 0);
|
|
681
|
+
if (offsetX !== 0) {
|
|
682
|
+
layoutProps.offsetX = offsetX;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
var offsetYComponents = [];
|
|
686
|
+
var ay = toFiniteNumber(annotation.ay);
|
|
687
|
+
var ayRef = typeof annotation.ayref === 'string' ? annotation.ayref.toLowerCase() : undefined;
|
|
688
|
+
if (ay !== undefined && (ayRef === undefined || ayRef === 'pixel')) {
|
|
689
|
+
offsetYComponents.push(ay);
|
|
690
|
+
hasExplicitOffset = true;
|
|
691
|
+
}
|
|
692
|
+
var yShift = toFiniteNumber(annotation.yshift);
|
|
693
|
+
if (yShift !== undefined) {
|
|
694
|
+
offsetYComponents.push(yShift);
|
|
695
|
+
hasExplicitOffset = true;
|
|
696
|
+
}
|
|
697
|
+
if (offsetYComponents.length > 0) {
|
|
698
|
+
var offsetY = offsetYComponents.reduce(function (sum, value) { return sum + value; }, 0);
|
|
699
|
+
if (offsetY !== 0) {
|
|
700
|
+
layoutProps.offsetY = offsetY;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
if (showArrow && !hasExplicitOffset && layoutProps.offsetY === undefined) {
|
|
704
|
+
layoutProps.offsetY = DEFAULT_ARROW_OFFSET;
|
|
705
|
+
}
|
|
706
|
+
var maxWidth = toFiniteNumber(annotation.width);
|
|
707
|
+
if (maxWidth !== undefined) {
|
|
708
|
+
layoutProps.maxWidth = maxWidth;
|
|
709
|
+
}
|
|
710
|
+
if (annotation.bgcolor) {
|
|
711
|
+
styleProps.backgroundColor = annotation.bgcolor;
|
|
712
|
+
}
|
|
713
|
+
if (annotation.bordercolor) {
|
|
714
|
+
styleProps.borderColor = annotation.bordercolor;
|
|
715
|
+
}
|
|
716
|
+
var borderWidth = toFiniteNumber(annotation.borderwidth);
|
|
717
|
+
if (borderWidth !== undefined) {
|
|
718
|
+
styleProps.borderWidth = borderWidth;
|
|
719
|
+
}
|
|
720
|
+
var borderPad = appendPx(annotation.borderpad);
|
|
721
|
+
if (borderPad) {
|
|
722
|
+
styleProps.padding = borderPad;
|
|
723
|
+
}
|
|
724
|
+
var opacity = toFiniteNumber(annotation.opacity);
|
|
725
|
+
if (opacity !== undefined) {
|
|
726
|
+
styleProps.opacity = opacity;
|
|
727
|
+
}
|
|
728
|
+
if (annotation.font) {
|
|
729
|
+
var font = annotation.font;
|
|
730
|
+
if (font === null || font === void 0 ? void 0 : font.color) {
|
|
731
|
+
styleProps.textColor = font.color;
|
|
732
|
+
}
|
|
733
|
+
var fontSize = appendPx(font === null || font === void 0 ? void 0 : font.size);
|
|
734
|
+
if (fontSize) {
|
|
735
|
+
styleProps.fontSize = fontSize;
|
|
736
|
+
}
|
|
737
|
+
if (font === null || font === void 0 ? void 0 : font.weight) {
|
|
738
|
+
styleProps.fontWeight = font.weight;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
if (Object.keys(layoutProps).length > 0) {
|
|
742
|
+
chartAnnotation.layout = layoutProps;
|
|
743
|
+
}
|
|
744
|
+
if (Object.keys(styleProps).length > 0) {
|
|
745
|
+
chartAnnotation.style = styleProps;
|
|
746
|
+
}
|
|
747
|
+
if (showArrow) {
|
|
748
|
+
var arrowColor = (_a = annotation.arrowcolor) !== null && _a !== void 0 ? _a : styleProps.textColor;
|
|
749
|
+
var arrowWidth = toFiniteNumber(annotation.arrowwidth);
|
|
750
|
+
var endPadding = toFiniteNumber(annotation.standoff);
|
|
751
|
+
var startPadding = toFiniteNumber(annotation.startstandoff);
|
|
752
|
+
var dashPattern = mapArrowDashToPattern(annotation.arrowdash);
|
|
753
|
+
chartAnnotation.connector = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, (arrowColor ? { strokeColor: arrowColor } : {})), (arrowWidth !== undefined ? { strokeWidth: arrowWidth } : {})), (endPadding !== undefined ? { endPadding: Math.max(endPadding, 0) } : {})), (startPadding !== undefined ? { startPadding: Math.max(startPadding, 0) } : {})), (dashPattern ? { dashArray: dashPattern } : {})), { arrow: mapArrowsideToArrow(annotation) });
|
|
754
|
+
}
|
|
755
|
+
return chartAnnotation;
|
|
756
|
+
};
|
|
757
|
+
var getChartAnnotationsFromLayout = function (layout, data, isMultiPlot) {
|
|
758
|
+
if (isMultiPlot || !(layout === null || layout === void 0 ? void 0 : layout.annotations)) {
|
|
759
|
+
return undefined;
|
|
760
|
+
}
|
|
761
|
+
var annotationsArray = Array.isArray(layout.annotations) ? layout.annotations : [layout.annotations];
|
|
762
|
+
var converted = annotationsArray
|
|
763
|
+
.map(function (annotation, index) { return convertPlotlyAnnotation(annotation, layout, data, index); })
|
|
764
|
+
.filter(function (annotation) { return annotation !== undefined; });
|
|
765
|
+
return converted.length > 0 ? converted : undefined;
|
|
766
|
+
};
|
|
265
767
|
/**
|
|
266
768
|
* Normalizes an array of objects by flattening nested structures and creating grouped data
|
|
267
769
|
* Uses json_normalize approach with D3 color detection and filtering
|
|
@@ -426,7 +928,7 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
|
|
|
426
928
|
var _j = getLegendProps(input.data, input.layout, isMultiPlot), legends = _j.legends, hideLegend = _j.hideLegend;
|
|
427
929
|
var colorScale = undefined;
|
|
428
930
|
var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
429
|
-
var
|
|
931
|
+
var resolveXValue = getAxisValueResolver(getAxisType(input.data, getAxisObjects(input.data, input.layout).x));
|
|
430
932
|
input.data.forEach(function (series, index1) {
|
|
431
933
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
432
934
|
colorScale = (0, PlotlyColorAdapter_1.createColorScale)(input.layout, series, colorScale);
|
|
@@ -434,7 +936,7 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
|
|
|
434
936
|
var extractedBarColors = (0, PlotlyColorAdapter_1.extractColor)((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.template) === null || _b === void 0 ? void 0 : _b.layout) === null || _c === void 0 ? void 0 : _c.colorway, colorwayType, (_d = series.marker) === null || _d === void 0 ? void 0 : _d.color, colorMap, isDarkTheme);
|
|
435
937
|
// extract line colors for each series only once
|
|
436
938
|
var extractedLineColors = (0, PlotlyColorAdapter_1.extractColor)((_g = (_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.template) === null || _f === void 0 ? void 0 : _f.layout) === null || _g === void 0 ? void 0 : _g.colorway, colorwayType, (_h = series.line) === null || _h === void 0 ? void 0 : _h.color, colorMap, isDarkTheme);
|
|
437
|
-
var validXYRanges = (0, exports.getValidXYRanges)(series,
|
|
939
|
+
var validXYRanges = (0, exports.getValidXYRanges)(series, resolveXValue);
|
|
438
940
|
validXYRanges.forEach(function (_a, rangeIdx) {
|
|
439
941
|
var rangeStart = _a[0], rangeEnd = _a[1];
|
|
440
942
|
var rangeXValues = series.x.slice(rangeStart, rangeEnd);
|
|
@@ -443,7 +945,7 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
|
|
|
443
945
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
444
946
|
if (!mapXToDataPoints[x]) {
|
|
445
947
|
mapXToDataPoints[x] = {
|
|
446
|
-
xAxisPoint:
|
|
948
|
+
xAxisPoint: resolveXValue(x),
|
|
447
949
|
chartData: [],
|
|
448
950
|
lineData: [],
|
|
449
951
|
};
|
|
@@ -496,7 +998,6 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
|
|
|
496
998
|
.forEach(function (shape, shapeIdx) {
|
|
497
999
|
var _a, _b, _c;
|
|
498
1000
|
var lineColor = (_a = shape.line) === null || _a === void 0 ? void 0 : _a.color;
|
|
499
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
500
1001
|
var resolveX = function (val) {
|
|
501
1002
|
if (typeof val === 'number' && Array.isArray(xCategories) && xCategories[val] !== undefined) {
|
|
502
1003
|
return xCategories[val];
|
|
@@ -505,7 +1006,6 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
|
|
|
505
1006
|
};
|
|
506
1007
|
var x0Key = resolveX(shape.x0);
|
|
507
1008
|
var x1Key = resolveX(shape.x1);
|
|
508
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
509
1009
|
var resolveY = function (val) {
|
|
510
1010
|
if (shape.yref === 'paper') {
|
|
511
1011
|
if (val === 0) {
|
|
@@ -514,7 +1014,10 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
|
|
|
514
1014
|
if (val === 1) {
|
|
515
1015
|
return yMaxValue;
|
|
516
1016
|
}
|
|
517
|
-
|
|
1017
|
+
if (typeof val === 'number') {
|
|
1018
|
+
return yMinValue + val * (yMaxValue - yMinValue);
|
|
1019
|
+
}
|
|
1020
|
+
return val;
|
|
518
1021
|
}
|
|
519
1022
|
return val;
|
|
520
1023
|
};
|
|
@@ -536,7 +1039,8 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
|
|
|
536
1039
|
});
|
|
537
1040
|
});
|
|
538
1041
|
var vsbcData = Object.values(mapXToDataPoints);
|
|
539
|
-
|
|
1042
|
+
var annotations = getChartAnnotationsFromLayout(input.layout, input.data, isMultiPlot);
|
|
1043
|
+
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: vsbcData, width: (_e = input.layout) === null || _e === void 0 ? void 0 : _e.width, height: (_g = (_f = input.layout) === null || _f === void 0 ? void 0 : _f.height) !== null && _g !== void 0 ? _g : 350, barWidth: 'auto', yMaxValue: yMaxValue, yMinValue: yMinValue, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, supportNegativeData: true, barGapMax: 2, showYAxisLables: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, wrapXAxisLables: typeof ((_h = vsbcData[0]) === null || _h === void 0 ? void 0 : _h.xAxisPoint) === 'string' }), getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getYMinMaxValues(input.data[0], input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getBarProps(input.data, input.layout)), getAxisTickProps(input.data, input.layout)), (annotations ? { annotations: annotations } : {}));
|
|
540
1044
|
};
|
|
541
1045
|
exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
|
|
542
1046
|
var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -635,7 +1139,8 @@ var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, col
|
|
|
635
1139
|
});
|
|
636
1140
|
}
|
|
637
1141
|
});
|
|
638
|
-
|
|
1142
|
+
var annotations = getChartAnnotationsFromLayout(processedInput.layout, processedInput.data, isMultiPlot);
|
|
1143
|
+
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ dataV2: gvbcDataV2, width: (_a = processedInput.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = processedInput.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barwidth: 'auto', mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, wrapXAxisLables: true }), getTitles(processedInput.layout)), getAxisCategoryOrderProps(processedInput.data, processedInput.layout)), getYMinMaxValues(processedInput.data[0], processedInput.layout)), getXAxisTickFormat(processedInput.data[0], processedInput.layout)), yAxisTickFormat), getBarProps(processedInput.data, processedInput.layout)), getAxisTickProps(processedInput.data, processedInput.layout)), (annotations ? { annotations: annotations } : {}));
|
|
639
1144
|
};
|
|
640
1145
|
exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
|
|
641
1146
|
var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -695,7 +1200,8 @@ var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colo
|
|
|
695
1200
|
: { xAxisCalloutData: "[".concat(bin.x0, " - ").concat(bin.x1, ")") })));
|
|
696
1201
|
});
|
|
697
1202
|
});
|
|
698
|
-
|
|
1203
|
+
var annotations = getChartAnnotationsFromLayout(input.layout, input.data, isMultiPlot);
|
|
1204
|
+
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: vbcData, width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, supportNegativeData: true, mode: 'histogram', hideTickOverlap: true, maxBarWidth: 50, hideLegend: hideLegend, roundCorners: true, wrapXAxisLables: typeof ((_d = vbcData[0]) === null || _d === void 0 ? void 0 : _d.x) === 'string' }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getYMinMaxValues(input.data[0], input.layout)), (annotations ? { annotations: annotations } : {}));
|
|
699
1205
|
};
|
|
700
1206
|
exports.transformPlotlyJsonToVBCProps = transformPlotlyJsonToVBCProps;
|
|
701
1207
|
var transformPlotlyJsonToAreaChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -710,7 +1216,6 @@ var transformPlotlyJsonToScatterChartProps = function (input, isMultiPlot, color
|
|
|
710
1216
|
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
|
|
711
1217
|
};
|
|
712
1218
|
exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterChartProps;
|
|
713
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
714
1219
|
var mapColorFillBars = function (layout) {
|
|
715
1220
|
if (!Array.isArray(layout === null || layout === void 0 ? void 0 : layout.shapes)) {
|
|
716
1221
|
return [];
|
|
@@ -730,7 +1235,7 @@ var mapColorFillBars = function (layout) {
|
|
|
730
1235
|
});
|
|
731
1236
|
};
|
|
732
1237
|
var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme) {
|
|
733
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1238
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
734
1239
|
var isScatterMarkers = [
|
|
735
1240
|
'text',
|
|
736
1241
|
'markers',
|
|
@@ -745,10 +1250,11 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
|
|
|
745
1250
|
var isScatterChart = chartType === 'scatter';
|
|
746
1251
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
747
1252
|
var mode = 'tonexty';
|
|
748
|
-
var
|
|
1253
|
+
var _q = getLegendProps(input.data, input.layout, isMultiPlot), legends = _q.legends, hideLegend = _q.hideLegend;
|
|
749
1254
|
var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
750
|
-
var
|
|
751
|
-
var
|
|
1255
|
+
var xAxisType = getAxisType(input.data, getAxisObjects(input.data, input.layout).x);
|
|
1256
|
+
var resolveXValue = getAxisValueResolver(xAxisType);
|
|
1257
|
+
var shouldWrapLabels = xAxisType === 'category';
|
|
752
1258
|
var chartData = input.data
|
|
753
1259
|
.map(function (series, index) {
|
|
754
1260
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
@@ -768,7 +1274,7 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
|
|
|
768
1274
|
// if mode contains 'text', we prioritize showing the text over curving the line
|
|
769
1275
|
var lineOptions = !((_l = series.mode) === null || _l === void 0 ? void 0 : _l.includes('text')) && series.type !== 'scatterpolar' ? getLineOptions(series.line) : undefined;
|
|
770
1276
|
var legendShape = getLegendShape(series);
|
|
771
|
-
var validXYRanges = (0, exports.getValidXYRanges)(series,
|
|
1277
|
+
var validXYRanges = (0, exports.getValidXYRanges)(series, resolveXValue);
|
|
772
1278
|
return validXYRanges.map(function (_a, rangeIdx) {
|
|
773
1279
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
774
1280
|
var rangeStart = _a[0], rangeEnd = _a[1];
|
|
@@ -788,7 +1294,7 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
|
|
|
788
1294
|
legendShape: legendShape,
|
|
789
1295
|
data: rangeXValues.map(function (x, i) {
|
|
790
1296
|
var _a, _b;
|
|
791
|
-
return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ x:
|
|
1297
|
+
return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ x: resolveXValue(x), y: rangeYValues[i] }, (Array.isArray((_a = series.marker) === null || _a === void 0 ? void 0 : _a.size)
|
|
792
1298
|
? { markerSize: markerSizes[i] }
|
|
793
1299
|
: typeof ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size) === 'number'
|
|
794
1300
|
? { markerSize: series.marker.size }
|
|
@@ -811,16 +1317,49 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
|
|
|
811
1317
|
});
|
|
812
1318
|
})
|
|
813
1319
|
.flat();
|
|
814
|
-
var
|
|
1320
|
+
var xMinValue = (_c = (_b = chartData[0]) === null || _b === void 0 ? void 0 : _b.data[0]) === null || _c === void 0 ? void 0 : _c.x;
|
|
1321
|
+
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;
|
|
1322
|
+
var yMinValue = (_g = (_f = chartData[0]) === null || _f === void 0 ? void 0 : _f.data[0]) === null || _g === void 0 ? void 0 : _g.y;
|
|
1323
|
+
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;
|
|
1324
|
+
var lineShape = ((_l = (_k = input.layout) === null || _k === void 0 ? void 0 : _k.shapes) !== null && _l !== void 0 ? _l : [])
|
|
815
1325
|
.filter(function (shape) { return shape.type === 'line'; })
|
|
816
1326
|
.map(function (shape, shapeIdx) {
|
|
817
1327
|
var _a, _b;
|
|
818
1328
|
var lineColor = (_a = shape.line) === null || _a === void 0 ? void 0 : _a.color;
|
|
1329
|
+
var resolveX = function (val) {
|
|
1330
|
+
if (shape.xref === 'paper') {
|
|
1331
|
+
if (val === 0) {
|
|
1332
|
+
return xMinValue;
|
|
1333
|
+
}
|
|
1334
|
+
if (val === 1) {
|
|
1335
|
+
return xMaxValue;
|
|
1336
|
+
}
|
|
1337
|
+
return typeof xMinValue === 'number' && typeof xMaxValue === 'number' && typeof val === 'number'
|
|
1338
|
+
? xMinValue + val * (xMaxValue - xMinValue)
|
|
1339
|
+
: val;
|
|
1340
|
+
}
|
|
1341
|
+
return val;
|
|
1342
|
+
};
|
|
1343
|
+
var resolveY = function (val) {
|
|
1344
|
+
if (shape.yref === 'paper') {
|
|
1345
|
+
if (val === 0) {
|
|
1346
|
+
return yMinValue;
|
|
1347
|
+
}
|
|
1348
|
+
if (val === 1) {
|
|
1349
|
+
return yMaxValue;
|
|
1350
|
+
}
|
|
1351
|
+
if (typeof val === 'number') {
|
|
1352
|
+
return yMinValue + val * (yMaxValue - yMinValue);
|
|
1353
|
+
}
|
|
1354
|
+
return val;
|
|
1355
|
+
}
|
|
1356
|
+
return val;
|
|
1357
|
+
};
|
|
819
1358
|
return {
|
|
820
1359
|
legend: "Reference_".concat(shapeIdx),
|
|
821
1360
|
data: [
|
|
822
|
-
{ x: shape.x0, y: shape.y0 },
|
|
823
|
-
{ x: shape.x1, y: shape.y1 },
|
|
1361
|
+
{ x: resolveX(shape.x0), y: resolveY(shape.y0) },
|
|
1362
|
+
{ x: resolveX(shape.x1), y: resolveY(shape.y1) },
|
|
824
1363
|
],
|
|
825
1364
|
color: (_b = (0, d3_color_1.rgb)(lineColor).formatHex8()) !== null && _b !== void 0 ? _b : lineColor,
|
|
826
1365
|
lineOptions: getLineOptions(shape.line),
|
|
@@ -840,15 +1379,18 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
|
|
|
840
1379
|
var scatterChartProps = {
|
|
841
1380
|
scatterChartData: chartData,
|
|
842
1381
|
};
|
|
843
|
-
var
|
|
1382
|
+
var annotations = getChartAnnotationsFromLayout(input.layout, input.data, isMultiPlot);
|
|
1383
|
+
var commonProps = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ supportNegativeData: true }, secondaryYAxisValues), { width: (_m = input.layout) === null || _m === void 0 ? void 0 : _m.width, height: (_p = (_o = input.layout) === null || _o === void 0 ? void 0 : _o.height) !== null && _p !== void 0 ? _p : 350, hideTickOverlap: true, hideLegend: hideLegend, useUTC: false, optimizeLargeData: numDataPoints > 1000, shouldWrapLabels: shouldWrapLabels }), getTitles(input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getAxisScaleTypeProps(input.data, input.layout)), getAxisTickProps(input.data, input.layout)), (annotations ? { annotations: annotations } : {}));
|
|
844
1384
|
if (isAreaChart) {
|
|
845
1385
|
return tslib_1.__assign({ data: chartProps, mode: mode }, commonProps);
|
|
846
1386
|
}
|
|
847
1387
|
else {
|
|
848
1388
|
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: isScatterChart ? scatterChartProps : chartProps, roundedTicks: true, enableReflow: false }, commonProps), yMinMax), (isScatterChart
|
|
849
|
-
? tslib_1.__assign({ showYAxisLablesTooltip: true }, getAxisCategoryOrderProps(input.data, input.layout)) : {})), (!isScatterChart &&
|
|
850
|
-
|
|
851
|
-
|
|
1389
|
+
? tslib_1.__assign({ showYAxisLablesTooltip: true }, getAxisCategoryOrderProps(input.data, input.layout)) : {})), (!isScatterChart &&
|
|
1390
|
+
(function () {
|
|
1391
|
+
var bars = mapColorFillBars(input.layout);
|
|
1392
|
+
return bars && !bars.includes(null) ? { colorFillBars: bars } : {};
|
|
1393
|
+
})()));
|
|
852
1394
|
}
|
|
853
1395
|
};
|
|
854
1396
|
var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -900,49 +1442,71 @@ var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPl
|
|
|
900
1442
|
exports.transformPlotlyJsonToHorizontalBarWithAxisProps = transformPlotlyJsonToHorizontalBarWithAxisProps;
|
|
901
1443
|
var transformPlotlyJsonToGanttChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
902
1444
|
var _a, _b, _c;
|
|
903
|
-
var
|
|
1445
|
+
var data = input.data.filter(function (series) { return series.type !== 'scatter' || series.mode !== 'markers'; });
|
|
1446
|
+
var _d = getLegendProps(data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
904
1447
|
var colorScale = undefined;
|
|
905
|
-
var
|
|
906
|
-
var
|
|
907
|
-
|
|
1448
|
+
var xAxisType = getAxisType(data, getAxisObjects(data, input.layout).x);
|
|
1449
|
+
var resolveXValue = getAxisValueResolver(xAxisType, parseLocalDate);
|
|
1450
|
+
var resolveGanttXValue = function (value) {
|
|
1451
|
+
var resolvedValue = resolveXValue(value);
|
|
1452
|
+
return typeof resolvedValue === 'string' ? 0 : resolvedValue !== null && resolvedValue !== void 0 ? resolvedValue : 0;
|
|
1453
|
+
};
|
|
1454
|
+
var isXDate = xAxisType === 'date';
|
|
1455
|
+
var ganttData = [];
|
|
1456
|
+
data.forEach(function (series, index) {
|
|
908
1457
|
var _a, _b, _c, _d;
|
|
909
|
-
colorScale = (0, PlotlyColorAdapter_1.createColorScale)(input.layout, series, colorScale);
|
|
910
|
-
// extract colors for each series only once
|
|
911
|
-
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.template) === null || _b === void 0 ? void 0 : _b.layout) === null || _c === void 0 ? void 0 : _c.colorway, colorwayType, (_d = series.marker) === null || _d === void 0 ? void 0 : _d.color, colorMap, isDarkTheme);
|
|
912
1458
|
var legend = legends[index];
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
1459
|
+
if (series.type === 'bar') {
|
|
1460
|
+
colorScale = (0, PlotlyColorAdapter_1.createColorScale)(input.layout, series, colorScale);
|
|
1461
|
+
// extract colors for each series only once
|
|
1462
|
+
var extractedColors_1 = (0, PlotlyColorAdapter_1.extractColor)((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.template) === null || _b === void 0 ? void 0 : _b.layout) === null || _c === void 0 ? void 0 : _c.colorway, colorwayType, (_d = series.marker) === null || _d === void 0 ? void 0 : _d.color, colorMap, isDarkTheme);
|
|
1463
|
+
series.y.forEach(function (yVal, i) {
|
|
1464
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1465
|
+
if ((0, chart_utilities_1.isInvalidValue)(yVal)) {
|
|
1466
|
+
return;
|
|
1467
|
+
}
|
|
1468
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
1469
|
+
var color = colorScale
|
|
1470
|
+
? colorScale((0, chart_utilities_1.isArrayOrTypedArray)((_a = series.marker) === null || _a === void 0 ? void 0 : _a.color)
|
|
1471
|
+
? (_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]
|
|
1472
|
+
: 0)
|
|
1473
|
+
: (0, PlotlyColorAdapter_1.resolveColor)(extractedColors_1, i, legend, colorMap, (_g = (_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.template) === null || _f === void 0 ? void 0 : _f.layout) === null || _g === void 0 ? void 0 : _g.colorway, isDarkTheme);
|
|
1474
|
+
var opacity = (0, PlotlyColorAdapter_1.getOpacity)(series, i);
|
|
1475
|
+
var base = +resolveGanttXValue((_h = series.base) === null || _h === void 0 ? void 0 : _h[i]);
|
|
1476
|
+
var xVal = +resolveGanttXValue((_j = series.x) === null || _j === void 0 ? void 0 : _j[i]);
|
|
1477
|
+
ganttData.push({
|
|
1478
|
+
x: {
|
|
1479
|
+
start: isXDate ? new Date(base) : base,
|
|
1480
|
+
end: isXDate ? new Date(base + xVal) : base + xVal,
|
|
1481
|
+
},
|
|
1482
|
+
y: yVal,
|
|
1483
|
+
legend: legend,
|
|
1484
|
+
color: (_k = (0, d3_color_1.rgb)(color).copy({ opacity: opacity }).formatHex8()) !== null && _k !== void 0 ? _k : color,
|
|
1485
|
+
});
|
|
1486
|
+
});
|
|
1487
|
+
}
|
|
1488
|
+
else if (series.type === 'scatter' && series.mode === 'none' && series.fill === 'toself') {
|
|
1489
|
+
for (var i = 0; i < series.y.length; i += 5) {
|
|
1490
|
+
if ((0, chart_utilities_1.isInvalidValue)(series.y[i]) || (0, chart_utilities_1.isInvalidValue)(series.y[i + 3])) {
|
|
1491
|
+
continue;
|
|
1492
|
+
}
|
|
1493
|
+
var x0 = resolveGanttXValue(series.x[i]);
|
|
1494
|
+
var x1 = resolveGanttXValue(series.x[i + 1]);
|
|
1495
|
+
var y0 = series.y[i];
|
|
1496
|
+
var y1 = series.y[i + 3];
|
|
1497
|
+
ganttData.push({
|
|
1498
|
+
x: {
|
|
1499
|
+
start: x0,
|
|
1500
|
+
end: x1,
|
|
1501
|
+
},
|
|
1502
|
+
y: Math.round((y0 + y1) / 2),
|
|
1503
|
+
legend: legend,
|
|
1504
|
+
color: series.fillcolor,
|
|
1505
|
+
});
|
|
922
1506
|
}
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
? (_c = (_b = series.marker) === null || _b === void 0 ? void 0 : _b.color) === null || _c === void 0 ? void 0 : _c[i % ((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color).length]
|
|
927
|
-
: 0)
|
|
928
|
-
: (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, i, legend, colorMap, (_g = (_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.template) === null || _f === void 0 ? void 0 : _f.layout) === null || _g === void 0 ? void 0 : _g.colorway, isDarkTheme);
|
|
929
|
-
var opacity = (0, PlotlyColorAdapter_1.getOpacity)(series, i);
|
|
930
|
-
var base = convertXValueToNumber((_h = series.base) === null || _h === void 0 ? void 0 : _h[i]);
|
|
931
|
-
var xVal = convertXValueToNumber((_j = series.x) === null || _j === void 0 ? void 0 : _j[i]);
|
|
932
|
-
return {
|
|
933
|
-
x: {
|
|
934
|
-
start: isXDate ? new Date(base) : base,
|
|
935
|
-
end: isXDate ? new Date(base + xVal) : base + xVal,
|
|
936
|
-
},
|
|
937
|
-
y: yVal,
|
|
938
|
-
legend: legend,
|
|
939
|
-
color: (_k = (0, d3_color_1.rgb)(color).copy({ opacity: opacity }).formatHex8()) !== null && _k !== void 0 ? _k : color,
|
|
940
|
-
};
|
|
941
|
-
})
|
|
942
|
-
.filter(function (point) { return point !== null; });
|
|
943
|
-
})
|
|
944
|
-
.flat();
|
|
945
|
-
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: chartData, showYAxisLables: true, height: (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 350, width: (_c = input.layout) === null || _c === void 0 ? void 0 : _c.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true, useUTC: false }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getBarProps(input.data, input.layout, true)), getAxisTickProps(input.data, input.layout));
|
|
1507
|
+
}
|
|
1508
|
+
});
|
|
1509
|
+
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: ganttData, showYAxisLables: true, height: (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 350, width: (_c = input.layout) === null || _c === void 0 ? void 0 : _c.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true, useUTC: false }, getTitles(input.layout)), getAxisCategoryOrderProps(data, input.layout)), getBarProps(data, input.layout, true)), getAxisTickProps(data, input.layout));
|
|
946
1510
|
};
|
|
947
1511
|
exports.transformPlotlyJsonToGanttChartProps = transformPlotlyJsonToGanttChartProps;
|
|
948
1512
|
var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -2127,9 +2691,15 @@ var getAxisTickProps = function (data, layout) {
|
|
|
2127
2691
|
var tickValues = axType === 'date' ? ax.tickvals.map(function (v) { return new Date(v); }) : ax.tickvals;
|
|
2128
2692
|
if (axId === 'x') {
|
|
2129
2693
|
props.tickValues = tickValues;
|
|
2694
|
+
props.xAxis = {
|
|
2695
|
+
tickText: ax.ticktext,
|
|
2696
|
+
};
|
|
2130
2697
|
}
|
|
2131
2698
|
else if (axId === 'y') {
|
|
2132
2699
|
props.yAxisTickValues = tickValues;
|
|
2700
|
+
props.yAxis = {
|
|
2701
|
+
tickText: ax.ticktext,
|
|
2702
|
+
};
|
|
2133
2703
|
}
|
|
2134
2704
|
return;
|
|
2135
2705
|
}
|
|
@@ -2243,16 +2813,8 @@ var getAxisObjects = function (data, layout) {
|
|
|
2243
2813
|
}
|
|
2244
2814
|
return axisObjects;
|
|
2245
2815
|
};
|
|
2246
|
-
function
|
|
2816
|
+
var getAxisType = function (data, ax) {
|
|
2247
2817
|
var _a;
|
|
2248
|
-
var ax;
|
|
2249
|
-
if (arg2 && typeof arg2 === 'object' && '_id' in arg2) {
|
|
2250
|
-
ax = arg2;
|
|
2251
|
-
}
|
|
2252
|
-
else if (typeof arg3 === 'string') {
|
|
2253
|
-
var layout = arg2;
|
|
2254
|
-
ax = getAxisObjects(data, layout)[arg3];
|
|
2255
|
-
}
|
|
2256
2818
|
if (!ax) {
|
|
2257
2819
|
return 'category';
|
|
2258
2820
|
}
|
|
@@ -2279,9 +2841,12 @@ function getAxisType(data, arg2, arg3) {
|
|
|
2279
2841
|
return 'date';
|
|
2280
2842
|
}
|
|
2281
2843
|
return 'category';
|
|
2282
|
-
}
|
|
2283
|
-
var getAxisValueResolver = function (
|
|
2284
|
-
var
|
|
2844
|
+
};
|
|
2845
|
+
var getAxisValueResolver = function (axType, dateParser) {
|
|
2846
|
+
var toDate = function (value) {
|
|
2847
|
+
var date = dateParser ? dateParser(value) : new Date(value);
|
|
2848
|
+
return isNaN(date.getTime()) ? null : date;
|
|
2849
|
+
};
|
|
2285
2850
|
return function (value) {
|
|
2286
2851
|
if ((0, chart_utilities_1.isInvalidValue)(value)) {
|
|
2287
2852
|
return null;
|
|
@@ -2292,10 +2857,10 @@ var getAxisValueResolver = function (data, layout, axisId) {
|
|
|
2292
2857
|
return (0, chart_utilities_1.isNumber)(value) ? +value : null;
|
|
2293
2858
|
case 'date':
|
|
2294
2859
|
if ((0, chart_utilities_1.isNumber)(value)) {
|
|
2295
|
-
return
|
|
2860
|
+
return toDate(+value);
|
|
2296
2861
|
}
|
|
2297
2862
|
if (typeof value === 'string') {
|
|
2298
|
-
return
|
|
2863
|
+
return toDate(value);
|
|
2299
2864
|
}
|
|
2300
2865
|
return null;
|
|
2301
2866
|
case 'category':
|