@fluentui/react-charts 9.2.1 → 9.2.2
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 +24 -2
- package/dist/index.d.ts +79 -5
- package/lib/ChartTable.js +1 -0
- package/lib/ChartTable.js.map +1 -0
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.js +57 -0
- package/lib/components/ChartTable/ChartTable.js.map +1 -0
- package/lib/components/ChartTable/ChartTable.types.js +1 -0
- package/lib/components/ChartTable/ChartTable.types.js.map +1 -0
- package/lib/components/ChartTable/index.js +3 -0
- package/lib/components/ChartTable/index.js.map +1 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.js +93 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +55 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
- package/lib/components/CommonComponents/CartesianChart.js +110 -81
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/ChartPopover.types.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +20 -10
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +95 -0
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +164 -77
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- 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.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib/components/GanttChart/GanttChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +161 -141
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib/components/Legends/Legends.js.map +1 -1
- package/lib/components/Legends/OverflowMenu.js.map +1 -1
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +12 -11
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +57 -51
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/utilities/FocusableTooltipText.js.map +1 -1
- package/lib/utilities/utilities.js +26 -37
- package/lib/utilities/utilities.js.map +1 -1
- package/lib/utilities/vbc-utils.js +24 -0
- package/lib/utilities/vbc-utils.js.map +1 -1
- package/lib-commonjs/ChartTable.js +6 -0
- package/lib-commonjs/ChartTable.js.map +1 -0
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.js +68 -0
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -0
- package/lib-commonjs/components/ChartTable/ChartTable.types.js +6 -0
- package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -0
- package/lib-commonjs/components/ChartTable/index.js +8 -0
- package/lib-commonjs/components/ChartTable/index.js.map +1 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +196 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +69 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +109 -80
- 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.types.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +19 -9
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +120 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +164 -77
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- 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.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +159 -139
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.js.map +1 -1
- package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +11 -10
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +56 -50
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/index.js +1 -0
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +29 -37
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/lib-commonjs/utilities/vbc-utils.js +27 -0
- package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
- package/package.json +9 -9
|
@@ -63,7 +63,7 @@ function yAxisTickFormatterInternal(value, limitWidth = false) {
|
|
|
63
63
|
* @export
|
|
64
64
|
* @param {IXAxisParams} xAxisParams
|
|
65
65
|
*/ export function createNumericXAxis(xAxisParams, tickParams, chartType, culture) {
|
|
66
|
-
const { domainNRangeValues, showRoundOffXTickValues = false, xAxistickSize = 6, tickPadding = 10, xAxisCount, xAxisElement, hideTickOverlap } = xAxisParams;
|
|
66
|
+
const { domainNRangeValues, showRoundOffXTickValues = false, xAxistickSize = 6, tickPadding = 10, xAxisCount, xAxisElement, hideTickOverlap, calcMaxLabelWidth } = xAxisParams;
|
|
67
67
|
const xAxisScale = d3ScaleLinear().domain([
|
|
68
68
|
domainNRangeValues.dStartValue,
|
|
69
69
|
domainNRangeValues.dEndValue
|
|
@@ -81,7 +81,7 @@ function yAxisTickFormatterInternal(value, limitWidth = false) {
|
|
|
81
81
|
return formatToLocaleString(xAxisValue, culture);
|
|
82
82
|
};
|
|
83
83
|
if (hideTickOverlap && typeof xAxisCount === 'undefined') {
|
|
84
|
-
const longestLabelWidth =
|
|
84
|
+
const longestLabelWidth = calcMaxLabelWidth(xAxisScale.ticks().map(tickFormat)) + 20;
|
|
85
85
|
const [start, end] = xAxisScale.range();
|
|
86
86
|
tickCount = Math.min(Math.max(1, Math.floor(Math.abs(end - start) / longestLabelWidth)), 10);
|
|
87
87
|
}
|
|
@@ -295,7 +295,7 @@ export function getDateFormatLevel(date, useUTC) {
|
|
|
295
295
|
* @param {IXAxisParams} xAxisParams
|
|
296
296
|
* @param {ITickParams} tickParams
|
|
297
297
|
*/ export function createDateXAxis(xAxisParams, tickParams, culture, options, timeFormatLocale, customDateTimeFormatter, useUTC, chartType) {
|
|
298
|
-
const { domainNRangeValues, xAxisElement, tickPadding = 6, xAxistickSize = 6, xAxisCount } = xAxisParams;
|
|
298
|
+
const { domainNRangeValues, xAxisElement, tickPadding = 6, xAxistickSize = 6, xAxisCount, calcMaxLabelWidth } = xAxisParams;
|
|
299
299
|
const isUtcSet = useUTC === true || useUTC === 'utc';
|
|
300
300
|
const xAxisScale = isUtcSet ? d3ScaleUtc() : d3ScaleTime();
|
|
301
301
|
xAxisScale.domain([
|
|
@@ -336,7 +336,7 @@ export function getDateFormatLevel(date, useUTC) {
|
|
|
336
336
|
}
|
|
337
337
|
return formatDateToLocaleString(domainValue, culture, useUTC ? true : false, false, formatOptions);
|
|
338
338
|
};
|
|
339
|
-
const longestLabelWidth =
|
|
339
|
+
const longestLabelWidth = calcMaxLabelWidth(xAxisScale.ticks().map(tickFormat)) + 40;
|
|
340
340
|
const [start, end] = xAxisScale.range();
|
|
341
341
|
const maxPossibleTickCount = Math.min(Math.max(1, Math.floor(Math.abs(end - start) / longestLabelWidth)), 10);
|
|
342
342
|
tickCount = Math.min(maxPossibleTickCount, xAxisCount !== null && xAxisCount !== void 0 ? xAxisCount : tickCount);
|
|
@@ -366,7 +366,7 @@ export function getDateFormatLevel(date, useUTC) {
|
|
|
366
366
|
* @param {string[]} dataset
|
|
367
367
|
* @returns
|
|
368
368
|
*/ export function createStringXAxis(xAxisParams, tickParams, dataset, culture) {
|
|
369
|
-
const { domainNRangeValues, xAxistickSize = 6, tickPadding = 10, xAxisPadding = 0.1, xAxisInnerPadding, xAxisOuterPadding, containerWidth, hideTickOverlap } = xAxisParams;
|
|
369
|
+
const { domainNRangeValues, xAxistickSize = 6, tickPadding = 10, xAxisPadding = 0.1, xAxisInnerPadding, xAxisOuterPadding, containerWidth, hideTickOverlap, calcMaxLabelWidth } = xAxisParams;
|
|
370
370
|
const xAxisScale = d3ScaleBand().domain(dataset).range([
|
|
371
371
|
domainNRangeValues.rStartValue,
|
|
372
372
|
domainNRangeValues.rEndValue
|
|
@@ -378,9 +378,9 @@ export function getDateFormatLevel(date, useUTC) {
|
|
|
378
378
|
};
|
|
379
379
|
if (hideTickOverlap) {
|
|
380
380
|
let nonOverlappingTickValues = [];
|
|
381
|
-
const tickSizes = tickValues.map((value
|
|
382
|
-
|
|
383
|
-
]
|
|
381
|
+
const tickSizes = tickValues.map((value)=>calcMaxLabelWidth([
|
|
382
|
+
value
|
|
383
|
+
]));
|
|
384
384
|
// for LTR
|
|
385
385
|
let start = 0;
|
|
386
386
|
let end = containerWidth;
|
|
@@ -654,6 +654,7 @@ export function getUnique(arr, comp) {
|
|
|
654
654
|
return array.slice(0, pos).concat(array.slice(pos + 1));
|
|
655
655
|
}
|
|
656
656
|
}
|
|
657
|
+
export const DEFAULT_WRAP_WIDTH = 10;
|
|
657
658
|
/**
|
|
658
659
|
* This method used for wrapping of x axis labels (tick values).
|
|
659
660
|
* It breaks down given text value by space separated and calculates the total height needed to display all the words.
|
|
@@ -663,21 +664,19 @@ export function getUnique(arr, comp) {
|
|
|
663
664
|
* @param {IWrapLabelProps} wrapLabelProps
|
|
664
665
|
* @returns
|
|
665
666
|
*/ export function createWrapOfXLabels(wrapLabelProps) {
|
|
666
|
-
const { node, xAxis, noOfCharsToTruncate, showXAxisLablesTooltip } = wrapLabelProps;
|
|
667
|
+
const { node, xAxis, noOfCharsToTruncate, showXAxisLablesTooltip, width = DEFAULT_WRAP_WIDTH } = wrapLabelProps;
|
|
667
668
|
if (node === null) {
|
|
668
669
|
return;
|
|
669
670
|
}
|
|
670
671
|
const axisNode = d3Select(node).call(xAxis);
|
|
671
672
|
let removeVal = 0;
|
|
672
|
-
|
|
673
|
-
const arr = [];
|
|
673
|
+
let maxLines = 1;
|
|
674
674
|
axisNode.selectAll('.tick text').each(function() {
|
|
675
675
|
const text = d3Select(this);
|
|
676
676
|
const totalWord = text.text();
|
|
677
677
|
const truncatedWord = `${text.text().slice(0, noOfCharsToTruncate)}...`;
|
|
678
678
|
const totalWordLength = text.text().length;
|
|
679
679
|
const words = text.text().split(/\s+/).reverse();
|
|
680
|
-
arr.push(words.length);
|
|
681
680
|
let word = '';
|
|
682
681
|
let line = [];
|
|
683
682
|
let lineNumber = 0;
|
|
@@ -686,9 +685,9 @@ export function getUnique(arr, comp) {
|
|
|
686
685
|
const dy = parseFloat(text.attr('dy'));
|
|
687
686
|
let tspan = text.text(null).append('tspan').attr('x', 0).attr('y', y).attr('id', 'BaseSpan').attr('dy', dy + 'em').attr('data-', totalWord);
|
|
688
687
|
if (showXAxisLablesTooltip && totalWordLength > noOfCharsToTruncate) {
|
|
689
|
-
tspan = text.append('tspan').attr('id', 'showDots').attr('x', 0).attr('y', y).attr('dy',
|
|
688
|
+
tspan = text.append('tspan').attr('id', 'showDots').attr('x', 0).attr('y', y).attr('dy', dy + 'em').text(truncatedWord);
|
|
690
689
|
} else if (showXAxisLablesTooltip && totalWordLength <= noOfCharsToTruncate) {
|
|
691
|
-
tspan = text.append('tspan').attr('id', 'LessLength').attr('x', 0).attr('y', y).attr('dy',
|
|
690
|
+
tspan = text.append('tspan').attr('id', 'LessLength').attr('x', 0).attr('y', y).attr('dy', dy + 'em').text(totalWord);
|
|
692
691
|
} else {
|
|
693
692
|
while(word = words.pop()){
|
|
694
693
|
line.push(word);
|
|
@@ -702,30 +701,20 @@ export function getUnique(arr, comp) {
|
|
|
702
701
|
tspan = text.append('tspan').attr('id', 'WordBreakId').attr('x', 0).attr('y', y).attr('dy', ++lineNumber * lineHeight + dy + 'em').text(word);
|
|
703
702
|
}
|
|
704
703
|
}
|
|
705
|
-
const maxDigit = Math.max(...arr);
|
|
706
|
-
let maxHeight = 12; // intial value to render corretly first time
|
|
707
|
-
axisNode.selectAll('text').each(()=>{
|
|
708
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
709
|
-
const outerHTMLElement = document.getElementById('WordBreakId');
|
|
710
|
-
const BoxCordinates = outerHTMLElement && outerHTMLElement.getBoundingClientRect();
|
|
711
|
-
const boxHeight = BoxCordinates && BoxCordinates.height;
|
|
712
|
-
if (boxHeight > maxHeight) {
|
|
713
|
-
maxHeight = boxHeight;
|
|
714
|
-
}
|
|
715
|
-
});
|
|
716
|
-
// If we take directly maxDigit * maxheight, then it will show more height between x axis tick values and bottom.
|
|
717
|
-
// To avoid this, reducing maxDigit value by removing some digit based on legth of word.
|
|
718
|
-
let removeDigit = 4;
|
|
719
|
-
if (maxDigit <= 2) {
|
|
720
|
-
removeDigit = 1;
|
|
721
|
-
} else if (maxDigit > 2 && maxDigit <= 6) {
|
|
722
|
-
removeDigit = 2;
|
|
723
|
-
} else if (maxDigit > 6 && maxDigit <= 9) {
|
|
724
|
-
removeDigit = 3;
|
|
725
|
-
}
|
|
726
|
-
removeVal = (maxDigit - removeDigit) * maxHeight;
|
|
727
704
|
}
|
|
705
|
+
maxLines = Math.max(maxLines, lineNumber + 1);
|
|
728
706
|
});
|
|
707
|
+
if (!showXAxisLablesTooltip) {
|
|
708
|
+
let maxHeight = 12; // intial value to render corretly first time
|
|
709
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
710
|
+
const outerHTMLElement = document.getElementById('WordBreakId');
|
|
711
|
+
const BoxCordinates = outerHTMLElement && outerHTMLElement.getBoundingClientRect();
|
|
712
|
+
const boxHeight = BoxCordinates && BoxCordinates.height;
|
|
713
|
+
if (boxHeight > maxHeight) {
|
|
714
|
+
maxHeight = boxHeight;
|
|
715
|
+
}
|
|
716
|
+
removeVal = (maxLines - 1) * maxHeight;
|
|
717
|
+
}
|
|
729
718
|
return removeVal > 0 ? removeVal : 0;
|
|
730
719
|
}
|
|
731
720
|
/**
|
|
@@ -743,7 +732,7 @@ yAxis, noOfCharsToTruncate, truncateLabel, isRtl) {
|
|
|
743
732
|
const totalWord = text.text();
|
|
744
733
|
const truncatedWord = isRtl ? `...${text.text().slice(0, noOfCharsToTruncate)}` : `${text.text().slice(0, noOfCharsToTruncate)}...`;
|
|
745
734
|
const totalWordLength = text.text().length;
|
|
746
|
-
const padding =
|
|
735
|
+
const padding = 0; // ems
|
|
747
736
|
const y = text.attr('y');
|
|
748
737
|
const x = text.attr('x');
|
|
749
738
|
const dy = parseFloat(text.attr('dy'));
|