@mui/x-charts 6.0.0-alpha.8 → 6.0.0-alpha.9
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 +59 -1
- package/LineChart/AreaElement.d.ts +1 -1
- package/LineChart/LineChart.d.ts +7 -2
- package/LineChart/LineChart.js +14 -2
- package/LineChart/LineElement.d.ts +1 -1
- package/LineChart/LineHighlightElement.d.ts +21 -0
- package/LineChart/LineHighlightElement.js +79 -0
- package/LineChart/LineHighlightPlot.d.ts +25 -0
- package/LineChart/LineHighlightPlot.js +99 -0
- package/LineChart/MarkElement.d.ts +1 -1
- package/LineChart/MarkElement.js +1 -4
- package/LineChart/MarkPlot.js +27 -11
- package/LineChart/index.d.ts +2 -0
- package/LineChart/index.js +20 -0
- package/PieChart/PieArc.d.ts +1 -1
- package/PieChart/PieArcLabel.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.d.ts +3 -2
- package/SparkLineChart/SparkLineChart.js +6 -11
- package/esm/LineChart/LineChart.js +14 -2
- package/esm/LineChart/LineHighlightElement.js +68 -0
- package/esm/LineChart/LineHighlightPlot.js +92 -0
- package/esm/LineChart/MarkElement.js +1 -4
- package/esm/LineChart/MarkPlot.js +27 -11
- package/esm/LineChart/index.js +3 -1
- package/esm/SparkLineChart/SparkLineChart.js +7 -12
- package/index.js +1 -1
- package/internals/defaultizeColor.d.ts +2 -0
- package/legacy/LineChart/LineChart.js +14 -2
- package/legacy/LineChart/LineHighlightElement.js +67 -0
- package/legacy/LineChart/LineHighlightPlot.js +85 -0
- package/legacy/LineChart/MarkElement.js +1 -4
- package/legacy/LineChart/MarkPlot.js +19 -4
- package/legacy/LineChart/index.js +3 -1
- package/legacy/SparkLineChart/SparkLineChart.js +7 -10
- package/legacy/index.js +1 -1
- package/models/seriesType/line.d.ts +33 -0
- package/modern/LineChart/LineChart.js +14 -2
- package/modern/LineChart/LineHighlightElement.js +68 -0
- package/modern/LineChart/LineHighlightPlot.js +91 -0
- package/modern/LineChart/MarkElement.js +1 -4
- package/modern/LineChart/MarkPlot.js +27 -11
- package/modern/LineChart/index.js +3 -1
- package/modern/SparkLineChart/SparkLineChart.js +7 -12
- package/modern/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
2
|
import * as React from 'react';
|
|
4
3
|
import PropTypes from 'prop-types';
|
|
5
|
-
import { styled } from '@mui/material/styles';
|
|
6
4
|
import { BarPlot } from '../BarChart';
|
|
7
|
-
import { LinePlot,
|
|
5
|
+
import { LinePlot, AreaPlot, LineHighlightPlot } from '../LineChart';
|
|
8
6
|
import { ResponsiveChartContainer } from '../ResponsiveChartContainer';
|
|
9
7
|
import { DEFAULT_X_AXIS_KEY } from '../constants';
|
|
10
8
|
import { ChartsTooltip } from '../ChartsTooltip';
|
|
11
9
|
import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
12
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
var SparkLineMarkPlot = styled(MarkPlot)(_defineProperty({}, "& .".concat(markElementClasses.root), _defineProperty({
|
|
15
|
-
display: 'none'
|
|
16
|
-
}, "&.".concat(markElementClasses.highlighted), {
|
|
17
|
-
display: 'inherit'
|
|
18
|
-
})));
|
|
19
12
|
var SPARKLINE_DEFAULT_MARGIN = {
|
|
20
13
|
top: 5,
|
|
21
14
|
bottom: 5,
|
|
@@ -61,7 +54,8 @@ var SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(props
|
|
|
61
54
|
valueFormatter: valueFormatter
|
|
62
55
|
}, plotType === 'bar' ? {} : {
|
|
63
56
|
area: area,
|
|
64
|
-
curve: curve
|
|
57
|
+
curve: curve,
|
|
58
|
+
disableHighlight: !showHighlight
|
|
65
59
|
})],
|
|
66
60
|
width: width,
|
|
67
61
|
height: height,
|
|
@@ -89,7 +83,10 @@ var SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(props
|
|
|
89
83
|
}), /*#__PURE__*/_jsx(LinePlot, {
|
|
90
84
|
slots: slots,
|
|
91
85
|
slotProps: slotProps
|
|
92
|
-
}),
|
|
86
|
+
}), /*#__PURE__*/_jsx(LineHighlightPlot, {
|
|
87
|
+
slots: slots,
|
|
88
|
+
slotProps: slotProps
|
|
89
|
+
})]
|
|
93
90
|
}), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), showTooltip && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip)), children]
|
|
94
91
|
});
|
|
95
92
|
});
|
package/legacy/index.js
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import { DefaultizedProps } from '../helpers';
|
|
2
2
|
import { CartesianSeriesType, CommonDefaultizedProps, CommonSeriesType, StackableSeriesType } from './common';
|
|
3
3
|
export type CurveType = 'catmullRom' | 'linear' | 'monotoneX' | 'monotoneY' | 'natural' | 'step' | 'stepBefore' | 'stepAfter';
|
|
4
|
+
export interface ShowMarkParams {
|
|
5
|
+
/**
|
|
6
|
+
* The item index.
|
|
7
|
+
*/
|
|
8
|
+
index: number;
|
|
9
|
+
/**
|
|
10
|
+
* The x coordinate in the SVG.
|
|
11
|
+
*/
|
|
12
|
+
x: number;
|
|
13
|
+
/**
|
|
14
|
+
* The y coordinate in the SVG.
|
|
15
|
+
*/
|
|
16
|
+
y: number;
|
|
17
|
+
/**
|
|
18
|
+
* The item position value. It likely comes from the axis `data` property.
|
|
19
|
+
*/
|
|
20
|
+
position: number | Date;
|
|
21
|
+
/**
|
|
22
|
+
* The item value. It comes from the series `data` property.
|
|
23
|
+
*/
|
|
24
|
+
value: number;
|
|
25
|
+
}
|
|
4
26
|
export interface LineSeriesType extends CommonSeriesType<number>, CartesianSeriesType, StackableSeriesType {
|
|
5
27
|
type: 'line';
|
|
6
28
|
/**
|
|
@@ -15,6 +37,17 @@ export interface LineSeriesType extends CommonSeriesType<number>, CartesianSerie
|
|
|
15
37
|
area?: boolean;
|
|
16
38
|
label?: string;
|
|
17
39
|
curve?: CurveType;
|
|
40
|
+
/**
|
|
41
|
+
* Define which items of the series should display a mark.
|
|
42
|
+
* If can be a boolean that applies to all items.
|
|
43
|
+
* Or a callback that gets some item properties and returns true if the item should be displayed.
|
|
44
|
+
*/
|
|
45
|
+
showMark?: boolean | ((params: ShowMarkParams) => boolean);
|
|
46
|
+
/**
|
|
47
|
+
* Do not render the line highlight item if set to `true`.
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
50
|
+
disableHighlight?: boolean;
|
|
18
51
|
}
|
|
19
52
|
/**
|
|
20
53
|
* An object that allows to identify a single line.
|
|
@@ -12,6 +12,7 @@ import { ChartsTooltip } from '../ChartsTooltip';
|
|
|
12
12
|
import { ChartsLegend } from '../ChartsLegend';
|
|
13
13
|
import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
14
14
|
import { ChartsClipPath } from '../ChartsClipPath';
|
|
15
|
+
import { LineHighlightPlot } from './LineHighlightPlot';
|
|
15
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
17
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
18
|
const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
@@ -29,6 +30,7 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
29
30
|
axisHighlight = {
|
|
30
31
|
x: 'line'
|
|
31
32
|
},
|
|
33
|
+
disableLineItemHighlight,
|
|
32
34
|
legend,
|
|
33
35
|
topAxis,
|
|
34
36
|
leftAxis,
|
|
@@ -43,6 +45,7 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
43
45
|
return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
|
|
44
46
|
ref: ref,
|
|
45
47
|
series: series.map(s => _extends({
|
|
48
|
+
disableHighlight: !!disableLineItemHighlight,
|
|
46
49
|
type: 'line'
|
|
47
50
|
}, s)),
|
|
48
51
|
width: width,
|
|
@@ -76,13 +79,16 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
76
79
|
bottomAxis: bottomAxis,
|
|
77
80
|
slots: slots,
|
|
78
81
|
slotProps: slotProps
|
|
79
|
-
}), /*#__PURE__*/_jsx(MarkPlot, {
|
|
82
|
+
}), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), /*#__PURE__*/_jsx(MarkPlot, {
|
|
83
|
+
slots: slots,
|
|
84
|
+
slotProps: slotProps
|
|
85
|
+
}), /*#__PURE__*/_jsx(LineHighlightPlot, {
|
|
80
86
|
slots: slots,
|
|
81
87
|
slotProps: slotProps
|
|
82
88
|
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
83
89
|
slots: slots,
|
|
84
90
|
slotProps: slotProps
|
|
85
|
-
})), /*#__PURE__*/_jsx(
|
|
91
|
+
})), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, {
|
|
86
92
|
id: clipPathId
|
|
87
93
|
}), children]
|
|
88
94
|
});
|
|
@@ -128,6 +134,10 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
128
134
|
dataset: PropTypes.arrayOf(PropTypes.object),
|
|
129
135
|
desc: PropTypes.string,
|
|
130
136
|
disableAxisListener: PropTypes.bool,
|
|
137
|
+
/**
|
|
138
|
+
* If `true`, render the line highlight item.
|
|
139
|
+
*/
|
|
140
|
+
disableLineItemHighlight: PropTypes.bool,
|
|
131
141
|
height: PropTypes.number,
|
|
132
142
|
/**
|
|
133
143
|
* Indicate which axis to display the left of the charts.
|
|
@@ -205,12 +215,14 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
205
215
|
curve: PropTypes.oneOf(['catmullRom', 'linear', 'monotoneX', 'monotoneY', 'natural', 'step', 'stepAfter', 'stepBefore']),
|
|
206
216
|
data: PropTypes.arrayOf(PropTypes.number),
|
|
207
217
|
dataKey: PropTypes.string,
|
|
218
|
+
disableHighlight: PropTypes.bool,
|
|
208
219
|
highlightScope: PropTypes.shape({
|
|
209
220
|
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
210
221
|
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
211
222
|
}),
|
|
212
223
|
id: PropTypes.string,
|
|
213
224
|
label: PropTypes.string,
|
|
225
|
+
showMark: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
|
|
214
226
|
stack: PropTypes.string,
|
|
215
227
|
stackOffset: PropTypes.oneOf(['diverging', 'expand', 'none', 'silhouette', 'wiggle']),
|
|
216
228
|
stackOrder: PropTypes.oneOf(['appearance', 'ascending', 'descending', 'insideOut', 'none', 'reverse']),
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["x", "y", "id", "classes", "color"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
7
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
8
|
+
import { styled } from '@mui/material/styles';
|
|
9
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
export function getHighlightElementUtilityClass(slot) {
|
|
12
|
+
return generateUtilityClass('MuiHighlightElement', slot);
|
|
13
|
+
}
|
|
14
|
+
export const lineHighlightElementClasses = generateUtilityClasses('MuiHighlightElement', ['root']);
|
|
15
|
+
const useUtilityClasses = ownerState => {
|
|
16
|
+
const {
|
|
17
|
+
classes,
|
|
18
|
+
id
|
|
19
|
+
} = ownerState;
|
|
20
|
+
const slots = {
|
|
21
|
+
root: ['root', `series-${id}`]
|
|
22
|
+
};
|
|
23
|
+
return composeClasses(slots, getHighlightElementUtilityClass, classes);
|
|
24
|
+
};
|
|
25
|
+
const HighlightElement = styled('circle', {
|
|
26
|
+
name: 'MuiHighlightElement',
|
|
27
|
+
slot: 'Root',
|
|
28
|
+
overridesResolver: (_, styles) => styles.root
|
|
29
|
+
})(({
|
|
30
|
+
ownerState
|
|
31
|
+
}) => ({
|
|
32
|
+
transform: `translate(${ownerState.x}px, ${ownerState.y}px)`,
|
|
33
|
+
transformOrigin: `${ownerState.x}px ${ownerState.y}px`,
|
|
34
|
+
fill: ownerState.color
|
|
35
|
+
}));
|
|
36
|
+
function LineHighlightElement(props) {
|
|
37
|
+
const {
|
|
38
|
+
x,
|
|
39
|
+
y,
|
|
40
|
+
id,
|
|
41
|
+
classes: innerClasses,
|
|
42
|
+
color
|
|
43
|
+
} = props,
|
|
44
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
45
|
+
const ownerState = {
|
|
46
|
+
id,
|
|
47
|
+
classes: innerClasses,
|
|
48
|
+
color,
|
|
49
|
+
x,
|
|
50
|
+
y
|
|
51
|
+
};
|
|
52
|
+
const classes = useUtilityClasses(ownerState);
|
|
53
|
+
return /*#__PURE__*/_jsx(HighlightElement, _extends({}, other, {
|
|
54
|
+
ownerState: ownerState,
|
|
55
|
+
className: classes.root,
|
|
56
|
+
cx: 0,
|
|
57
|
+
cy: 0,
|
|
58
|
+
r: other.r === undefined ? 5 : other.r
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
process.env.NODE_ENV !== "production" ? LineHighlightElement.propTypes = {
|
|
62
|
+
// ----------------------------- Warning --------------------------------
|
|
63
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
64
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
65
|
+
// ----------------------------------------------------------------------
|
|
66
|
+
classes: PropTypes.object
|
|
67
|
+
} : void 0;
|
|
68
|
+
export { LineHighlightElement };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["slots", "slotProps"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
7
|
+
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
8
|
+
import { LineHighlightElement } from './LineHighlightElement';
|
|
9
|
+
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
10
|
+
import { InteractionContext } from '../context/InteractionProvider';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
function LineHighlightPlot(props) {
|
|
13
|
+
const {
|
|
14
|
+
slots,
|
|
15
|
+
slotProps
|
|
16
|
+
} = props,
|
|
17
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
18
|
+
const seriesData = React.useContext(SeriesContext).line;
|
|
19
|
+
const axisData = React.useContext(CartesianContext);
|
|
20
|
+
const {
|
|
21
|
+
axis
|
|
22
|
+
} = React.useContext(InteractionContext);
|
|
23
|
+
const highlightedIndex = axis.x?.index;
|
|
24
|
+
if (highlightedIndex === undefined) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
if (seriesData === undefined) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const {
|
|
31
|
+
series,
|
|
32
|
+
stackingGroups
|
|
33
|
+
} = seriesData;
|
|
34
|
+
const {
|
|
35
|
+
xAxis,
|
|
36
|
+
yAxis,
|
|
37
|
+
xAxisIds,
|
|
38
|
+
yAxisIds
|
|
39
|
+
} = axisData;
|
|
40
|
+
const defaultXAxisId = xAxisIds[0];
|
|
41
|
+
const defaultYAxisId = yAxisIds[0];
|
|
42
|
+
const Element = slots?.lineHighlight ?? LineHighlightElement;
|
|
43
|
+
return /*#__PURE__*/_jsx("g", _extends({}, other, {
|
|
44
|
+
children: stackingGroups.flatMap(({
|
|
45
|
+
ids: groupIds
|
|
46
|
+
}) => {
|
|
47
|
+
return groupIds.flatMap(seriesId => {
|
|
48
|
+
const {
|
|
49
|
+
xAxisKey = defaultXAxisId,
|
|
50
|
+
yAxisKey = defaultYAxisId,
|
|
51
|
+
stackedData,
|
|
52
|
+
disableHighlight
|
|
53
|
+
} = series[seriesId];
|
|
54
|
+
if (disableHighlight) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
58
|
+
const yScale = yAxis[yAxisKey].scale;
|
|
59
|
+
const xData = xAxis[xAxisKey].data;
|
|
60
|
+
if (xData === undefined) {
|
|
61
|
+
throw new Error(`Axis of id "${xAxisKey}" should have data property to be able to display a line plot.`);
|
|
62
|
+
}
|
|
63
|
+
const x = xScale(xData[highlightedIndex]);
|
|
64
|
+
const y = yScale(stackedData[highlightedIndex][1]);
|
|
65
|
+
return /*#__PURE__*/_jsx(Element, _extends({
|
|
66
|
+
id: seriesId,
|
|
67
|
+
color: series[seriesId].color,
|
|
68
|
+
x: x,
|
|
69
|
+
y: y
|
|
70
|
+
}, slotProps?.lineHighlight), `${seriesId}`);
|
|
71
|
+
});
|
|
72
|
+
})
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
process.env.NODE_ENV !== "production" ? LineHighlightPlot.propTypes = {
|
|
76
|
+
// ----------------------------- Warning --------------------------------
|
|
77
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
78
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
79
|
+
// ----------------------------------------------------------------------
|
|
80
|
+
/**
|
|
81
|
+
* The props used for each component slot.
|
|
82
|
+
* @default {}
|
|
83
|
+
*/
|
|
84
|
+
slotProps: PropTypes.object,
|
|
85
|
+
/**
|
|
86
|
+
* Overridable component slots.
|
|
87
|
+
* @default {}
|
|
88
|
+
*/
|
|
89
|
+
slots: PropTypes.object
|
|
90
|
+
} : void 0;
|
|
91
|
+
export { LineHighlightPlot };
|
|
@@ -40,10 +40,7 @@ const MarkElementPath = styled('path', {
|
|
|
40
40
|
transformOrigin: `${ownerState.x}px ${ownerState.y}px`,
|
|
41
41
|
fill: theme.palette.background.paper,
|
|
42
42
|
stroke: ownerState.color,
|
|
43
|
-
strokeWidth: 2
|
|
44
|
-
'&.MuiMarkElement-highlighted': {
|
|
45
|
-
fill: ownerState.color
|
|
46
|
-
}
|
|
43
|
+
strokeWidth: 2
|
|
47
44
|
}));
|
|
48
45
|
MarkElementPath.propTypes = {
|
|
49
46
|
// ----------------------------- Warning --------------------------------
|
|
@@ -40,8 +40,12 @@ function MarkPlot(props) {
|
|
|
40
40
|
const {
|
|
41
41
|
xAxisKey = defaultXAxisId,
|
|
42
42
|
yAxisKey = defaultYAxisId,
|
|
43
|
-
stackedData
|
|
43
|
+
stackedData,
|
|
44
|
+
showMark = true
|
|
44
45
|
} = series[seriesId];
|
|
46
|
+
if (showMark === false) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
45
49
|
const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
46
50
|
const yScale = yAxis[yAxisKey].scale;
|
|
47
51
|
const xData = xAxis[xAxisKey].data;
|
|
@@ -67,21 +71,33 @@ function MarkPlot(props) {
|
|
|
67
71
|
return {
|
|
68
72
|
x: xScale(x),
|
|
69
73
|
y: yScale(y),
|
|
74
|
+
position: x,
|
|
75
|
+
value: y,
|
|
70
76
|
index
|
|
71
77
|
};
|
|
72
78
|
}).filter(isInRange).map(({
|
|
73
79
|
x,
|
|
74
80
|
y,
|
|
75
|
-
index
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
index,
|
|
82
|
+
position,
|
|
83
|
+
value
|
|
84
|
+
}) => {
|
|
85
|
+
return showMark === true || showMark({
|
|
86
|
+
x,
|
|
87
|
+
y,
|
|
88
|
+
index,
|
|
89
|
+
position,
|
|
90
|
+
value
|
|
91
|
+
}) ? /*#__PURE__*/_jsx(Mark, _extends({
|
|
92
|
+
id: seriesId,
|
|
93
|
+
dataIndex: index,
|
|
94
|
+
shape: "circle",
|
|
95
|
+
color: series[seriesId].color,
|
|
96
|
+
x: x,
|
|
97
|
+
y: y,
|
|
98
|
+
highlightScope: series[seriesId].highlightScope
|
|
99
|
+
}, slotProps?.mark), `${seriesId}-${index}`) : null;
|
|
100
|
+
});
|
|
85
101
|
});
|
|
86
102
|
})
|
|
87
103
|
}));
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { LinePlot } from './LinePlot';
|
|
2
2
|
export { AreaPlot } from './AreaPlot';
|
|
3
3
|
export { MarkPlot } from './MarkPlot';
|
|
4
|
+
export { LineHighlightPlot } from './LineHighlightPlot';
|
|
4
5
|
export { LineChart } from './LineChart';
|
|
5
6
|
export * from './AreaElement';
|
|
6
7
|
export * from './LineElement';
|
|
7
|
-
export * from './MarkElement';
|
|
8
|
+
export * from './MarkElement';
|
|
9
|
+
export * from './LineHighlightElement';
|
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import { styled } from '@mui/material/styles';
|
|
5
4
|
import { BarPlot } from '../BarChart';
|
|
6
|
-
import { LinePlot,
|
|
5
|
+
import { LinePlot, AreaPlot, LineHighlightPlot } from '../LineChart';
|
|
7
6
|
import { ResponsiveChartContainer } from '../ResponsiveChartContainer';
|
|
8
7
|
import { DEFAULT_X_AXIS_KEY } from '../constants';
|
|
9
8
|
import { ChartsTooltip } from '../ChartsTooltip';
|
|
10
9
|
import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
11
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
const SparkLineMarkPlot = styled(MarkPlot)({
|
|
14
|
-
[`& .${markElementClasses.root}`]: {
|
|
15
|
-
display: 'none',
|
|
16
|
-
[`&.${markElementClasses.highlighted}`]: {
|
|
17
|
-
display: 'inherit'
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
12
|
const SPARKLINE_DEFAULT_MARGIN = {
|
|
22
13
|
top: 5,
|
|
23
14
|
bottom: 5,
|
|
@@ -59,7 +50,8 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
|
|
|
59
50
|
valueFormatter
|
|
60
51
|
}, plotType === 'bar' ? {} : {
|
|
61
52
|
area,
|
|
62
|
-
curve
|
|
53
|
+
curve,
|
|
54
|
+
disableHighlight: !showHighlight
|
|
63
55
|
})],
|
|
64
56
|
width: width,
|
|
65
57
|
height: height,
|
|
@@ -85,7 +77,10 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
|
|
|
85
77
|
}), /*#__PURE__*/_jsx(LinePlot, {
|
|
86
78
|
slots: slots,
|
|
87
79
|
slotProps: slotProps
|
|
88
|
-
}),
|
|
80
|
+
}), /*#__PURE__*/_jsx(LineHighlightPlot, {
|
|
81
|
+
slots: slots,
|
|
82
|
+
slotProps: slotProps
|
|
83
|
+
})]
|
|
89
84
|
}), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), showTooltip && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip)), children]
|
|
90
85
|
});
|
|
91
86
|
});
|
package/modern/index.js
CHANGED