react-native-wagmi-charts 2.4.0 → 2.4.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/README.md +1 -1
- package/example/README.md +14 -5
- package/example/src/LineChart.tsx +18 -17
- package/lib/commonjs/charts/line/Highlight.js +16 -26
- package/lib/commonjs/charts/line/Highlight.js.map +1 -1
- package/lib/module/charts/line/Highlight.js +17 -27
- package/lib/module/charts/line/Highlight.js.map +1 -1
- package/lib/typescript/example/src/LineChart.d.ts.map +1 -1
- package/lib/typescript/src/charts/line/Highlight.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/charts/line/Highlight.tsx +20 -23
package/README.md
CHANGED
|
@@ -405,7 +405,7 @@ To achieve this, simply add `<LineChart.HoverTrap />` as the child of your curso
|
|
|
405
405
|
<LineChart.Provider data={data}>
|
|
406
406
|
<LineChart>
|
|
407
407
|
<LineChart.Path color="hotpink" />
|
|
408
|
-
<LineChart.CursorCrosshair color="hotpink"
|
|
408
|
+
<LineChart.CursorCrosshair color="hotpink">
|
|
409
409
|
<LineChart.HoverTrap />
|
|
410
410
|
</LineChart.CursorCrosshair>
|
|
411
411
|
</LineChart>
|
package/example/README.md
CHANGED
|
@@ -2,23 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
## Getting Started
|
|
4
4
|
|
|
5
|
-
First install project dependencies in this directory:
|
|
5
|
+
First install project dependencies in this directory (`yarn` is recommended):
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```bash
|
|
8
|
+
yarn install
|
|
9
|
+
```
|
|
8
10
|
|
|
9
11
|
After dependencies are installed, you can go ahead and run the project on either a simulator, or a real device using the following commands
|
|
10
12
|
|
|
11
13
|
For iOS:
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
```bash
|
|
16
|
+
yarn run ios
|
|
17
|
+
```
|
|
14
18
|
|
|
15
19
|
For Android:
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
```bash
|
|
22
|
+
yarn run android
|
|
23
|
+
```
|
|
18
24
|
|
|
19
25
|
For Web:
|
|
20
26
|
|
|
21
|
-
|
|
27
|
+
```bash
|
|
28
|
+
yarn run web
|
|
29
|
+
```
|
|
22
30
|
|
|
23
31
|
|
|
24
32
|
## Example Charts
|
|
@@ -29,4 +37,5 @@ The following charts are included:
|
|
|
29
37
|
- Line Chart
|
|
30
38
|
|
|
31
39
|
### Sample Data
|
|
40
|
+
|
|
32
41
|
The charts in this example use hardcoded data, which is stored in the `src/data` directory
|
|
@@ -51,6 +51,7 @@ export default function App() {
|
|
|
51
51
|
|
|
52
52
|
const [toggleMinMaxLabels, setToggleMinMaxLabels] = React.useState(false);
|
|
53
53
|
const [toggleSnapToPoint, setToggleSnapToPoint] = React.useState(false);
|
|
54
|
+
const [toggleHighlight, setToggleHighlight] = React.useState(false);
|
|
54
55
|
|
|
55
56
|
let dataProp: TLineChartDataProp = data;
|
|
56
57
|
const [min, max] = useMemo(() => {
|
|
@@ -68,25 +69,22 @@ export default function App() {
|
|
|
68
69
|
|
|
69
70
|
let chart = (
|
|
70
71
|
<LineChart>
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
{partialDay && (
|
|
86
|
-
<LineChart.Dot at={data.length - 1} color="red" hasPulse />
|
|
72
|
+
<LineChart.Path color="black">
|
|
73
|
+
{toggleMinMaxLabels && (
|
|
74
|
+
<>
|
|
75
|
+
<LineChart.Gradient color="black" />
|
|
76
|
+
<LineChart.Tooltip position="top" at={max} />
|
|
77
|
+
<LineChart.Tooltip position="bottom" at={min} yGutter={-10} />
|
|
78
|
+
</>
|
|
79
|
+
)}
|
|
80
|
+
{toggleHighlight && (
|
|
81
|
+
<LineChart.Highlight
|
|
82
|
+
color="red"
|
|
83
|
+
from={Math.floor(data.length / 3)}
|
|
84
|
+
to={Math.floor(data.length * (2/3))}
|
|
85
|
+
/>
|
|
87
86
|
)}
|
|
88
87
|
</LineChart.Path>
|
|
89
|
-
*/}
|
|
90
88
|
<LineChart.CursorCrosshair
|
|
91
89
|
snapToPoint={toggleSnapToPoint}
|
|
92
90
|
onActivated={invokeHaptic}
|
|
@@ -200,6 +198,9 @@ export default function App() {
|
|
|
200
198
|
</Button>
|
|
201
199
|
<Button onPress={toggleMultiData}>{`Multi Data`}</Button>
|
|
202
200
|
<Button onPress={togglePartialDay}>{`Partial Day`}</Button>
|
|
201
|
+
<Button onPress={() => setToggleHighlight((val) => !val)}>
|
|
202
|
+
Toggle highlight
|
|
203
|
+
</Button>
|
|
203
204
|
<Button
|
|
204
205
|
onPress={() => setToggleMinMaxLabels((p) => !p)}
|
|
205
206
|
>{`Toggle min/max labels`}</Button>
|
|
@@ -10,8 +10,7 @@ var _reactNativeSvg = require("react-native-svg");
|
|
|
10
10
|
var _Chart = require("./Chart");
|
|
11
11
|
var _LineChartPathContext = require("./LineChartPathContext");
|
|
12
12
|
var _useAnimatedPath = _interopRequireDefault(require("./useAnimatedPath"));
|
|
13
|
-
var
|
|
14
|
-
var _utils = require("./utils");
|
|
13
|
+
var _getXPositionForCurve = require("./utils/getXPositionForCurve");
|
|
15
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
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); }
|
|
17
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 && Object.prototype.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; }
|
|
@@ -28,14 +27,9 @@ function LineChartHighlight({
|
|
|
28
27
|
...props
|
|
29
28
|
}) {
|
|
30
29
|
const {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const {
|
|
35
|
-
pathWidth,
|
|
36
|
-
height,
|
|
37
|
-
gutter,
|
|
38
|
-
shape
|
|
30
|
+
path,
|
|
31
|
+
parsedPath,
|
|
32
|
+
height
|
|
39
33
|
} = React.useContext(_Chart.LineChartDimensionsContext);
|
|
40
34
|
const {
|
|
41
35
|
isTransitionEnabled,
|
|
@@ -45,21 +39,6 @@ function LineChartHighlight({
|
|
|
45
39
|
|
|
46
40
|
////////////////////////////////////////////////
|
|
47
41
|
|
|
48
|
-
const path = React.useMemo(() => {
|
|
49
|
-
if (data && data.length > 0) {
|
|
50
|
-
return (0, _utils.getPath)({
|
|
51
|
-
data,
|
|
52
|
-
from,
|
|
53
|
-
to,
|
|
54
|
-
width: pathWidth,
|
|
55
|
-
height,
|
|
56
|
-
gutter,
|
|
57
|
-
shape,
|
|
58
|
-
yDomain
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return '';
|
|
62
|
-
}, [data, from, to, pathWidth, height, gutter, shape, yDomain]);
|
|
63
42
|
const {
|
|
64
43
|
animatedProps
|
|
65
44
|
} = (0, _useAnimatedPath.default)({
|
|
@@ -69,7 +48,18 @@ function LineChartHighlight({
|
|
|
69
48
|
|
|
70
49
|
////////////////////////////////////////////////
|
|
71
50
|
|
|
72
|
-
|
|
51
|
+
const clipStart = (0, _getXPositionForCurve.getXPositionForCurve)(parsedPath, from);
|
|
52
|
+
const clipEnd = (0, _getXPositionForCurve.getXPositionForCurve)(parsedPath, to);
|
|
53
|
+
return /*#__PURE__*/React.createElement(_reactNativeSvg.G, null, /*#__PURE__*/React.createElement(_reactNativeSvg.Defs, null, /*#__PURE__*/React.createElement(_reactNativeSvg.ClipPath, {
|
|
54
|
+
id: "clip"
|
|
55
|
+
}, /*#__PURE__*/React.createElement(_reactNativeSvg.Rect, {
|
|
56
|
+
x: clipStart,
|
|
57
|
+
y: "0",
|
|
58
|
+
width: clipEnd - clipStart,
|
|
59
|
+
height: height,
|
|
60
|
+
fill: "white"
|
|
61
|
+
}))), /*#__PURE__*/React.createElement(AnimatedPath, _extends({
|
|
62
|
+
clipPath: "url(#clip)",
|
|
73
63
|
animatedProps: animatedProps,
|
|
74
64
|
fill: "transparent",
|
|
75
65
|
stroke: isInactive ? inactiveColor || color : color,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","_interopRequireWildcard","require","_reactNativeReanimated","_interopRequireDefault","_reactNativeSvg","_Chart","_LineChartPathContext","_useAnimatedPath","
|
|
1
|
+
{"version":3,"names":["React","_interopRequireWildcard","require","_reactNativeReanimated","_interopRequireDefault","_reactNativeSvg","_Chart","_LineChartPathContext","_useAnimatedPath","_getXPositionForCurve","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","AnimatedPath","Animated","createAnimatedComponent","Path","LineChartHighlight","displayName","color","inactiveColor","showInactiveColor","from","to","width","strokeWidth","props","path","parsedPath","height","useContext","LineChartDimensionsContext","isTransitionEnabled","isInactive","_isInactive","LineChartPathContext","animatedProps","useAnimatedPath","enabled","clipStart","getXPositionForCurve","clipEnd","createElement","G","Defs","ClipPath","id","Rect","x","y","fill","clipPath","stroke","strokeOpacity"],"sourceRoot":"../../../../src","sources":["charts/line/Highlight.tsx"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,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;EAEA,MAAMY,SAAS,GAAG,IAAAC,0CAAoB,EAACZ,UAAU,EAAEN,IAAI,CAAC;EACxD,MAAMmB,OAAO,GAAG,IAAAD,0CAAoB,EAACZ,UAAU,EAAEL,EAAE,CAAC;EAEpD,oBACEnD,KAAA,CAAAsE,aAAA,CAACjE,eAAA,CAAAkE,CAAC,qBACAvE,KAAA,CAAAsE,aAAA,CAACjE,eAAA,CAAAmE,IAAI,qBACHxE,KAAA,CAAAsE,aAAA,CAACjE,eAAA,CAAAoE,QAAQ;IAACC,EAAE,EAAC;EAAM,gBACjB1E,KAAA,CAAAsE,aAAA,CAACjE,eAAA,CAAAsE,IAAI;IACHC,CAAC,EAAET,SAAU;IACbU,CAAC,EAAC,GAAG;IACLzB,KAAK,EAAEiB,OAAO,GAAGF,SAAU;IAC3BV,MAAM,EAAEA,MAAO;IACfqB,IAAI,EAAC;EAAO,CACb,CACO,CACN,CAAC,eACP9E,KAAA,CAAAsE,aAAA,CAAC7B,YAAY,EAAAT,QAAA;IACX+C,QAAQ,EAAC,YAAY;IACrBf,aAAa,EAAEA,aAAc;IAC7Bc,IAAI,EAAC,aAAa;IAClBE,MAAM,EAAEnB,UAAU,GAAGb,aAAa,IAAID,KAAK,GAAGA,KAAM;IACpDM,WAAW,EAAEA,WAAY;IACzB4B,aAAa,EAAEpB,UAAU,IAAI,CAACb,aAAa,GAAG,GAAG,GAAG;EAAE,GAClDM,KAAK,CACV,CACA,CAAC;AAER"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import Animated from 'react-native-reanimated';
|
|
4
|
-
import { Path } from 'react-native-svg';
|
|
4
|
+
import { ClipPath, Defs, G, Path, Rect } from 'react-native-svg';
|
|
5
5
|
import { LineChartDimensionsContext } from './Chart';
|
|
6
6
|
import { LineChartPathContext } from './LineChartPathContext';
|
|
7
7
|
import useAnimatedPath from './useAnimatedPath';
|
|
8
|
-
import {
|
|
9
|
-
import { getPath } from './utils';
|
|
8
|
+
import { getXPositionForCurve } from './utils/getXPositionForCurve';
|
|
10
9
|
const AnimatedPath = Animated.createAnimatedComponent(Path);
|
|
11
10
|
LineChartHighlight.displayName = 'LineChartHighlight';
|
|
12
11
|
export function LineChartHighlight({
|
|
@@ -19,14 +18,9 @@ export function LineChartHighlight({
|
|
|
19
18
|
...props
|
|
20
19
|
}) {
|
|
21
20
|
const {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const {
|
|
26
|
-
pathWidth,
|
|
27
|
-
height,
|
|
28
|
-
gutter,
|
|
29
|
-
shape
|
|
21
|
+
path,
|
|
22
|
+
parsedPath,
|
|
23
|
+
height
|
|
30
24
|
} = React.useContext(LineChartDimensionsContext);
|
|
31
25
|
const {
|
|
32
26
|
isTransitionEnabled,
|
|
@@ -36,21 +30,6 @@ export function LineChartHighlight({
|
|
|
36
30
|
|
|
37
31
|
////////////////////////////////////////////////
|
|
38
32
|
|
|
39
|
-
const path = React.useMemo(() => {
|
|
40
|
-
if (data && data.length > 0) {
|
|
41
|
-
return getPath({
|
|
42
|
-
data,
|
|
43
|
-
from,
|
|
44
|
-
to,
|
|
45
|
-
width: pathWidth,
|
|
46
|
-
height,
|
|
47
|
-
gutter,
|
|
48
|
-
shape,
|
|
49
|
-
yDomain
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
return '';
|
|
53
|
-
}, [data, from, to, pathWidth, height, gutter, shape, yDomain]);
|
|
54
33
|
const {
|
|
55
34
|
animatedProps
|
|
56
35
|
} = useAnimatedPath({
|
|
@@ -60,7 +39,18 @@ export function LineChartHighlight({
|
|
|
60
39
|
|
|
61
40
|
////////////////////////////////////////////////
|
|
62
41
|
|
|
63
|
-
|
|
42
|
+
const clipStart = getXPositionForCurve(parsedPath, from);
|
|
43
|
+
const clipEnd = getXPositionForCurve(parsedPath, to);
|
|
44
|
+
return /*#__PURE__*/React.createElement(G, null, /*#__PURE__*/React.createElement(Defs, null, /*#__PURE__*/React.createElement(ClipPath, {
|
|
45
|
+
id: "clip"
|
|
46
|
+
}, /*#__PURE__*/React.createElement(Rect, {
|
|
47
|
+
x: clipStart,
|
|
48
|
+
y: "0",
|
|
49
|
+
width: clipEnd - clipStart,
|
|
50
|
+
height: height,
|
|
51
|
+
fill: "white"
|
|
52
|
+
}))), /*#__PURE__*/React.createElement(AnimatedPath, _extends({
|
|
53
|
+
clipPath: "url(#clip)",
|
|
64
54
|
animatedProps: animatedProps,
|
|
65
55
|
fill: "transparent",
|
|
66
56
|
stroke: isInactive ? inactiveColor || color : color,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Animated","Path","LineChartDimensionsContext","LineChartPathContext","useAnimatedPath","
|
|
1
|
+
{"version":3,"names":["React","Animated","ClipPath","Defs","G","Path","Rect","LineChartDimensionsContext","LineChartPathContext","useAnimatedPath","getXPositionForCurve","AnimatedPath","createAnimatedComponent","LineChartHighlight","displayName","color","inactiveColor","showInactiveColor","from","to","width","strokeWidth","props","path","parsedPath","height","useContext","isTransitionEnabled","isInactive","_isInactive","animatedProps","enabled","clipStart","clipEnd","createElement","id","x","y","fill","_extends","clipPath","stroke","strokeOpacity"],"sourceRoot":"../../../../src","sources":["charts/line/Highlight.tsx"],"mappings":";AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,OAAOC,QAAQ,MAAM,yBAAyB;AAC9C,SAASC,QAAQ,EAAEC,IAAI,EAAEC,CAAC,EAAEC,IAAI,EAAaC,IAAI,QAAQ,kBAAkB;AAE3E,SAASC,0BAA0B,QAAQ,SAAS;AACpD,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,OAAOC,eAAe,MAAM,mBAAmB;AAC/C,SAASC,oBAAo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,CAAAkC,aAAA,CAACvB,YAAY,EAAA4B,QAAA;IACXC,QAAQ,EAAC,YAAY;IACrBV,aAAa,EAAEA,aAAc;IAC7BQ,IAAI,EAAC,aAAa;IAClBG,MAAM,EAAEb,UAAU,GAAGZ,aAAa,IAAID,KAAK,GAAGA,KAAM;IACpDM,WAAW,EAAEA,WAAY;IACzBqB,aAAa,EAAEd,UAAU,IAAI,CAACZ,aAAa,GAAG,GAAG,GAAG;EAAE,GAClDM,KAAK,CACV,CACA,CAAC;AAER"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../example/src/LineChart.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAsB/B,MAAM,CAAC,OAAO,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../example/src/LineChart.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAsB/B,MAAM,CAAC,OAAO,UAAU,GAAG,sBAqP1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Highlight.d.ts","sourceRoot":"","sources":["../../../../../src/charts/line/Highlight.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"Highlight.d.ts","sourceRoot":"","sources":["../../../../../src/charts/line/Highlight.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAA2B,SAAS,EAAQ,MAAM,kBAAkB,CAAC;AAS5E,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAIF,wBAAgB,kBAAkB,CAAC,EACjC,KAAe,EACf,aAAa,EACb,iBAAwB,EACxB,IAAI,EACJ,EAAE,EACF,KAAK,EAAE,WAAe,EACtB,GAAG,KAAK,EACT,EAAE,mBAAmB,qBA4CrB;yBApDe,kBAAkB"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import Animated from 'react-native-reanimated';
|
|
3
|
-
import { Path, PathProps } from 'react-native-svg';
|
|
3
|
+
import { ClipPath, Defs, G, Path, PathProps, Rect } from 'react-native-svg';
|
|
4
4
|
|
|
5
5
|
import { LineChartDimensionsContext } from './Chart';
|
|
6
6
|
import { LineChartPathContext } from './LineChartPathContext';
|
|
7
7
|
import useAnimatedPath from './useAnimatedPath';
|
|
8
|
-
import {
|
|
9
|
-
import { getPath } from './utils';
|
|
8
|
+
import { getXPositionForCurve } from './utils/getXPositionForCurve';
|
|
10
9
|
|
|
11
10
|
const AnimatedPath = Animated.createAnimatedComponent(Path);
|
|
12
11
|
|
|
@@ -30,8 +29,7 @@ export function LineChartHighlight({
|
|
|
30
29
|
width: strokeWidth = 3,
|
|
31
30
|
...props
|
|
32
31
|
}: LineChartColorProps) {
|
|
33
|
-
const {
|
|
34
|
-
const { pathWidth, height, gutter, shape } = React.useContext(
|
|
32
|
+
const { path, parsedPath, height } = React.useContext(
|
|
35
33
|
LineChartDimensionsContext
|
|
36
34
|
);
|
|
37
35
|
const { isTransitionEnabled, isInactive: _isInactive } =
|
|
@@ -40,22 +38,6 @@ export function LineChartHighlight({
|
|
|
40
38
|
|
|
41
39
|
////////////////////////////////////////////////
|
|
42
40
|
|
|
43
|
-
const path = React.useMemo(() => {
|
|
44
|
-
if (data && data.length > 0) {
|
|
45
|
-
return getPath({
|
|
46
|
-
data,
|
|
47
|
-
from,
|
|
48
|
-
to,
|
|
49
|
-
width: pathWidth,
|
|
50
|
-
height,
|
|
51
|
-
gutter,
|
|
52
|
-
shape,
|
|
53
|
-
yDomain,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
return '';
|
|
57
|
-
}, [data, from, to, pathWidth, height, gutter, shape, yDomain]);
|
|
58
|
-
|
|
59
41
|
const { animatedProps } = useAnimatedPath({
|
|
60
42
|
enabled: isTransitionEnabled,
|
|
61
43
|
path,
|
|
@@ -63,9 +45,24 @@ export function LineChartHighlight({
|
|
|
63
45
|
|
|
64
46
|
////////////////////////////////////////////////
|
|
65
47
|
|
|
48
|
+
const clipStart = getXPositionForCurve(parsedPath, from);
|
|
49
|
+
const clipEnd = getXPositionForCurve(parsedPath, to);
|
|
50
|
+
|
|
66
51
|
return (
|
|
67
|
-
|
|
52
|
+
<G>
|
|
53
|
+
<Defs>
|
|
54
|
+
<ClipPath id="clip">
|
|
55
|
+
<Rect
|
|
56
|
+
x={clipStart}
|
|
57
|
+
y="0"
|
|
58
|
+
width={clipEnd - clipStart}
|
|
59
|
+
height={height}
|
|
60
|
+
fill="white"
|
|
61
|
+
/>
|
|
62
|
+
</ClipPath>
|
|
63
|
+
</Defs>
|
|
68
64
|
<AnimatedPath
|
|
65
|
+
clipPath="url(#clip)"
|
|
69
66
|
animatedProps={animatedProps}
|
|
70
67
|
fill="transparent"
|
|
71
68
|
stroke={isInactive ? inactiveColor || color : color}
|
|
@@ -73,6 +70,6 @@ export function LineChartHighlight({
|
|
|
73
70
|
strokeOpacity={isInactive && !inactiveColor ? 0.5 : 1}
|
|
74
71
|
{...props}
|
|
75
72
|
/>
|
|
76
|
-
|
|
73
|
+
</G>
|
|
77
74
|
);
|
|
78
75
|
}
|