@fluentui/react-charts 0.0.0-nightly-20251212-0406.1 → 0.0.0-nightly-20251216-0407.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -13
- package/dist/index.d.ts +18 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js +20 -18
- 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 +8 -1
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +165 -19
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +15 -0
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +5 -1
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +11 -1
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +12 -5
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +13 -4
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/utilities/utilities.js +2 -2
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js +20 -18
- 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 +8 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +165 -18
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +15 -0
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +5 -1
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +11 -1
- 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/VerticalBarChart/VerticalBarChart.js +12 -5
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +13 -4
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/types/DataPoint.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +2 -2
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +12 -12
|
@@ -217,6 +217,62 @@ export const resolveXAxisPoint = (x, isXYearCategory, isXString, isXDate, isXNum
|
|
|
217
217
|
}
|
|
218
218
|
return x;
|
|
219
219
|
};
|
|
220
|
+
/**
|
|
221
|
+
* Formats text values according to the texttemplate specification
|
|
222
|
+
* Supports D3 format specifiers within %{text:format} patterns
|
|
223
|
+
* @param textValue The raw text value to format
|
|
224
|
+
* @param textTemplate The template string (e.g., "%{text:.1f}%", "%{text:.2%}", "%{text:,.0f}")
|
|
225
|
+
* @param index Optional index for array-based templates
|
|
226
|
+
* @returns Formatted text string
|
|
227
|
+
*
|
|
228
|
+
* Examples:
|
|
229
|
+
* - "%{text:.1f}%" → Formats number with 1 decimal place and adds % suffix
|
|
230
|
+
* - "%{text:.2%}" → Formats as percentage with 2 decimal places
|
|
231
|
+
* - "%{text:,.0f}" → Formats with thousands separator and no decimals
|
|
232
|
+
* - "%{text:$,.2f}" → Formats as currency with thousands separator and 2 decimals
|
|
233
|
+
*/ const formatTextWithTemplate = (textValue, textTemplate, index)=>{
|
|
234
|
+
if (!textTemplate) {
|
|
235
|
+
return String(textValue);
|
|
236
|
+
}
|
|
237
|
+
const numVal = typeof textValue === 'number' ? textValue : parseFloat(String(textValue));
|
|
238
|
+
if (isNaN(numVal)) {
|
|
239
|
+
return String(textValue);
|
|
240
|
+
}
|
|
241
|
+
const template = typeof textTemplate === 'string' ? textTemplate : textTemplate[index || 0] || '';
|
|
242
|
+
// Match Plotly's texttemplate pattern: %{text:format} or %{text}
|
|
243
|
+
// Can be followed by any literal text like %, $, etc.
|
|
244
|
+
const plotlyPattern = /%\{text(?::([^}]+))?\}(.*)$/;
|
|
245
|
+
const match = template.match(plotlyPattern);
|
|
246
|
+
if (match) {
|
|
247
|
+
const formatSpec = match[1]; // The format specifier (e.g., ".1f", ".2%", ",.0f") or undefined
|
|
248
|
+
const suffix = match[2]; // Any text after the closing brace (e.g., "%", " units")
|
|
249
|
+
// If no format specifier is provided (e.g., %{text}%), try to infer from suffix
|
|
250
|
+
if (!formatSpec) {
|
|
251
|
+
// Check if suffix starts with % - assume simple percentage with 1 decimal
|
|
252
|
+
if (suffix.startsWith('%')) {
|
|
253
|
+
return `${numVal.toFixed(1)}${suffix}`;
|
|
254
|
+
}
|
|
255
|
+
// No format specifier, just return the number with the suffix
|
|
256
|
+
return `${numVal}${suffix}`;
|
|
257
|
+
}
|
|
258
|
+
try {
|
|
259
|
+
// Use D3 format function to apply the format specifier
|
|
260
|
+
const formatter = d3Format(formatSpec);
|
|
261
|
+
const formattedValue = formatter(numVal);
|
|
262
|
+
return `${formattedValue}${suffix}`;
|
|
263
|
+
} catch (error) {
|
|
264
|
+
// Try to extract precision for basic fallback
|
|
265
|
+
const precisionMatch = formatSpec.match(/\.(\d+)[f%]/);
|
|
266
|
+
const precision = precisionMatch ? parseInt(precisionMatch[1], 10) : 2;
|
|
267
|
+
// Check if it's a percentage format
|
|
268
|
+
if (formatSpec.includes('%')) {
|
|
269
|
+
return `${(numVal * 100).toFixed(precision)}%${suffix}`;
|
|
270
|
+
}
|
|
271
|
+
return `${numVal.toFixed(precision)}${suffix}`;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return String(textValue);
|
|
275
|
+
};
|
|
220
276
|
/**
|
|
221
277
|
* Extracts unique X-axis categories from Plotly data traces
|
|
222
278
|
* @param data Array of Plotly data traces
|
|
@@ -873,7 +929,8 @@ export const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, co
|
|
|
873
929
|
const hideLabels = firstData.textinfo ? ![
|
|
874
930
|
'value',
|
|
875
931
|
'percent',
|
|
876
|
-
'label+percent'
|
|
932
|
+
'label+percent',
|
|
933
|
+
'percent+label'
|
|
877
934
|
].includes(firstData.textinfo) : false;
|
|
878
935
|
const donutMarginHorizontal = hideLabels ? 0 : 80;
|
|
879
936
|
const donutMarginVertical = 40 + (hideLabels ? 0 : 40);
|
|
@@ -906,7 +963,8 @@ export const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, co
|
|
|
906
963
|
hideLabels,
|
|
907
964
|
showLabelsInPercent: firstData.textinfo ? [
|
|
908
965
|
'percent',
|
|
909
|
-
'label+percent'
|
|
966
|
+
'label+percent',
|
|
967
|
+
'percent+label'
|
|
910
968
|
].includes(firstData.textinfo) : true,
|
|
911
969
|
roundCorners: true,
|
|
912
970
|
order: 'sorted'
|
|
@@ -933,6 +991,7 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
933
991
|
validXYRanges.forEach(([rangeStart, rangeEnd], rangeIdx)=>{
|
|
934
992
|
const rangeXValues = series.x.slice(rangeStart, rangeEnd);
|
|
935
993
|
const rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
994
|
+
const textValues = Array.isArray(series.text) ? series.text.slice(rangeStart, rangeEnd) : typeof series.text === 'string' ? series.text : undefined;
|
|
936
995
|
rangeXValues.forEach((x, index2)=>{
|
|
937
996
|
var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout;
|
|
938
997
|
if (!mapXToDataPoints[x]) {
|
|
@@ -948,6 +1007,11 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
948
1007
|
const opacity = getOpacity(series, index2);
|
|
949
1008
|
const yVal = rangeYValues[index2];
|
|
950
1009
|
const yAxisCalloutData = getFormattedCalloutYData(yVal, yAxisTickFormat);
|
|
1010
|
+
let barLabel = Array.isArray(textValues) ? textValues[index2] : textValues;
|
|
1011
|
+
// Apply texttemplate formatting if specified
|
|
1012
|
+
if (barLabel && series.texttemplate) {
|
|
1013
|
+
barLabel = formatTextWithTemplate(barLabel, series.texttemplate, index2);
|
|
1014
|
+
}
|
|
951
1015
|
if (series.type === 'bar') {
|
|
952
1016
|
var _rgb_copy_formatHex8;
|
|
953
1017
|
mapXToDataPoints[x].chartData.push({
|
|
@@ -956,7 +1020,10 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
956
1020
|
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
957
1021
|
opacity
|
|
958
1022
|
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
959
|
-
yAxisCalloutData
|
|
1023
|
+
yAxisCalloutData,
|
|
1024
|
+
...barLabel ? {
|
|
1025
|
+
barLabel: String(barLabel)
|
|
1026
|
+
} : {}
|
|
960
1027
|
});
|
|
961
1028
|
if (typeof yVal === 'number') {
|
|
962
1029
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
@@ -1143,6 +1210,12 @@ export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, col
|
|
|
1143
1210
|
const color = colorScale ? colorScale(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) : 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);
|
|
1144
1211
|
const opacity = getOpacity(series, xIndex);
|
|
1145
1212
|
const yVal = series.y[xIndex];
|
|
1213
|
+
// Extract text value for barLabel
|
|
1214
|
+
let barLabel = Array.isArray(series.text) ? series.text[xIndex] : series.text;
|
|
1215
|
+
// Apply texttemplate formatting if specified
|
|
1216
|
+
if (barLabel && series.texttemplate) {
|
|
1217
|
+
barLabel = formatTextWithTemplate(barLabel, series.texttemplate, xIndex);
|
|
1218
|
+
}
|
|
1146
1219
|
var _rgb_copy_formatHex8;
|
|
1147
1220
|
return {
|
|
1148
1221
|
x: x.toString(),
|
|
@@ -1150,7 +1223,10 @@ export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, col
|
|
|
1150
1223
|
yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat),
|
|
1151
1224
|
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
1152
1225
|
opacity
|
|
1153
|
-
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
1226
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
1227
|
+
...barLabel ? {
|
|
1228
|
+
barLabel: String(barLabel)
|
|
1229
|
+
} : {}
|
|
1154
1230
|
};
|
|
1155
1231
|
}).filter((item)=>typeof item !== 'undefined'),
|
|
1156
1232
|
useSecondaryYScale: usesSecondaryYScale(series, processedInput.layout)
|
|
@@ -1267,6 +1343,11 @@ export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colo
|
|
|
1267
1343
|
const color = colorScale ? colorScale(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) : 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);
|
|
1268
1344
|
const opacity = getOpacity(series, index);
|
|
1269
1345
|
const yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
|
|
1346
|
+
// Handle text values and texttemplate formatting for histogram bins
|
|
1347
|
+
let barLabel = Array.isArray(series.text) ? series.text[index] : series.text;
|
|
1348
|
+
if (barLabel && series.texttemplate) {
|
|
1349
|
+
barLabel = formatTextWithTemplate(barLabel, series.texttemplate, index);
|
|
1350
|
+
}
|
|
1270
1351
|
var _rgb_copy_formatHex8;
|
|
1271
1352
|
vbcData.push({
|
|
1272
1353
|
x: isXString ? bin.join(', ') : getBinCenter(bin),
|
|
@@ -1277,7 +1358,10 @@ export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colo
|
|
|
1277
1358
|
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
1278
1359
|
...isXString ? {} : {
|
|
1279
1360
|
xAxisCalloutData: `[${bin.x0} - ${bin.x1})`
|
|
1280
|
-
}
|
|
1361
|
+
},
|
|
1362
|
+
...barLabel ? {
|
|
1363
|
+
barLabel: String(barLabel)
|
|
1364
|
+
} : {}
|
|
1281
1365
|
});
|
|
1282
1366
|
});
|
|
1283
1367
|
});
|
|
@@ -1694,11 +1778,53 @@ export const transformPlotlyJsonToGanttChartProps = (input, isMultiPlot, colorMa
|
|
|
1694
1778
|
};
|
|
1695
1779
|
};
|
|
1696
1780
|
export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
1697
|
-
var _input_layout, _input_layout_coloraxis,
|
|
1781
|
+
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;
|
|
1698
1782
|
const firstData = input.data[0];
|
|
1699
1783
|
const heatmapDataPoints = [];
|
|
1700
1784
|
let zMin = Number.POSITIVE_INFINITY;
|
|
1701
1785
|
let zMax = Number.NEGATIVE_INFINITY;
|
|
1786
|
+
// Build a 2D array of annotations based on their grid position
|
|
1787
|
+
const annotationGrid = [];
|
|
1788
|
+
const rawAnnotations = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.annotations;
|
|
1789
|
+
if (rawAnnotations) {
|
|
1790
|
+
const annotationsArray = Array.isArray(rawAnnotations) ? rawAnnotations : [
|
|
1791
|
+
rawAnnotations
|
|
1792
|
+
];
|
|
1793
|
+
// Collect all unique x and y values from valid annotations
|
|
1794
|
+
const xSet = new Set();
|
|
1795
|
+
const ySet = new Set();
|
|
1796
|
+
const validAnnotations = [];
|
|
1797
|
+
annotationsArray.forEach((a)=>{
|
|
1798
|
+
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)) {
|
|
1799
|
+
xSet.add(a.x);
|
|
1800
|
+
ySet.add(a.y);
|
|
1801
|
+
validAnnotations.push({
|
|
1802
|
+
x: a.x,
|
|
1803
|
+
y: a.y,
|
|
1804
|
+
text: cleanText(a.text)
|
|
1805
|
+
});
|
|
1806
|
+
}
|
|
1807
|
+
});
|
|
1808
|
+
if (validAnnotations.length > 0) {
|
|
1809
|
+
// Get sorted unique x and y values
|
|
1810
|
+
const xValues = Array.from(xSet).sort((a, b)=>a - b);
|
|
1811
|
+
const yValues = Array.from(ySet).sort((a, b)=>a - b);
|
|
1812
|
+
// Initialize 2D grid and populate
|
|
1813
|
+
validAnnotations.forEach((annotation)=>{
|
|
1814
|
+
const xIdx = xValues.indexOf(annotation.x);
|
|
1815
|
+
const yIdx = yValues.indexOf(annotation.y);
|
|
1816
|
+
if (!annotationGrid[yIdx]) {
|
|
1817
|
+
annotationGrid[yIdx] = [];
|
|
1818
|
+
}
|
|
1819
|
+
annotationGrid[yIdx][xIdx] = annotation.text;
|
|
1820
|
+
});
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
// Helper function to get annotation from 2D grid by index
|
|
1824
|
+
const getAnnotationByIndex = (xIdx, yIdx)=>{
|
|
1825
|
+
var _annotationGrid_yIdx;
|
|
1826
|
+
return (_annotationGrid_yIdx = annotationGrid[yIdx]) === null || _annotationGrid_yIdx === void 0 ? void 0 : _annotationGrid_yIdx[xIdx];
|
|
1827
|
+
};
|
|
1702
1828
|
if (firstData.type === 'histogram2d') {
|
|
1703
1829
|
var _firstData_x, _firstData_xbins, _firstData_xbins1, _firstData_xbins2, _firstData_ybins, _firstData_ybins1, _firstData_ybins2;
|
|
1704
1830
|
const xValues = [];
|
|
@@ -1738,11 +1864,12 @@ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap,
|
|
|
1738
1864
|
xBins.forEach((xBin, xIdx)=>{
|
|
1739
1865
|
yBins.forEach((yBin, yIdx)=>{
|
|
1740
1866
|
const zVal = calculateHistNorm(firstData.histnorm, z[yIdx][xIdx], total, isXString ? xBin.length : getBinSize(xBin), isYString ? yBin.length : getBinSize(yBin));
|
|
1867
|
+
const annotationText = getAnnotationByIndex(xIdx, yIdx);
|
|
1741
1868
|
heatmapDataPoints.push({
|
|
1742
1869
|
x: isXString ? xBin.join(', ') : getBinCenter(xBin),
|
|
1743
1870
|
y: isYString ? yBin.join(', ') : getBinCenter(yBin),
|
|
1744
1871
|
value: zVal,
|
|
1745
|
-
rectText: zVal
|
|
1872
|
+
rectText: annotationText || zVal
|
|
1746
1873
|
});
|
|
1747
1874
|
if (typeof zVal === 'number') {
|
|
1748
1875
|
zMin = Math.min(zMin, zVal);
|
|
@@ -1751,18 +1878,34 @@ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap,
|
|
|
1751
1878
|
});
|
|
1752
1879
|
});
|
|
1753
1880
|
} else {
|
|
1754
|
-
var
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1881
|
+
var _zArray_;
|
|
1882
|
+
// If x and y are not provided, generate indices based on z dimensions
|
|
1883
|
+
const zArray = firstData.z;
|
|
1884
|
+
const xValues = firstData.x;
|
|
1885
|
+
const yValues = firstData.y;
|
|
1886
|
+
var _zArray_length;
|
|
1887
|
+
// Determine the dimensions from z array
|
|
1888
|
+
const yLength = (_zArray_length = zArray === null || zArray === void 0 ? void 0 : zArray.length) !== null && _zArray_length !== void 0 ? _zArray_length : 0;
|
|
1889
|
+
var _zArray__length;
|
|
1890
|
+
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;
|
|
1891
|
+
// Use provided x/y values or generate indices
|
|
1892
|
+
const xData = xValues !== null && xValues !== void 0 ? xValues : Array.from({
|
|
1893
|
+
length: xLength
|
|
1894
|
+
}, (_, i)=>i);
|
|
1895
|
+
const yData = yValues !== null && yValues !== void 0 ? yValues : Array.from({
|
|
1896
|
+
length: yLength
|
|
1897
|
+
}, (_, i)=>yLength - 1 - i);
|
|
1898
|
+
xData.forEach((xVal, xIdx)=>{
|
|
1899
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1900
|
+
yData.forEach((yVal, yIdx)=>{
|
|
1901
|
+
var _zArray_yIdx, _input_layout_xaxis, _input_layout, _input_layout_yaxis, _input_layout1;
|
|
1902
|
+
const zVal = zArray === null || zArray === void 0 ? void 0 : (_zArray_yIdx = zArray[yIdx]) === null || _zArray_yIdx === void 0 ? void 0 : _zArray_yIdx[xIdx];
|
|
1903
|
+
const annotationText = getAnnotationByIndex(xIdx, yIdx);
|
|
1761
1904
|
heatmapDataPoints.push({
|
|
1762
1905
|
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,
|
|
1763
1906
|
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,
|
|
1764
1907
|
value: zVal,
|
|
1765
|
-
rectText: zVal
|
|
1908
|
+
rectText: annotationText || zVal
|
|
1766
1909
|
});
|
|
1767
1910
|
if (typeof zVal === 'number') {
|
|
1768
1911
|
zMin = Math.min(zMin, zVal);
|
|
@@ -1789,7 +1932,7 @@ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap,
|
|
|
1789
1932
|
getColorFromToken(DataVizPalette.color3)
|
|
1790
1933
|
];
|
|
1791
1934
|
var _firstData_colorscale, _ref, _ref1, _ref2, _ref3;
|
|
1792
|
-
let colorscale = (_ref3 = (_ref2 = (_ref1 = (_ref = (_firstData_colorscale = firstData === null || firstData === void 0 ? void 0 : firstData.colorscale) !== null && _firstData_colorscale !== void 0 ? _firstData_colorscale : (
|
|
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 : (_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;
|
|
1793
1936
|
// determine if the types diverging, sequential or sequentialminus are present in colorscale
|
|
1794
1937
|
if (colorscale && typeof colorscale === 'object' && ('diverging' in colorscale || 'sequential' in colorscale || 'sequentialminus' in colorscale)) {
|
|
1795
1938
|
const isDivergent = zMin < 0 && zMax > 0; // Data spans both positive and negative values
|
|
@@ -1815,8 +1958,8 @@ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap,
|
|
|
1815
1958
|
hideLegend: true,
|
|
1816
1959
|
showYAxisLables: true,
|
|
1817
1960
|
sortOrder: 'none',
|
|
1818
|
-
width: (
|
|
1819
|
-
height: (_input_layout_height = (
|
|
1961
|
+
width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
|
|
1962
|
+
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,
|
|
1820
1963
|
hideTickOverlap: true,
|
|
1821
1964
|
noOfCharsToTruncate: 20,
|
|
1822
1965
|
showYAxisLablesTooltip: true,
|
|
@@ -2670,7 +2813,10 @@ export const isNonPlotType = (chartType)=>{
|
|
|
2670
2813
|
'donut',
|
|
2671
2814
|
'sankey',
|
|
2672
2815
|
'pie',
|
|
2673
|
-
'annotation'
|
|
2816
|
+
'annotation',
|
|
2817
|
+
'table',
|
|
2818
|
+
'gauge',
|
|
2819
|
+
'funnel'
|
|
2674
2820
|
].includes(chartType);
|
|
2675
2821
|
};
|
|
2676
2822
|
export const getGridProperties = (schema, isMultiPlot, validTracesInfo)=>{
|