@fluentui/react-charts 9.1.2 → 9.1.4
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 +34 -2
- package/dist/index.d.ts +36 -1
- package/lib/components/AreaChart/AreaChart.js +18 -8
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +20 -15
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +57 -43
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.js +4 -2
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +44 -18
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +3 -2
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +181 -38
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +40 -36
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +8 -8
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +1 -1
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +4 -4
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +61 -23
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/utilities/utilities.js +77 -46
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js +16 -7
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +19 -15
- 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/DeclarativeChart/PlotlySchemaAdapter.js +57 -43
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js +4 -2
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +43 -17
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +4 -2
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +175 -36
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +40 -36
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +7 -7
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +4 -4
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +60 -22
- 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 +76 -46
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +8 -8
|
@@ -24,6 +24,9 @@ _export(exports, {
|
|
|
24
24
|
HighContrastSelectorWhite: function() {
|
|
25
25
|
return HighContrastSelectorWhite;
|
|
26
26
|
},
|
|
27
|
+
MIN_DOMAIN_MARGIN: function() {
|
|
28
|
+
return MIN_DOMAIN_MARGIN;
|
|
29
|
+
},
|
|
27
30
|
Points: function() {
|
|
28
31
|
return Points;
|
|
29
32
|
},
|
|
@@ -42,6 +45,9 @@ _export(exports, {
|
|
|
42
45
|
calloutData: function() {
|
|
43
46
|
return calloutData;
|
|
44
47
|
},
|
|
48
|
+
computeLongestBars: function() {
|
|
49
|
+
return computeLongestBars;
|
|
50
|
+
},
|
|
45
51
|
createDateXAxis: function() {
|
|
46
52
|
return createDateXAxis;
|
|
47
53
|
},
|
|
@@ -156,6 +162,9 @@ _export(exports, {
|
|
|
156
162
|
getXAxisType: function() {
|
|
157
163
|
return getXAxisType;
|
|
158
164
|
},
|
|
165
|
+
groupChartDataByYValue: function() {
|
|
166
|
+
return groupChartDataByYValue;
|
|
167
|
+
},
|
|
159
168
|
isScalePaddingDefined: function() {
|
|
160
169
|
return isScalePaddingDefined;
|
|
161
170
|
},
|
|
@@ -197,6 +206,7 @@ const _d3time = require("d3-time");
|
|
|
197
206
|
const _d3shape = require("d3-shape");
|
|
198
207
|
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
|
|
199
208
|
const _chartutilities = require("@fluentui/chart-utilities");
|
|
209
|
+
const MIN_DOMAIN_MARGIN = 8;
|
|
200
210
|
var ChartTypes;
|
|
201
211
|
(function(ChartTypes) {
|
|
202
212
|
ChartTypes[ChartTypes["AreaChart"] = 0] = "AreaChart";
|
|
@@ -641,10 +651,10 @@ function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl, axisData,
|
|
|
641
651
|
startValue: 0,
|
|
642
652
|
endValue: 0
|
|
643
653
|
}, yAxisElement = null, yMaxValue = 0, yMinValue = 0, containerHeight, margins, tickPadding = 12, maxOfYVal = 0, yAxisTickFormat, yAxisTickCount = 4 } = yAxisParams;
|
|
644
|
-
// maxOfYVal coming from
|
|
654
|
+
// maxOfYVal coming from horizontal bar chart with axis (Calculation done at base file)
|
|
645
655
|
const tempVal = maxOfYVal || yMinMaxValues.endValue;
|
|
646
656
|
const finalYmax = tempVal > yMaxValue ? tempVal : yMaxValue;
|
|
647
|
-
const finalYmin = yMinMaxValues.startValue < yMinValue ? 0 : yMinValue;
|
|
657
|
+
const finalYmin = yMinMaxValues.startValue < yMinValue ? Math.min(0, yMinMaxValues.startValue) : yMinValue;
|
|
648
658
|
const yAxisScale = (0, _d3scale.scaleLinear)().domain([
|
|
649
659
|
finalYmin,
|
|
650
660
|
finalYmax
|
|
@@ -664,9 +674,9 @@ function createNumericYAxisForOtherCharts(yAxisParams, isRtl, axisData, isIntegr
|
|
|
664
674
|
endValue: 0
|
|
665
675
|
}, yAxisElement = null, yMaxValue = 0, yMinValue = 0, containerHeight, containerWidth, margins, tickPadding = 12, maxOfYVal = 0, yAxisTickFormat, yAxisTickCount = 4, eventAnnotationProps, eventLabelHeight } = yAxisParams;
|
|
666
676
|
// maxOfYVal coming from only area chart and Grouped vertical bar chart(Calculation done at base file)
|
|
667
|
-
const tempVal = maxOfYVal || yMinMaxValues.endValue;
|
|
677
|
+
const tempVal = maxOfYVal || yMinMaxValues.endValue || 0;
|
|
668
678
|
const finalYmax = tempVal > yMaxValue ? tempVal : yMaxValue;
|
|
669
|
-
const finalYmin = Math.min(yMinMaxValues.startValue, yMinValue || 0);
|
|
679
|
+
const finalYmin = Math.min(yMinMaxValues.startValue || 0, yMinValue || 0);
|
|
670
680
|
const domainValues = prepareDatapoints(finalYmax, finalYmin, yAxisTickCount, isIntegralDataset, roundedTicks);
|
|
671
681
|
let yMin = finalYmin;
|
|
672
682
|
let yMax = domainValues[domainValues.length - 1];
|
|
@@ -698,11 +708,13 @@ const createStringYAxis = (yAxisParams, dataPoints, isRtl, chartType, barWidth,
|
|
|
698
708
|
}
|
|
699
709
|
};
|
|
700
710
|
const createStringYAxisForHorizontalBarChartWithAxis = (yAxisParams, dataPoints, isRtl, barWidth, culture)=>{
|
|
701
|
-
const { containerHeight, tickPadding = 12, margins, yAxisTickFormat, yAxisElement } = yAxisParams;
|
|
711
|
+
const { containerHeight, tickPadding = 12, margins, yAxisTickFormat, yAxisElement, yAxisPadding } = yAxisParams;
|
|
712
|
+
let yAxisPaddingValue = yAxisPadding !== null && yAxisPadding !== void 0 ? yAxisPadding : 0.5;
|
|
713
|
+
yAxisPaddingValue = yAxisPaddingValue === 1 ? 0.99 : yAxisPaddingValue;
|
|
702
714
|
const yAxisScale = (0, _d3scale.scaleBand)().domain(dataPoints).range([
|
|
703
|
-
containerHeight - margins.bottom
|
|
704
|
-
margins.top
|
|
705
|
-
]);
|
|
715
|
+
containerHeight - margins.bottom,
|
|
716
|
+
margins.top
|
|
717
|
+
]).padding(yAxisPaddingValue);
|
|
706
718
|
const axis = isRtl ? (0, _d3axis.axisRight)(yAxisScale) : (0, _d3axis.axisLeft)(yAxisScale);
|
|
707
719
|
const yAxis = axis.tickPadding(tickPadding).ticks(dataPoints);
|
|
708
720
|
if (yAxisTickFormat) {
|
|
@@ -1007,17 +1019,44 @@ function domainRangeOfNumericForScatterChart(points, margins, width, isRTL) {
|
|
|
1007
1019
|
rEndValue
|
|
1008
1020
|
};
|
|
1009
1021
|
}
|
|
1010
|
-
function
|
|
1011
|
-
const
|
|
1022
|
+
function groupChartDataByYValue(chartData) {
|
|
1023
|
+
const map = {};
|
|
1024
|
+
chartData.forEach((dataPoint)=>{
|
|
1025
|
+
const key = dataPoint.y;
|
|
1026
|
+
if (!map[key]) {
|
|
1027
|
+
map[key] = [];
|
|
1028
|
+
}
|
|
1029
|
+
map[key].push(dataPoint);
|
|
1030
|
+
});
|
|
1031
|
+
return Object.values(map);
|
|
1032
|
+
}
|
|
1033
|
+
function computeLongestBars(stackedChartData, X_ORIGIN) {
|
|
1034
|
+
let longestPositiveBar = 0;
|
|
1035
|
+
let longestNegativeBar = 0;
|
|
1036
|
+
stackedChartData.forEach((group)=>{
|
|
1037
|
+
const positiveBarTotal = group.reduce((acc, point)=>acc + (point.x > 0 ? point.x : 0), X_ORIGIN);
|
|
1038
|
+
const negativeBarTotal = group.reduce((acc, point)=>acc + (point.x < 0 ? point.x : 0), X_ORIGIN);
|
|
1039
|
+
longestPositiveBar = Math.max(longestPositiveBar, positiveBarTotal);
|
|
1040
|
+
longestNegativeBar = Math.min(longestNegativeBar, negativeBarTotal);
|
|
1041
|
+
});
|
|
1042
|
+
return {
|
|
1043
|
+
longestPositiveBar,
|
|
1044
|
+
longestNegativeBar
|
|
1045
|
+
};
|
|
1046
|
+
}
|
|
1047
|
+
function domainRangeOfNumericForHorizontalBarChartWithAxis(points, margins, containerWidth, isRTL, shiftX, X_ORIGIN) {
|
|
1048
|
+
const longestBars = computeLongestBars(groupChartDataByYValue(points), X_ORIGIN);
|
|
1049
|
+
const xMax = longestBars.longestPositiveBar;
|
|
1050
|
+
const xMin = longestBars.longestNegativeBar;
|
|
1012
1051
|
const rMin = isRTL ? margins.left : margins.left + shiftX;
|
|
1013
1052
|
const rMax = isRTL ? containerWidth - margins.right - shiftX : containerWidth - margins.right;
|
|
1014
1053
|
return isRTL ? {
|
|
1015
1054
|
dStartValue: xMax,
|
|
1016
|
-
dEndValue:
|
|
1055
|
+
dEndValue: Math.min(xMin, X_ORIGIN),
|
|
1017
1056
|
rStartValue: rMin,
|
|
1018
1057
|
rEndValue: rMax
|
|
1019
1058
|
} : {
|
|
1020
|
-
dStartValue:
|
|
1059
|
+
dStartValue: Math.min(xMin, X_ORIGIN),
|
|
1021
1060
|
dEndValue: xMax,
|
|
1022
1061
|
rStartValue: rMin,
|
|
1023
1062
|
rEndValue: rMax
|
|
@@ -1164,7 +1203,7 @@ function domainRageOfVerticalNumeric(points, margins, containerWidth, isRTL, bar
|
|
|
1164
1203
|
rEndValue: rMax
|
|
1165
1204
|
};
|
|
1166
1205
|
}
|
|
1167
|
-
function getDomainNRangeValues(points, margins, width, chartType, isRTL, xAxisType, barWidth, tickValues, shiftX) {
|
|
1206
|
+
function getDomainNRangeValues(points, margins, width, chartType, isRTL, xAxisType, barWidth, tickValues, shiftX, X_ORIGIN) {
|
|
1168
1207
|
let domainNRangeValue;
|
|
1169
1208
|
if (xAxisType === 0) {
|
|
1170
1209
|
switch(chartType){
|
|
@@ -1179,7 +1218,7 @@ function getDomainNRangeValues(points, margins, width, chartType, isRTL, xAxisTy
|
|
|
1179
1218
|
domainNRangeValue = domainRageOfVerticalNumeric(points, margins, width, isRTL, barWidth);
|
|
1180
1219
|
break;
|
|
1181
1220
|
case 6:
|
|
1182
|
-
domainNRangeValue = domainRangeOfNumericForHorizontalBarChartWithAxis(points, margins, width, isRTL, shiftX);
|
|
1221
|
+
domainNRangeValue = domainRangeOfNumericForHorizontalBarChartWithAxis(points, margins, width, isRTL, shiftX, X_ORIGIN);
|
|
1183
1222
|
break;
|
|
1184
1223
|
case 7:
|
|
1185
1224
|
domainNRangeValue = domainRangeOfNumericForScatterChart(points, margins, width, isRTL);
|
|
@@ -1232,16 +1271,18 @@ function getDomainNRangeValues(points, margins, width, chartType, isRTL, xAxisTy
|
|
|
1232
1271
|
}
|
|
1233
1272
|
return domainNRangeValue;
|
|
1234
1273
|
}
|
|
1235
|
-
function findNumericMinMaxOfY(points) {
|
|
1236
|
-
const
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1274
|
+
function findNumericMinMaxOfY(points, yAxisType, useSecondaryYScale) {
|
|
1275
|
+
const values = [];
|
|
1276
|
+
points.forEach((point)=>{
|
|
1277
|
+
if (!useSecondaryYScale === !point.useSecondaryYScale) {
|
|
1278
|
+
point.data.forEach((data)=>{
|
|
1279
|
+
values.push(data.y);
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1241
1282
|
});
|
|
1242
1283
|
return {
|
|
1243
|
-
startValue:
|
|
1244
|
-
endValue:
|
|
1284
|
+
startValue: (0, _d3array.min)(values),
|
|
1285
|
+
endValue: (0, _d3array.max)(values)
|
|
1245
1286
|
};
|
|
1246
1287
|
}
|
|
1247
1288
|
function findVSBCNumericMinMaxOfY(dataset) {
|
|
@@ -1252,32 +1293,21 @@ function findVSBCNumericMinMaxOfY(dataset) {
|
|
|
1252
1293
|
endValue: yMax
|
|
1253
1294
|
};
|
|
1254
1295
|
}
|
|
1255
|
-
function findVerticalNumericMinMaxOfY(points) {
|
|
1256
|
-
const
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
} else {
|
|
1261
|
-
return point.lineData.y;
|
|
1262
|
-
}
|
|
1263
|
-
} else {
|
|
1264
|
-
return point.y;
|
|
1296
|
+
function findVerticalNumericMinMaxOfY(points, yAxisType, useSecondaryYScale) {
|
|
1297
|
+
const values = [];
|
|
1298
|
+
points.forEach((point)=>{
|
|
1299
|
+
if (!useSecondaryYScale) {
|
|
1300
|
+
values.push(point.y);
|
|
1265
1301
|
}
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
if (point.y < point.lineData.y) {
|
|
1270
|
-
return point.y;
|
|
1271
|
-
} else {
|
|
1272
|
-
return point.lineData.y;
|
|
1302
|
+
if (typeof point.lineData !== 'undefined') {
|
|
1303
|
+
if (!useSecondaryYScale === !point.lineData.useSecondaryYScale) {
|
|
1304
|
+
values.push(point.lineData.y);
|
|
1273
1305
|
}
|
|
1274
|
-
} else {
|
|
1275
|
-
return point.y;
|
|
1276
1306
|
}
|
|
1277
1307
|
});
|
|
1278
1308
|
return {
|
|
1279
|
-
startValue:
|
|
1280
|
-
endValue:
|
|
1309
|
+
startValue: (0, _d3array.min)(values),
|
|
1310
|
+
endValue: (0, _d3array.max)(values)
|
|
1281
1311
|
};
|
|
1282
1312
|
}
|
|
1283
1313
|
function findHBCWANumericMinMaxOfY(points, yAxisType) {
|
|
@@ -1294,19 +1324,19 @@ function findHBCWANumericMinMaxOfY(points, yAxisType) {
|
|
|
1294
1324
|
endValue: 0
|
|
1295
1325
|
};
|
|
1296
1326
|
}
|
|
1297
|
-
function getMinMaxOfYAxis(points, chartType, yAxisType = 0) {
|
|
1327
|
+
function getMinMaxOfYAxis(points, chartType, yAxisType = 0, useSecondaryYScale) {
|
|
1298
1328
|
let minMaxValues;
|
|
1299
1329
|
switch(chartType){
|
|
1300
1330
|
case 0:
|
|
1301
1331
|
case 1:
|
|
1302
1332
|
case 7:
|
|
1303
|
-
minMaxValues = findNumericMinMaxOfY(points);
|
|
1333
|
+
minMaxValues = findNumericMinMaxOfY(points, yAxisType, useSecondaryYScale);
|
|
1304
1334
|
break;
|
|
1305
1335
|
case 3:
|
|
1306
1336
|
minMaxValues = findVSBCNumericMinMaxOfY(points);
|
|
1307
1337
|
break;
|
|
1308
1338
|
case 2:
|
|
1309
|
-
minMaxValues = findVerticalNumericMinMaxOfY(points);
|
|
1339
|
+
minMaxValues = findVerticalNumericMinMaxOfY(points, yAxisType, useSecondaryYScale);
|
|
1310
1340
|
break;
|
|
1311
1341
|
case 6:
|
|
1312
1342
|
minMaxValues = findHBCWANumericMinMaxOfY(points, yAxisType);
|