@mui/x-charts 6.0.0-alpha.14 → 6.0.0-alpha.15
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/BarChart/BarChart.d.ts +3 -0
- package/BarChart/BarChart.js +4 -8
- package/CHANGELOG.md +104 -0
- package/ChartsLegend/ChartsLegend.d.ts +43 -24
- package/ChartsLegend/ChartsLegend.js +185 -143
- package/ChartsLegend/utils.d.ts +1 -6
- package/ChartsSurface.js +3 -11
- package/ChartsXAxis/ChartsXAxis.js +48 -25
- package/ChartsYAxis/ChartsYAxis.js +47 -26
- package/LineChart/LineChart.d.ts +3 -0
- package/LineChart/LineChart.js +4 -8
- package/PieChart/PieChart.d.ts +3 -0
- package/PieChart/PieChart.js +4 -8
- package/ScatterChart/ScatterChart.d.ts +3 -0
- package/ScatterChart/ScatterChart.js +4 -8
- package/constants.js +1 -1
- package/context/CartesianContextProvider.js +10 -10
- package/context/DrawingProvider.d.ts +2 -0
- package/context/DrawingProvider.js +2 -0
- package/esm/BarChart/BarChart.js +4 -8
- package/esm/ChartsLegend/ChartsLegend.js +184 -142
- package/esm/ChartsSurface.js +3 -11
- package/esm/ChartsXAxis/ChartsXAxis.js +47 -24
- package/esm/ChartsYAxis/ChartsYAxis.js +46 -25
- package/esm/LineChart/LineChart.js +4 -8
- package/esm/PieChart/PieChart.js +4 -8
- package/esm/ScatterChart/ScatterChart.js +4 -8
- package/esm/constants.js +1 -1
- package/esm/context/CartesianContextProvider.js +11 -11
- package/esm/context/DrawingProvider.js +2 -0
- package/esm/hooks/useChartDimensions.js +2 -0
- package/esm/hooks/useTicks.js +5 -5
- package/esm/internals/components/AxisSharedComponents.js +15 -70
- package/esm/internals/components/ChartsText.js +71 -0
- package/esm/internals/domUtils.js +113 -0
- package/hooks/useChartDimensions.d.ts +2 -0
- package/hooks/useChartDimensions.js +2 -0
- package/hooks/useTicks.d.ts +2 -3
- package/hooks/useTicks.js +6 -6
- package/index.js +1 -1
- package/internals/components/AxisSharedComponents.d.ts +0 -4
- package/internals/components/AxisSharedComponents.js +16 -71
- package/internals/components/ChartsText.d.ts +32 -0
- package/internals/components/ChartsText.js +81 -0
- package/internals/domUtils.d.ts +14 -0
- package/internals/domUtils.js +122 -0
- package/legacy/BarChart/BarChart.js +4 -8
- package/legacy/ChartsLegend/ChartsLegend.js +196 -140
- package/legacy/ChartsSurface.js +2 -11
- package/legacy/ChartsXAxis/ChartsXAxis.js +47 -24
- package/legacy/ChartsYAxis/ChartsYAxis.js +46 -25
- package/legacy/LineChart/LineChart.js +4 -8
- package/legacy/PieChart/PieChart.js +4 -8
- package/legacy/ScatterChart/ScatterChart.js +4 -8
- package/legacy/constants.js +1 -1
- package/legacy/context/CartesianContextProvider.js +11 -11
- package/legacy/context/DrawingProvider.js +2 -0
- package/legacy/hooks/useChartDimensions.js +2 -0
- package/legacy/hooks/useTicks.js +5 -5
- package/legacy/index.js +1 -1
- package/legacy/internals/components/AxisSharedComponents.js +9 -63
- package/legacy/internals/components/ChartsText.js +77 -0
- package/legacy/internals/domUtils.js +121 -0
- package/models/axis.d.ts +6 -5
- package/models/layout.d.ts +7 -6
- package/modern/BarChart/BarChart.js +4 -8
- package/modern/ChartsLegend/ChartsLegend.js +184 -142
- package/modern/ChartsSurface.js +3 -11
- package/modern/ChartsXAxis/ChartsXAxis.js +47 -24
- package/modern/ChartsYAxis/ChartsYAxis.js +46 -25
- package/modern/LineChart/LineChart.js +4 -8
- package/modern/PieChart/PieChart.js +4 -8
- package/modern/ScatterChart/ScatterChart.js +4 -8
- package/modern/constants.js +1 -1
- package/modern/context/CartesianContextProvider.js +11 -11
- package/modern/context/DrawingProvider.js +2 -0
- package/modern/hooks/useChartDimensions.js +2 -0
- package/modern/hooks/useTicks.js +5 -5
- package/modern/index.js +1 -1
- package/modern/internals/components/AxisSharedComponents.js +15 -70
- package/modern/internals/components/ChartsText.js +71 -0
- package/modern/internals/domUtils.js +113 -0
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.AxisRoot = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _styles = require("@mui/material/styles");
|
|
10
10
|
var _axisClasses = require("../../ChartsAxis/axisClasses");
|
|
@@ -12,77 +12,22 @@ const AxisRoot = exports.AxisRoot = (0, _styles.styled)('g', {
|
|
|
12
12
|
name: 'MuiChartsAxis',
|
|
13
13
|
slot: 'Root',
|
|
14
14
|
overridesResolver: (props, styles) => styles.root
|
|
15
|
-
})({
|
|
16
|
-
[`&.${_axisClasses.axisClasses.directionY}`]: {
|
|
17
|
-
[`.${_axisClasses.axisClasses.tickLabel}`]: {
|
|
18
|
-
dominantBaseline: 'middle'
|
|
19
|
-
},
|
|
20
|
-
[`.${_axisClasses.axisClasses.label}`]: {
|
|
21
|
-
dominantBaseline: 'auto',
|
|
22
|
-
textAnchor: 'middle'
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
[`&.${_axisClasses.axisClasses.left}`]: {
|
|
26
|
-
[`.${_axisClasses.axisClasses.tickLabel}`]: {
|
|
27
|
-
dominantBaseline: 'central',
|
|
28
|
-
textAnchor: 'end'
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
[`&.${_axisClasses.axisClasses.right}`]: {
|
|
32
|
-
[`.${_axisClasses.axisClasses.tickLabel}`]: {
|
|
33
|
-
dominantBaseline: 'central',
|
|
34
|
-
textAnchor: 'start'
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
[`&.${_axisClasses.axisClasses.bottom}`]: {
|
|
38
|
-
[`.${_axisClasses.axisClasses.tickLabel}, .${_axisClasses.axisClasses.label}`]: {
|
|
39
|
-
dominantBaseline: 'hanging',
|
|
40
|
-
textAnchor: 'middle'
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
[`&.${_axisClasses.axisClasses.top}`]: {
|
|
44
|
-
[`.${_axisClasses.axisClasses.tickLabel}, .${_axisClasses.axisClasses.label}`]: {
|
|
45
|
-
dominantBaseline: 'baseline',
|
|
46
|
-
textAnchor: 'middle'
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
const ChartsLine = exports.ChartsLine = (0, _styles.styled)('line', {
|
|
51
|
-
name: 'MuiChartsAxis',
|
|
52
|
-
slot: 'Line',
|
|
53
|
-
overridesResolver: (props, styles) => styles.line
|
|
54
15
|
})(({
|
|
55
16
|
theme
|
|
56
17
|
}) => ({
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
name: 'MuiChartsAxis',
|
|
73
|
-
slot: 'TickLabel',
|
|
74
|
-
overridesResolver: (props, styles) => styles.tickLabel
|
|
75
|
-
})(({
|
|
76
|
-
theme
|
|
77
|
-
}) => (0, _extends2.default)({}, theme.typography.caption, {
|
|
78
|
-
fill: (theme.vars || theme).palette.text.primary
|
|
79
|
-
}));
|
|
80
|
-
const ChartsLabel = exports.ChartsLabel = (0, _styles.styled)('text', {
|
|
81
|
-
name: 'MuiChartsAxis',
|
|
82
|
-
slot: 'Label',
|
|
83
|
-
overridesResolver: (props, styles) => styles.label
|
|
84
|
-
})(({
|
|
85
|
-
theme
|
|
86
|
-
}) => (0, _extends2.default)({}, theme.typography.body1, {
|
|
87
|
-
fill: (theme.vars || theme).palette.text.primary
|
|
18
|
+
[`& .${_axisClasses.axisClasses.tickLabel}`]: (0, _extends2.default)({}, theme.typography.caption, {
|
|
19
|
+
fill: (theme.vars || theme).palette.text.primary
|
|
20
|
+
}),
|
|
21
|
+
[`& .${_axisClasses.axisClasses.label}`]: (0, _extends2.default)({}, theme.typography.body1, {
|
|
22
|
+
fill: (theme.vars || theme).palette.text.primary
|
|
23
|
+
}),
|
|
24
|
+
[`& .${_axisClasses.axisClasses.line}`]: {
|
|
25
|
+
stroke: (theme.vars || theme).palette.text.primary,
|
|
26
|
+
shapeRendering: 'crispEdges',
|
|
27
|
+
strokeWidth: 1
|
|
28
|
+
},
|
|
29
|
+
[`& .${_axisClasses.axisClasses.tick}`]: {
|
|
30
|
+
stroke: (theme.vars || theme).palette.text.primary,
|
|
31
|
+
shapeRendering: 'crispEdges'
|
|
32
|
+
}
|
|
88
33
|
}));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface GetWordsByLinesParams {
|
|
3
|
+
/**
|
|
4
|
+
* Text displayed.
|
|
5
|
+
*/
|
|
6
|
+
text: string;
|
|
7
|
+
/**
|
|
8
|
+
* Style applied to text elements.
|
|
9
|
+
*/
|
|
10
|
+
style?: React.SVGAttributes<'text'>['style'];
|
|
11
|
+
/**
|
|
12
|
+
* If true, the line width is computed.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
needsComputation?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export type ChartsTextBaseline = 'hanging' | 'central' | 'auto';
|
|
18
|
+
export interface ChartsTextProps extends Omit<React.SVGTextElementAttributes<SVGTextElement>, 'width' | 'ref'>, GetWordsByLinesParams {
|
|
19
|
+
/**
|
|
20
|
+
* Height of a text line (in `em`).
|
|
21
|
+
*/
|
|
22
|
+
lineHeight?: number;
|
|
23
|
+
/**
|
|
24
|
+
* The text baseline
|
|
25
|
+
* @default 'central'
|
|
26
|
+
*/
|
|
27
|
+
dominantBaseline?: ChartsTextBaseline;
|
|
28
|
+
ownerState?: any;
|
|
29
|
+
}
|
|
30
|
+
export declare function getWordsByLines({ style, needsComputation, text }: GetWordsByLinesParams): any[];
|
|
31
|
+
export declare function ChartsText(props: ChartsTextProps): React.JSX.Element;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ChartsText = ChartsText;
|
|
8
|
+
exports.getWordsByLines = getWordsByLines;
|
|
9
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
var React = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _domUtils = require("../domUtils");
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
const _excluded = ["x", "y", "textAnchor", "dominantBaseline", "style", "text", "ownerState"];
|
|
15
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
+
function getWordsByLines({
|
|
18
|
+
style,
|
|
19
|
+
needsComputation,
|
|
20
|
+
text
|
|
21
|
+
}) {
|
|
22
|
+
return text.split('\n').map(subText => (0, _extends2.default)({
|
|
23
|
+
text: subText
|
|
24
|
+
}, needsComputation ? (0, _domUtils.getStringSize)(subText, style) : {
|
|
25
|
+
width: 0,
|
|
26
|
+
height: 0
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
function ChartsText(props) {
|
|
30
|
+
const {
|
|
31
|
+
x,
|
|
32
|
+
y,
|
|
33
|
+
textAnchor = 'start',
|
|
34
|
+
dominantBaseline = 'central',
|
|
35
|
+
style,
|
|
36
|
+
text
|
|
37
|
+
} = props,
|
|
38
|
+
textProps = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
39
|
+
const wordsByLines = React.useMemo(() => getWordsByLines({
|
|
40
|
+
style,
|
|
41
|
+
needsComputation: text.includes('\n'),
|
|
42
|
+
text
|
|
43
|
+
}), [style, text]);
|
|
44
|
+
let startDy;
|
|
45
|
+
switch (dominantBaseline) {
|
|
46
|
+
case 'hanging':
|
|
47
|
+
startDy = 0;
|
|
48
|
+
break;
|
|
49
|
+
case 'central':
|
|
50
|
+
startDy = (wordsByLines.length - 1) / 2 * -wordsByLines[0].height;
|
|
51
|
+
break;
|
|
52
|
+
default:
|
|
53
|
+
startDy = (wordsByLines.length - 1) * -wordsByLines[0].height;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// const transforms = [];
|
|
58
|
+
// if (scaleToFit) {
|
|
59
|
+
// const lineWidth = wordsByLines[0].width;
|
|
60
|
+
// transforms.push(`scale(${(isNumber(width as number) ? (width as number) / lineWidth : 1) / lineWidth})`);
|
|
61
|
+
// }
|
|
62
|
+
// if (angle) {
|
|
63
|
+
// transforms.push(`rotate(${angle}, ${x}, ${y})`);
|
|
64
|
+
// }
|
|
65
|
+
// if (transforms.length) {
|
|
66
|
+
// textProps.transform = transforms.join(' ');
|
|
67
|
+
// }
|
|
68
|
+
|
|
69
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("text", (0, _extends2.default)({}, textProps, {
|
|
70
|
+
x: x,
|
|
71
|
+
y: y,
|
|
72
|
+
textAnchor: textAnchor,
|
|
73
|
+
dominantBaseline: dominantBaseline,
|
|
74
|
+
style: style,
|
|
75
|
+
children: wordsByLines.map((line, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)("tspan", {
|
|
76
|
+
x: x,
|
|
77
|
+
dy: `${index === 0 ? startDy : wordsByLines[0].height}px`,
|
|
78
|
+
children: line.text
|
|
79
|
+
}, index))
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param style React style object
|
|
5
|
+
* @returns CSS styling string
|
|
6
|
+
*/
|
|
7
|
+
export declare const getStyleString: (style: React.CSSProperties) => string;
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param text The string to estimate
|
|
11
|
+
* @param style The style applied
|
|
12
|
+
* @returns width and height of the text
|
|
13
|
+
*/
|
|
14
|
+
export declare const getStringSize: (text: string | number, style?: React.CSSProperties) => any;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getStyleString = exports.getStringSize = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
// DOM utils taken from
|
|
10
|
+
// https://github.com/recharts/recharts/blob/master/src/util/DOMUtils.ts
|
|
11
|
+
|
|
12
|
+
const isSsr = () => !(typeof window !== 'undefined' && window.document && window.setTimeout);
|
|
13
|
+
const stringCache = {
|
|
14
|
+
widthCache: {},
|
|
15
|
+
cacheCount: 0
|
|
16
|
+
};
|
|
17
|
+
const MAX_CACHE_NUM = 2000;
|
|
18
|
+
const SPAN_STYLE = {
|
|
19
|
+
position: 'absolute',
|
|
20
|
+
top: '-20000px',
|
|
21
|
+
left: 0,
|
|
22
|
+
padding: 0,
|
|
23
|
+
margin: 0,
|
|
24
|
+
border: 'none',
|
|
25
|
+
whiteSpace: 'pre'
|
|
26
|
+
};
|
|
27
|
+
const STYLE_LIST = ['minWidth', 'maxWidth', 'width', 'minHeight', 'maxHeight', 'height', 'top', 'left', 'fontSize', 'padding', 'margin', 'paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom', 'marginLeft', 'marginRight', 'marginTop', 'marginBottom'];
|
|
28
|
+
const MEASUREMENT_SPAN_ID = 'mui_measurement_span';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @param name CSS property name
|
|
33
|
+
* @param value
|
|
34
|
+
* @returns add 'px' for distance properties
|
|
35
|
+
*/
|
|
36
|
+
function autoCompleteStyle(name, value) {
|
|
37
|
+
if (STYLE_LIST.indexOf(name) >= 0 && value === +value) {
|
|
38
|
+
return `${value}px`;
|
|
39
|
+
}
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @param text camelcase css property
|
|
46
|
+
* @returns css property
|
|
47
|
+
*/
|
|
48
|
+
function camelToMiddleLine(text) {
|
|
49
|
+
const strs = text.split('');
|
|
50
|
+
const formatStrs = strs.reduce((result, entry) => {
|
|
51
|
+
if (entry === entry.toUpperCase()) {
|
|
52
|
+
return [...result, '-', entry.toLowerCase()];
|
|
53
|
+
}
|
|
54
|
+
return [...result, entry];
|
|
55
|
+
}, []);
|
|
56
|
+
return formatStrs.join('');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @param style React style object
|
|
62
|
+
* @returns CSS styling string
|
|
63
|
+
*/
|
|
64
|
+
const getStyleString = style => Object.keys(style).sort().reduce((result, s) => `${result}${camelToMiddleLine(s)}:${autoCompleteStyle(s, style[s])};`, '');
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* @param text The string to estimate
|
|
69
|
+
* @param style The style applied
|
|
70
|
+
* @returns width and height of the text
|
|
71
|
+
*/
|
|
72
|
+
exports.getStyleString = getStyleString;
|
|
73
|
+
const getStringSize = (text, style = {}) => {
|
|
74
|
+
if (text === undefined || text === null || isSsr()) {
|
|
75
|
+
return {
|
|
76
|
+
width: 0,
|
|
77
|
+
height: 0
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const str = `${text}`;
|
|
81
|
+
const styleString = getStyleString(style);
|
|
82
|
+
const cacheKey = `${str}-${styleString}`;
|
|
83
|
+
if (stringCache.widthCache[cacheKey]) {
|
|
84
|
+
return stringCache.widthCache[cacheKey];
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
let measurementSpan = document.getElementById(MEASUREMENT_SPAN_ID);
|
|
88
|
+
if (measurementSpan === null) {
|
|
89
|
+
measurementSpan = document.createElement('span');
|
|
90
|
+
measurementSpan.setAttribute('id', MEASUREMENT_SPAN_ID);
|
|
91
|
+
measurementSpan.setAttribute('aria-hidden', 'true');
|
|
92
|
+
document.body.appendChild(measurementSpan);
|
|
93
|
+
}
|
|
94
|
+
// Need to use CSS Object Model (CSSOM) to be able to comply with Content Security Policy (CSP)
|
|
95
|
+
// https://en.wikipedia.org/wiki/Content_Security_Policy
|
|
96
|
+
const measurementSpanStyle = (0, _extends2.default)({}, SPAN_STYLE, style);
|
|
97
|
+
Object.keys(measurementSpanStyle).map(styleKey => {
|
|
98
|
+
measurementSpan.style[camelToMiddleLine(styleKey)] = autoCompleteStyle(styleKey, measurementSpanStyle[styleKey]);
|
|
99
|
+
return styleKey;
|
|
100
|
+
});
|
|
101
|
+
measurementSpan.textContent = str;
|
|
102
|
+
const rect = measurementSpan.getBoundingClientRect();
|
|
103
|
+
const result = {
|
|
104
|
+
width: rect.width,
|
|
105
|
+
height: rect.height
|
|
106
|
+
};
|
|
107
|
+
stringCache.widthCache[cacheKey] = result;
|
|
108
|
+
if (stringCache.cacheCount + 1 > MAX_CACHE_NUM) {
|
|
109
|
+
stringCache.cacheCount = 0;
|
|
110
|
+
stringCache.widthCache = {};
|
|
111
|
+
} else {
|
|
112
|
+
stringCache.cacheCount += 1;
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
115
|
+
} catch (e) {
|
|
116
|
+
return {
|
|
117
|
+
width: 0,
|
|
118
|
+
height: 0
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
exports.getStringSize = getStringSize;
|
|
@@ -167,23 +167,19 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
167
167
|
tickNumber: PropTypes.number,
|
|
168
168
|
tickSize: PropTypes.number
|
|
169
169
|
}), PropTypes.string]),
|
|
170
|
+
/**
|
|
171
|
+
* @deprecated Consider using `slotProps.legend` instead.
|
|
172
|
+
*/
|
|
170
173
|
legend: PropTypes.shape({
|
|
171
174
|
classes: PropTypes.object,
|
|
172
175
|
direction: PropTypes.oneOf(['column', 'row']),
|
|
173
176
|
hidden: PropTypes.bool,
|
|
174
|
-
itemWidth: PropTypes.number,
|
|
175
|
-
markSize: PropTypes.number,
|
|
176
|
-
offset: PropTypes.shape({
|
|
177
|
-
x: PropTypes.number,
|
|
178
|
-
y: PropTypes.number
|
|
179
|
-
}),
|
|
180
177
|
position: PropTypes.shape({
|
|
181
178
|
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
182
179
|
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
183
180
|
}),
|
|
184
181
|
slotProps: PropTypes.object,
|
|
185
|
-
slots: PropTypes.object
|
|
186
|
-
spacing: PropTypes.number
|
|
182
|
+
slots: PropTypes.object
|
|
187
183
|
}),
|
|
188
184
|
margin: PropTypes.shape({
|
|
189
185
|
bottom: PropTypes.number,
|