@fluentui/react-charting 5.24.6 → 5.24.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.json +43 -1
- package/CHANGELOG.md +22 -2
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/lib/components/CommonComponents/CartesianChart.base.d.ts +3 -2
- package/lib/components/CommonComponents/CartesianChart.base.js +118 -102
- package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +13 -10
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +15 -24
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.base.js +22 -23
- package/lib/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js +14 -12
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +13 -17
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib/utilities/utilities.d.ts +3 -0
- package/lib/utilities/utilities.js +25 -38
- package/lib/utilities/utilities.js.map +1 -1
- package/lib/utilities/vbc-utils.d.ts +18 -0
- package/lib/utilities/vbc-utils.js +29 -0
- package/lib/utilities/vbc-utils.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.base.d.ts +3 -2
- package/lib-amd/components/CommonComponents/CartesianChart.base.js +117 -101
- package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +13 -10
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +14 -23
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/ScatterChart/ScatterChart.base.js +22 -23
- package/lib-amd/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +13 -11
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +12 -16
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-amd/utilities/utilities.d.ts +3 -0
- package/lib-amd/utilities/utilities.js +26 -39
- package/lib-amd/utilities/utilities.js.map +1 -1
- package/lib-amd/utilities/vbc-utils.d.ts +18 -0
- package/lib-amd/utilities/vbc-utils.js +34 -1
- package/lib-amd/utilities/vbc-utils.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.d.ts +3 -2
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +117 -101
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +13 -10
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +14 -23
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js +22 -23
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +13 -11
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +12 -16
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-commonjs/utilities/utilities.d.ts +3 -0
- package/lib-commonjs/utilities/utilities.js +27 -40
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/lib-commonjs/utilities/vbc-utils.d.ts +18 -0
- package/lib-commonjs/utilities/vbc-utils.js +34 -1
- package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -70,7 +70,7 @@ export function defaultYAxisTickFormatter(value) {
|
|
|
70
70
|
*/
|
|
71
71
|
export function createNumericXAxis(xAxisParams, tickParams, chartType, culture) {
|
|
72
72
|
var _a;
|
|
73
|
-
var domainNRangeValues = xAxisParams.domainNRangeValues, _b = xAxisParams.showRoundOffXTickValues, showRoundOffXTickValues = _b === void 0 ? true : _b, _c = xAxisParams.xAxistickSize, xAxistickSize = _c === void 0 ? 6 : _c, _d = xAxisParams.tickPadding, tickPadding = _d === void 0 ? 10 : _d, xAxisCount = xAxisParams.xAxisCount, xAxisElement = xAxisParams.xAxisElement, hideTickOverlap = xAxisParams.hideTickOverlap;
|
|
73
|
+
var domainNRangeValues = xAxisParams.domainNRangeValues, _b = xAxisParams.showRoundOffXTickValues, showRoundOffXTickValues = _b === void 0 ? true : _b, _c = xAxisParams.xAxistickSize, xAxistickSize = _c === void 0 ? 6 : _c, _d = xAxisParams.tickPadding, tickPadding = _d === void 0 ? 10 : _d, xAxisCount = xAxisParams.xAxisCount, xAxisElement = xAxisParams.xAxisElement, hideTickOverlap = xAxisParams.hideTickOverlap, calcMaxLabelWidth = xAxisParams.calcMaxLabelWidth;
|
|
74
74
|
var xAxisScale = d3ScaleLinear()
|
|
75
75
|
.domain([domainNRangeValues.dStartValue, domainNRangeValues.dEndValue])
|
|
76
76
|
.range([domainNRangeValues.rStartValue, domainNRangeValues.rEndValue]);
|
|
@@ -84,7 +84,7 @@ export function createNumericXAxis(xAxisParams, tickParams, chartType, culture)
|
|
|
84
84
|
return formatToLocaleString(xAxisValue, culture);
|
|
85
85
|
};
|
|
86
86
|
if (hideTickOverlap && typeof xAxisCount === 'undefined') {
|
|
87
|
-
var longestLabelWidth =
|
|
87
|
+
var longestLabelWidth = calcMaxLabelWidth(xAxisScale.ticks().map(tickFormat)) + 20;
|
|
88
88
|
var _e = xAxisScale.range(), start = _e[0], end = _e[1];
|
|
89
89
|
tickCount = Math.min(Math.max(1, Math.floor(Math.abs(end - start) / longestLabelWidth)), 10);
|
|
90
90
|
}
|
|
@@ -209,7 +209,7 @@ function isPowerOf10(num) {
|
|
|
209
209
|
*/
|
|
210
210
|
export function createDateXAxis(xAxisParams, tickParams, culture, options, timeFormatLocale, customDateTimeFormatter, useUTC) {
|
|
211
211
|
var _a;
|
|
212
|
-
var domainNRangeValues = xAxisParams.domainNRangeValues, xAxisElement = xAxisParams.xAxisElement, _b = xAxisParams.tickPadding, tickPadding = _b === void 0 ? 6 : _b, _c = xAxisParams.xAxistickSize, xAxistickSize = _c === void 0 ? 6 : _c, xAxisCount = xAxisParams.xAxisCount;
|
|
212
|
+
var domainNRangeValues = xAxisParams.domainNRangeValues, xAxisElement = xAxisParams.xAxisElement, _b = xAxisParams.tickPadding, tickPadding = _b === void 0 ? 6 : _b, _c = xAxisParams.xAxistickSize, xAxistickSize = _c === void 0 ? 6 : _c, xAxisCount = xAxisParams.xAxisCount, calcMaxLabelWidth = xAxisParams.calcMaxLabelWidth;
|
|
213
213
|
var xAxisScale = useUTC ? d3ScaleUtc() : d3ScaleTime();
|
|
214
214
|
xAxisScale
|
|
215
215
|
.domain([domainNRangeValues.dStartValue, domainNRangeValues.dEndValue])
|
|
@@ -247,7 +247,7 @@ export function createDateXAxis(xAxisParams, tickParams, culture, options, timeF
|
|
|
247
247
|
}
|
|
248
248
|
return formatDateToLocaleString(domainValue, culture, useUTC, false, formatOptions);
|
|
249
249
|
};
|
|
250
|
-
var longestLabelWidth =
|
|
250
|
+
var longestLabelWidth = calcMaxLabelWidth(xAxisScale.ticks().map(tickFormat)) + 40;
|
|
251
251
|
var _d = xAxisScale.range(), start = _d[0], end = _d[1];
|
|
252
252
|
var maxPossibleTickCount = Math.min(Math.max(1, Math.floor(Math.abs(end - start) / longestLabelWidth)), 10);
|
|
253
253
|
tickCount = Math.min(maxPossibleTickCount, xAxisCount !== null && xAxisCount !== void 0 ? xAxisCount : tickCount);
|
|
@@ -274,7 +274,7 @@ export function createDateXAxis(xAxisParams, tickParams, culture, options, timeF
|
|
|
274
274
|
*/
|
|
275
275
|
export function createStringXAxis(xAxisParams, tickParams, dataset, culture) {
|
|
276
276
|
var _a;
|
|
277
|
-
var domainNRangeValues = xAxisParams.domainNRangeValues, _b = xAxisParams.xAxistickSize, xAxistickSize = _b === void 0 ? 6 : _b, _c = xAxisParams.tickPadding, tickPadding = _c === void 0 ? 10 : _c, _d = xAxisParams.xAxisPadding, xAxisPadding = _d === void 0 ? 0.1 : _d, xAxisInnerPadding = xAxisParams.xAxisInnerPadding, xAxisOuterPadding = xAxisParams.xAxisOuterPadding, containerWidth = xAxisParams.containerWidth, hideTickOverlap = xAxisParams.hideTickOverlap;
|
|
277
|
+
var domainNRangeValues = xAxisParams.domainNRangeValues, _b = xAxisParams.xAxistickSize, xAxistickSize = _b === void 0 ? 6 : _b, _c = xAxisParams.tickPadding, tickPadding = _c === void 0 ? 10 : _c, _d = xAxisParams.xAxisPadding, xAxisPadding = _d === void 0 ? 0.1 : _d, xAxisInnerPadding = xAxisParams.xAxisInnerPadding, xAxisOuterPadding = xAxisParams.xAxisOuterPadding, containerWidth = xAxisParams.containerWidth, hideTickOverlap = xAxisParams.hideTickOverlap, calcMaxLabelWidth = xAxisParams.calcMaxLabelWidth;
|
|
278
278
|
var xAxisScale = d3ScaleBand()
|
|
279
279
|
.domain(dataset)
|
|
280
280
|
.range([domainNRangeValues.rStartValue, domainNRangeValues.rEndValue])
|
|
@@ -286,7 +286,7 @@ export function createStringXAxis(xAxisParams, tickParams, dataset, culture) {
|
|
|
286
286
|
// Here, we need the width of each individual label to detect overlaps,
|
|
287
287
|
// but calculateLongestLabelWidth returns the maximum pixel width from an array of labels.
|
|
288
288
|
// So call this function separately for each label, instead of the entire array.
|
|
289
|
-
var tickSizes = tickValues.map(function (value) { return
|
|
289
|
+
var tickSizes = tickValues.map(function (value) { return calcMaxLabelWidth([value]); });
|
|
290
290
|
// for LTR
|
|
291
291
|
var start = 0;
|
|
292
292
|
var end = containerWidth;
|
|
@@ -397,10 +397,10 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
397
397
|
if (roundedTicks === void 0) { roundedTicks = false; }
|
|
398
398
|
var _a = yAxisParams.yMinMaxValues, yMinMaxValues = _a === void 0 ? { startValue: 0, endValue: 0 } : _a, _b = yAxisParams.yAxisElement, yAxisElement = _b === void 0 ? null : _b, _c = yAxisParams.yMaxValue, yMaxValue = _c === void 0 ? 0 : _c, _d = yAxisParams.yMinValue, yMinValue = _d === void 0 ? 0 : _d, containerHeight = yAxisParams.containerHeight, containerWidth = yAxisParams.containerWidth, margins = yAxisParams.margins, _e = yAxisParams.tickPadding, tickPadding = _e === void 0 ? 12 : _e, _f = yAxisParams.maxOfYVal, maxOfYVal = _f === void 0 ? 0 : _f, yAxisTickFormat = yAxisParams.yAxisTickFormat, _g = yAxisParams.yAxisTickCount, yAxisTickCount = _g === void 0 ? 4 : _g, eventAnnotationProps = yAxisParams.eventAnnotationProps, eventLabelHeight = yAxisParams.eventLabelHeight;
|
|
399
399
|
// maxOfYVal coming from only area chart and Grouped vertical bar chart(Calculation done at base file)
|
|
400
|
-
var tempVal = maxOfYVal || yMinMaxValues.endValue;
|
|
400
|
+
var tempVal = maxOfYVal || yMinMaxValues.endValue || 0;
|
|
401
401
|
var finalYmax = tempVal > yMaxValue ? tempVal : yMaxValue;
|
|
402
402
|
var finalYmin = supportNegativeData
|
|
403
|
-
? Math.min(yMinMaxValues.startValue, yMinValue || 0)
|
|
403
|
+
? Math.min(yMinMaxValues.startValue || 0, yMinValue || 0)
|
|
404
404
|
: yMinMaxValues.startValue < yMinValue
|
|
405
405
|
? 0
|
|
406
406
|
: yMinValue;
|
|
@@ -550,6 +550,7 @@ export function silceOrAppendToArray(array, value) {
|
|
|
550
550
|
return array.slice(0, pos).concat(array.slice(pos + 1));
|
|
551
551
|
}
|
|
552
552
|
}
|
|
553
|
+
export var DEFAULT_WRAP_WIDTH = 10;
|
|
553
554
|
/**
|
|
554
555
|
* This method used for wrapping of x axis labels (tick values).
|
|
555
556
|
* It breaks down given text value by space separated and calculates the total height needed to display all the words.
|
|
@@ -560,21 +561,19 @@ export function silceOrAppendToArray(array, value) {
|
|
|
560
561
|
* @returns
|
|
561
562
|
*/
|
|
562
563
|
export function createWrapOfXLabels(wrapLabelProps) {
|
|
563
|
-
var node = wrapLabelProps.node, xAxis = wrapLabelProps.xAxis, noOfCharsToTruncate = wrapLabelProps.noOfCharsToTruncate, showXAxisLablesTooltip = wrapLabelProps.showXAxisLablesTooltip;
|
|
564
|
+
var node = wrapLabelProps.node, xAxis = wrapLabelProps.xAxis, noOfCharsToTruncate = wrapLabelProps.noOfCharsToTruncate, showXAxisLablesTooltip = wrapLabelProps.showXAxisLablesTooltip, _a = wrapLabelProps.width, width = _a === void 0 ? DEFAULT_WRAP_WIDTH : _a;
|
|
564
565
|
if (node === null) {
|
|
565
566
|
return;
|
|
566
567
|
}
|
|
567
568
|
var axisNode = d3Select(node).call(xAxis);
|
|
568
569
|
var removeVal = 0;
|
|
569
|
-
var
|
|
570
|
-
var arr = [];
|
|
570
|
+
var maxLines = 1;
|
|
571
571
|
axisNode.selectAll('.tick text').each(function () {
|
|
572
572
|
var text = d3Select(this);
|
|
573
573
|
var totalWord = text.text();
|
|
574
574
|
var truncatedWord = "".concat(text.text().slice(0, noOfCharsToTruncate), "...");
|
|
575
575
|
var totalWordLength = text.text().length;
|
|
576
576
|
var words = text.text().split(/\s+/).reverse();
|
|
577
|
-
arr.push(words.length);
|
|
578
577
|
var word = '';
|
|
579
578
|
var line = [];
|
|
580
579
|
var lineNumber = 0;
|
|
@@ -595,7 +594,7 @@ export function createWrapOfXLabels(wrapLabelProps) {
|
|
|
595
594
|
.attr('id', 'showDots')
|
|
596
595
|
.attr('x', 0)
|
|
597
596
|
.attr('y', y)
|
|
598
|
-
.attr('dy',
|
|
597
|
+
.attr('dy', dy + 'em')
|
|
599
598
|
.text(truncatedWord);
|
|
600
599
|
}
|
|
601
600
|
else if (showXAxisLablesTooltip && totalWordLength <= noOfCharsToTruncate) {
|
|
@@ -604,7 +603,7 @@ export function createWrapOfXLabels(wrapLabelProps) {
|
|
|
604
603
|
.attr('id', 'LessLength')
|
|
605
604
|
.attr('x', 0)
|
|
606
605
|
.attr('y', y)
|
|
607
|
-
.attr('dy',
|
|
606
|
+
.attr('dy', dy + 'em')
|
|
608
607
|
.text(totalWord);
|
|
609
608
|
}
|
|
610
609
|
else {
|
|
@@ -624,32 +623,20 @@ export function createWrapOfXLabels(wrapLabelProps) {
|
|
|
624
623
|
.text(word);
|
|
625
624
|
}
|
|
626
625
|
}
|
|
627
|
-
var maxDigit = Math.max.apply(Math, arr);
|
|
628
|
-
var maxHeight_1 = 12; // intial value to render corretly first time
|
|
629
|
-
axisNode.selectAll('text').each(function () {
|
|
630
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
631
|
-
var outerHTMLElement = document.getElementById('WordBreakId');
|
|
632
|
-
var BoxCordinates = outerHTMLElement && outerHTMLElement.getBoundingClientRect();
|
|
633
|
-
var boxHeight = BoxCordinates && BoxCordinates.height;
|
|
634
|
-
if (boxHeight > maxHeight_1) {
|
|
635
|
-
maxHeight_1 = boxHeight;
|
|
636
|
-
}
|
|
637
|
-
});
|
|
638
|
-
// If we take directly maxDigit * maxheight, then it will show more height between x axis tick values and bottom.
|
|
639
|
-
// To avoid this, reducing maxDigit value by removing some digit based on legth of word.
|
|
640
|
-
var removeDigit = 4;
|
|
641
|
-
if (maxDigit <= 2) {
|
|
642
|
-
removeDigit = 1;
|
|
643
|
-
}
|
|
644
|
-
else if (maxDigit > 2 && maxDigit <= 6) {
|
|
645
|
-
removeDigit = 2;
|
|
646
|
-
}
|
|
647
|
-
else if (maxDigit > 6 && maxDigit <= 9) {
|
|
648
|
-
removeDigit = 3;
|
|
649
|
-
}
|
|
650
|
-
removeVal = (maxDigit - removeDigit) * maxHeight_1;
|
|
651
626
|
}
|
|
627
|
+
maxLines = Math.max(maxLines, lineNumber + 1);
|
|
652
628
|
});
|
|
629
|
+
if (!showXAxisLablesTooltip) {
|
|
630
|
+
var maxHeight = 12; // intial value to render corretly first time
|
|
631
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
632
|
+
var outerHTMLElement = document.getElementById('WordBreakId');
|
|
633
|
+
var BoxCordinates = outerHTMLElement && outerHTMLElement.getBoundingClientRect();
|
|
634
|
+
var boxHeight = BoxCordinates && BoxCordinates.height;
|
|
635
|
+
if (boxHeight > maxHeight) {
|
|
636
|
+
maxHeight = boxHeight;
|
|
637
|
+
}
|
|
638
|
+
removeVal = (maxLines - 1) * maxHeight;
|
|
639
|
+
}
|
|
653
640
|
return removeVal > 0 ? removeVal : 0;
|
|
654
641
|
}
|
|
655
642
|
/**
|