@fluentui/react-charts 9.3.6 → 9.3.8
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 +46 -2
- package/dist/index.d.ts +70 -17
- package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.js +2 -16
- package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.js.map +1 -1
- package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js.map +1 -1
- package/lib/components/AreaChart/AreaChart.js +3 -43
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.js +1 -2
- package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.js +8 -11
- package/lib/components/ChartTable/ChartTable.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.types.js.map +1 -1
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js +107 -67
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -1
- package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js +7 -1
- package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js.map +1 -1
- package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js +7 -1
- package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +52 -32
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/ChartPopover.js +1 -2
- package/lib/components/CommonComponents/ChartPopover.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +9 -7
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +8 -5
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js +0 -2
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +48 -25
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +309 -209
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +9 -15
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib/components/DonutChart/Pie/Pie.js +4 -2
- package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.js +8 -13
- package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.types.js.map +1 -1
- package/lib/components/GanttChart/GanttChart.js +4 -17
- package/lib/components/GanttChart/GanttChart.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.js +8 -13
- package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.types.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +24 -36
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +1 -2
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js +3 -16
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +5 -25
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib/components/Legends/Legends.js +3 -4
- package/lib/components/Legends/Legends.js.map +1 -1
- package/lib/components/Legends/Legends.types.js.map +1 -1
- package/lib/components/Legends/OverflowMenu.js.map +1 -1
- package/lib/components/Legends/useLegendsStyles.styles.raw.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +68 -75
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/LineChart/LineChart.types.js +1 -1
- package/lib/components/LineChart/LineChart.types.js.map +1 -1
- package/lib/components/LineChart/eventAnnotation/EventAnnotation.js +3 -4
- package/lib/components/LineChart/eventAnnotation/EventAnnotation.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.js +1 -2
- package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib/components/SankeyChart/SankeyChart.js +4 -10
- package/lib/components/SankeyChart/SankeyChart.js.map +1 -1
- package/lib/components/SankeyChart/SankeyChart.types.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +1 -2
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +41 -49
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js +1 -2
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib/components/Sparkline/Sparkline.js +11 -7
- package/lib/components/Sparkline/Sparkline.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +15 -92
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +1 -2
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +28 -49
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +1 -2
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib/types/ChartAnnotation.js.map +1 -1
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/utilities/Common.styles.js +0 -1
- package/lib/utilities/Common.styles.js.map +1 -1
- package/lib/utilities/Common.styles.raw.js +0 -1
- package/lib/utilities/Common.styles.raw.js.map +1 -1
- package/lib/utilities/FocusableTooltipText.js +1 -1
- package/lib/utilities/FocusableTooltipText.js.map +1 -1
- package/lib/utilities/getWindow.js +0 -1
- package/lib/utilities/getWindow.js.map +1 -1
- package/lib/utilities/hooks.js +34 -0
- package/lib/utilities/hooks.js.map +1 -0
- package/lib/utilities/image-export-utils.js +118 -78
- package/lib/utilities/image-export-utils.js.map +1 -1
- package/lib/utilities/utilities.js +243 -102
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.js +2 -16
- package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.js.map +1 -1
- package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js +2 -41
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +0 -2
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.js +9 -11
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js +107 -67
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js +7 -1
- package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js +7 -1
- package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +51 -31
- 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/ChartPopover.js +1 -2
- package/lib-commonjs/components/CommonComponents/ChartPopover.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +7 -6
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +7 -4
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js +0 -2
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +48 -25
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +309 -208
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +7 -13
- package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Pie/Pie.js +4 -2
- package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.js +7 -12
- package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.types.js.map +1 -1
- package/lib-commonjs/components/GanttChart/GanttChart.js +3 -16
- package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.js +7 -12
- package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.types.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +22 -34
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +0 -2
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +2 -15
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +4 -23
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.js +3 -4
- 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/Legends/OverflowMenu.js.map +1 -1
- package/lib-commonjs/components/Legends/useLegendsStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +67 -74
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.types.js +1 -1
- package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
- package/lib-commonjs/components/LineChart/eventAnnotation/EventAnnotation.js +2 -2
- package/lib-commonjs/components/LineChart/eventAnnotation/EventAnnotation.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +0 -2
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.js +4 -10
- package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.types.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +0 -2
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +38 -46
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +0 -2
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/Sparkline/Sparkline.js +11 -7
- package/lib-commonjs/components/Sparkline/Sparkline.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +14 -91
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +0 -2
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +26 -47
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +0 -2
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/types/ChartAnnotation.js.map +1 -1
- package/lib-commonjs/types/DataPoint.js.map +1 -1
- package/lib-commonjs/utilities/Common.styles.js +0 -1
- package/lib-commonjs/utilities/Common.styles.js.map +1 -1
- package/lib-commonjs/utilities/Common.styles.raw.js +0 -1
- package/lib-commonjs/utilities/Common.styles.raw.js.map +1 -1
- package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/getWindow.js +0 -1
- package/lib-commonjs/utilities/getWindow.js.map +1 -1
- package/lib-commonjs/utilities/hooks.js +45 -0
- package/lib-commonjs/utilities/hooks.js.map +1 -0
- package/lib-commonjs/utilities/image-export-utils.js +119 -79
- package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +253 -101
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +9 -9
- package/lib/components/DeclarativeChart/imageExporter.js +0 -223
- package/lib/components/DeclarativeChart/imageExporter.js.map +0 -1
- package/lib-commonjs/components/DeclarativeChart/imageExporter.js +0 -233
- package/lib-commonjs/components/DeclarativeChart/imageExporter.js.map +0 -1
|
@@ -185,6 +185,18 @@ const getYMinMaxValues = (series, layout)=>{
|
|
|
185
185
|
}
|
|
186
186
|
return {};
|
|
187
187
|
};
|
|
188
|
+
const getXMinMaxValues = (series, layout)=>{
|
|
189
|
+
var _getXAxisProperties;
|
|
190
|
+
const range = (_getXAxisProperties = getXAxisProperties(series, layout)) === null || _getXAxisProperties === void 0 ? void 0 : _getXAxisProperties.range;
|
|
191
|
+
if (range && range.length === 2) {
|
|
192
|
+
return {
|
|
193
|
+
xMinValue: range[0],
|
|
194
|
+
xMaxValue: range[1],
|
|
195
|
+
showRoundOffXTickValues: false
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
return {};
|
|
199
|
+
};
|
|
188
200
|
const getYAxisProperties = (series, layout)=>{
|
|
189
201
|
return layout === null || layout === void 0 ? void 0 : layout.yaxis;
|
|
190
202
|
};
|
|
@@ -301,6 +313,62 @@ const resolveXAxisPoint = (x, isXYearCategory, isXString, isXDate, isXNumber)=>{
|
|
|
301
313
|
}
|
|
302
314
|
return x;
|
|
303
315
|
};
|
|
316
|
+
/**
|
|
317
|
+
* Formats text values according to the texttemplate specification
|
|
318
|
+
* Supports D3 format specifiers within %{text:format} patterns
|
|
319
|
+
* @param textValue The raw text value to format
|
|
320
|
+
* @param textTemplate The template string (e.g., "%{text:.1f}%", "%{text:.2%}", "%{text:,.0f}")
|
|
321
|
+
* @param index Optional index for array-based templates
|
|
322
|
+
* @returns Formatted text string
|
|
323
|
+
*
|
|
324
|
+
* Examples:
|
|
325
|
+
* - "%{text:.1f}%" → Formats number with 1 decimal place and adds % suffix
|
|
326
|
+
* - "%{text:.2%}" → Formats as percentage with 2 decimal places
|
|
327
|
+
* - "%{text:,.0f}" → Formats with thousands separator and no decimals
|
|
328
|
+
* - "%{text:$,.2f}" → Formats as currency with thousands separator and 2 decimals
|
|
329
|
+
*/ const formatTextWithTemplate = (textValue, textTemplate, index)=>{
|
|
330
|
+
if (!textTemplate) {
|
|
331
|
+
return String(textValue);
|
|
332
|
+
}
|
|
333
|
+
const numVal = typeof textValue === 'number' ? textValue : parseFloat(String(textValue));
|
|
334
|
+
if (isNaN(numVal)) {
|
|
335
|
+
return String(textValue);
|
|
336
|
+
}
|
|
337
|
+
const template = typeof textTemplate === 'string' ? textTemplate : textTemplate[index || 0] || '';
|
|
338
|
+
// Match Plotly's texttemplate pattern: %{text:format} or %{text}
|
|
339
|
+
// Can be followed by any literal text like %, $, etc.
|
|
340
|
+
const plotlyPattern = /%\{text(?::([^}]+))?\}(.*)$/;
|
|
341
|
+
const match = template.match(plotlyPattern);
|
|
342
|
+
if (match) {
|
|
343
|
+
const formatSpec = match[1]; // The format specifier (e.g., ".1f", ".2%", ",.0f") or undefined
|
|
344
|
+
const suffix = match[2]; // Any text after the closing brace (e.g., "%", " units")
|
|
345
|
+
// If no format specifier is provided (e.g., %{text}%), try to infer from suffix
|
|
346
|
+
if (!formatSpec) {
|
|
347
|
+
// Check if suffix starts with % - assume simple percentage with 1 decimal
|
|
348
|
+
if (suffix.startsWith('%')) {
|
|
349
|
+
return `${numVal.toFixed(1)}${suffix}`;
|
|
350
|
+
}
|
|
351
|
+
// No format specifier, just return the number with the suffix
|
|
352
|
+
return `${numVal}${suffix}`;
|
|
353
|
+
}
|
|
354
|
+
try {
|
|
355
|
+
// Use D3 format function to apply the format specifier
|
|
356
|
+
const formatter = (0, _d3format.format)(formatSpec);
|
|
357
|
+
const formattedValue = formatter(numVal);
|
|
358
|
+
return `${formattedValue}${suffix}`;
|
|
359
|
+
} catch (error) {
|
|
360
|
+
// Try to extract precision for basic fallback
|
|
361
|
+
const precisionMatch = formatSpec.match(/\.(\d+)[f%]/);
|
|
362
|
+
const precision = precisionMatch ? parseInt(precisionMatch[1], 10) : 2;
|
|
363
|
+
// Check if it's a percentage format
|
|
364
|
+
if (formatSpec.includes('%')) {
|
|
365
|
+
return `${(numVal * 100).toFixed(precision)}%${suffix}`;
|
|
366
|
+
}
|
|
367
|
+
return `${numVal.toFixed(precision)}${suffix}`;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return String(textValue);
|
|
371
|
+
};
|
|
304
372
|
/**
|
|
305
373
|
* Extracts unique X-axis categories from Plotly data traces
|
|
306
374
|
* @param data Array of Plotly data traces
|
|
@@ -365,62 +433,6 @@ const toFiniteNumber = (value)=>{
|
|
|
365
433
|
const numeric = typeof value === 'number' ? value : Number(value);
|
|
366
434
|
return Number.isFinite(numeric) ? numeric : undefined;
|
|
367
435
|
};
|
|
368
|
-
/**
|
|
369
|
-
* Normalizes Plotly axis reference strings so equivalent aliases (e.g. `xaxis1`, `x1`) collapse to the base axis id.
|
|
370
|
-
*/ const normalizeAxisRef = (ref, axis)=>{
|
|
371
|
-
if (!ref) {
|
|
372
|
-
return axis;
|
|
373
|
-
}
|
|
374
|
-
const normalized = ref.toLowerCase();
|
|
375
|
-
if (normalized === axis || normalized === `${axis}axis` || normalized === `${axis}axis1` || normalized === `${axis}1`) {
|
|
376
|
-
return axis;
|
|
377
|
-
}
|
|
378
|
-
const match = normalized.match(/^([xy])(axis)?(\d+)$/);
|
|
379
|
-
if (match && match[1] === axis && match[3]) {
|
|
380
|
-
return match[3] === '1' ? axis : `${axis}${match[3]}`;
|
|
381
|
-
}
|
|
382
|
-
return normalized;
|
|
383
|
-
};
|
|
384
|
-
/**
|
|
385
|
-
* Scans the data traces bound to a given axis and returns the numeric min/max values plotted on that axis.
|
|
386
|
-
*/ const getAxisNumericRangeFromData = (axis, ref, layout, data)=>{
|
|
387
|
-
if (!data || data.length === 0) {
|
|
388
|
-
return undefined;
|
|
389
|
-
}
|
|
390
|
-
const axisLayout = getAxisLayoutByRef(layout, ref, axis);
|
|
391
|
-
const targetRef = normalizeAxisRef(ref, axis);
|
|
392
|
-
const traceAxisKey = axis === 'x' ? 'xaxis' : 'yaxis';
|
|
393
|
-
let minValue;
|
|
394
|
-
let maxValue;
|
|
395
|
-
data.forEach((trace)=>{
|
|
396
|
-
const plotTrace = trace;
|
|
397
|
-
const traceAxisRef = normalizeAxisRef(plotTrace[traceAxisKey], axis);
|
|
398
|
-
if (traceAxisRef !== targetRef) {
|
|
399
|
-
return;
|
|
400
|
-
}
|
|
401
|
-
const values = axis === 'x' ? plotTrace.x : plotTrace.y;
|
|
402
|
-
if (!(0, _chartutilities.isArrayOrTypedArray)(values)) {
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
const arrayLike = values;
|
|
406
|
-
for(let index = 0; index < arrayLike.length; index++){
|
|
407
|
-
const value = arrayLike[index];
|
|
408
|
-
const numeric = toNumericValue(convertDataValue(value, axisLayout));
|
|
409
|
-
if (numeric === undefined || Number.isNaN(numeric)) {
|
|
410
|
-
continue;
|
|
411
|
-
}
|
|
412
|
-
minValue = minValue === undefined ? numeric : Math.min(minValue, numeric);
|
|
413
|
-
maxValue = maxValue === undefined ? numeric : Math.max(maxValue, numeric);
|
|
414
|
-
}
|
|
415
|
-
});
|
|
416
|
-
if (minValue === undefined || maxValue === undefined || minValue === maxValue) {
|
|
417
|
-
return undefined;
|
|
418
|
-
}
|
|
419
|
-
return [
|
|
420
|
-
minValue,
|
|
421
|
-
maxValue
|
|
422
|
-
];
|
|
423
|
-
};
|
|
424
436
|
/**
|
|
425
437
|
* Converts Plotly's bottom-origin relative Y coordinate into the SVG top-origin space used by our overlay.
|
|
426
438
|
*/ const transformRelativeYForChart = (value)=>{
|
|
@@ -521,49 +533,32 @@ const appendPx = (value)=>{
|
|
|
521
533
|
if (value === undefined || value === null) {
|
|
522
534
|
return undefined;
|
|
523
535
|
}
|
|
524
|
-
|
|
536
|
+
const axisType = axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type;
|
|
537
|
+
if (axisType === 'date') {
|
|
525
538
|
const dateValue = value instanceof Date ? value : new Date(value);
|
|
526
539
|
return Number.isNaN(dateValue.getTime()) ? undefined : dateValue;
|
|
527
540
|
}
|
|
528
|
-
if (typeof value === 'number') {
|
|
529
|
-
return value;
|
|
530
|
-
}
|
|
531
|
-
if ((axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) === 'linear' || (axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) === 'log') {
|
|
532
|
-
const numeric = Number(value);
|
|
533
|
-
return Number.isFinite(numeric) ? numeric : undefined;
|
|
534
|
-
}
|
|
535
|
-
if (value instanceof Date) {
|
|
536
|
-
return value;
|
|
537
|
-
}
|
|
538
|
-
return value;
|
|
539
|
-
};
|
|
540
|
-
const toNumericValue = (value)=>{
|
|
541
541
|
if (value instanceof Date) {
|
|
542
|
-
|
|
543
|
-
return Number.isFinite(timestamp) ? timestamp : undefined;
|
|
542
|
+
return Number.isNaN(value.getTime()) ? undefined : value;
|
|
544
543
|
}
|
|
545
544
|
if (typeof value === 'number') {
|
|
546
545
|
return Number.isFinite(value) ? value : undefined;
|
|
547
546
|
}
|
|
548
|
-
if (
|
|
547
|
+
if (axisType === 'linear' || axisType === 'log') {
|
|
549
548
|
const numeric = Number(value);
|
|
550
549
|
return Number.isFinite(numeric) ? numeric : undefined;
|
|
551
550
|
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
const current = toNumericValue(convertDataValue(value, axisLayout));
|
|
562
|
-
if (start === undefined || end === undefined || current === undefined || start === end) {
|
|
563
|
-
return undefined;
|
|
551
|
+
if (typeof value === 'string') {
|
|
552
|
+
const shouldTryParseDate = axisType === undefined || axisType === '-' || axisType === null;
|
|
553
|
+
if (shouldTryParseDate && (0, _chartutilities.isDate)(value)) {
|
|
554
|
+
const parsedDate = new Date(value);
|
|
555
|
+
if (!Number.isNaN(parsedDate.getTime()) && parsedDate.getFullYear() >= 1900) {
|
|
556
|
+
return parsedDate;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
return value;
|
|
564
560
|
}
|
|
565
|
-
|
|
566
|
-
return Number.isFinite(relative) ? relative : undefined;
|
|
561
|
+
return value;
|
|
567
562
|
};
|
|
568
563
|
const createAnnotationId = (text, index)=>{
|
|
569
564
|
const normalized = text.replace(/\s+/g, ' ').trim();
|
|
@@ -628,10 +623,35 @@ const mapArrowDashToPattern = (value)=>{
|
|
|
628
623
|
return value;
|
|
629
624
|
}
|
|
630
625
|
};
|
|
626
|
+
const mapRefTypeToCoordinateType = (refType)=>{
|
|
627
|
+
return refType === 'axis' ? 'data' : refType;
|
|
628
|
+
};
|
|
629
|
+
const normalizeCoordinateValueForType = (coordinateType, value)=>{
|
|
630
|
+
if (coordinateType === 'data') {
|
|
631
|
+
return value;
|
|
632
|
+
}
|
|
633
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
634
|
+
};
|
|
635
|
+
const getAnnotationCoordinateValue = (axis, refType, annotation, layout)=>{
|
|
636
|
+
if (refType === 'axis') {
|
|
637
|
+
const axisRef = axis === 'x' ? annotation === null || annotation === void 0 ? void 0 : annotation.xref : annotation === null || annotation === void 0 ? void 0 : annotation.yref;
|
|
638
|
+
const axisLayout = getAxisLayoutByRef(layout, axisRef, axis);
|
|
639
|
+
const rawValue = axis === 'x' ? annotation === null || annotation === void 0 ? void 0 : annotation.x : annotation === null || annotation === void 0 ? void 0 : annotation.y;
|
|
640
|
+
return convertDataValue(rawValue, axisLayout);
|
|
641
|
+
}
|
|
642
|
+
const numericValue = toFiniteNumber(axis === 'x' ? annotation === null || annotation === void 0 ? void 0 : annotation.x : annotation === null || annotation === void 0 ? void 0 : annotation.y);
|
|
643
|
+
if (numericValue === undefined) {
|
|
644
|
+
return undefined;
|
|
645
|
+
}
|
|
646
|
+
if (refType === 'relative') {
|
|
647
|
+
return axis === 'y' ? transformRelativeYForChart(numericValue) : numericValue;
|
|
648
|
+
}
|
|
649
|
+
return numericValue;
|
|
650
|
+
};
|
|
631
651
|
/**
|
|
632
652
|
* Converts a Plotly annotation definition into the internal `ChartAnnotation` format, translating coordinates,
|
|
633
653
|
* layout alignment, styling, and connector metadata while skipping unsupported configurations.
|
|
634
|
-
*/ const convertPlotlyAnnotation = (annotation, layout,
|
|
654
|
+
*/ const convertPlotlyAnnotation = (annotation, layout, index)=>{
|
|
635
655
|
if (!annotation || annotation.visible === false) {
|
|
636
656
|
return undefined;
|
|
637
657
|
}
|
|
@@ -640,77 +660,51 @@ const mapArrowDashToPattern = (value)=>{
|
|
|
640
660
|
if (!xRefType || !yRefType) {
|
|
641
661
|
return undefined;
|
|
642
662
|
}
|
|
663
|
+
const xValue = getAnnotationCoordinateValue('x', xRefType, annotation, layout);
|
|
664
|
+
const yValue = getAnnotationCoordinateValue('y', yRefType, annotation, layout);
|
|
665
|
+
if (xValue === undefined || yValue === undefined) {
|
|
666
|
+
return undefined;
|
|
667
|
+
}
|
|
668
|
+
const xCoordinateType = mapRefTypeToCoordinateType(xRefType);
|
|
669
|
+
const yCoordinateType = mapRefTypeToCoordinateType(yRefType);
|
|
670
|
+
const normalizedX = normalizeCoordinateValueForType(xCoordinateType, xValue);
|
|
671
|
+
const normalizedY = normalizeCoordinateValueForType(yCoordinateType, yValue);
|
|
672
|
+
if (normalizedX === undefined || normalizedY === undefined) {
|
|
673
|
+
return undefined;
|
|
674
|
+
}
|
|
675
|
+
const yRefNormalized = typeof annotation.yref === 'string' ? annotation.yref.toLowerCase() : undefined;
|
|
676
|
+
const yAxisProps = yCoordinateType === 'data' && yRefNormalized === 'y2' ? {
|
|
677
|
+
yAxis: 'secondary'
|
|
678
|
+
} : undefined;
|
|
643
679
|
let coordinates;
|
|
644
|
-
if (
|
|
645
|
-
const xAxisLayout = getAxisLayoutByRef(layout, annotation.xref, 'x');
|
|
646
|
-
const yAxisLayout = getAxisLayoutByRef(layout, annotation.yref, 'y');
|
|
647
|
-
const xValue = convertDataValue(annotation.x, xAxisLayout);
|
|
648
|
-
const yValue = convertDataValue(annotation.y, yAxisLayout);
|
|
649
|
-
if (xValue === undefined || yValue === undefined) {
|
|
650
|
-
return undefined;
|
|
651
|
-
}
|
|
652
|
-
const yRefNormalized = typeof annotation.yref === 'string' ? annotation.yref.toLowerCase() : undefined;
|
|
680
|
+
if (xCoordinateType === 'data' && yCoordinateType === 'data') {
|
|
653
681
|
coordinates = {
|
|
654
682
|
type: 'data',
|
|
655
|
-
x:
|
|
656
|
-
y:
|
|
657
|
-
...
|
|
658
|
-
yAxis: 'secondary'
|
|
659
|
-
} : {}
|
|
683
|
+
x: normalizedX,
|
|
684
|
+
y: normalizedY,
|
|
685
|
+
...yAxisProps !== null && yAxisProps !== void 0 ? yAxisProps : {}
|
|
660
686
|
};
|
|
661
|
-
} else if (
|
|
662
|
-
const xValue = toFiniteNumber(annotation.x);
|
|
663
|
-
const yValue = toFiniteNumber(annotation.y);
|
|
664
|
-
const chartRelativeY = transformRelativeYForChart(yValue);
|
|
665
|
-
if (xValue === undefined || chartRelativeY === undefined) {
|
|
666
|
-
return undefined;
|
|
667
|
-
}
|
|
687
|
+
} else if (xCoordinateType === 'relative' && yCoordinateType === 'relative') {
|
|
668
688
|
coordinates = {
|
|
669
689
|
type: 'relative',
|
|
670
|
-
x:
|
|
671
|
-
y:
|
|
690
|
+
x: normalizedX,
|
|
691
|
+
y: normalizedY
|
|
672
692
|
};
|
|
673
|
-
} else if (
|
|
674
|
-
const xValue = toFiniteNumber(annotation.x);
|
|
675
|
-
const yAxisLayout = getAxisLayoutByRef(layout, annotation.yref, 'y');
|
|
676
|
-
const yFallbackRange = getAxisNumericRangeFromData('y', annotation.yref, layout, data);
|
|
677
|
-
const yRelative = toRelativeCoordinate(annotation.y, yAxisLayout, yFallbackRange);
|
|
678
|
-
const chartRelativeY = transformRelativeYForChart(yRelative);
|
|
679
|
-
if (xValue === undefined || chartRelativeY === undefined) {
|
|
680
|
-
return undefined;
|
|
681
|
-
}
|
|
682
|
-
coordinates = {
|
|
683
|
-
type: 'relative',
|
|
684
|
-
x: xValue,
|
|
685
|
-
y: chartRelativeY
|
|
686
|
-
};
|
|
687
|
-
} else if (xRefType === 'axis' && yRefType === 'relative') {
|
|
688
|
-
const yValue = toFiniteNumber(annotation.y);
|
|
689
|
-
const xAxisLayout = getAxisLayoutByRef(layout, annotation.xref, 'x');
|
|
690
|
-
const xFallbackRange = getAxisNumericRangeFromData('x', annotation.xref, layout, data);
|
|
691
|
-
const xRelative = toRelativeCoordinate(annotation.x, xAxisLayout, xFallbackRange);
|
|
692
|
-
const chartRelativeY = transformRelativeYForChart(yValue);
|
|
693
|
-
if (xRelative === undefined || chartRelativeY === undefined) {
|
|
694
|
-
return undefined;
|
|
695
|
-
}
|
|
696
|
-
coordinates = {
|
|
697
|
-
type: 'relative',
|
|
698
|
-
x: xRelative,
|
|
699
|
-
y: chartRelativeY
|
|
700
|
-
};
|
|
701
|
-
} else if (xRefType === 'pixel' && yRefType === 'pixel') {
|
|
702
|
-
const xValue = toFiniteNumber(annotation.x);
|
|
703
|
-
const yValue = toFiniteNumber(annotation.y);
|
|
704
|
-
if (xValue === undefined || yValue === undefined) {
|
|
705
|
-
return undefined;
|
|
706
|
-
}
|
|
693
|
+
} else if (xCoordinateType === 'pixel' && yCoordinateType === 'pixel') {
|
|
707
694
|
coordinates = {
|
|
708
695
|
type: 'pixel',
|
|
709
|
-
x:
|
|
710
|
-
y:
|
|
696
|
+
x: normalizedX,
|
|
697
|
+
y: normalizedY
|
|
711
698
|
};
|
|
712
699
|
} else {
|
|
713
|
-
|
|
700
|
+
coordinates = {
|
|
701
|
+
type: 'mixed',
|
|
702
|
+
xCoordinateType,
|
|
703
|
+
yCoordinateType,
|
|
704
|
+
x: normalizedX,
|
|
705
|
+
y: normalizedY,
|
|
706
|
+
...yAxisProps !== null && yAxisProps !== void 0 ? yAxisProps : {}
|
|
707
|
+
};
|
|
714
708
|
}
|
|
715
709
|
const textValue = annotation.text;
|
|
716
710
|
const rawText = textValue === undefined || textValue === null ? '' : String(textValue);
|
|
@@ -867,14 +861,14 @@ const mapArrowDashToPattern = (value)=>{
|
|
|
867
861
|
}
|
|
868
862
|
return chartAnnotation;
|
|
869
863
|
};
|
|
870
|
-
const getChartAnnotationsFromLayout = (layout,
|
|
864
|
+
const getChartAnnotationsFromLayout = (layout, isMultiPlot)=>{
|
|
871
865
|
if (isMultiPlot || !(layout === null || layout === void 0 ? void 0 : layout.annotations)) {
|
|
872
866
|
return undefined;
|
|
873
867
|
}
|
|
874
868
|
const annotationsArray = Array.isArray(layout.annotations) ? layout.annotations : [
|
|
875
869
|
layout.annotations
|
|
876
870
|
];
|
|
877
|
-
const converted = annotationsArray.map((annotation, index)=>convertPlotlyAnnotation(annotation, layout,
|
|
871
|
+
const converted = annotationsArray.map((annotation, index)=>convertPlotlyAnnotation(annotation, layout, index)).filter((annotation)=>annotation !== undefined);
|
|
878
872
|
return converted.length > 0 ? converted : undefined;
|
|
879
873
|
};
|
|
880
874
|
const normalizeObjectArrayForGVBC = (data, xLabels)=>{
|
|
@@ -951,7 +945,7 @@ const normalizeObjectArrayForGVBC = (data, xLabels)=>{
|
|
|
951
945
|
const transformPlotlyJsonToAnnotationChartProps = (input, isMultiPlot, _colorMap, _colorwayType, _isDarkTheme)=>{
|
|
952
946
|
var _layoutWithMeta_meta, _input_layout, _input_layout1, _input_layout2, _input_layout3, _input_layout_font, _input_layout4, _input_layout_font1, _input_layout5, _input_layout6;
|
|
953
947
|
var _getChartAnnotationsFromLayout;
|
|
954
|
-
const annotations = (_getChartAnnotationsFromLayout = getChartAnnotationsFromLayout(input.layout,
|
|
948
|
+
const annotations = (_getChartAnnotationsFromLayout = getChartAnnotationsFromLayout(input.layout, isMultiPlot)) !== null && _getChartAnnotationsFromLayout !== void 0 ? _getChartAnnotationsFromLayout : [];
|
|
955
949
|
const titles = getTitles(input.layout);
|
|
956
950
|
const layoutTitle = titles.chartTitle || undefined;
|
|
957
951
|
const layoutWithMeta = input.layout;
|
|
@@ -1026,7 +1020,8 @@ const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, colorwayT
|
|
|
1026
1020
|
const hideLabels = firstData.textinfo ? ![
|
|
1027
1021
|
'value',
|
|
1028
1022
|
'percent',
|
|
1029
|
-
'label+percent'
|
|
1023
|
+
'label+percent',
|
|
1024
|
+
'percent+label'
|
|
1030
1025
|
].includes(firstData.textinfo) : false;
|
|
1031
1026
|
const donutMarginHorizontal = hideLabels ? 0 : 80;
|
|
1032
1027
|
const donutMarginVertical = 40 + (hideLabels ? 0 : 40);
|
|
@@ -1059,14 +1054,15 @@ const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, colorwayT
|
|
|
1059
1054
|
hideLabels,
|
|
1060
1055
|
showLabelsInPercent: firstData.textinfo ? [
|
|
1061
1056
|
'percent',
|
|
1062
|
-
'label+percent'
|
|
1057
|
+
'label+percent',
|
|
1058
|
+
'percent+label'
|
|
1063
1059
|
].includes(firstData.textinfo) : true,
|
|
1064
1060
|
roundCorners: true,
|
|
1065
1061
|
order: 'sorted'
|
|
1066
1062
|
};
|
|
1067
1063
|
};
|
|
1068
1064
|
const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme, fallbackVSBC)=>{
|
|
1069
|
-
var _input_layout, _input_layout1, _input_layout2
|
|
1065
|
+
var _input_layout, _input_layout1, _input_layout2;
|
|
1070
1066
|
const mapXToDataPoints = {};
|
|
1071
1067
|
let yMaxValue = 0;
|
|
1072
1068
|
let yMinValue = 0;
|
|
@@ -1086,6 +1082,7 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
1086
1082
|
validXYRanges.forEach(([rangeStart, rangeEnd], rangeIdx)=>{
|
|
1087
1083
|
const rangeXValues = series.x.slice(rangeStart, rangeEnd);
|
|
1088
1084
|
const rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
1085
|
+
const textValues = Array.isArray(series.text) ? series.text.slice(rangeStart, rangeEnd) : typeof series.text === 'string' ? series.text : undefined;
|
|
1089
1086
|
rangeXValues.forEach((x, index2)=>{
|
|
1090
1087
|
var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout;
|
|
1091
1088
|
if (!mapXToDataPoints[x]) {
|
|
@@ -1101,6 +1098,11 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
1101
1098
|
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index2);
|
|
1102
1099
|
const yVal = rangeYValues[index2];
|
|
1103
1100
|
const yAxisCalloutData = getFormattedCalloutYData(yVal, yAxisTickFormat);
|
|
1101
|
+
let barLabel = Array.isArray(textValues) ? textValues[index2] : textValues;
|
|
1102
|
+
// Apply texttemplate formatting if specified
|
|
1103
|
+
if (barLabel && series.texttemplate) {
|
|
1104
|
+
barLabel = formatTextWithTemplate(barLabel, series.texttemplate, index2);
|
|
1105
|
+
}
|
|
1104
1106
|
if (series.type === 'bar') {
|
|
1105
1107
|
var _rgb_copy_formatHex8;
|
|
1106
1108
|
mapXToDataPoints[x].chartData.push({
|
|
@@ -1109,7 +1111,10 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
1109
1111
|
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
1110
1112
|
opacity
|
|
1111
1113
|
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
1112
|
-
yAxisCalloutData
|
|
1114
|
+
yAxisCalloutData,
|
|
1115
|
+
...barLabel ? {
|
|
1116
|
+
barLabel: String(barLabel)
|
|
1117
|
+
} : {}
|
|
1113
1118
|
});
|
|
1114
1119
|
if (typeof yVal === 'number') {
|
|
1115
1120
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
@@ -1207,7 +1212,7 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
1207
1212
|
}
|
|
1208
1213
|
});
|
|
1209
1214
|
const vsbcData = Object.values(mapXToDataPoints);
|
|
1210
|
-
const annotations = getChartAnnotationsFromLayout(input.layout,
|
|
1215
|
+
const annotations = getChartAnnotationsFromLayout(input.layout, isMultiPlot);
|
|
1211
1216
|
var _input_layout_height;
|
|
1212
1217
|
return {
|
|
1213
1218
|
data: vsbcData,
|
|
@@ -1218,7 +1223,6 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
1218
1223
|
yMinValue,
|
|
1219
1224
|
mode: 'plotly',
|
|
1220
1225
|
...secondaryYAxisValues,
|
|
1221
|
-
wrapXAxisLables: typeof ((_vsbcData_ = vsbcData[0]) === null || _vsbcData_ === void 0 ? void 0 : _vsbcData_.xAxisPoint) === 'string',
|
|
1222
1226
|
hideTickOverlap: true,
|
|
1223
1227
|
barGapMax: 2,
|
|
1224
1228
|
hideLegend,
|
|
@@ -1226,6 +1230,8 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
1226
1230
|
showYAxisLables: true,
|
|
1227
1231
|
noOfCharsToTruncate: 20,
|
|
1228
1232
|
showYAxisLablesTooltip: true,
|
|
1233
|
+
roundedTicks: true,
|
|
1234
|
+
...getXMinMaxValues(input.data[0], input.layout),
|
|
1229
1235
|
...getTitles(input.layout),
|
|
1230
1236
|
...getXAxisTickFormat(input.data[0], input.layout),
|
|
1231
1237
|
...yAxisTickFormat,
|
|
@@ -1294,6 +1300,12 @@ const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
1294
1300
|
const color = colorScale ? colorScale((0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[xIndex % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : (0, _PlotlyColorAdapter.resolveColor)(extractedBarColors, xIndex, legend, colorMap, (_processedInput_layout = processedInput.layout) === null || _processedInput_layout === void 0 ? void 0 : (_processedInput_layout_template = _processedInput_layout.template) === null || _processedInput_layout_template === void 0 ? void 0 : (_processedInput_layout_template_layout = _processedInput_layout_template.layout) === null || _processedInput_layout_template_layout === void 0 ? void 0 : _processedInput_layout_template_layout.colorway, isDarkTheme);
|
|
1295
1301
|
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, xIndex);
|
|
1296
1302
|
const yVal = series.y[xIndex];
|
|
1303
|
+
// Extract text value for barLabel
|
|
1304
|
+
let barLabel = Array.isArray(series.text) ? series.text[xIndex] : series.text;
|
|
1305
|
+
// Apply texttemplate formatting if specified
|
|
1306
|
+
if (barLabel && series.texttemplate) {
|
|
1307
|
+
barLabel = formatTextWithTemplate(barLabel, series.texttemplate, xIndex);
|
|
1308
|
+
}
|
|
1297
1309
|
var _rgb_copy_formatHex8;
|
|
1298
1310
|
return {
|
|
1299
1311
|
x: x.toString(),
|
|
@@ -1301,7 +1313,10 @@ const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
1301
1313
|
yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat),
|
|
1302
1314
|
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
1303
1315
|
opacity
|
|
1304
|
-
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
1316
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
1317
|
+
...barLabel ? {
|
|
1318
|
+
barLabel: String(barLabel)
|
|
1319
|
+
} : {}
|
|
1305
1320
|
};
|
|
1306
1321
|
}).filter((item)=>typeof item !== 'undefined'),
|
|
1307
1322
|
useSecondaryYScale: usesSecondaryYScale(series, processedInput.layout)
|
|
@@ -1342,7 +1357,7 @@ const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
1342
1357
|
});
|
|
1343
1358
|
}
|
|
1344
1359
|
});
|
|
1345
|
-
const annotations = getChartAnnotationsFromLayout(processedInput.layout,
|
|
1360
|
+
const annotations = getChartAnnotationsFromLayout(processedInput.layout, isMultiPlot);
|
|
1346
1361
|
var _processedInput_layout_height;
|
|
1347
1362
|
return {
|
|
1348
1363
|
dataV2: gvbcDataV2,
|
|
@@ -1352,10 +1367,11 @@ const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
1352
1367
|
mode: 'plotly',
|
|
1353
1368
|
...secondaryYAxisValues,
|
|
1354
1369
|
hideTickOverlap: true,
|
|
1355
|
-
wrapXAxisLables: true,
|
|
1356
1370
|
hideLegend,
|
|
1357
1371
|
roundCorners: true,
|
|
1358
1372
|
showYAxisLables: true,
|
|
1373
|
+
roundedTicks: true,
|
|
1374
|
+
...getXMinMaxValues(processedInput.data[0], processedInput.layout),
|
|
1359
1375
|
...getTitles(processedInput.layout),
|
|
1360
1376
|
...getAxisCategoryOrderProps(processedInput.data, processedInput.layout),
|
|
1361
1377
|
...getYMinMaxValues(processedInput.data[0], processedInput.layout),
|
|
@@ -1369,7 +1385,7 @@ const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
1369
1385
|
};
|
|
1370
1386
|
};
|
|
1371
1387
|
const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
1372
|
-
var _input_layout, _input_layout1
|
|
1388
|
+
var _input_layout, _input_layout1;
|
|
1373
1389
|
const vbcData = [];
|
|
1374
1390
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
1375
1391
|
let colorScale = undefined;
|
|
@@ -1416,6 +1432,11 @@ const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayTyp
|
|
|
1416
1432
|
const color = colorScale ? colorScale((0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[index % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index, legend, colorMap, (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, isDarkTheme);
|
|
1417
1433
|
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index);
|
|
1418
1434
|
const yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
|
|
1435
|
+
// Handle text values and texttemplate formatting for histogram bins
|
|
1436
|
+
let barLabel = Array.isArray(series.text) ? series.text[index] : series.text;
|
|
1437
|
+
if (barLabel && series.texttemplate) {
|
|
1438
|
+
barLabel = formatTextWithTemplate(barLabel, series.texttemplate, index);
|
|
1439
|
+
}
|
|
1419
1440
|
var _rgb_copy_formatHex8;
|
|
1420
1441
|
vbcData.push({
|
|
1421
1442
|
x: isXString ? bin.join(', ') : getBinCenter(bin),
|
|
@@ -1426,11 +1447,14 @@ const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayTyp
|
|
|
1426
1447
|
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
1427
1448
|
...isXString ? {} : {
|
|
1428
1449
|
xAxisCalloutData: `[${bin.x0} - ${bin.x1})`
|
|
1429
|
-
}
|
|
1450
|
+
},
|
|
1451
|
+
...barLabel ? {
|
|
1452
|
+
barLabel: String(barLabel)
|
|
1453
|
+
} : {}
|
|
1430
1454
|
});
|
|
1431
1455
|
});
|
|
1432
1456
|
});
|
|
1433
|
-
const annotations = getChartAnnotationsFromLayout(input.layout,
|
|
1457
|
+
const annotations = getChartAnnotationsFromLayout(input.layout, isMultiPlot);
|
|
1434
1458
|
var _input_layout_height;
|
|
1435
1459
|
return {
|
|
1436
1460
|
data: vbcData,
|
|
@@ -1438,11 +1462,12 @@ const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayTyp
|
|
|
1438
1462
|
height: (_input_layout_height = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
1439
1463
|
mode: 'histogram',
|
|
1440
1464
|
hideTickOverlap: true,
|
|
1441
|
-
wrapXAxisLables: typeof ((_vbcData_ = vbcData[0]) === null || _vbcData_ === void 0 ? void 0 : _vbcData_.x) === 'string',
|
|
1442
1465
|
maxBarWidth: 50,
|
|
1443
1466
|
hideLegend,
|
|
1444
1467
|
roundCorners: true,
|
|
1445
1468
|
showYAxisLables: true,
|
|
1469
|
+
roundedTicks: true,
|
|
1470
|
+
...getXMinMaxValues(input.data[0], input.layout),
|
|
1446
1471
|
...getTitles(input.layout),
|
|
1447
1472
|
...getYMinMaxValues(input.data[0], input.layout),
|
|
1448
1473
|
...getAxisCategoryOrderProps(input.data, input.layout),
|
|
@@ -1499,9 +1524,7 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
1499
1524
|
let mode = 'tonexty';
|
|
1500
1525
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
1501
1526
|
const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
1502
|
-
const
|
|
1503
|
-
const resolveXValue = getAxisValueResolver(xAxisType);
|
|
1504
|
-
const shouldWrapLabels = xAxisType === 'category';
|
|
1527
|
+
const resolveXValue = getAxisValueResolver(getAxisType(input.data, getAxisObjects(input.data, input.layout).x));
|
|
1505
1528
|
const chartData = input.data.map((series, index)=>{
|
|
1506
1529
|
var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_mode1;
|
|
1507
1530
|
const colors = isScatterMarkers ? (series === null || series === void 0 ? void 0 : (_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('line')) ? (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color : (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color : (_series_line1 = series.line) === null || _series_line1 === void 0 ? void 0 : _series_line1.color;
|
|
@@ -1650,7 +1673,7 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
1650
1673
|
...lineShape
|
|
1651
1674
|
]
|
|
1652
1675
|
};
|
|
1653
|
-
const annotations = getChartAnnotationsFromLayout(input.layout,
|
|
1676
|
+
const annotations = getChartAnnotationsFromLayout(input.layout, isMultiPlot);
|
|
1654
1677
|
var _input_layout_height;
|
|
1655
1678
|
const commonProps = {
|
|
1656
1679
|
supportNegativeData: true,
|
|
@@ -1660,9 +1683,10 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
1660
1683
|
hideTickOverlap: true,
|
|
1661
1684
|
hideLegend,
|
|
1662
1685
|
useUTC: false,
|
|
1663
|
-
wrapXAxisLabels: shouldWrapLabels,
|
|
1664
1686
|
optimizeLargeData: numDataPoints > 1000,
|
|
1665
1687
|
showYAxisLables: true,
|
|
1688
|
+
roundedTicks: true,
|
|
1689
|
+
...getXMinMaxValues(input.data[0], input.layout),
|
|
1666
1690
|
...getTitles(input.layout),
|
|
1667
1691
|
...getXAxisTickFormat(input.data[0], input.layout),
|
|
1668
1692
|
...yAxisTickFormat,
|
|
@@ -1681,7 +1705,6 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
1681
1705
|
} else {
|
|
1682
1706
|
return {
|
|
1683
1707
|
data: isScatterChart ? scatterChartProps : chartProps,
|
|
1684
|
-
roundedTicks: true,
|
|
1685
1708
|
...commonProps,
|
|
1686
1709
|
...yMinMax,
|
|
1687
1710
|
...isScatterChart ? {
|
|
@@ -1749,6 +1772,8 @@ const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, col
|
|
|
1749
1772
|
showYAxisLablesTooltip: true,
|
|
1750
1773
|
hideLegend,
|
|
1751
1774
|
roundCorners: true,
|
|
1775
|
+
roundedTicks: true,
|
|
1776
|
+
...getXMinMaxValues(input.data[0], input.layout),
|
|
1752
1777
|
...getTitles(input.layout),
|
|
1753
1778
|
...getAxisCategoryOrderProps(input.data, input.layout),
|
|
1754
1779
|
...getBarProps(input.data, input.layout, true),
|
|
@@ -1776,14 +1801,14 @@ const transformPlotlyJsonToGanttChartProps = (input, isMultiPlot, colorMap, colo
|
|
|
1776
1801
|
// extract colors for each series only once
|
|
1777
1802
|
const extractedColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
|
|
1778
1803
|
series.y.forEach((yVal, i)=>{
|
|
1779
|
-
var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout,
|
|
1804
|
+
var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout, _series_x;
|
|
1780
1805
|
if ((0, _chartutilities.isInvalidValue)(yVal)) {
|
|
1781
1806
|
return;
|
|
1782
1807
|
}
|
|
1783
1808
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
1784
1809
|
const color = colorScale ? colorScale((0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[i % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : (0, _PlotlyColorAdapter.resolveColor)(extractedColors, i, legend, colorMap, (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, isDarkTheme);
|
|
1785
1810
|
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, i);
|
|
1786
|
-
const base = +resolveGanttXValue((
|
|
1811
|
+
const base = +resolveGanttXValue((0, _chartutilities.isArrayOrTypedArray)(series.base) ? series.base[i] : series.base);
|
|
1787
1812
|
const xVal = +resolveGanttXValue((_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x[i]);
|
|
1788
1813
|
var _rgb_copy_formatHex8;
|
|
1789
1814
|
ganttData.push({
|
|
@@ -1838,11 +1863,53 @@ const transformPlotlyJsonToGanttChartProps = (input, isMultiPlot, colorMap, colo
|
|
|
1838
1863
|
};
|
|
1839
1864
|
};
|
|
1840
1865
|
const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
1841
|
-
var _input_layout, _input_layout_coloraxis,
|
|
1866
|
+
var _input_layout, _input_layout1, _input_layout_coloraxis, _input_layout2, _input_layout_template_layout, _input_layout_template, _input_layout3, _input_layout_template_data_histogram2d_, _input_layout_template_data_histogram2d, _input_layout_template_data, _input_layout_template1, _input_layout4, _input_layout_template_data_heatmap_, _input_layout_template_data_heatmap, _input_layout_template_data1, _input_layout_template2, _input_layout5, _input_layout6, _input_layout7;
|
|
1842
1867
|
const firstData = input.data[0];
|
|
1843
1868
|
const heatmapDataPoints = [];
|
|
1844
1869
|
let zMin = Number.POSITIVE_INFINITY;
|
|
1845
1870
|
let zMax = Number.NEGATIVE_INFINITY;
|
|
1871
|
+
// Build a 2D array of annotations based on their grid position
|
|
1872
|
+
const annotationGrid = [];
|
|
1873
|
+
const rawAnnotations = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.annotations;
|
|
1874
|
+
if (rawAnnotations) {
|
|
1875
|
+
const annotationsArray = Array.isArray(rawAnnotations) ? rawAnnotations : [
|
|
1876
|
+
rawAnnotations
|
|
1877
|
+
];
|
|
1878
|
+
// Collect all unique x and y values from valid annotations
|
|
1879
|
+
const xSet = new Set();
|
|
1880
|
+
const ySet = new Set();
|
|
1881
|
+
const validAnnotations = [];
|
|
1882
|
+
annotationsArray.forEach((a)=>{
|
|
1883
|
+
if (a && typeof a.x === 'number' && typeof a.y === 'number' && typeof a.text === 'string' && (a.xref === 'x' || a.xref === undefined) && (a.yref === 'y' || a.yref === undefined)) {
|
|
1884
|
+
xSet.add(a.x);
|
|
1885
|
+
ySet.add(a.y);
|
|
1886
|
+
validAnnotations.push({
|
|
1887
|
+
x: a.x,
|
|
1888
|
+
y: a.y,
|
|
1889
|
+
text: cleanText(a.text)
|
|
1890
|
+
});
|
|
1891
|
+
}
|
|
1892
|
+
});
|
|
1893
|
+
if (validAnnotations.length > 0) {
|
|
1894
|
+
// Get sorted unique x and y values
|
|
1895
|
+
const xValues = Array.from(xSet).sort((a, b)=>a - b);
|
|
1896
|
+
const yValues = Array.from(ySet).sort((a, b)=>a - b);
|
|
1897
|
+
// Initialize 2D grid and populate
|
|
1898
|
+
validAnnotations.forEach((annotation)=>{
|
|
1899
|
+
const xIdx = xValues.indexOf(annotation.x);
|
|
1900
|
+
const yIdx = yValues.indexOf(annotation.y);
|
|
1901
|
+
if (!annotationGrid[yIdx]) {
|
|
1902
|
+
annotationGrid[yIdx] = [];
|
|
1903
|
+
}
|
|
1904
|
+
annotationGrid[yIdx][xIdx] = annotation.text;
|
|
1905
|
+
});
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
// Helper function to get annotation from 2D grid by index
|
|
1909
|
+
const getAnnotationByIndex = (xIdx, yIdx)=>{
|
|
1910
|
+
var _annotationGrid_yIdx;
|
|
1911
|
+
return (_annotationGrid_yIdx = annotationGrid[yIdx]) === null || _annotationGrid_yIdx === void 0 ? void 0 : _annotationGrid_yIdx[xIdx];
|
|
1912
|
+
};
|
|
1846
1913
|
if (firstData.type === 'histogram2d') {
|
|
1847
1914
|
var _firstData_x, _firstData_xbins, _firstData_xbins1, _firstData_xbins2, _firstData_ybins, _firstData_ybins1, _firstData_ybins2;
|
|
1848
1915
|
const xValues = [];
|
|
@@ -1882,11 +1949,12 @@ const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwa
|
|
|
1882
1949
|
xBins.forEach((xBin, xIdx)=>{
|
|
1883
1950
|
yBins.forEach((yBin, yIdx)=>{
|
|
1884
1951
|
const zVal = calculateHistNorm(firstData.histnorm, z[yIdx][xIdx], total, isXString ? xBin.length : getBinSize(xBin), isYString ? yBin.length : getBinSize(yBin));
|
|
1952
|
+
const annotationText = getAnnotationByIndex(xIdx, yIdx);
|
|
1885
1953
|
heatmapDataPoints.push({
|
|
1886
1954
|
x: isXString ? xBin.join(', ') : getBinCenter(xBin),
|
|
1887
1955
|
y: isYString ? yBin.join(', ') : getBinCenter(yBin),
|
|
1888
1956
|
value: zVal,
|
|
1889
|
-
rectText: zVal
|
|
1957
|
+
rectText: annotationText || zVal
|
|
1890
1958
|
});
|
|
1891
1959
|
if (typeof zVal === 'number') {
|
|
1892
1960
|
zMin = Math.min(zMin, zVal);
|
|
@@ -1895,17 +1963,34 @@ const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwa
|
|
|
1895
1963
|
});
|
|
1896
1964
|
});
|
|
1897
1965
|
} else {
|
|
1898
|
-
var
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1966
|
+
var _zArray_;
|
|
1967
|
+
// If x and y are not provided, generate indices based on z dimensions
|
|
1968
|
+
const zArray = firstData.z;
|
|
1969
|
+
const xValues = firstData.x;
|
|
1970
|
+
const yValues = firstData.y;
|
|
1971
|
+
var _zArray_length;
|
|
1972
|
+
// Determine the dimensions from z array
|
|
1973
|
+
const yLength = (_zArray_length = zArray === null || zArray === void 0 ? void 0 : zArray.length) !== null && _zArray_length !== void 0 ? _zArray_length : 0;
|
|
1974
|
+
var _zArray__length;
|
|
1975
|
+
const xLength = (_zArray__length = zArray === null || zArray === void 0 ? void 0 : (_zArray_ = zArray[0]) === null || _zArray_ === void 0 ? void 0 : _zArray_.length) !== null && _zArray__length !== void 0 ? _zArray__length : 0;
|
|
1976
|
+
// Use provided x/y values or generate indices
|
|
1977
|
+
const xData = xValues !== null && xValues !== void 0 ? xValues : Array.from({
|
|
1978
|
+
length: xLength
|
|
1979
|
+
}, (_, i)=>i);
|
|
1980
|
+
const yData = yValues !== null && yValues !== void 0 ? yValues : Array.from({
|
|
1981
|
+
length: yLength
|
|
1982
|
+
}, (_, i)=>yLength - 1 - i);
|
|
1983
|
+
xData.forEach((xVal, xIdx)=>{
|
|
1984
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1985
|
+
yData.forEach((yVal, yIdx)=>{
|
|
1986
|
+
var _zArray_yIdx, _input_layout_xaxis, _input_layout, _input_layout_yaxis, _input_layout1;
|
|
1987
|
+
const zVal = zArray === null || zArray === void 0 ? void 0 : (_zArray_yIdx = zArray[yIdx]) === null || _zArray_yIdx === void 0 ? void 0 : _zArray_yIdx[xIdx];
|
|
1988
|
+
const annotationText = getAnnotationByIndex(xIdx, yIdx);
|
|
1904
1989
|
heatmapDataPoints.push({
|
|
1905
1990
|
x: ((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_xaxis = _input_layout.xaxis) === null || _input_layout_xaxis === void 0 ? void 0 : _input_layout_xaxis.type) === 'date' ? xVal : xVal !== null && xVal !== void 0 ? xVal : 0,
|
|
1906
1991
|
y: ((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_yaxis = _input_layout1.yaxis) === null || _input_layout_yaxis === void 0 ? void 0 : _input_layout_yaxis.type) === 'date' ? yVal : yVal,
|
|
1907
1992
|
value: zVal,
|
|
1908
|
-
rectText: zVal
|
|
1993
|
+
rectText: annotationText || zVal
|
|
1909
1994
|
});
|
|
1910
1995
|
if (typeof zVal === 'number') {
|
|
1911
1996
|
zMin = Math.min(zMin, zVal);
|
|
@@ -1932,7 +2017,7 @@ const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwa
|
|
|
1932
2017
|
(0, _colors.getColorFromToken)(_colors.DataVizPalette.color3)
|
|
1933
2018
|
];
|
|
1934
2019
|
var _firstData_colorscale, _ref, _ref1, _ref2, _ref3;
|
|
1935
|
-
let colorscale = (_ref3 = (_ref2 = (_ref1 = (_ref = (_firstData_colorscale = firstData === null || firstData === void 0 ? void 0 : firstData.colorscale) !== null && _firstData_colorscale !== void 0 ? _firstData_colorscale : (
|
|
2020
|
+
let colorscale = (_ref3 = (_ref2 = (_ref1 = (_ref = (_firstData_colorscale = firstData === null || firstData === void 0 ? void 0 : firstData.colorscale) !== null && _firstData_colorscale !== void 0 ? _firstData_colorscale : (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.colorscale) !== null && _ref !== void 0 ? _ref : (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : (_input_layout_coloraxis = _input_layout2.coloraxis) === null || _input_layout_coloraxis === void 0 ? void 0 : _input_layout_coloraxis.colorscale) !== null && _ref1 !== void 0 ? _ref1 : (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : (_input_layout_template = _input_layout3.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorscale) !== null && _ref2 !== void 0 ? _ref2 : firstData.type === 'histogram2d' && ((_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : (_input_layout_template1 = _input_layout4.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_data = _input_layout_template1.data) === null || _input_layout_template_data === void 0 ? void 0 : (_input_layout_template_data_histogram2d = _input_layout_template_data.histogram2d) === null || _input_layout_template_data_histogram2d === void 0 ? void 0 : (_input_layout_template_data_histogram2d_ = _input_layout_template_data_histogram2d[0]) === null || _input_layout_template_data_histogram2d_ === void 0 ? void 0 : _input_layout_template_data_histogram2d_.colorscale)) !== null && _ref3 !== void 0 ? _ref3 : (_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : (_input_layout_template2 = _input_layout5.template) === null || _input_layout_template2 === void 0 ? void 0 : (_input_layout_template_data1 = _input_layout_template2.data) === null || _input_layout_template_data1 === void 0 ? void 0 : (_input_layout_template_data_heatmap = _input_layout_template_data1.heatmap) === null || _input_layout_template_data_heatmap === void 0 ? void 0 : (_input_layout_template_data_heatmap_ = _input_layout_template_data_heatmap[0]) === null || _input_layout_template_data_heatmap_ === void 0 ? void 0 : _input_layout_template_data_heatmap_.colorscale;
|
|
1936
2021
|
// determine if the types diverging, sequential or sequentialminus are present in colorscale
|
|
1937
2022
|
if (colorscale && typeof colorscale === 'object' && ('diverging' in colorscale || 'sequential' in colorscale || 'sequentialminus' in colorscale)) {
|
|
1938
2023
|
const isDivergent = zMin < 0 && zMax > 0; // Data spans both positive and negative values
|
|
@@ -1958,12 +2043,11 @@ const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwa
|
|
|
1958
2043
|
hideLegend: true,
|
|
1959
2044
|
showYAxisLables: true,
|
|
1960
2045
|
sortOrder: 'none',
|
|
1961
|
-
width: (
|
|
1962
|
-
height: (_input_layout_height = (
|
|
2046
|
+
width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
|
|
2047
|
+
height: (_input_layout_height = (_input_layout7 = input.layout) === null || _input_layout7 === void 0 ? void 0 : _input_layout7.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
1963
2048
|
hideTickOverlap: true,
|
|
1964
2049
|
noOfCharsToTruncate: 20,
|
|
1965
2050
|
showYAxisLablesTooltip: true,
|
|
1966
|
-
wrapXAxisLables: true,
|
|
1967
2051
|
...getTitles(input.layout),
|
|
1968
2052
|
...getAxisCategoryOrderProps([
|
|
1969
2053
|
firstData
|
|
@@ -1972,7 +2056,7 @@ const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwa
|
|
|
1972
2056
|
};
|
|
1973
2057
|
};
|
|
1974
2058
|
const transformPlotlyJsonToSankeyProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
1975
|
-
var _input_layout_template_layout, _input_layout_template, _input_layout,
|
|
2059
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _node_label, _input_layout2, _input_layout3;
|
|
1976
2060
|
const { link, node } = input.data[0];
|
|
1977
2061
|
var _link_value;
|
|
1978
2062
|
const validLinks = ((_link_value = link === null || link === void 0 ? void 0 : link.value) !== null && _link_value !== void 0 ? _link_value : []).map((val, index)=>{
|
|
@@ -1988,6 +2072,7 @@ const transformPlotlyJsonToSankeyProps = (input, isMultiPlot, colorMap, colorway
|
|
|
1988
2072
|
}) // Filter out negative nodes, unequal nodes and self-references (circular links)
|
|
1989
2073
|
.filter((x)=>x !== null && x.source >= 0 && x.target >= 0 && x.source !== x.target);
|
|
1990
2074
|
const extractedNodeColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, node === null || node === void 0 ? void 0 : node.color, colorMap, isDarkTheme);
|
|
2075
|
+
const extractedLinkColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template1 = _input_layout1.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, colorwayType, link === null || link === void 0 ? void 0 : link.color, colorMap, isDarkTheme);
|
|
1991
2076
|
const sankeyChartData = {
|
|
1992
2077
|
nodes: (_node_label = node.label) === null || _node_label === void 0 ? void 0 : _node_label.map((label, index)=>{
|
|
1993
2078
|
var _input_layout_template_layout, _input_layout_template, _input_layout;
|
|
@@ -2000,8 +2085,11 @@ const transformPlotlyJsonToSankeyProps = (input, isMultiPlot, colorMap, colorway
|
|
|
2000
2085
|
}),
|
|
2001
2086
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2002
2087
|
links: validLinks.map((validLink, index)=>{
|
|
2088
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout;
|
|
2089
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedLinkColors, index, validLink.target, colorMap, (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, isDarkTheme);
|
|
2003
2090
|
return {
|
|
2004
|
-
...validLink
|
|
2091
|
+
...validLink,
|
|
2092
|
+
color
|
|
2005
2093
|
};
|
|
2006
2094
|
})
|
|
2007
2095
|
};
|
|
@@ -2017,8 +2105,8 @@ const transformPlotlyJsonToSankeyProps = (input, isMultiPlot, colorMap, colorway
|
|
|
2017
2105
|
chartTitle,
|
|
2018
2106
|
SankeyChartData: sankeyChartData
|
|
2019
2107
|
},
|
|
2020
|
-
width: (
|
|
2021
|
-
height: (_input_layout_height = (
|
|
2108
|
+
width: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.width,
|
|
2109
|
+
height: (_input_layout_height = (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 468
|
|
2022
2110
|
};
|
|
2023
2111
|
};
|
|
2024
2112
|
const transformPlotlyJsonToGaugeProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
@@ -2701,23 +2789,25 @@ const getAllupLegendsProps = (input, colorMap, colorwayType, traceInfo, isDarkTh
|
|
|
2701
2789
|
if (toShowLegend) {
|
|
2702
2790
|
input.data.forEach((series, index)=>{
|
|
2703
2791
|
if (traceInfo[index].type === 'donut') {
|
|
2704
|
-
var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _pieSeries_marker
|
|
2792
|
+
var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _pieSeries_marker;
|
|
2705
2793
|
const pieSeries = series;
|
|
2706
2794
|
var _input_layout_piecolorway, _input_layout_piecolorway1;
|
|
2707
2795
|
const colors = (0, _PlotlyColorAdapter.extractColor)((_input_layout_piecolorway = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.piecolorway) !== null && _input_layout_piecolorway !== void 0 ? _input_layout_piecolorway : (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template = _input_layout1.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_input_layout_piecolorway1 = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.piecolorway) !== null && _input_layout_piecolorway1 !== void 0 ? _input_layout_piecolorway1 : pieSeries === null || pieSeries === void 0 ? void 0 : (_pieSeries_marker = pieSeries.marker) === null || _pieSeries_marker === void 0 ? void 0 : _pieSeries_marker.colors, colorMap, isDarkTheme, true);
|
|
2708
|
-
(
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
allupLegends.
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2796
|
+
if ((0, _chartutilities.isArrayOrTypedArray)(pieSeries.labels)) {
|
|
2797
|
+
pieSeries.labels.forEach((label, labelIndex)=>{
|
|
2798
|
+
var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1;
|
|
2799
|
+
const legend = `${label}`;
|
|
2800
|
+
var _input_layout_piecolorway;
|
|
2801
|
+
// resolve color for each legend from the extracted colors
|
|
2802
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(colors, labelIndex, legend, colorMap, (_input_layout_piecolorway = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.piecolorway) !== null && _input_layout_piecolorway !== void 0 ? _input_layout_piecolorway : (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template = _input_layout1.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, isDarkTheme, true);
|
|
2803
|
+
if (legend !== '' && allupLegends.some((group)=>group.title === legend) === false) {
|
|
2804
|
+
allupLegends.push({
|
|
2805
|
+
title: legend,
|
|
2806
|
+
color
|
|
2807
|
+
});
|
|
2808
|
+
}
|
|
2809
|
+
});
|
|
2810
|
+
}
|
|
2721
2811
|
} else if (isNonPlotType(traceInfo[index].type) === false) {
|
|
2722
2812
|
var _plotSeries_line, _plotSeries_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout3;
|
|
2723
2813
|
const plotSeries = series;
|
|
@@ -2802,7 +2892,10 @@ const isNonPlotType = (chartType)=>{
|
|
|
2802
2892
|
'donut',
|
|
2803
2893
|
'sankey',
|
|
2804
2894
|
'pie',
|
|
2805
|
-
'annotation'
|
|
2895
|
+
'annotation',
|
|
2896
|
+
'table',
|
|
2897
|
+
'gauge',
|
|
2898
|
+
'funnel'
|
|
2806
2899
|
].includes(chartType);
|
|
2807
2900
|
};
|
|
2808
2901
|
const getGridProperties = (schema, isMultiPlot, validTracesInfo)=>{
|
|
@@ -2988,7 +3081,7 @@ const getGridProperties = (schema, isMultiPlot, validTracesInfo)=>{
|
|
|
2988
3081
|
}
|
|
2989
3082
|
const isValidArray = (0, _chartutilities.isArrayOrTypedArray)(ax === null || ax === void 0 ? void 0 : ax.categoryarray) && ax.categoryarray.length > 0;
|
|
2990
3083
|
if (isValidArray && (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'array')) {
|
|
2991
|
-
result[propName] = ax.categoryarray;
|
|
3084
|
+
result[propName] = (ax === null || ax === void 0 ? void 0 : ax.autorange) === 'reversed' ? ax.categoryarray.slice().reverse() : ax.categoryarray;
|
|
2992
3085
|
return;
|
|
2993
3086
|
}
|
|
2994
3087
|
if (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'trace' || ax.categoryorder === 'array') {
|
|
@@ -3065,16 +3158,23 @@ const getAxisScaleTypeProps = (data, layout)=>{
|
|
|
3065
3158
|
return;
|
|
3066
3159
|
}
|
|
3067
3160
|
const axType = getAxisType(data, ax);
|
|
3161
|
+
if (axId === 'x' && axType === 'category') {
|
|
3162
|
+
props.xAxis = {
|
|
3163
|
+
tickLayout: 'auto'
|
|
3164
|
+
};
|
|
3165
|
+
}
|
|
3068
3166
|
if ((!ax.tickmode || ax.tickmode === 'array') && (0, _chartutilities.isArrayOrTypedArray)(ax.tickvals)) {
|
|
3069
3167
|
const tickValues = axType === 'date' ? ax.tickvals.map((v)=>new Date(v)) : ax.tickvals;
|
|
3070
3168
|
if (axId === 'x') {
|
|
3071
3169
|
props.tickValues = tickValues;
|
|
3072
3170
|
props.xAxis = {
|
|
3171
|
+
...props.xAxis,
|
|
3073
3172
|
tickText: ax.ticktext
|
|
3074
3173
|
};
|
|
3075
3174
|
} else if (axId === 'y') {
|
|
3076
3175
|
props.yAxisTickValues = tickValues;
|
|
3077
3176
|
props.yAxis = {
|
|
3177
|
+
...props.yAxis,
|
|
3078
3178
|
tickText: ax.ticktext
|
|
3079
3179
|
};
|
|
3080
3180
|
}
|
|
@@ -3085,11 +3185,13 @@ const getAxisScaleTypeProps = (data, layout)=>{
|
|
|
3085
3185
|
const tick0 = plotlyTick0(ax.tick0, axType, dtick);
|
|
3086
3186
|
if (axId === 'x') {
|
|
3087
3187
|
props.xAxis = {
|
|
3188
|
+
...props.xAxis,
|
|
3088
3189
|
tickStep: dtick,
|
|
3089
3190
|
tick0
|
|
3090
3191
|
};
|
|
3091
3192
|
} else if (axId === 'y') {
|
|
3092
3193
|
props.yAxis = {
|
|
3194
|
+
...props.yAxis,
|
|
3093
3195
|
tickStep: dtick,
|
|
3094
3196
|
tick0
|
|
3095
3197
|
};
|
|
@@ -3201,9 +3303,8 @@ const getAxisType = (data, ax)=>{
|
|
|
3201
3303
|
const values = [];
|
|
3202
3304
|
data.forEach((series)=>{
|
|
3203
3305
|
const axId = series[`${axLetter}axis`];
|
|
3204
|
-
if (axId === ax._id || !axId && ax._id === axLetter) {
|
|
3205
|
-
|
|
3206
|
-
(_series_axLetter = series[axLetter]) === null || _series_axLetter === void 0 ? void 0 : _series_axLetter.forEach((val)=>{
|
|
3306
|
+
if ((axId === ax._id || !axId && ax._id === axLetter) && (0, _chartutilities.isArrayOrTypedArray)(series[axLetter])) {
|
|
3307
|
+
series[axLetter].forEach((val)=>{
|
|
3207
3308
|
if (!(0, _chartutilities.isInvalidValue)(val)) {
|
|
3208
3309
|
values.push(val);
|
|
3209
3310
|
}
|