@fluentui/react-charts 0.0.0-nightly-20251110-0407.1 → 0.0.0-nightly-20251111-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 +12 -44
- package/lib/components/AreaChart/useAreaChartStyles.styles.js +8 -5
- package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib/components/ChartTable/useChartTableStyles.styles.js +59 -39
- package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +5 -5
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +129 -129
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +13 -10
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.js +2 -6
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js +3 -2
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +3 -0
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/Arc/useArcStyles.styles.js +23 -8
- package/lib/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
- package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js +2 -2
- package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.js +2 -2
- package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib/components/GanttChart/GanttChart.js +3 -3
- package/lib/components/GanttChart/GanttChart.js.map +1 -1
- package/lib/components/GanttChart/GanttChart.types.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +8 -5
- 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/HeatMapChart/HeatMapChart.types.js.map +1 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +25 -12
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +4 -4
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +2 -2
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -1
- package/lib/components/Legends/useLegendsStyles.styles.js +97 -37
- package/lib/components/Legends/useLegendsStyles.styles.js.map +1 -1
- package/lib/components/Legends/useLegendsStyles.styles.raw.js +10 -11
- package/lib/components/Legends/useLegendsStyles.styles.raw.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +1 -1
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.js +12 -9
- package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +13 -10
- 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/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js +10 -7
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +10 -7
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +8 -5
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib/utilities/Common.styles.js +1 -2
- package/lib/utilities/Common.styles.js.map +1 -1
- package/lib/utilities/Common.styles.raw.js +1 -2
- package/lib/utilities/Common.styles.raw.js.map +1 -1
- package/lib/utilities/utilities.js +16 -13
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +11 -14
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +74 -102
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +4 -4
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +129 -128
- 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/useCartesianChartStyles.styles.js +16 -19
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js +0 -14
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +3 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js +25 -16
- package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js +1 -1
- package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +2 -2
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GanttChart/GanttChart.js +3 -3
- package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
- package/lib-commonjs/components/GanttChart/GanttChart.types.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +11 -14
- 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/HeatMapChart/HeatMapChart.types.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +47 -34
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +3 -3
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +2 -2
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -1
- package/lib-commonjs/components/Legends/useLegendsStyles.styles.js +144 -86
- package/lib-commonjs/components/Legends/useLegendsStyles.styles.js.map +1 -1
- package/lib-commonjs/components/Legends/useLegendsStyles.styles.raw.js +9 -10
- package/lib-commonjs/components/Legends/useLegendsStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +15 -18
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +16 -19
- 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/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +13 -16
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +13 -16
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +11 -14
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/utilities/Common.styles.js +1 -2
- package/lib-commonjs/utilities/Common.styles.js.map +1 -1
- package/lib-commonjs/utilities/Common.styles.raw.js +1 -2
- package/lib-commonjs/utilities/Common.styles.raw.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +16 -13
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +13 -13
|
@@ -8,11 +8,15 @@ import { SVGTooltipText } from '../../utilities/SVGTooltipText';
|
|
|
8
8
|
import { ChartAnnotationLayer } from './Annotations/ChartAnnotationLayer';
|
|
9
9
|
import { ChartPopover } from './ChartPopover';
|
|
10
10
|
import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabster';
|
|
11
|
+
const HORIZONTAL_MARGIN_FOR_YAXIS_TITLE = 24;
|
|
12
|
+
const VERTICAL_MARGIN_FOR_XAXIS_TITLE = 20;
|
|
13
|
+
const AXIS_TITLE_PADDING = 8;
|
|
14
|
+
const DEFAULT_MARGIN_WITH_TICKS = 40;
|
|
15
|
+
const DEFAULT_MARGIN_NO_TICKS = 20;
|
|
11
16
|
/**
|
|
12
17
|
* Cartesian Chart component
|
|
13
18
|
* {@docCategory CartesianChart}
|
|
14
19
|
*/ export const CartesianChart = /*#__PURE__*/ React.forwardRef(({ hideTickOverlap = true, ...props }, forwardedRef)=>{
|
|
15
|
-
var _props_margins, _props_margins1, _props_margins2, _props_margins3, _props_margins4, _props_margins5;
|
|
16
20
|
const chartContainer = React.useRef(null);
|
|
17
21
|
let legendContainer;
|
|
18
22
|
const minLegendContainerHeight = 40;
|
|
@@ -24,7 +28,6 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
|
|
|
24
28
|
let _reqID;
|
|
25
29
|
const _useRtl = useRtl();
|
|
26
30
|
let _tickValues;
|
|
27
|
-
const titleMargin = 8;
|
|
28
31
|
const _isFirstRender = React.useRef(true);
|
|
29
32
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
33
|
let _xScale;
|
|
@@ -40,61 +43,12 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
|
|
|
40
43
|
* These value need to be removed from actual svg height/graph height.
|
|
41
44
|
* Defalut value is 0. And this values calculted when 'wrapXAxisLables' or 'showXAxisLablesTooltip' is true.
|
|
42
45
|
*/ let _removalValueForTextTuncate = 0;
|
|
46
|
+
const _yAxisTickText = React.useRef([]);
|
|
43
47
|
const [containerWidth, setContainerWidth] = React.useState(0);
|
|
44
48
|
const [containerHeight, setContainerHeight] = React.useState(0);
|
|
45
49
|
const [startFromX, setStartFromX] = React.useState(0);
|
|
46
50
|
const prevWidthRef = React.useRef(undefined);
|
|
47
51
|
const prevHeightRef = React.useRef(undefined);
|
|
48
|
-
const chartTypesWithStringYAxis = [
|
|
49
|
-
ChartTypes.HorizontalBarChartWithAxis,
|
|
50
|
-
ChartTypes.HeatMapChart,
|
|
51
|
-
ChartTypes.VerticalStackedBarChart,
|
|
52
|
-
ChartTypes.GanttChart,
|
|
53
|
-
ChartTypes.ScatterChart
|
|
54
|
-
];
|
|
55
|
-
var _props_margins_top, _props_margins_bottom, _props_margins_left, _props_margins_right, _props_margins_right1, _props_margins_left1;
|
|
56
|
-
/**
|
|
57
|
-
* In RTL mode, Only graph will be rendered left/right. We need to provide left and right margins manually.
|
|
58
|
-
* So that, in RTL, left margins becomes right margins and viceversa.
|
|
59
|
-
* As graph needs to be drawn perfecty, these values consider as default values.
|
|
60
|
-
* Same margins using for all other cartesian charts. Can be accessible through 'getMargins' call back method.
|
|
61
|
-
*/ // eslint-disable-next-line prefer-const
|
|
62
|
-
margins = {
|
|
63
|
-
top: (_props_margins_top = (_props_margins = props.margins) === null || _props_margins === void 0 ? void 0 : _props_margins.top) !== null && _props_margins_top !== void 0 ? _props_margins_top : 20,
|
|
64
|
-
bottom: (_props_margins_bottom = (_props_margins1 = props.margins) === null || _props_margins1 === void 0 ? void 0 : _props_margins1.bottom) !== null && _props_margins_bottom !== void 0 ? _props_margins_bottom : 35,
|
|
65
|
-
right: _useRtl ? (_props_margins_left = (_props_margins2 = props.margins) === null || _props_margins2 === void 0 ? void 0 : _props_margins2.left) !== null && _props_margins_left !== void 0 ? _props_margins_left : 40 : ((_props_margins_right = (_props_margins3 = props.margins) === null || _props_margins3 === void 0 ? void 0 : _props_margins3.right) !== null && _props_margins_right !== void 0 ? _props_margins_right : props === null || props === void 0 ? void 0 : props.secondaryYScaleOptions) ? 40 : 20,
|
|
66
|
-
left: _useRtl ? ((_props_margins_right1 = (_props_margins4 = props.margins) === null || _props_margins4 === void 0 ? void 0 : _props_margins4.right) !== null && _props_margins_right1 !== void 0 ? _props_margins_right1 : props === null || props === void 0 ? void 0 : props.secondaryYScaleOptions) ? 40 : 20 : (_props_margins_left1 = (_props_margins5 = props.margins) === null || _props_margins5 === void 0 ? void 0 : _props_margins5.left) !== null && _props_margins_left1 !== void 0 ? _props_margins_left1 : 40
|
|
67
|
-
};
|
|
68
|
-
const TITLE_MARGIN_HORIZONTAL = 24;
|
|
69
|
-
const TITLE_MARGIN_VERTICAL = 20;
|
|
70
|
-
if (props.xAxisTitle !== undefined && props.xAxisTitle !== '') {
|
|
71
|
-
var _props_margins6;
|
|
72
|
-
var _props_margins_bottom1;
|
|
73
|
-
margins.bottom = (_props_margins_bottom1 = (_props_margins6 = props.margins) === null || _props_margins6 === void 0 ? void 0 : _props_margins6.bottom) !== null && _props_margins_bottom1 !== void 0 ? _props_margins_bottom1 : margins.bottom + TITLE_MARGIN_VERTICAL;
|
|
74
|
-
}
|
|
75
|
-
if (props.yAxisTitle !== undefined && props.yAxisTitle !== '') {
|
|
76
|
-
var _props_margins7, _props_margins8, _props_margins9, _props_margins10;
|
|
77
|
-
var _props_margins_right2, _props_margins_left2;
|
|
78
|
-
margins.left = _useRtl ? ((_props_margins_right2 = (_props_margins7 = props.margins) === null || _props_margins7 === void 0 ? void 0 : _props_margins7.right) !== null && _props_margins_right2 !== void 0 ? _props_margins_right2 : props === null || props === void 0 ? void 0 : props.secondaryYAxistitle) ? margins.right + 2 * TITLE_MARGIN_HORIZONTAL : margins.right + TITLE_MARGIN_HORIZONTAL : (_props_margins_left2 = (_props_margins8 = props.margins) === null || _props_margins8 === void 0 ? void 0 : _props_margins8.left) !== null && _props_margins_left2 !== void 0 ? _props_margins_left2 : margins.left + TITLE_MARGIN_HORIZONTAL;
|
|
79
|
-
var _props_margins_left3, _props_margins_right3;
|
|
80
|
-
margins.right = _useRtl ? (_props_margins_left3 = (_props_margins9 = props.margins) === null || _props_margins9 === void 0 ? void 0 : _props_margins9.left) !== null && _props_margins_left3 !== void 0 ? _props_margins_left3 : margins.left + TITLE_MARGIN_HORIZONTAL : ((_props_margins_right3 = (_props_margins10 = props.margins) === null || _props_margins10 === void 0 ? void 0 : _props_margins10.right) !== null && _props_margins_right3 !== void 0 ? _props_margins_right3 : props === null || props === void 0 ? void 0 : props.secondaryYAxistitle) ? margins.right + 2 * TITLE_MARGIN_HORIZONTAL : margins.right + TITLE_MARGIN_HORIZONTAL;
|
|
81
|
-
}
|
|
82
|
-
if (props.xAxisAnnotation !== undefined && props.xAxisAnnotation !== '') {
|
|
83
|
-
var _props_margins11;
|
|
84
|
-
var _props_margins_top1;
|
|
85
|
-
margins.top = (_props_margins_top1 = (_props_margins11 = props.margins) === null || _props_margins11 === void 0 ? void 0 : _props_margins11.top) !== null && _props_margins_top1 !== void 0 ? _props_margins_top1 : margins.top + TITLE_MARGIN_VERTICAL;
|
|
86
|
-
}
|
|
87
|
-
if (props.yAxisAnnotation !== undefined && props.yAxisAnnotation !== '' && (props.secondaryYAxistitle === undefined || props.secondaryYAxistitle === '')) {
|
|
88
|
-
if (_useRtl) {
|
|
89
|
-
var _props_margins12;
|
|
90
|
-
var _props_margins_right4;
|
|
91
|
-
margins.left = (_props_margins_right4 = (_props_margins12 = props.margins) === null || _props_margins12 === void 0 ? void 0 : _props_margins12.right) !== null && _props_margins_right4 !== void 0 ? _props_margins_right4 : margins.right + TITLE_MARGIN_HORIZONTAL;
|
|
92
|
-
} else {
|
|
93
|
-
var _props_margins13;
|
|
94
|
-
var _props_margins_right5;
|
|
95
|
-
margins.right = (_props_margins_right5 = (_props_margins13 = props.margins) === null || _props_margins13 === void 0 ? void 0 : _props_margins13.right) !== null && _props_margins_right5 !== void 0 ? _props_margins_right5 : margins.right + TITLE_MARGIN_HORIZONTAL;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
52
|
const classes = useCartesianChartStyles(props);
|
|
99
53
|
const focusAttributes = useFocusableGroup();
|
|
100
54
|
const arrowAttributes = useArrowNavigationGroup({
|
|
@@ -103,7 +57,7 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
|
|
|
103
57
|
// ComponentdidMount and Componentwillunmount logic
|
|
104
58
|
React.useEffect(()=>{
|
|
105
59
|
_fitParentContainer();
|
|
106
|
-
if (
|
|
60
|
+
if (props.showYAxisLables) {
|
|
107
61
|
const maxYAxisLabelLength = calculateMaxYAxisLabelLength(classes.yAxis);
|
|
108
62
|
if (startFromX !== maxYAxisLabelLength) {
|
|
109
63
|
setStartFromX(maxYAxisLabelLength);
|
|
@@ -128,7 +82,7 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
|
|
|
128
82
|
// Update refs with current values
|
|
129
83
|
prevWidthRef.current = props.width;
|
|
130
84
|
prevHeightRef.current = props.height;
|
|
131
|
-
if (
|
|
85
|
+
if (props.showYAxisLables) {
|
|
132
86
|
const maxYAxisLabelLength = calculateMaxYAxisLabelLength(classes.yAxis);
|
|
133
87
|
if (startFromX !== maxYAxisLabelLength) {
|
|
134
88
|
setStartFromX(maxYAxisLabelLength);
|
|
@@ -166,25 +120,15 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
|
|
|
166
120
|
}
|
|
167
121
|
return str;
|
|
168
122
|
};
|
|
169
|
-
return calculateLongestLabelWidth(
|
|
123
|
+
return calculateLongestLabelWidth(_yAxisTickText.current.map((label)=>formatTickLabel(label)), `.${className} text`);
|
|
170
124
|
}
|
|
171
125
|
const { calloutProps, points, chartType, svgProps, culture, dateLocalizeOptions, timeFormatLocale, customDateTimeFormatter } = props;
|
|
172
126
|
if (props.parentRef) {
|
|
173
127
|
_fitParentContainer();
|
|
174
128
|
}
|
|
175
|
-
|
|
176
|
-
...margins
|
|
177
|
-
};
|
|
178
|
-
// Note: This check is unnecessary since startFromX is only set for charts with string y-axis.
|
|
179
|
-
if (chartTypesWithStringYAxis.includes(props.chartType)) {
|
|
180
|
-
if (!_useRtl) {
|
|
181
|
-
margin.left += startFromX;
|
|
182
|
-
} else {
|
|
183
|
-
margin.right += startFromX;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
129
|
+
margins = _calcMargins();
|
|
186
130
|
// Callback for margins to the chart
|
|
187
|
-
props.getmargins && props.getmargins(
|
|
131
|
+
props.getmargins && props.getmargins(margins);
|
|
188
132
|
let callout = null;
|
|
189
133
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
190
134
|
let yScalePrimary;
|
|
@@ -195,8 +139,7 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
|
|
|
195
139
|
_isFirstRender.current = false;
|
|
196
140
|
var _props_showRoundOffXTickValues;
|
|
197
141
|
const XAxisParams = {
|
|
198
|
-
domainNRangeValues: props.getDomainNRangeValues(points, props.getDomainMargins ? props.getDomainMargins(containerWidth) : margins, containerWidth, chartType, _useRtl, props.xAxisType, props.barwidth, props.tickValues,
|
|
199
|
-
startFromX),
|
|
142
|
+
domainNRangeValues: props.getDomainNRangeValues(points, props.getDomainMargins ? props.getDomainMargins(containerWidth) : margins, containerWidth, chartType, _useRtl, props.xAxisType, props.barwidth, props.tickValues),
|
|
200
143
|
// FIXME: In XAxisParams, containerHeight is used by HBWA to generate vertical gridlines.
|
|
201
144
|
// Since the x-axis in HBWA is numeric, it typically doesn't require transformation.
|
|
202
145
|
// However, if transformation props are enabled, the updated _removalValueForTextTuncate
|
|
@@ -267,10 +210,11 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
|
|
|
267
210
|
* 2. To draw the graph.
|
|
268
211
|
* For area/line chart using same scales. For other charts, creating their own scales to draw the graph.
|
|
269
212
|
*/ const axisData = {
|
|
270
|
-
yAxisDomainValues: []
|
|
213
|
+
yAxisDomainValues: [],
|
|
214
|
+
yAxisTickText: []
|
|
271
215
|
};
|
|
272
216
|
if (props.yAxisType && props.yAxisType === YAxisType.StringAxis) {
|
|
273
|
-
yScalePrimary = props.createStringYAxis(YAxisParams, props.stringDatasetForYAxisDomain, _useRtl, props.barwidth, props.chartType);
|
|
217
|
+
yScalePrimary = props.createStringYAxis(YAxisParams, props.stringDatasetForYAxisDomain, _useRtl, axisData, props.barwidth, props.chartType);
|
|
274
218
|
} else {
|
|
275
219
|
// TODO: Since the scale domain values are now computed independently for both the primary and
|
|
276
220
|
// secondary y-axes, the yMinValue and yMaxValue props are no longer necessary for accurately
|
|
@@ -297,42 +241,41 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
|
|
|
297
241
|
}
|
|
298
242
|
yScalePrimary = props.createYAxis(YAxisParams, _useRtl, axisData, isIntegralDataset, chartType, false, props.roundedTicks, props.yScaleType, _useRtl);
|
|
299
243
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
244
|
+
_yAxisTickText.current = axisData.yAxisTickText;
|
|
245
|
+
props.getAxisData && props.getAxisData(axisData);
|
|
246
|
+
// Removing un wanted tooltip div from DOM, when prop not provided, for proper cleanup
|
|
247
|
+
// of unwanted DOM elements, to prevent flacky behaviour in tooltips , that might occur
|
|
248
|
+
// in creating tooltips when tooltips are enabled( as we try to recreate a tspan with _tooltipId)
|
|
249
|
+
if (!props.showYAxisLablesTooltip) {
|
|
250
|
+
try {
|
|
251
|
+
document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
|
|
252
|
+
//eslint-disable-next-line no-empty
|
|
253
|
+
} catch (e) {}
|
|
254
|
+
}
|
|
255
|
+
// Used to display tooltip at y axis labels.
|
|
256
|
+
if (props.showYAxisLablesTooltip) {
|
|
257
|
+
// To create y axis tick values by if specified truncating the rest of the text
|
|
258
|
+
// and showing elipsis or showing the whole string,
|
|
259
|
+
yScalePrimary && // Note: This function should be invoked within the showYAxisLablesTooltip check,
|
|
260
|
+
// as its sole purpose is to truncate labels that exceed the noOfCharsToTruncate limit.
|
|
261
|
+
createYAxisLabels(yAxisElement.current, yScalePrimary, props.noOfCharsToTruncate || 4, props.showYAxisLablesTooltip || false, _useRtl);
|
|
262
|
+
const _yAxisElement = d3Select(yAxisElement.current).call(yScalePrimary);
|
|
263
|
+
try {
|
|
264
|
+
document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
|
|
265
|
+
//eslint-disable-next-line no-empty
|
|
266
|
+
} catch (e) {}
|
|
267
|
+
const ytooltipProps = {
|
|
268
|
+
tooltipCls: classes.tooltip,
|
|
269
|
+
id: _tooltipId,
|
|
270
|
+
axis: _yAxisElement
|
|
271
|
+
};
|
|
272
|
+
_yAxisElement && tooltipOfAxislabels(ytooltipProps);
|
|
329
273
|
}
|
|
330
274
|
// Call back to the chart.
|
|
331
275
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
332
276
|
const _getData = (xScale, yScalePrimary, yScaleSecondary)=>{
|
|
333
277
|
props.getGraphData && props.getGraphData(xScale, yScalePrimary, containerHeight - _removalValueForTextTuncate, containerWidth, xAxisElement.current, yAxisElement.current, yScaleSecondary);
|
|
334
278
|
};
|
|
335
|
-
props.getAxisData && props.getAxisData(axisData);
|
|
336
279
|
// Callback function for chart, returns axis
|
|
337
280
|
_getData(xScale, yScalePrimary, yScaleSecondary);
|
|
338
281
|
children = props.children({
|
|
@@ -350,11 +293,10 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
|
|
|
350
293
|
width: containerWidth,
|
|
351
294
|
height: containerHeight
|
|
352
295
|
};
|
|
353
|
-
const
|
|
354
|
-
const plotWidth = Math.max(0, svgDimensions.width - margins.left - margins.right - _startFromX);
|
|
296
|
+
const plotWidth = Math.max(0, svgDimensions.width - margins.left - margins.right);
|
|
355
297
|
const plotHeight = Math.max(0, svgDimensions.height - margins.top - margins.bottom - _removalValueForTextTuncate);
|
|
356
298
|
const plotRect = {
|
|
357
|
-
x:
|
|
299
|
+
x: margins.left,
|
|
358
300
|
y: margins.top,
|
|
359
301
|
width: plotWidth,
|
|
360
302
|
height: plotHeight
|
|
@@ -370,8 +312,11 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
|
|
|
370
312
|
yScalePrimary,
|
|
371
313
|
yScaleSecondary
|
|
372
314
|
} : undefined;
|
|
373
|
-
const
|
|
374
|
-
const
|
|
315
|
+
const xAxisTitleMaxWidth = svgDimensions.width - margins.left - margins.right - AXIS_TITLE_PADDING * 2;
|
|
316
|
+
const yAxisTitleMaxHeight = svgDimensions.height - margins.bottom - margins.top - _removalValueForTextTuncate - AXIS_TITLE_PADDING * 2;
|
|
317
|
+
const yAxisTitleCenterY = margins.top + AXIS_TITLE_PADDING + yAxisTitleMaxHeight / 2;
|
|
318
|
+
const yAxisTitleCenterX = _useRtl ? svgDimensions.width - AXIS_TITLE_PADDING : HORIZONTAL_MARGIN_FOR_YAXIS_TITLE - AXIS_TITLE_PADDING;
|
|
319
|
+
const secondaryYAxisTitleCenterX = _useRtl ? HORIZONTAL_MARGIN_FOR_YAXIS_TITLE - AXIS_TITLE_PADDING : svgDimensions.width - AXIS_TITLE_PADDING;
|
|
375
320
|
const commonSvgToolTipProps = {
|
|
376
321
|
wrapContent,
|
|
377
322
|
showBackground: true,
|
|
@@ -491,6 +436,64 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
|
|
|
491
436
|
_removalValueForTextTuncate = rotatedHeight + margins.bottom;
|
|
492
437
|
}
|
|
493
438
|
}
|
|
439
|
+
function _calcMargins() {
|
|
440
|
+
let _margins = _getDefaultMargins();
|
|
441
|
+
_margins = _applyTitleMargins(_margins);
|
|
442
|
+
_margins = _applyAnnotationMargins(_margins);
|
|
443
|
+
if (_useRtl) {
|
|
444
|
+
_margins = _swapRtlMargins(_margins);
|
|
445
|
+
}
|
|
446
|
+
return {
|
|
447
|
+
..._margins,
|
|
448
|
+
...props.margins
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
function _getDefaultMargins() {
|
|
452
|
+
return {
|
|
453
|
+
top: DEFAULT_MARGIN_NO_TICKS,
|
|
454
|
+
// Smaller than the default because it is based on the line height rather than
|
|
455
|
+
// the length of the tick labels.
|
|
456
|
+
bottom: DEFAULT_MARGIN_WITH_TICKS - 5,
|
|
457
|
+
// For the actual margin, add the tick size, tick padding, and some extra space to
|
|
458
|
+
// the width of the longest yaxis tick label (startFromX).
|
|
459
|
+
left: Math.max(DEFAULT_MARGIN_WITH_TICKS, startFromX + 20),
|
|
460
|
+
right: props.secondaryYScaleOptions ? DEFAULT_MARGIN_WITH_TICKS : DEFAULT_MARGIN_NO_TICKS
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
function _applyTitleMargins(_margins) {
|
|
464
|
+
const updated = {
|
|
465
|
+
..._margins
|
|
466
|
+
};
|
|
467
|
+
if (props.xAxisTitle !== undefined && props.xAxisTitle !== '') {
|
|
468
|
+
updated.bottom += VERTICAL_MARGIN_FOR_XAXIS_TITLE;
|
|
469
|
+
}
|
|
470
|
+
if (props.yAxisTitle !== undefined && props.yAxisTitle !== '') {
|
|
471
|
+
updated.left += HORIZONTAL_MARGIN_FOR_YAXIS_TITLE;
|
|
472
|
+
}
|
|
473
|
+
if (props.secondaryYAxistitle !== undefined && props.secondaryYAxistitle !== '') {
|
|
474
|
+
updated.right += HORIZONTAL_MARGIN_FOR_YAXIS_TITLE;
|
|
475
|
+
}
|
|
476
|
+
return updated;
|
|
477
|
+
}
|
|
478
|
+
function _applyAnnotationMargins(_margins) {
|
|
479
|
+
const updated = {
|
|
480
|
+
..._margins
|
|
481
|
+
};
|
|
482
|
+
if (props.xAxisAnnotation !== undefined && props.xAxisAnnotation !== '') {
|
|
483
|
+
updated.top += VERTICAL_MARGIN_FOR_XAXIS_TITLE;
|
|
484
|
+
}
|
|
485
|
+
if (props.yAxisAnnotation !== undefined && props.yAxisAnnotation !== '' && (props.secondaryYAxistitle === undefined || props.secondaryYAxistitle === '')) {
|
|
486
|
+
updated.right += HORIZONTAL_MARGIN_FOR_YAXIS_TITLE;
|
|
487
|
+
}
|
|
488
|
+
return updated;
|
|
489
|
+
}
|
|
490
|
+
function _swapRtlMargins(_margins) {
|
|
491
|
+
return {
|
|
492
|
+
..._margins,
|
|
493
|
+
left: _margins.right,
|
|
494
|
+
right: _margins.left
|
|
495
|
+
};
|
|
496
|
+
}
|
|
494
497
|
/**
|
|
495
498
|
* We have use the {@link defaultTabbableElement } to fix
|
|
496
499
|
* the Focus not landing on chart while tabbing, instead goes to legend.
|
|
@@ -542,74 +545,71 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
|
|
|
542
545
|
...commonSvgToolTipProps,
|
|
543
546
|
content: props.xAxisTitle,
|
|
544
547
|
textProps: {
|
|
545
|
-
x: margins.left +
|
|
546
|
-
y: svgDimensions.height -
|
|
548
|
+
x: margins.left + AXIS_TITLE_PADDING + xAxisTitleMaxWidth / 2,
|
|
549
|
+
y: svgDimensions.height - AXIS_TITLE_PADDING,
|
|
547
550
|
className: classes.axisTitle,
|
|
548
551
|
textAnchor: 'middle'
|
|
549
552
|
},
|
|
550
|
-
maxWidth:
|
|
553
|
+
maxWidth: xAxisTitleMaxWidth
|
|
551
554
|
}), props.xAxisAnnotation !== undefined && props.xAxisAnnotation !== '' && /*#__PURE__*/ React.createElement(SVGTooltipText, {
|
|
552
555
|
...commonSvgToolTipProps,
|
|
553
556
|
content: props.xAxisAnnotation,
|
|
554
557
|
textProps: {
|
|
555
|
-
x: margins.left +
|
|
556
|
-
y:
|
|
558
|
+
x: margins.left + AXIS_TITLE_PADDING + xAxisTitleMaxWidth / 2,
|
|
559
|
+
y: VERTICAL_MARGIN_FOR_XAXIS_TITLE - AXIS_TITLE_PADDING,
|
|
557
560
|
className: classes.axisAnnotation,
|
|
558
561
|
textAnchor: 'middle',
|
|
559
562
|
'aria-hidden': true
|
|
560
563
|
},
|
|
561
|
-
maxWidth:
|
|
564
|
+
maxWidth: xAxisTitleMaxWidth
|
|
562
565
|
}), /*#__PURE__*/ React.createElement("g", {
|
|
563
566
|
ref: (e)=>{
|
|
564
567
|
yAxisElement.current = e;
|
|
565
568
|
},
|
|
566
569
|
id: `yAxisGElement${idForGraph}`,
|
|
567
|
-
transform: `translate(${_useRtl ? svgDimensions.width - margins.right
|
|
570
|
+
transform: `translate(${_useRtl ? svgDimensions.width - margins.right : margins.left}, 0)`,
|
|
568
571
|
className: classes.yAxis
|
|
569
572
|
}), props.secondaryYScaleOptions && /*#__PURE__*/ React.createElement("g", null, /*#__PURE__*/ React.createElement("g", {
|
|
570
573
|
ref: (e)=>{
|
|
571
574
|
yAxisElementSecondary.current = e;
|
|
572
575
|
},
|
|
573
576
|
id: `yAxisGElementSecondary${idForGraph}`,
|
|
574
|
-
transform: `translate(${_useRtl ? margins.left
|
|
577
|
+
transform: `translate(${_useRtl ? margins.left : svgDimensions.width - margins.right}, 0)`,
|
|
575
578
|
className: classes.yAxis
|
|
576
579
|
}), props.secondaryYAxistitle !== undefined && props.secondaryYAxistitle !== '' && /*#__PURE__*/ React.createElement(SVGTooltipText, {
|
|
577
580
|
...commonSvgToolTipProps,
|
|
578
581
|
content: props.secondaryYAxistitle,
|
|
579
582
|
textProps: {
|
|
580
|
-
x:
|
|
581
|
-
y:
|
|
583
|
+
x: secondaryYAxisTitleCenterX,
|
|
584
|
+
y: yAxisTitleCenterY,
|
|
582
585
|
textAnchor: 'middle',
|
|
583
|
-
transform: `
|
|
584
|
-
${svgDimensions.height - margins.bottom - margins.top - titleMargin})rotate(-90)`,
|
|
586
|
+
transform: `rotate(-90, ${secondaryYAxisTitleCenterX}, ${yAxisTitleCenterY})`,
|
|
585
587
|
className: classes.axisTitle
|
|
586
588
|
},
|
|
587
|
-
maxWidth:
|
|
589
|
+
maxWidth: yAxisTitleMaxHeight
|
|
588
590
|
})), children, props.yAxisTitle !== undefined && props.yAxisTitle !== '' && /*#__PURE__*/ React.createElement(SVGTooltipText, {
|
|
589
591
|
...commonSvgToolTipProps,
|
|
590
592
|
content: props.yAxisTitle,
|
|
591
593
|
textProps: {
|
|
592
|
-
x:
|
|
593
|
-
y:
|
|
594
|
+
x: yAxisTitleCenterX,
|
|
595
|
+
y: yAxisTitleCenterY,
|
|
594
596
|
textAnchor: 'middle',
|
|
595
|
-
transform: `
|
|
596
|
-
${svgDimensions.height - margins.bottom - margins.top - titleMargin})rotate(-90)`,
|
|
597
|
+
transform: `rotate(-90, ${yAxisTitleCenterX}, ${yAxisTitleCenterY})`,
|
|
597
598
|
className: classes.axisTitle
|
|
598
599
|
},
|
|
599
|
-
maxWidth:
|
|
600
|
+
maxWidth: yAxisTitleMaxHeight
|
|
600
601
|
}), props.yAxisAnnotation !== undefined && props.yAxisAnnotation !== '' && (props.secondaryYAxistitle === undefined || props.secondaryYAxistitle === '') && /*#__PURE__*/ React.createElement(SVGTooltipText, {
|
|
601
602
|
...commonSvgToolTipProps,
|
|
602
603
|
content: props.yAxisAnnotation,
|
|
603
604
|
textProps: {
|
|
604
|
-
x:
|
|
605
|
-
y:
|
|
605
|
+
x: secondaryYAxisTitleCenterX,
|
|
606
|
+
y: yAxisTitleCenterY,
|
|
606
607
|
textAnchor: 'middle',
|
|
607
|
-
transform: `
|
|
608
|
-
${svgDimensions.height - margins.bottom - margins.top - titleMargin})rotate(-90)`,
|
|
608
|
+
transform: `rotate(-90, ${secondaryYAxisTitleCenterX}, ${yAxisTitleCenterY})`,
|
|
609
609
|
className: classes.axisAnnotation,
|
|
610
610
|
'aria-hidden': true
|
|
611
611
|
},
|
|
612
|
-
maxWidth:
|
|
612
|
+
maxWidth: yAxisTitleMaxHeight
|
|
613
613
|
})), hasAnnotations && annotationContext && /*#__PURE__*/ React.createElement(ChartAnnotationLayer, {
|
|
614
614
|
annotations: annotations,
|
|
615
615
|
context: annotationContext,
|