@mui/x-charts 7.3.2 → 7.5.0
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.js +18 -11
- package/BarChart/BarClipPath.d.ts +14 -0
- package/BarChart/BarClipPath.js +50 -0
- package/BarChart/BarElement.d.ts +10 -5
- package/BarChart/BarElement.js +3 -2
- package/BarChart/BarPlot.d.ts +4 -0
- package/BarChart/BarPlot.js +102 -30
- package/BarChart/getRadius.d.ts +15 -0
- package/BarChart/getRadius.js +37 -0
- package/BarChart/legend.js +13 -6
- package/BarChart/types.d.ts +25 -0
- package/BarChart/types.js +5 -0
- package/CHANGELOG.md +160 -2
- package/ChartContainer/ChartContainer.js +10 -10
- package/ChartsGrid/ChartsGrid.js +22 -11
- package/ChartsOverlay/ChartsLoadingOverlay.js +3 -3
- package/ChartsOverlay/ChartsNoDataOverlay.js +2 -2
- package/ChartsOverlay/ChartsOverlay.d.ts +9 -0
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +4 -2
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +7 -3
- package/ChartsTooltip/utils.js +13 -8
- package/ChartsXAxis/ChartsXAxis.js +1 -2
- package/ChartsYAxis/ChartsYAxis.js +2 -2
- package/LineChart/AreaElement.d.ts +1 -1
- package/LineChart/AreaElement.js +3 -3
- package/LineChart/AreaPlot.js +3 -2
- package/LineChart/LineChart.js +11 -10
- package/LineChart/LineElement.d.ts +1 -1
- package/LineChart/LineElement.js +3 -3
- package/LineChart/LineHighlightElement.d.ts +1 -1
- package/LineChart/MarkElement.d.ts +1 -1
- package/LineChart/legend.js +13 -6
- package/PieChart/PieArc.d.ts +1 -1
- package/PieChart/PieArcLabel.d.ts +1 -1
- package/PieChart/PieArcLabel.js +3 -1
- package/PieChart/PieArcLabelPlot.js +14 -5
- package/PieChart/PieArcPlot.js +1 -1
- package/PieChart/PieChart.js +11 -10
- package/PieChart/formatter.js +4 -1
- package/PieChart/legend.js +15 -5
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +10 -10
- package/ScatterChart/ScatterChart.js +16 -15
- package/ScatterChart/legend.js +13 -6
- package/SparkLineChart/SparkLineChart.js +5 -5
- package/context/ZAxisContextProvider.js +5 -5
- package/esm/BarChart/BarChart.js +18 -11
- package/esm/BarChart/BarClipPath.js +42 -0
- package/esm/BarChart/BarElement.js +3 -2
- package/esm/BarChart/BarPlot.js +103 -31
- package/esm/BarChart/getRadius.js +30 -0
- package/esm/BarChart/legend.js +13 -6
- package/esm/BarChart/types.js +1 -0
- package/esm/ChartContainer/ChartContainer.js +10 -10
- package/esm/ChartsGrid/ChartsGrid.js +23 -12
- package/esm/ChartsOverlay/ChartsLoadingOverlay.js +3 -3
- package/esm/ChartsOverlay/ChartsNoDataOverlay.js +2 -2
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +4 -2
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +7 -3
- package/esm/ChartsTooltip/utils.js +13 -8
- package/esm/ChartsXAxis/ChartsXAxis.js +1 -2
- package/esm/ChartsYAxis/ChartsYAxis.js +2 -2
- package/esm/LineChart/AreaElement.js +3 -3
- package/esm/LineChart/AreaPlot.js +3 -2
- package/esm/LineChart/LineChart.js +11 -10
- package/esm/LineChart/LineElement.js +3 -3
- package/esm/LineChart/legend.js +13 -6
- package/esm/PieChart/PieArcLabel.js +3 -1
- package/esm/PieChart/PieArcLabelPlot.js +14 -5
- package/esm/PieChart/PieArcPlot.js +1 -1
- package/esm/PieChart/PieChart.js +11 -10
- package/esm/PieChart/formatter.js +4 -1
- package/esm/PieChart/legend.js +15 -5
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +10 -10
- package/esm/ScatterChart/ScatterChart.js +16 -15
- package/esm/ScatterChart/legend.js +13 -6
- package/esm/SparkLineChart/SparkLineChart.js +5 -5
- package/esm/context/ZAxisContextProvider.js +5 -5
- package/esm/hooks/useAxisEvents.js +12 -7
- package/esm/internals/getLabel.js +3 -0
- package/hooks/useAxisEvents.js +12 -7
- package/index.js +1 -1
- package/internals/defaultizeColor.d.ts +7 -5
- package/internals/getLabel.d.ts +1 -0
- package/internals/getLabel.js +9 -0
- package/internals/utils.d.ts +1 -1
- package/models/seriesType/bar.d.ts +4 -1
- package/models/seriesType/line.d.ts +4 -1
- package/models/seriesType/pie.d.ts +9 -4
- package/models/seriesType/scatter.d.ts +4 -1
- package/modern/BarChart/BarChart.js +18 -11
- package/modern/BarChart/BarClipPath.js +42 -0
- package/modern/BarChart/BarElement.js +3 -2
- package/modern/BarChart/BarPlot.js +103 -31
- package/modern/BarChart/getRadius.js +30 -0
- package/modern/BarChart/legend.js +13 -6
- package/modern/BarChart/types.js +1 -0
- package/modern/ChartContainer/ChartContainer.js +10 -10
- package/modern/ChartsGrid/ChartsGrid.js +23 -12
- package/modern/ChartsOverlay/ChartsLoadingOverlay.js +3 -3
- package/modern/ChartsOverlay/ChartsNoDataOverlay.js +2 -2
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +4 -2
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +7 -3
- package/modern/ChartsTooltip/utils.js +13 -8
- package/modern/ChartsXAxis/ChartsXAxis.js +1 -2
- package/modern/ChartsYAxis/ChartsYAxis.js +2 -2
- package/modern/LineChart/AreaElement.js +3 -3
- package/modern/LineChart/AreaPlot.js +3 -2
- package/modern/LineChart/LineChart.js +11 -10
- package/modern/LineChart/LineElement.js +3 -3
- package/modern/LineChart/legend.js +13 -6
- package/modern/PieChart/PieArcLabel.js +3 -1
- package/modern/PieChart/PieArcLabelPlot.js +14 -5
- package/modern/PieChart/PieArcPlot.js +1 -1
- package/modern/PieChart/PieChart.js +11 -10
- package/modern/PieChart/formatter.js +4 -1
- package/modern/PieChart/legend.js +15 -5
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +10 -10
- package/modern/ScatterChart/ScatterChart.js +16 -15
- package/modern/ScatterChart/legend.js +13 -6
- package/modern/SparkLineChart/SparkLineChart.js +5 -5
- package/modern/context/ZAxisContextProvider.js +5 -5
- package/modern/hooks/useAxisEvents.js +12 -7
- package/modern/index.js +1 -1
- package/modern/internals/getLabel.js +3 -0
- package/package.json +3 -3
- package/themeAugmentation/components.d.ts +4 -0
- package/themeAugmentation/overrides.d.ts +2 -0
- package/themeAugmentation/props.d.ts +2 -0
package/BarChart/BarChart.js
CHANGED
|
@@ -55,6 +55,7 @@ const BarChart = exports.BarChart = /*#__PURE__*/React.forwardRef(function BarCh
|
|
|
55
55
|
rightAxis,
|
|
56
56
|
bottomAxis,
|
|
57
57
|
skipAnimation,
|
|
58
|
+
borderRadius,
|
|
58
59
|
onItemClick,
|
|
59
60
|
onAxisClick,
|
|
60
61
|
children,
|
|
@@ -107,7 +108,8 @@ const BarChart = exports.BarChart = /*#__PURE__*/React.forwardRef(function BarCh
|
|
|
107
108
|
slots: slots,
|
|
108
109
|
slotProps: slotProps,
|
|
109
110
|
skipAnimation: skipAnimation,
|
|
110
|
-
onItemClick: onItemClick
|
|
111
|
+
onItemClick: onItemClick,
|
|
112
|
+
borderRadius: borderRadius
|
|
111
113
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, {
|
|
112
114
|
loading: loading,
|
|
113
115
|
slots: slots,
|
|
@@ -146,6 +148,10 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
146
148
|
x: _propTypes.default.oneOf(['band', 'line', 'none']),
|
|
147
149
|
y: _propTypes.default.oneOf(['band', 'line', 'none'])
|
|
148
150
|
}),
|
|
151
|
+
/**
|
|
152
|
+
* Defines the border radius of the bar element.
|
|
153
|
+
*/
|
|
154
|
+
borderRadius: _propTypes.default.number,
|
|
149
155
|
/**
|
|
150
156
|
* Indicate which axis to display the bottom of the charts.
|
|
151
157
|
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
@@ -208,6 +214,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
208
214
|
}),
|
|
209
215
|
/**
|
|
210
216
|
* If `true`, a loading overlay is displayed.
|
|
217
|
+
* @default false
|
|
211
218
|
*/
|
|
212
219
|
loading: _propTypes.default.bool,
|
|
213
220
|
/**
|
|
@@ -300,6 +307,11 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
300
307
|
axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
301
308
|
classes: _propTypes.default.object,
|
|
302
309
|
colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
310
|
+
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
311
|
+
type: _propTypes.default.oneOf(['ordinal']).isRequired,
|
|
312
|
+
unknownColor: _propTypes.default.string,
|
|
313
|
+
values: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number, _propTypes.default.string]).isRequired)
|
|
314
|
+
}), _propTypes.default.shape({
|
|
303
315
|
color: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string.isRequired), _propTypes.default.func]).isRequired,
|
|
304
316
|
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
305
317
|
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
@@ -308,11 +320,6 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
308
320
|
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
309
321
|
thresholds: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]).isRequired).isRequired,
|
|
310
322
|
type: _propTypes.default.oneOf(['piecewise']).isRequired
|
|
311
|
-
}), _propTypes.default.shape({
|
|
312
|
-
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
313
|
-
type: _propTypes.default.oneOf(['ordinal']).isRequired,
|
|
314
|
-
unknownColor: _propTypes.default.string,
|
|
315
|
-
values: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number, _propTypes.default.string]).isRequired)
|
|
316
323
|
})]),
|
|
317
324
|
data: _propTypes.default.array,
|
|
318
325
|
dataKey: _propTypes.default.string,
|
|
@@ -353,6 +360,11 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
353
360
|
axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
354
361
|
classes: _propTypes.default.object,
|
|
355
362
|
colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
363
|
+
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
364
|
+
type: _propTypes.default.oneOf(['ordinal']).isRequired,
|
|
365
|
+
unknownColor: _propTypes.default.string,
|
|
366
|
+
values: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number, _propTypes.default.string]).isRequired)
|
|
367
|
+
}), _propTypes.default.shape({
|
|
356
368
|
color: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string.isRequired), _propTypes.default.func]).isRequired,
|
|
357
369
|
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
358
370
|
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
@@ -361,11 +373,6 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
361
373
|
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
362
374
|
thresholds: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]).isRequired).isRequired,
|
|
363
375
|
type: _propTypes.default.oneOf(['piecewise']).isRequired
|
|
364
|
-
}), _propTypes.default.shape({
|
|
365
|
-
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
366
|
-
type: _propTypes.default.oneOf(['ordinal']).isRequired,
|
|
367
|
-
unknownColor: _propTypes.default.string,
|
|
368
|
-
values: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number, _propTypes.default.string]).isRequired)
|
|
369
376
|
})]),
|
|
370
377
|
data: _propTypes.default.array,
|
|
371
378
|
dataKey: _propTypes.default.string,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface BarClipPathProps {
|
|
3
|
+
maskId: string;
|
|
4
|
+
borderRadius?: number;
|
|
5
|
+
hasNegative: boolean;
|
|
6
|
+
hasPositive: boolean;
|
|
7
|
+
layout?: 'vertical' | 'horizontal';
|
|
8
|
+
style: {};
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @ignore - internal component.
|
|
12
|
+
*/
|
|
13
|
+
declare function BarClipPath(props: BarClipPathProps): React.JSX.Element | null;
|
|
14
|
+
export { BarClipPath };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.BarClipPath = BarClipPath;
|
|
8
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _web = require("@react-spring/web");
|
|
12
|
+
var _getRadius = require("./getRadius");
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
const _excluded = ["style", "maskId"];
|
|
15
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
|
+
const buildInset = corners => `inset(0px round ${corners.topLeft}px ${corners.topRight}px ${corners.bottomRight}px ${corners.bottomLeft}px)`;
|
|
18
|
+
function BarClipRect(props) {
|
|
19
|
+
const radiusData = props.ownerState;
|
|
20
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_web.animated.rect, {
|
|
21
|
+
style: (0, _extends2.default)({}, props.style, {
|
|
22
|
+
clipPath: (props.ownerState.layout === 'vertical' ? props.style?.height : props.style?.width).to(value => buildInset({
|
|
23
|
+
topLeft: Math.min(value, (0, _getRadius.getRadius)('top-left', radiusData)),
|
|
24
|
+
topRight: Math.min(value, (0, _getRadius.getRadius)('top-right', radiusData)),
|
|
25
|
+
bottomRight: Math.min(value, (0, _getRadius.getRadius)('bottom-right', radiusData)),
|
|
26
|
+
bottomLeft: Math.min(value, (0, _getRadius.getRadius)('bottom-left', radiusData))
|
|
27
|
+
}))
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @ignore - internal component.
|
|
33
|
+
*/
|
|
34
|
+
function BarClipPath(props) {
|
|
35
|
+
const {
|
|
36
|
+
style,
|
|
37
|
+
maskId
|
|
38
|
+
} = props,
|
|
39
|
+
rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
40
|
+
if (!props.borderRadius || props.borderRadius <= 0) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("clipPath", {
|
|
44
|
+
id: maskId,
|
|
45
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(BarClipRect, {
|
|
46
|
+
ownerState: rest,
|
|
47
|
+
style: style
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
}
|
package/BarChart/BarElement.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="@react-spring/shared" />
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { AnimatedProps } from '@react-spring/web';
|
|
3
4
|
import { HighlightScope } from '../context/HighlightProvider';
|
|
4
5
|
import { SeriesId } from '../models/seriesType/common';
|
|
5
6
|
export interface BarElementClasses {
|
|
@@ -17,7 +18,7 @@ export interface BarElementOwnerState {
|
|
|
17
18
|
}
|
|
18
19
|
export declare function getBarElementUtilityClass(slot: string): string;
|
|
19
20
|
export declare const barElementClasses: BarElementClasses;
|
|
20
|
-
export declare const BarElementPath: import("@emotion/styled").StyledComponent<Pick<
|
|
21
|
+
export declare const BarElementPath: import("@emotion/styled").StyledComponent<Pick<AnimatedProps<{
|
|
21
22
|
string?: string | number | undefined;
|
|
22
23
|
end?: string | number | undefined;
|
|
23
24
|
accumulate?: "none" | "sum" | undefined;
|
|
@@ -1352,9 +1353,13 @@ export declare const BarElementPath: import("@emotion/styled").StyledComponent<P
|
|
|
1352
1353
|
}, "string" | "end" | "accumulate" | "local" | "color" | "clip" | "style" | "unicode" | "fill" | "stroke" | "x" | "y" | "clipPath" | "cursor" | "direction" | "display" | "filter" | "fontFamily" | "fontSize" | "fontSizeAdjust" | "fontStretch" | "fontStyle" | "fontVariant" | "fontWeight" | "height" | "imageRendering" | "letterSpacing" | "opacity" | "order" | "paintOrder" | "pointerEvents" | "rotate" | "scale" | "textRendering" | "transform" | "unicodeBidi" | "visibility" | "width" | "wordSpacing" | "writingMode" | "alphabetic" | "hanging" | "ideographic" | "mathematical" | "mask" | "offset" | "overflow" | "textDecoration" | "azimuth" | "alignmentBaseline" | "baselineShift" | "clipRule" | "colorInterpolation" | "colorRendering" | "dominantBaseline" | "fillOpacity" | "fillRule" | "floodColor" | "floodOpacity" | "glyphOrientationVertical" | "lightingColor" | "markerEnd" | "markerMid" | "markerStart" | "shapeRendering" | "stopColor" | "stopOpacity" | "strokeDasharray" | "strokeDashoffset" | "strokeLinecap" | "strokeLinejoin" | "strokeMiterlimit" | "strokeOpacity" | "strokeWidth" | "textAnchor" | "vectorEffect" | "additive" | "path" | "ref" | "suppressHydrationWarning" | "className" | "id" | "lang" | "max" | "media" | "method" | "min" | "name" | "target" | "type" | "role" | "tabIndex" | "crossOrigin" | "accentHeight" | "allowReorder" | "amplitude" | "arabicForm" | "ascent" | "attributeName" | "attributeType" | "autoReverse" | "baseFrequency" | "baseProfile" | "bbox" | "begin" | "bias" | "by" | "calcMode" | "capHeight" | "clipPathUnits" | "colorInterpolationFilters" | "colorProfile" | "contentScriptType" | "contentStyleType" | "cx" | "cy" | "d" | "decelerate" | "descent" | "diffuseConstant" | "divisor" | "dur" | "dx" | "dy" | "edgeMode" | "elevation" | "enableBackground" | "exponent" | "externalResourcesRequired" | "filterRes" | "filterUnits" | "focusable" | "format" | "fr" | "from" | "fx" | "fy" | "g1" | "g2" | "glyphName" | "glyphOrientationHorizontal" | "glyphRef" | "gradientTransform" | "gradientUnits" | "horizAdvX" | "horizOriginX" | "href" | "in2" | "in" | "intercept" | "k1" | "k2" | "k3" | "k4" | "k" | "kernelMatrix" | "kernelUnitLength" | "kerning" | "keyPoints" | "keySplines" | "keyTimes" | "lengthAdjust" | "limitingConeAngle" | "markerHeight" | "markerUnits" | "markerWidth" | "maskContentUnits" | "maskUnits" | "mode" | "numOctaves" | "operator" | "orient" | "orientation" | "origin" | "overlinePosition" | "overlineThickness" | "panose1" | "pathLength" | "patternContentUnits" | "patternTransform" | "patternUnits" | "points" | "pointsAtX" | "pointsAtY" | "pointsAtZ" | "preserveAlpha" | "preserveAspectRatio" | "primitiveUnits" | "r" | "radius" | "refX" | "refY" | "renderingIntent" | "repeatCount" | "repeatDur" | "requiredExtensions" | "requiredFeatures" | "restart" | "result" | "rx" | "ry" | "seed" | "slope" | "spacing" | "specularConstant" | "specularExponent" | "speed" | "spreadMethod" | "startOffset" | "stdDeviation" | "stemh" | "stemv" | "stitchTiles" | "strikethroughPosition" | "strikethroughThickness" | "surfaceScale" | "systemLanguage" | "tableValues" | "targetX" | "targetY" | "textLength" | "to" | "u1" | "u2" | "underlinePosition" | "underlineThickness" | "unicodeRange" | "unitsPerEm" | "vAlphabetic" | "values" | "version" | "vertAdvY" | "vertOriginX" | "vertOriginY" | "vHanging" | "vIdeographic" | "viewBox" | "viewTarget" | "vMathematical" | "widths" | "x1" | "x2" | "xChannelSelector" | "xHeight" | "xlinkActuate" | "xlinkArcrole" | "xlinkHref" | "xlinkRole" | "xlinkShow" | "xlinkTitle" | "xlinkType" | "xmlBase" | "xmlLang" | "xmlns" | "xmlnsXlink" | "xmlSpace" | "y1" | "y2" | "yChannelSelector" | "z" | "zoomAndPan" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "scrollTop" | "scrollLeft"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
1353
1354
|
ownerState: BarElementOwnerState;
|
|
1354
1355
|
}, {}, {}>;
|
|
1355
|
-
interface BarProps extends Omit<React.
|
|
1356
|
+
interface BarProps extends Omit<React.SVGProps<SVGRectElement>, 'id' | 'color' | 'ref' | 'x' | 'y' | 'height' | 'width'>, AnimatedProps<{
|
|
1357
|
+
x?: string | number | undefined;
|
|
1358
|
+
y?: string | number | undefined;
|
|
1359
|
+
height?: string | number | undefined;
|
|
1360
|
+
width?: string | number | undefined;
|
|
1361
|
+
}> {
|
|
1356
1362
|
highlightScope?: Partial<HighlightScope>;
|
|
1357
|
-
onClick?: (event: React.MouseEvent<SVGPathElement, MouseEvent>) => void;
|
|
1358
1363
|
ownerState: BarElementOwnerState;
|
|
1359
1364
|
}
|
|
1360
1365
|
export interface BarElementSlots {
|
|
@@ -1362,12 +1367,12 @@ export interface BarElementSlots {
|
|
|
1362
1367
|
* The component that renders the bar.
|
|
1363
1368
|
* @default BarElementPath
|
|
1364
1369
|
*/
|
|
1365
|
-
bar?: React.
|
|
1370
|
+
bar?: React.ElementType<BarProps>;
|
|
1366
1371
|
}
|
|
1367
1372
|
export interface BarElementSlotProps {
|
|
1368
1373
|
bar?: Partial<BarProps>;
|
|
1369
1374
|
}
|
|
1370
|
-
export type BarElementProps = Omit<BarElementOwnerState, 'isFaded' | 'isHighlighted'> & Omit<React.
|
|
1375
|
+
export type BarElementProps = Omit<BarElementOwnerState, 'isFaded' | 'isHighlighted'> & Omit<React.SVGProps<SVGRectElement>, 'ref' | 'id'> & {
|
|
1371
1376
|
highlightScope?: Partial<HighlightScope>;
|
|
1372
1377
|
/**
|
|
1373
1378
|
* The props used for each component slot.
|
package/BarChart/BarElement.js
CHANGED
|
@@ -90,16 +90,17 @@ function BarElement(props) {
|
|
|
90
90
|
const barProps = (0, _utils.useSlotProps)({
|
|
91
91
|
elementType: Bar,
|
|
92
92
|
externalSlotProps: slotProps?.bar,
|
|
93
|
-
|
|
93
|
+
externalForwardedProps: other,
|
|
94
|
+
additionalProps: (0, _extends2.default)({}, getInteractionItemProps({
|
|
94
95
|
type: 'bar',
|
|
95
96
|
seriesId: id,
|
|
96
97
|
dataIndex
|
|
97
98
|
}), {
|
|
98
99
|
style,
|
|
99
|
-
className: classes.root,
|
|
100
100
|
onClick,
|
|
101
101
|
cursor: onClick ? 'pointer' : 'unset'
|
|
102
102
|
}),
|
|
103
|
+
className: classes.root,
|
|
103
104
|
ownerState
|
|
104
105
|
});
|
|
105
106
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Bar, (0, _extends2.default)({}, barProps));
|
package/BarChart/BarPlot.d.ts
CHANGED
|
@@ -17,6 +17,10 @@ export interface BarPlotProps extends Pick<BarElementProps, 'slots' | 'slotProps
|
|
|
17
17
|
* @param {BarItemIdentifier} barItemIdentifier The bar item identifier.
|
|
18
18
|
*/
|
|
19
19
|
onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, barItemIdentifier: BarItemIdentifier) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Defines the border radius of the bar element.
|
|
22
|
+
*/
|
|
23
|
+
borderRadius?: number;
|
|
20
24
|
}
|
|
21
25
|
/**
|
|
22
26
|
* Demos:
|
package/BarChart/BarPlot.js
CHANGED
|
@@ -16,8 +16,10 @@ var _BarElement = require("./BarElement");
|
|
|
16
16
|
var _axis = require("../models/axis");
|
|
17
17
|
var _constants = require("../constants");
|
|
18
18
|
var _getColor = _interopRequireDefault(require("./getColor"));
|
|
19
|
+
var _hooks = require("../hooks");
|
|
20
|
+
var _BarClipPath = require("./BarClipPath");
|
|
19
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
-
const _excluded = ["skipAnimation", "onItemClick"];
|
|
22
|
+
const _excluded = ["skipAnimation", "onItemClick", "borderRadius"];
|
|
21
23
|
/**
|
|
22
24
|
* Solution of the equations
|
|
23
25
|
* W = barWidth * N + offset * (N-1)
|
|
@@ -54,6 +56,7 @@ const useAggregatedData = () => {
|
|
|
54
56
|
seriesOrder: []
|
|
55
57
|
};
|
|
56
58
|
const axisData = React.useContext(_CartesianContextProvider.CartesianContext);
|
|
59
|
+
const chartId = (0, _hooks.useChartId)();
|
|
57
60
|
const {
|
|
58
61
|
series,
|
|
59
62
|
stackingGroups
|
|
@@ -66,6 +69,7 @@ const useAggregatedData = () => {
|
|
|
66
69
|
} = axisData;
|
|
67
70
|
const defaultXAxisId = xAxisIds[0];
|
|
68
71
|
const defaultYAxisId = yAxisIds[0];
|
|
72
|
+
const masks = {};
|
|
69
73
|
const data = stackingGroups.flatMap(({
|
|
70
74
|
ids: groupIds
|
|
71
75
|
}, groupIndex) => {
|
|
@@ -119,7 +123,8 @@ const useAggregatedData = () => {
|
|
|
119
123
|
const valueCoordinates = values.map(v => verticalLayout ? yScale(v) : xScale(v));
|
|
120
124
|
const minValueCoord = Math.round(Math.min(...valueCoordinates));
|
|
121
125
|
const maxValueCoord = Math.round(Math.max(...valueCoordinates));
|
|
122
|
-
|
|
126
|
+
const stackId = series[seriesId].stack;
|
|
127
|
+
const result = {
|
|
123
128
|
seriesId,
|
|
124
129
|
dataIndex,
|
|
125
130
|
layout: series[seriesId].layout,
|
|
@@ -130,14 +135,41 @@ const useAggregatedData = () => {
|
|
|
130
135
|
height: verticalLayout ? maxValueCoord - minValueCoord : barWidth,
|
|
131
136
|
width: verticalLayout ? barWidth : maxValueCoord - minValueCoord,
|
|
132
137
|
color: colorGetter(dataIndex),
|
|
133
|
-
highlightScope: series[seriesId].highlightScope
|
|
138
|
+
highlightScope: series[seriesId].highlightScope,
|
|
139
|
+
value: series[seriesId].data[dataIndex],
|
|
140
|
+
maskId: `${chartId}_${stackId || seriesId}_${groupIndex}_${dataIndex}`
|
|
134
141
|
};
|
|
142
|
+
if (!masks[result.maskId]) {
|
|
143
|
+
masks[result.maskId] = {
|
|
144
|
+
id: result.maskId,
|
|
145
|
+
width: 0,
|
|
146
|
+
height: 0,
|
|
147
|
+
hasNegative: false,
|
|
148
|
+
hasPositive: false,
|
|
149
|
+
layout: result.layout,
|
|
150
|
+
xOrigin: xScale(0),
|
|
151
|
+
yOrigin: yScale(0),
|
|
152
|
+
x: 0,
|
|
153
|
+
y: 0
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
const mask = masks[result.maskId];
|
|
157
|
+
mask.width = result.layout === 'vertical' ? result.width : mask.width + result.width;
|
|
158
|
+
mask.height = result.layout === 'vertical' ? mask.height + result.height : result.height;
|
|
159
|
+
mask.x = Math.min(mask.x === 0 ? Infinity : mask.x, result.x);
|
|
160
|
+
mask.y = Math.min(mask.y === 0 ? Infinity : mask.y, result.y);
|
|
161
|
+
mask.hasNegative = mask.hasNegative || (result.value ?? 0) < 0;
|
|
162
|
+
mask.hasPositive = mask.hasPositive || (result.value ?? 0) > 0;
|
|
163
|
+
return result;
|
|
135
164
|
});
|
|
136
165
|
});
|
|
137
166
|
});
|
|
138
|
-
return
|
|
167
|
+
return {
|
|
168
|
+
completedData: data,
|
|
169
|
+
masksData: Object.values(masks)
|
|
170
|
+
};
|
|
139
171
|
};
|
|
140
|
-
const
|
|
172
|
+
const leaveStyle = ({
|
|
141
173
|
layout,
|
|
142
174
|
yOrigin,
|
|
143
175
|
x,
|
|
@@ -156,7 +188,7 @@ const getOutStyle = ({
|
|
|
156
188
|
height,
|
|
157
189
|
width: 0
|
|
158
190
|
});
|
|
159
|
-
const
|
|
191
|
+
const enterStyle = ({
|
|
160
192
|
x,
|
|
161
193
|
width,
|
|
162
194
|
y,
|
|
@@ -180,41 +212,77 @@ const getInStyle = ({
|
|
|
180
212
|
* - [BarPlot API](https://mui.com/x/api/charts/bar-plot/)
|
|
181
213
|
*/
|
|
182
214
|
function BarPlot(props) {
|
|
183
|
-
const
|
|
215
|
+
const {
|
|
216
|
+
completedData,
|
|
217
|
+
masksData
|
|
218
|
+
} = useAggregatedData();
|
|
184
219
|
const {
|
|
185
220
|
skipAnimation,
|
|
186
|
-
onItemClick
|
|
221
|
+
onItemClick,
|
|
222
|
+
borderRadius
|
|
187
223
|
} = props,
|
|
188
224
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
189
225
|
const transition = (0, _web.useTransition)(completedData, {
|
|
190
226
|
keys: bar => `${bar.seriesId}-${bar.dataIndex}`,
|
|
191
|
-
from:
|
|
192
|
-
leave:
|
|
193
|
-
enter:
|
|
194
|
-
update:
|
|
227
|
+
from: leaveStyle,
|
|
228
|
+
leave: leaveStyle,
|
|
229
|
+
enter: enterStyle,
|
|
230
|
+
update: enterStyle,
|
|
231
|
+
immediate: skipAnimation
|
|
232
|
+
});
|
|
233
|
+
const maskTransition = (0, _web.useTransition)(masksData, {
|
|
234
|
+
keys: v => v.id,
|
|
235
|
+
from: leaveStyle,
|
|
236
|
+
leave: leaveStyle,
|
|
237
|
+
enter: enterStyle,
|
|
238
|
+
update: enterStyle,
|
|
195
239
|
immediate: skipAnimation
|
|
196
240
|
});
|
|
197
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
198
|
-
children:
|
|
241
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
242
|
+
children: [maskTransition((style, {
|
|
243
|
+
id,
|
|
244
|
+
hasPositive,
|
|
245
|
+
hasNegative,
|
|
246
|
+
layout
|
|
247
|
+
}) => {
|
|
248
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_BarClipPath.BarClipPath, {
|
|
249
|
+
maskId: id,
|
|
250
|
+
borderRadius: borderRadius,
|
|
251
|
+
hasNegative: hasNegative,
|
|
252
|
+
hasPositive: hasPositive,
|
|
253
|
+
layout: layout,
|
|
254
|
+
style: style
|
|
255
|
+
});
|
|
256
|
+
}), transition((style, {
|
|
199
257
|
seriesId,
|
|
200
258
|
dataIndex,
|
|
201
259
|
color,
|
|
202
|
-
highlightScope
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
260
|
+
highlightScope,
|
|
261
|
+
maskId
|
|
262
|
+
}) => {
|
|
263
|
+
const barElement = /*#__PURE__*/(0, _jsxRuntime.jsx)(_BarElement.BarElement, (0, _extends2.default)({
|
|
264
|
+
id: seriesId,
|
|
265
|
+
dataIndex: dataIndex,
|
|
266
|
+
color: color,
|
|
267
|
+
highlightScope: highlightScope
|
|
268
|
+
}, other, {
|
|
269
|
+
onClick: onItemClick && (event => {
|
|
270
|
+
onItemClick(event, {
|
|
271
|
+
type: 'bar',
|
|
272
|
+
seriesId,
|
|
273
|
+
dataIndex
|
|
274
|
+
});
|
|
275
|
+
}),
|
|
276
|
+
style: style
|
|
277
|
+
}));
|
|
278
|
+
if (!borderRadius || borderRadius <= 0) {
|
|
279
|
+
return barElement;
|
|
280
|
+
}
|
|
281
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
|
|
282
|
+
clipPath: `url(#${maskId})`,
|
|
283
|
+
children: barElement
|
|
284
|
+
});
|
|
285
|
+
})]
|
|
218
286
|
});
|
|
219
287
|
}
|
|
220
288
|
process.env.NODE_ENV !== "production" ? BarPlot.propTypes = {
|
|
@@ -222,6 +290,10 @@ process.env.NODE_ENV !== "production" ? BarPlot.propTypes = {
|
|
|
222
290
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
223
291
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
224
292
|
// ----------------------------------------------------------------------
|
|
293
|
+
/**
|
|
294
|
+
* Defines the border radius of the bar element.
|
|
295
|
+
*/
|
|
296
|
+
borderRadius: _propTypes.default.number,
|
|
225
297
|
/**
|
|
226
298
|
* Callback fired when a bar item is clicked.
|
|
227
299
|
* @param {React.MouseEvent<SVGElement, MouseEvent>} event The event source of the callback.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type GetRadiusData = {
|
|
2
|
+
hasNegative: boolean;
|
|
3
|
+
hasPositive: boolean;
|
|
4
|
+
borderRadius?: number;
|
|
5
|
+
layout?: 'vertical' | 'horizontal';
|
|
6
|
+
};
|
|
7
|
+
type GetRadiusCorner = 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left';
|
|
8
|
+
/**
|
|
9
|
+
* Returns if the corner should have a radius or not based on the layout and the data.
|
|
10
|
+
* @param {GetRadiusCorner} corner The corner to check.
|
|
11
|
+
* @param {GetRadiusData} cornerData The data for the corner.
|
|
12
|
+
* @returns {number} The radius for the corner.
|
|
13
|
+
*/
|
|
14
|
+
export declare const getRadius: (corner: GetRadiusCorner, { hasNegative, hasPositive, borderRadius, layout }: GetRadiusData) => number;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getRadius = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Returns if the corner should have a radius or not based on the layout and the data.
|
|
9
|
+
* @param {GetRadiusCorner} corner The corner to check.
|
|
10
|
+
* @param {GetRadiusData} cornerData The data for the corner.
|
|
11
|
+
* @returns {number} The radius for the corner.
|
|
12
|
+
*/
|
|
13
|
+
const getRadius = (corner, {
|
|
14
|
+
hasNegative,
|
|
15
|
+
hasPositive,
|
|
16
|
+
borderRadius,
|
|
17
|
+
layout
|
|
18
|
+
}) => {
|
|
19
|
+
if (!borderRadius) {
|
|
20
|
+
return 0;
|
|
21
|
+
}
|
|
22
|
+
const isVertical = layout === 'vertical';
|
|
23
|
+
if (corner === 'top-left' && (isVertical && hasPositive || !isVertical && hasNegative)) {
|
|
24
|
+
return borderRadius;
|
|
25
|
+
}
|
|
26
|
+
if (corner === 'top-right' && (isVertical && hasPositive || !isVertical && hasPositive)) {
|
|
27
|
+
return borderRadius;
|
|
28
|
+
}
|
|
29
|
+
if (corner === 'bottom-right' && (isVertical && hasNegative || !isVertical && hasPositive)) {
|
|
30
|
+
return borderRadius;
|
|
31
|
+
}
|
|
32
|
+
if (corner === 'bottom-left' && (isVertical && hasNegative || !isVertical && hasNegative)) {
|
|
33
|
+
return borderRadius;
|
|
34
|
+
}
|
|
35
|
+
return 0;
|
|
36
|
+
};
|
|
37
|
+
exports.getRadius = getRadius;
|
package/BarChart/legend.js
CHANGED
|
@@ -4,16 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _getLabel = require("../internals/getLabel");
|
|
7
8
|
const legendGetter = params => {
|
|
8
9
|
const {
|
|
9
10
|
seriesOrder,
|
|
10
11
|
series
|
|
11
12
|
} = params;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
return seriesOrder.reduce((acc, seriesId) => {
|
|
14
|
+
const formattedLabel = (0, _getLabel.getLabel)(series[seriesId].label, 'legend');
|
|
15
|
+
if (formattedLabel === undefined) {
|
|
16
|
+
return acc;
|
|
17
|
+
}
|
|
18
|
+
acc.push({
|
|
19
|
+
color: series[seriesId].color,
|
|
20
|
+
label: formattedLabel,
|
|
21
|
+
id: seriesId
|
|
22
|
+
});
|
|
23
|
+
return acc;
|
|
24
|
+
}, []);
|
|
18
25
|
};
|
|
19
26
|
var _default = exports.default = legendGetter;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { HighlightScope } from '../context';
|
|
2
|
+
import type { BarSeriesType } from '../models';
|
|
3
|
+
import type { SeriesId } from '../models/seriesType/common';
|
|
4
|
+
export type AnimationData = {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
yOrigin: number;
|
|
10
|
+
xOrigin: number;
|
|
11
|
+
layout: BarSeriesType['layout'];
|
|
12
|
+
};
|
|
13
|
+
export interface CompletedBarData extends AnimationData {
|
|
14
|
+
seriesId: SeriesId;
|
|
15
|
+
dataIndex: number;
|
|
16
|
+
color: string;
|
|
17
|
+
value: number | null;
|
|
18
|
+
highlightScope?: Partial<HighlightScope>;
|
|
19
|
+
maskId: string;
|
|
20
|
+
}
|
|
21
|
+
export interface MaskData extends AnimationData {
|
|
22
|
+
id: string;
|
|
23
|
+
hasNegative: boolean;
|
|
24
|
+
hasPositive: boolean;
|
|
25
|
+
}
|