@semcore/d3-chart 1.0.0-8 → 1.2.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/CHANGELOG.md +62 -0
- package/lib/cjs/Area.js +71 -49
- package/lib/cjs/Area.js.map +1 -1
- package/lib/cjs/Axis.js +148 -142
- package/lib/cjs/Axis.js.map +1 -1
- package/lib/cjs/Bar.js +101 -54
- package/lib/cjs/Bar.js.map +1 -1
- package/lib/cjs/ClipPath.js +110 -0
- package/lib/cjs/ClipPath.js.map +1 -0
- package/lib/cjs/Donut.js +169 -68
- package/lib/cjs/Donut.js.map +1 -1
- package/lib/cjs/Dots.js +55 -21
- package/lib/cjs/Dots.js.map +1 -1
- package/lib/cjs/GroupBar.js +7 -6
- package/lib/cjs/GroupBar.js.map +1 -1
- package/lib/cjs/HorizontalBar.js +72 -45
- package/lib/cjs/HorizontalBar.js.map +1 -1
- package/lib/cjs/Hover.js +46 -47
- package/lib/cjs/Hover.js.map +1 -1
- package/lib/cjs/Line.js +63 -41
- package/lib/cjs/Line.js.map +1 -1
- package/lib/cjs/Plot.js +16 -29
- package/lib/cjs/Plot.js.map +1 -1
- package/lib/cjs/ResponsiveContainer.js +13 -9
- package/lib/cjs/ResponsiveContainer.js.map +1 -1
- package/lib/cjs/StackBar.js +6 -6
- package/lib/cjs/StackBar.js.map +1 -1
- package/lib/cjs/StackedArea.js +8 -9
- package/lib/cjs/StackedArea.js.map +1 -1
- package/lib/cjs/Tooltip.js +49 -75
- package/lib/cjs/Tooltip.js.map +1 -1
- package/lib/cjs/Venn.js +235 -0
- package/lib/cjs/Venn.js.map +1 -0
- package/lib/cjs/index.js +8 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/area.shadow.css +11 -10
- package/lib/cjs/style/bar.shadow.css +4 -0
- package/lib/cjs/style/donut.shadow.css +1 -0
- package/lib/cjs/style/dot.shadow.css +19 -0
- package/lib/cjs/style/line.shadow.css +4 -15
- package/lib/cjs/style/tooltip.shadow.css +1 -0
- package/lib/cjs/style/venn.shadow.css +23 -0
- package/lib/cjs/utils.js +8 -1
- package/lib/cjs/utils.js.map +1 -1
- package/lib/es6/Area.js +72 -50
- package/lib/es6/Area.js.map +1 -1
- package/lib/es6/Axis.js +149 -143
- package/lib/es6/Axis.js.map +1 -1
- package/lib/es6/Bar.js +100 -54
- package/lib/es6/Bar.js.map +1 -1
- package/lib/es6/ClipPath.js +91 -0
- package/lib/es6/ClipPath.js.map +1 -0
- package/lib/es6/Donut.js +167 -67
- package/lib/es6/Donut.js.map +1 -1
- package/lib/es6/Dots.js +51 -20
- package/lib/es6/Dots.js.map +1 -1
- package/lib/es6/GroupBar.js +7 -6
- package/lib/es6/GroupBar.js.map +1 -1
- package/lib/es6/HorizontalBar.js +72 -45
- package/lib/es6/HorizontalBar.js.map +1 -1
- package/lib/es6/Hover.js +47 -48
- package/lib/es6/Hover.js.map +1 -1
- package/lib/es6/Line.js +65 -43
- package/lib/es6/Line.js.map +1 -1
- package/lib/es6/Plot.js +17 -29
- package/lib/es6/Plot.js.map +1 -1
- package/lib/es6/ResponsiveContainer.js +13 -7
- package/lib/es6/ResponsiveContainer.js.map +1 -1
- package/lib/es6/StackBar.js +6 -6
- package/lib/es6/StackBar.js.map +1 -1
- package/lib/es6/StackedArea.js +8 -9
- package/lib/es6/StackedArea.js.map +1 -1
- package/lib/es6/Tooltip.js +52 -76
- package/lib/es6/Tooltip.js.map +1 -1
- package/lib/es6/Venn.js +217 -0
- package/lib/es6/Venn.js.map +1 -0
- package/lib/es6/index.js +1 -0
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/style/area.shadow.css +11 -10
- package/lib/es6/style/bar.shadow.css +4 -0
- package/lib/es6/style/donut.shadow.css +1 -0
- package/lib/es6/style/dot.shadow.css +19 -0
- package/lib/es6/style/line.shadow.css +4 -15
- package/lib/es6/style/tooltip.shadow.css +1 -0
- package/lib/es6/style/venn.shadow.css +23 -0
- package/lib/es6/utils.js +6 -1
- package/lib/es6/utils.js.map +1 -1
- package/lib/types/Area.d.ts +7 -8
- package/lib/types/Axis.d.ts +6 -6
- package/lib/types/Bar.d.ts +7 -3
- package/lib/types/ClipPath.d.ts +26 -0
- package/lib/types/Donut.d.ts +12 -2
- package/lib/types/GroupBar.d.ts +2 -2
- package/lib/types/HorizontalBar.d.ts +7 -3
- package/lib/types/Hover.d.ts +2 -2
- package/lib/types/Line.d.ts +9 -4
- package/{src/types/Plot.ts → lib/types/Plot.d.ts} +2 -2
- package/lib/types/ResponsiveContainer.d.ts +1 -1
- package/lib/types/StackBar.d.ts +3 -11
- package/lib/types/StackedArea.d.ts +7 -6
- package/lib/types/Tooltip.d.ts +4 -4
- package/lib/types/Venn.d.ts +45 -0
- package/lib/types/context.d.ts +1 -1
- package/lib/types/index.d.ts +6 -0
- package/package.json +10 -5
- package/src/Area.js +43 -14
- package/src/Axis.js +24 -22
- package/src/Bar.js +69 -24
- package/src/ClipPath.js +36 -0
- package/src/Donut.js +84 -12
- package/src/Dots.js +36 -20
- package/src/GroupBar.js +1 -0
- package/src/HorizontalBar.js +49 -22
- package/src/Hover.js +3 -3
- package/src/Line.js +41 -13
- package/src/Plot.js +3 -7
- package/src/ResponsiveContainer.js +3 -3
- package/src/StackBar.js +1 -1
- package/src/StackedArea.js +3 -2
- package/src/Tooltip.js +11 -12
- package/src/Venn.js +112 -0
- package/src/index.js +1 -0
- package/src/style/area.shadow.css +11 -10
- package/src/style/bar.shadow.css +4 -0
- package/src/style/donut.shadow.css +1 -0
- package/src/style/dot.shadow.css +19 -0
- package/src/style/line.shadow.css +4 -15
- package/src/style/tooltip.shadow.css +1 -0
- package/src/style/venn.shadow.css +23 -0
- package/src/types/Area.d.ts +7 -8
- package/src/types/Axis.d.ts +6 -6
- package/src/types/Bar.d.ts +7 -3
- package/src/types/ClipPath.d.ts +26 -0
- package/src/types/Donut.d.ts +12 -2
- package/src/types/GroupBar.d.ts +2 -2
- package/src/types/HorizontalBar.d.ts +7 -3
- package/src/types/Hover.d.ts +2 -2
- package/src/types/Line.d.ts +9 -4
- package/src/types/Plot.d.ts +16 -0
- package/src/types/ResponsiveContainer.d.ts +1 -1
- package/src/types/StackBar.d.ts +3 -11
- package/src/types/StackedArea.d.ts +7 -6
- package/src/types/Tooltip.d.ts +4 -4
- package/src/types/Venn.d.ts +45 -0
- package/src/types/context.d.ts +1 -1
- package/src/types/index.d.ts +6 -0
- package/src/utils.js +7 -1
- package/lib/cjs/style/chart.shadow.css +0 -4
- package/lib/cjs/types/Plot.js +0 -2
- package/lib/cjs/types/Plot.js.map +0 -1
- package/lib/es6/style/chart.shadow.css +0 -4
- package/lib/es6/types/Plot.js +0 -2
- package/lib/es6/types/Plot.js.map +0 -1
- package/src/style/chart.shadow.css +0 -4
package/lib/es6/HorizontalBar.js
CHANGED
|
@@ -5,33 +5,34 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
5
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
import
|
|
8
|
+
import { sstyled as _sstyled } from "@semcore/core";
|
|
9
9
|
|
|
10
10
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
11
|
|
|
12
12
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
13
13
|
|
|
14
14
|
import React from 'react';
|
|
15
|
-
import { Component,
|
|
15
|
+
import { Component, sstyled } from '@semcore/core';
|
|
16
16
|
import createElement from './createElement';
|
|
17
|
+
import ClipPath from './ClipPath';
|
|
18
|
+
import uniqueIDEnhancement from '@semcore/utils/lib/uniqueID';
|
|
17
19
|
|
|
18
20
|
/*__reshadow-styles__:"./style/bar.shadow.css"*/
|
|
19
|
-
var
|
|
21
|
+
var style = (
|
|
20
22
|
/*__reshadow_css_start__*/
|
|
21
|
-
|
|
23
|
+
_sstyled.insert(
|
|
22
24
|
/*__inner_css_start__*/
|
|
23
|
-
".
|
|
25
|
+
".___SBar_1u1r9_gg_{fill:var(--color_10kcl1b);transition-property:height,width,y;transition-duration:var(--duration_10kcl1b);transition-timing-function:ease-in-out}.___SBar_1u1r9_gg_.__hide_1u1r9_gg_{display:none}.___SBackground_1u1r9_gg_{fill:#e4ecf1}"
|
|
24
26
|
/*__inner_css_end__*/
|
|
25
|
-
, "
|
|
27
|
+
, "10kcl1b_gg_")
|
|
26
28
|
/*__reshadow_css_end__*/
|
|
27
29
|
, {
|
|
28
|
-
"__SBar": "
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var styled_c8 = create([]);
|
|
30
|
+
"__SBar": "___SBar_1u1r9_gg_",
|
|
31
|
+
"--color": "--color_10kcl1b",
|
|
32
|
+
"--duration": "--duration_10kcl1b",
|
|
33
|
+
"_hide": "__hide_1u1r9_gg_",
|
|
34
|
+
"__SBackground": "___SBackground_1u1r9_gg_"
|
|
35
|
+
});
|
|
35
36
|
|
|
36
37
|
var HorizontalBarRoot = /*#__PURE__*/function (_Component) {
|
|
37
38
|
_inherits(HorizontalBarRoot, _Component);
|
|
@@ -55,8 +56,10 @@ var HorizontalBarRoot = /*#__PURE__*/function (_Component) {
|
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
58
|
}, {
|
|
58
|
-
key: "
|
|
59
|
-
value: function
|
|
59
|
+
key: "renderBar",
|
|
60
|
+
value: function renderBar(d, i) {
|
|
61
|
+
var _ref, _d$x, _d$x2;
|
|
62
|
+
|
|
60
63
|
var SBar = this.Element;
|
|
61
64
|
var _this$asProps2 = this.asProps,
|
|
62
65
|
styles = _this$asProps2.styles,
|
|
@@ -64,31 +67,52 @@ var HorizontalBarRoot = /*#__PURE__*/function (_Component) {
|
|
|
64
67
|
x = _this$asProps2.x,
|
|
65
68
|
x0 = _this$asProps2.x0,
|
|
66
69
|
y = _this$asProps2.y,
|
|
67
|
-
data = _this$asProps2.data,
|
|
68
70
|
scale = _this$asProps2.scale,
|
|
69
|
-
|
|
71
|
+
hide = _this$asProps2.hide,
|
|
72
|
+
offset = _this$asProps2.offset,
|
|
73
|
+
uid = _this$asProps2.uid,
|
|
74
|
+
duration = _this$asProps2.duration;
|
|
70
75
|
|
|
71
76
|
var _scale = _slicedToArray(scale, 2),
|
|
72
77
|
xScale = _scale[0],
|
|
73
78
|
yScale = _scale[1];
|
|
74
79
|
|
|
75
|
-
return
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
80
|
+
return _ref = sstyled(styles), /*#__PURE__*/React.createElement(SBar, _ref.cn("SBar", {
|
|
81
|
+
"key": "horizontal-bar-".concat(i),
|
|
82
|
+
"render": "rect",
|
|
83
|
+
"clipPath": "url(#".concat(uid, ")"),
|
|
84
|
+
"__excludeProps": ['data', 'scale', 'value'],
|
|
85
|
+
"childrenPosition": "above",
|
|
86
|
+
"value": d,
|
|
87
|
+
"index": i,
|
|
88
|
+
"hide": hide,
|
|
89
|
+
"color": color,
|
|
90
|
+
"width": Math.abs(xScale(d[x]) - Math.max(xScale(xScale.domain()[0]), xScale((_d$x = d[x0]) !== null && _d$x !== void 0 ? _d$x : 0))),
|
|
91
|
+
"height": yScale.bandwidth(),
|
|
92
|
+
"x": xScale(Math.min((_d$x2 = d[x0]) !== null && _d$x2 !== void 0 ? _d$x2 : 0, d[x])) + offset[0],
|
|
93
|
+
"y": yScale(d[y]) + offset[1],
|
|
94
|
+
"use:duration": "".concat(duration, "ms")
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
98
|
+
key: "render",
|
|
99
|
+
value: function render() {
|
|
100
|
+
var _this$asProps3 = this.asProps,
|
|
101
|
+
data = _this$asProps3.data,
|
|
102
|
+
uid = _this$asProps3.uid,
|
|
103
|
+
size = _this$asProps3.size,
|
|
104
|
+
duration = _this$asProps3.duration;
|
|
105
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, data.map(this.renderBar.bind(this)), duration && /*#__PURE__*/React.createElement(ClipPath, {
|
|
106
|
+
setAttributeTag: function setAttributeTag(rect) {
|
|
107
|
+
rect.setAttribute('width', size[0]);
|
|
108
|
+
},
|
|
109
|
+
id: uid,
|
|
110
|
+
x: "0",
|
|
111
|
+
y: "0",
|
|
112
|
+
width: 0,
|
|
113
|
+
height: size[1],
|
|
114
|
+
transition: "width ".concat(duration, "ms ease-in-out")
|
|
115
|
+
}));
|
|
92
116
|
}
|
|
93
117
|
}]);
|
|
94
118
|
|
|
@@ -97,16 +121,19 @@ var HorizontalBarRoot = /*#__PURE__*/function (_Component) {
|
|
|
97
121
|
|
|
98
122
|
_defineProperty(HorizontalBarRoot, "displayName", 'HorizontalBar');
|
|
99
123
|
|
|
124
|
+
_defineProperty(HorizontalBarRoot, "enhance", [uniqueIDEnhancement()]);
|
|
125
|
+
|
|
100
126
|
_defineProperty(HorizontalBarRoot, "style", style);
|
|
101
127
|
|
|
102
128
|
_defineProperty(HorizontalBarRoot, "defaultProps", {
|
|
103
129
|
color: '#50aef4',
|
|
104
|
-
offset: [0, 0]
|
|
130
|
+
offset: [0, 0],
|
|
131
|
+
duration: 500
|
|
105
132
|
});
|
|
106
133
|
|
|
107
|
-
var styled_12c = create([]);
|
|
108
|
-
|
|
109
134
|
function Background(props) {
|
|
135
|
+
var _ref2;
|
|
136
|
+
|
|
110
137
|
var SBackground = props.Element,
|
|
111
138
|
styles = props.styles,
|
|
112
139
|
scale = props.scale,
|
|
@@ -117,14 +144,14 @@ function Background(props) {
|
|
|
117
144
|
yScale = _scale2[1];
|
|
118
145
|
|
|
119
146
|
var xRange = xScale.range();
|
|
120
|
-
return
|
|
121
|
-
render: "rect",
|
|
122
|
-
childrenPosition: "above",
|
|
123
|
-
width: xRange[1] - xRange[0],
|
|
124
|
-
height: yScale.bandwidth(),
|
|
125
|
-
x: xRange[0],
|
|
126
|
-
y: yScale(value)
|
|
127
|
-
}))
|
|
147
|
+
return _ref2 = sstyled(styles), /*#__PURE__*/React.createElement(SBackground, _ref2.cn("SBackground", {
|
|
148
|
+
"render": "rect",
|
|
149
|
+
"childrenPosition": "above",
|
|
150
|
+
"width": xRange[1] - xRange[0],
|
|
151
|
+
"height": yScale.bandwidth(),
|
|
152
|
+
"x": xRange[0],
|
|
153
|
+
"y": yScale(value)
|
|
154
|
+
}));
|
|
128
155
|
}
|
|
129
156
|
|
|
130
157
|
export default createElement(HorizontalBarRoot, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/HorizontalBar.js"],"names":["React","Component","
|
|
1
|
+
{"version":3,"sources":["../../src/HorizontalBar.js"],"names":["React","Component","sstyled","createElement","ClipPath","uniqueIDEnhancement","HorizontalBarRoot","props","index","asProps","data","y","value","d","i","SBar","Element","styles","color","x","x0","scale","hide","offset","uid","duration","xScale","yScale","Math","abs","max","domain","bandwidth","min","size","map","renderBar","bind","rect","setAttribute","style","Background","SBackground","xRange","range"],"mappings":";;;;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,SAAT,EAAoBC,OAApB,QAAmC,eAAnC;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,QAAP,MAAqB,YAArB;AACA,O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iB,WAGWkC,K;;gBAHXlC,iB,kBAKkB;AACpBY,EAAAA,KAAK,EAAE,SADa;AAEpBK,EAAAA,MAAM,EAAE,CAAC,CAAD,EAAI,CAAJ,CAFY;AAGpBE,EAAAA,QAAQ,EAAE;AAHU,C;;AA8DxB,SAASgB,UAAT,CAAoBlC,KAApB,EAA2B;AAAA;;AAAA,MACRmC,WADQ,GAC8BnC,KAD9B,CACjBS,OADiB;AAAA,MACKC,MADL,GAC8BV,KAD9B,CACKU,MADL;AAAA,MACaI,KADb,GAC8Bd,KAD9B,CACac,KADb;AAAA,MACoBT,KADpB,GAC8BL,KAD9B,CACoBK,KADpB;;AAAA,+BAEAS,KAFA;AAAA,MAElBK,MAFkB;AAAA,MAEVC,MAFU;;AAGzB,MAAMgB,MAAM,GAAGjB,MAAM,CAACkB,KAAP,EAAf;AAEA,iBAAO1C,OAAO,CAACe,MAAD,CAAd,eACE,oBAAC,WAAD;AAAA,cACS,MADT;AAAA,wBAEmB,OAFnB;AAAA,aAGS0B,MAAM,CAAC,CAAD,CAAN,GAAYA,MAAM,CAAC,CAAD,CAH3B;AAAA,cAIUhB,MAAM,CAACK,SAAP,EAJV;AAAA,SAKKW,MAAM,CAAC,CAAD,CALX;AAAA,SAMKhB,MAAM,CAACf,KAAD;AANX,KADF;AAUD;;AAED,eAAeT,aAAa,CAACG,iBAAD,EAAoB;AAAEmC,EAAAA,UAAU,EAAVA;AAAF,CAApB,CAA5B","sourcesContent":["import React from 'react';\nimport { Component, sstyled } from '@semcore/core';\nimport createElement from './createElement';\nimport ClipPath from './ClipPath';\nimport uniqueIDEnhancement from '@semcore/utils/lib/uniqueID';\n\nimport style from './style/bar.shadow.css';\n\nclass HorizontalBarRoot extends Component {\n static displayName = 'HorizontalBar';\n static enhance = [uniqueIDEnhancement()];\n static style = style;\n\n static defaultProps = {\n color: '#50aef4',\n offset: [0, 0],\n duration: 500,\n };\n\n getBackgroundProps(props, index) {\n const { data, y } = this.asProps;\n return {\n value: data[index][y],\n };\n }\n\n renderBar(d, i) {\n const SBar = this.Element;\n const { styles, color, x, x0, y, scale, hide, offset, uid, duration } = this.asProps;\n const [xScale, yScale] = scale;\n\n return sstyled(styles)(\n <SBar\n key={`horizontal-bar-${i}`}\n render=\"rect\"\n clipPath={`url(#${uid})`}\n __excludeProps={['data', 'scale', 'value']}\n childrenPosition=\"above\"\n value={d}\n index={i}\n hide={hide}\n color={color}\n width={Math.abs(xScale(d[x]) - Math.max(xScale(xScale.domain()[0]), xScale(d[x0] ?? 0)))}\n height={yScale.bandwidth()}\n x={xScale(Math.min(d[x0] ?? 0, d[x])) + offset[0]}\n y={yScale(d[y]) + offset[1]}\n use:duration={`${duration}ms`}\n />,\n );\n }\n\n render() {\n const { data, uid, size, duration } = this.asProps;\n\n return (\n <>\n {data.map(this.renderBar.bind(this))}\n {duration && (\n <ClipPath\n setAttributeTag={(rect) => {\n rect.setAttribute('width', size[0]);\n }}\n id={uid}\n x=\"0\"\n y=\"0\"\n width={0}\n height={size[1]}\n transition={`width ${duration}ms ease-in-out`}\n />\n )}\n </>\n );\n }\n}\n\nfunction Background(props) {\n const { Element: SBackground, styles, scale, value } = props;\n const [xScale, yScale] = scale;\n const xRange = xScale.range();\n\n return sstyled(styles)(\n <SBackground\n render=\"rect\"\n childrenPosition=\"above\"\n width={xRange[1] - xRange[0]}\n height={yScale.bandwidth()}\n x={xRange[0]}\n y={yScale(value)}\n />,\n );\n}\n\nexport default createElement(HorizontalBarRoot, { Background });\n"],"file":"HorizontalBar.js"}
|
package/lib/es6/Hover.js
CHANGED
|
@@ -6,32 +6,31 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
6
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
import
|
|
9
|
+
import { sstyled as _sstyled } from "@semcore/core";
|
|
10
10
|
|
|
11
11
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
12
|
|
|
13
13
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
14
14
|
|
|
15
15
|
import React from 'react';
|
|
16
|
-
import { Component,
|
|
16
|
+
import { Component, sstyled } from '@semcore/core';
|
|
17
17
|
import createElement from './createElement';
|
|
18
18
|
import trottle from '@semcore/utils/lib/rafTrottle';
|
|
19
19
|
import { scaleOfBandwidth, getIndexFromData, eventToPoint, invert } from './utils';
|
|
20
20
|
|
|
21
21
|
/*__reshadow-styles__:"./style/hover.shadow.css"*/
|
|
22
|
-
var
|
|
22
|
+
var style = (
|
|
23
23
|
/*__reshadow_css_start__*/
|
|
24
|
-
|
|
24
|
+
_sstyled.insert(
|
|
25
25
|
/*__inner_css_start__*/
|
|
26
|
-
".
|
|
26
|
+
".___SHoverLine_wqcps_gg_{stroke:#a6b0b3}.___SHoverRect_wqcps_gg_{fill:rgba(152,170,175,.3)}"
|
|
27
27
|
/*__inner_css_end__*/
|
|
28
|
-
, "
|
|
28
|
+
, "1tjsi7e_gg_")
|
|
29
29
|
/*__reshadow_css_end__*/
|
|
30
30
|
, {
|
|
31
|
-
"__SHoverLine": "
|
|
32
|
-
"__SHoverRect": "
|
|
33
|
-
})
|
|
34
|
-
style = _extends({}, _ref);
|
|
31
|
+
"__SHoverLine": "___SHoverLine_wqcps_gg_",
|
|
32
|
+
"__SHoverRect": "___SHoverRect_wqcps_gg_"
|
|
33
|
+
});
|
|
35
34
|
|
|
36
35
|
var Hover = /*#__PURE__*/function (_Component) {
|
|
37
36
|
_inherits(Hover, _Component);
|
|
@@ -133,8 +132,6 @@ var Hover = /*#__PURE__*/function (_Component) {
|
|
|
133
132
|
|
|
134
133
|
_defineProperty(Hover, "style", style);
|
|
135
134
|
|
|
136
|
-
var styled_c8 = create([]);
|
|
137
|
-
|
|
138
135
|
var HoverLineRoot = /*#__PURE__*/function (_Hover) {
|
|
139
136
|
_inherits(HoverLineRoot, _Hover);
|
|
140
137
|
|
|
@@ -149,6 +146,8 @@ var HoverLineRoot = /*#__PURE__*/function (_Hover) {
|
|
|
149
146
|
_createClass(HoverLineRoot, [{
|
|
150
147
|
key: "render",
|
|
151
148
|
value: function render() {
|
|
149
|
+
var _ref;
|
|
150
|
+
|
|
152
151
|
var SHoverLine = this.Element;
|
|
153
152
|
var _this$asProps2 = this.asProps,
|
|
154
153
|
styles = _this$asProps2.styles,
|
|
@@ -168,23 +167,23 @@ var HoverLineRoot = /*#__PURE__*/function (_Hover) {
|
|
|
168
167
|
var yRange = yScale.range();
|
|
169
168
|
var x1 = xIndex !== null ? scaleOfBandwidth(xScale, data[xIndex][x]) : undefined;
|
|
170
169
|
var y1 = yIndex !== null ? scaleOfBandwidth(yScale, data[yIndex][y]) : undefined;
|
|
171
|
-
return
|
|
172
|
-
render: "line",
|
|
173
|
-
ref: this.hoverRef,
|
|
174
|
-
index: xIndex,
|
|
175
|
-
x1: x1,
|
|
176
|
-
y1: yRange[0],
|
|
177
|
-
x2: x1,
|
|
178
|
-
y2: yRange[1]
|
|
179
|
-
})) : null, yIndex !== null ? /*#__PURE__*/React.createElement(SHoverLine,
|
|
180
|
-
render: "line",
|
|
181
|
-
ref: this.hoverRef,
|
|
182
|
-
index: yIndex,
|
|
183
|
-
x1: xRange[0],
|
|
184
|
-
y1: y1,
|
|
185
|
-
x2: xRange[1],
|
|
186
|
-
y2: y1
|
|
187
|
-
})) : null)
|
|
170
|
+
return _ref = sstyled(styles), /*#__PURE__*/React.createElement(React.Fragment, null, xIndex !== null ? /*#__PURE__*/React.createElement(SHoverLine, _ref.cn("SHoverLine", {
|
|
171
|
+
"render": "line",
|
|
172
|
+
"ref": this.hoverRef,
|
|
173
|
+
"index": xIndex,
|
|
174
|
+
"x1": x1,
|
|
175
|
+
"y1": yRange[0],
|
|
176
|
+
"x2": x1,
|
|
177
|
+
"y2": yRange[1]
|
|
178
|
+
})) : null, yIndex !== null ? /*#__PURE__*/React.createElement(SHoverLine, _ref.cn("SHoverLine", {
|
|
179
|
+
"render": "line",
|
|
180
|
+
"ref": this.hoverRef,
|
|
181
|
+
"index": yIndex,
|
|
182
|
+
"x1": xRange[0],
|
|
183
|
+
"y1": y1,
|
|
184
|
+
"x2": xRange[1],
|
|
185
|
+
"y2": y1
|
|
186
|
+
})) : null);
|
|
188
187
|
}
|
|
189
188
|
}]);
|
|
190
189
|
|
|
@@ -193,8 +192,6 @@ var HoverLineRoot = /*#__PURE__*/function (_Hover) {
|
|
|
193
192
|
|
|
194
193
|
_defineProperty(HoverLineRoot, "displayName", 'HoverLine');
|
|
195
194
|
|
|
196
|
-
var styled_12c = create([]);
|
|
197
|
-
|
|
198
195
|
var HoverRectRoot = /*#__PURE__*/function (_Hover2) {
|
|
199
196
|
_inherits(HoverRectRoot, _Hover2);
|
|
200
197
|
|
|
@@ -209,6 +206,8 @@ var HoverRectRoot = /*#__PURE__*/function (_Hover2) {
|
|
|
209
206
|
_createClass(HoverRectRoot, [{
|
|
210
207
|
key: "render",
|
|
211
208
|
value: function render() {
|
|
209
|
+
var _ref2;
|
|
210
|
+
|
|
212
211
|
var SHoverRect = this.Element;
|
|
213
212
|
var _this$asProps3 = this.asProps,
|
|
214
213
|
styles = _this$asProps3.styles,
|
|
@@ -226,23 +225,23 @@ var HoverRectRoot = /*#__PURE__*/function (_Hover2) {
|
|
|
226
225
|
|
|
227
226
|
var xRange = xScale.range();
|
|
228
227
|
var yRange = yScale.range();
|
|
229
|
-
return
|
|
230
|
-
render: "rect",
|
|
231
|
-
ref: this.hoverRef,
|
|
232
|
-
index: xIndex,
|
|
233
|
-
width: xScale.step() - xScale.paddingInner() / 2,
|
|
234
|
-
height: yRange[0] - yRange[1],
|
|
235
|
-
x: xScale(data[xIndex][x]) - xScale.step() * xScale.paddingInner() / 2,
|
|
236
|
-
y: yRange[1]
|
|
237
|
-
})) : null, yIndex !== null ? /*#__PURE__*/React.createElement(SHoverRect,
|
|
238
|
-
render: "rect",
|
|
239
|
-
ref: this.hoverRef,
|
|
240
|
-
index: yIndex,
|
|
241
|
-
width: xRange[1] - xRange[0],
|
|
242
|
-
height: yScale.step() - yScale.paddingInner() / 2,
|
|
243
|
-
x: xRange[0],
|
|
244
|
-
y: yScale(data[yIndex][y]) - yScale.step() * yScale.paddingInner() / 2
|
|
245
|
-
})) : null)
|
|
228
|
+
return _ref2 = sstyled(styles), /*#__PURE__*/React.createElement(React.Fragment, null, xIndex !== null ? /*#__PURE__*/React.createElement(SHoverRect, _ref2.cn("SHoverRect", {
|
|
229
|
+
"render": "rect",
|
|
230
|
+
"ref": this.hoverRef,
|
|
231
|
+
"index": xIndex,
|
|
232
|
+
"width": xScale.step() - xScale.paddingInner() / 2,
|
|
233
|
+
"height": yRange[0] - yRange[1],
|
|
234
|
+
"x": xScale(data[xIndex][x]) - xScale.step() * xScale.paddingInner() / 2,
|
|
235
|
+
"y": yRange[1]
|
|
236
|
+
})) : null, yIndex !== null ? /*#__PURE__*/React.createElement(SHoverRect, _ref2.cn("SHoverRect", {
|
|
237
|
+
"render": "rect",
|
|
238
|
+
"ref": this.hoverRef,
|
|
239
|
+
"index": yIndex,
|
|
240
|
+
"width": xRange[1] - xRange[0],
|
|
241
|
+
"height": yScale.step() - yScale.paddingInner() / 2,
|
|
242
|
+
"x": xRange[0],
|
|
243
|
+
"y": yScale(data[yIndex][y]) - yScale.step() * yScale.paddingInner() / 2
|
|
244
|
+
})) : null);
|
|
246
245
|
}
|
|
247
246
|
}]);
|
|
248
247
|
|
package/lib/es6/Hover.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Hover.js"],"names":["React","Component","styled","createElement","trottle","scaleOfBandwidth","getIndexFromData","eventToPoint","invert","Hover","xIndex","yIndex","createRef","e","asProps","eventEmitter","data","scale","x","y","rootRef","xScale","yScale","current","pX","pY","vX","vY","undefined","state","setState","emit","hoverRef","unsubscribeMouseMoveRoot","subscribe","persist","handlerMouseMoveRoot","unsubscribeMouseLeaveRoot","handlerMouseLeaveRoot","style","HoverLineRoot","SHoverLine","Element","styles","xRange","range","yRange","x1","y1","HoverRectRoot","SHoverRect","step","paddingInner","HoverLine","HoverRect"],"mappings":";;;;;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,SAAT,EAAoBC,MAApB,wCAAkC,eAAlC;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,OAAP,MAAoB,+BAApB;AACA,SAASC,gBAAT,EAA2BC,gBAA3B,EAA6CC,YAA7C,EAA2DC,MAA3D,QAAyE,SAAzE;;;;;;;;;;;;;;;;;IAIMC,K;;;;;;;;;;;;;;;;4DAGI;AACNC,MAAAA,MAAM,EAAE,IADF;AAENC,MAAAA,MAAM,EAAE;AAFF,K;;4EAKGX,KAAK,CAACY,SAAN,E;;2EAEYR,OAAO,CAAC,UAACS,CAAD,EAAO;AAAA,0BACiB,MAAKC,OADtB;AAAA,UAC5BC,YAD4B,iBAC5BA,YAD4B;AAAA,UACdC,IADc,iBACdA,IADc;AAAA,UACRC,KADQ,iBACRA,KADQ;AAAA,UACDC,CADC,iBACDA,CADC;AAAA,UACEC,CADF,iBACEA,CADF;AAAA,UACKC,OADL,iBACKA,OADL;;AAAA,kCAEXH,KAFW;AAAA,UAE7BI,MAF6B;AAAA,UAErBC,MAFqB;;AAAA,0BAGnBf,YAAY,CAACM,CAAD,EAAIO,OAAO,CAACG,OAAZ,CAHO;AAAA;AAAA,UAG7BC,EAH6B;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oBAAC,UAAD;AAAA,gBACS,MADT;AAAA,aAEO,KAAKsB,QAFZ;AAAA,eAGStB,MAHT;AAAA,eAISW,MAAM,CAAC8B,IAAP,KAAgB9B,MAAM,CAAC+B,YAAP,KAAwB,CAJjD;AAAA,gBAKUN,MAAM,CAAC,CAAD,CAAN,GAAYA,MAAM,CAAC,CAAD,CAL5B;AAAA,WAMKzB,MAAM,CAACL,IAAI,CAACN,MAAD,CAAJ,CAAaQ,CAAb,CAAD,CAAN,GAA2BG,MAAM,CAAC8B,IAAP,KAAgB9B,MAAM,CAAC+B,YAAP,EAAjB,GAA0C,CANzE;AAAA,WAOKN,MAAM,CAAC,CAAD;AAPX,SADD,GAUG,IAXN,EAYGnC,MAAM,KAAK,IAAX,gBACC,oBAAC,UAAD;AAAA,gBACS,MADT;AAAA,aAEO,KAAKqB,QAFZ;AAAA,eAGSrB,MAHT;AAAA,eAISiC,MAAM,CAAC,CAAD,CAAN,GAAYA,MAAM,CAAC,CAAD,CAJ3B;AAAA,gBAKUtB,MAAM,CAAC6B,IAAP,KAAgB7B,MAAM,CAAC8B,YAAP,KAAwB,CALlD;AAAA,WAMKR,MAAM,CAAC,CAAD,CANX;AAAA,WAOKtB,MAAM,CAACN,IAAI,CAACL,MAAD,CAAJ,CAAaQ,CAAb,CAAD,CAAN,GAA2BG,MAAM,CAAC6B,IAAP,KAAgB7B,MAAM,CAAC8B,YAAP,EAAjB,GAA0C;AAPzE,SADD,GAUG,IAtBN,CADK,EAAP;AA0BD;;;;EAtCyB3C,K;;gBAAtBwC,a,iBACiB,W;;AAwCvB,IAAMI,SAAS,GAAGlD,aAAa,CAACqC,aAAD,CAA/B;AACA,IAAMc,SAAS,GAAGnD,aAAa,CAAC8C,aAAD,CAA/B;AAEA,SAASI,SAAT,EAAoBC,SAApB","sourcesContent":["import React from 'react';\nimport { Component, styled } from '@semcore/core';\nimport createElement from './createElement';\nimport trottle from '@semcore/utils/lib/rafTrottle';\nimport { scaleOfBandwidth, getIndexFromData, eventToPoint, invert } from './utils';\n\nimport style from './style/hover.shadow.css';\n\nclass Hover extends Component {\n static style = style;\n\n state = {\n xIndex: null,\n yIndex: null,\n };\n\n hoverRef = React.createRef();\n\n handlerMouseMoveRoot = trottle((e) => {\n const { eventEmitter, data, scale, x, y, rootRef } = this.asProps;\n const [xScale, yScale] = scale;\n const [pX, pY] = eventToPoint(e, rootRef.current);\n const vX = invert(xScale, pX);\n const vY = invert(yScale, pY);\n const xIndex =\n x === undefined || vX === undefined ? null : getIndexFromData(data, xScale, x, vX);\n const yIndex =\n y === undefined || vY === undefined ? null : getIndexFromData(data, yScale, y, vY);\n const state = { xIndex, yIndex };\n this.setState(state, () => {\n eventEmitter.emit(\n 'onTooltipVisible',\n xIndex !== null || yIndex !== null,\n state,\n this.hoverRef.current,\n );\n });\n });\n\n handlerMouseLeaveRoot = trottle(() => {\n const state = {\n xIndex: null,\n yIndex: null,\n };\n this.setState(state, () => {\n this.asProps.eventEmitter.emit('onTooltipVisible', false, state);\n });\n });\n\n componentDidMount() {\n const { eventEmitter } = this.asProps;\n this.unsubscribeMouseMoveRoot = eventEmitter.subscribe('onMouseMoveRoot', (e) => {\n e.persist();\n this.handlerMouseMoveRoot(e);\n });\n this.unsubscribeMouseLeaveRoot = eventEmitter.subscribe(\n 'onMouseLeaveRoot',\n this.handlerMouseLeaveRoot,\n );\n }\n\n componentWillUnmount() {\n if (this.unsubscribeMouseMoveRoot) {\n this.unsubscribeMouseMoveRoot();\n }\n if (this.unsubscribeMouseLeaveRoot) {\n this.unsubscribeMouseLeaveRoot();\n }\n }\n}\n\nclass HoverLineRoot extends Hover {\n static displayName = 'HoverLine';\n\n render() {\n const SHoverLine = this.Element;\n const { styles, x, y, data, scale } = this.asProps;\n const { xIndex, yIndex } = this.state;\n const [xScale, yScale] = scale;\n\n const xRange = xScale.range();\n const yRange = yScale.range();\n const x1 = xIndex !== null ? scaleOfBandwidth(xScale, data[xIndex][x]) : undefined;\n const y1 = yIndex !== null ? scaleOfBandwidth(yScale, data[yIndex][y]) : undefined;\n\n return styled(styles)(\n <>\n {xIndex !== null ? (\n <SHoverLine\n render=\"line\"\n ref={this.hoverRef}\n index={xIndex}\n x1={x1}\n y1={yRange[0]}\n x2={x1}\n y2={yRange[1]}\n />\n ) : null}\n {yIndex !== null ? (\n <SHoverLine\n render=\"line\"\n ref={this.hoverRef}\n index={yIndex}\n x1={xRange[0]}\n y1={y1}\n x2={xRange[1]}\n y2={y1}\n />\n ) : null}\n </>,\n );\n }\n}\n\nclass HoverRectRoot extends Hover {\n static displayName = 'HoverRect';\n\n render() {\n const SHoverRect = this.Element;\n const { styles, x, y, data, scale } = this.asProps;\n const { xIndex, yIndex } = this.state;\n const [xScale, yScale] = scale;\n\n const xRange = xScale.range();\n const yRange = yScale.range();\n\n return styled(styles)(\n <>\n {xIndex !== null ? (\n <SHoverRect\n render=\"rect\"\n ref={this.hoverRef}\n index={xIndex}\n width={xScale.step() - xScale.paddingInner() / 2}\n height={yRange[0] - yRange[1]}\n x={xScale(data[xIndex][x]) - (xScale.step() * xScale.paddingInner()) / 2}\n y={yRange[1]}\n />\n ) : null}\n {yIndex !== null ? (\n <SHoverRect\n render=\"rect\"\n ref={this.hoverRef}\n index={yIndex}\n width={xRange[1] - xRange[0]}\n height={yScale.step() - yScale.paddingInner() / 2}\n x={xRange[0]}\n y={yScale(data[yIndex][y]) - (yScale.step() * yScale.paddingInner()) / 2}\n />\n ) : null}\n </>,\n );\n }\n}\n\nconst HoverLine = createElement(HoverLineRoot);\nconst HoverRect = createElement(HoverRectRoot);\n\nexport { HoverLine, HoverRect };\n"],"file":"Hover.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/Hover.js"],"names":["React","Component","sstyled","createElement","trottle","scaleOfBandwidth","getIndexFromData","eventToPoint","invert","Hover","xIndex","yIndex","createRef","e","asProps","eventEmitter","data","scale","x","y","rootRef","xScale","yScale","current","pX","pY","vX","vY","undefined","state","setState","emit","hoverRef","unsubscribeMouseMoveRoot","subscribe","persist","handlerMouseMoveRoot","unsubscribeMouseLeaveRoot","handlerMouseLeaveRoot","style","HoverLineRoot","SHoverLine","Element","styles","xRange","range","yRange","x1","y1","HoverRectRoot","SHoverRect","step","paddingInner","HoverLine","HoverRect"],"mappings":";;;;;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,SAAT,EAAoBC,OAApB,QAAmC,eAAnC;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,OAAP,MAAoB,+BAApB;AACA,SAASC,gBAAT,EAA2BC,gBAA3B,EAA6CC,YAA7C,EAA2DC,MAA3D,QAAyE,SAAzE;;;;;;;;;;;;;;;;IAIMC,K;;;;;;;;;;;;;;;;4DAGI;AACNC,MAAAA,MAAM,EAAE,IADF;AAENC,MAAAA,MAAM,EAAE;AAFF,K;;4EAKGX,KAAK,CAACY,SAAN,E;;2EAEYR,OAAO,CAAC,UAACS,CAAD,EAAO;AAAA,0BACiB,MAAKC,OADtB;AAAA,UAC5BC,YAD4B,iBAC5BA,YAD4B;AAAA,UACdC,IADc,iBACdA,IADc;AAAA,UACRC,KADQ,iBACRA,KADQ;AAAA,UACDC,CADC,iBACDA,CADC;AAAA,UACEC,CADF,iBACEA,CADF;AAAA,UACKC,OADL,iBACKA,OADL;;AAAA,kCAEXH,KAFW;AAAA,UAE7BI,MAF6B;AAAA,UAErBC,MAFqB;;AAAA,0BAGnBf,YAAY,CAACM,CAAD,EAAIO,OAAO,CAACG,OAAZ,CAHO;AAAA;AAAA,UAG7BC,EAH6B;AAAA,UAGzBC,EAHyB;;AAIpC,UAAMC,EAAE,GAAGlB,MAAM,CAACa,MAAD,EAASG,EAAT,CAAjB;AACA,UAAMG,EAAE,GAAGnB,MAAM,CAACc,MAAD,EAASG,EAAT,CAAjB;AACA,UAAMf,MAAM,GACVQ,CAAC,KAAKU,SAAN,IAAmBF,EAAE,KAAKE,SAA1B,GAAsC,IAAtC,GAA6CtB,gBAAgB,CAACU,IAAD,EAA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MAAM,CAACL,IAAI,CAACN,MAAD,CAAJ,CAAaQ,CAAb,CAAD,CAAN,GAA2BG,MAAM,CAAC8B,IAAP,KAAgB9B,MAAM,CAAC+B,YAAP,EAAjB,GAA0C,CANzE;AAAA,aAOKN,MAAM,CAAC,CAAD;AAPX,SADD,GAUG,IAXN,EAYGnC,MAAM,KAAK,IAAX,gBACC,oBAAC,UAAD;AAAA,kBACS,MADT;AAAA,eAEO,KAAKqB,QAFZ;AAAA,iBAGSrB,MAHT;AAAA,iBAISiC,MAAM,CAAC,CAAD,CAAN,GAAYA,MAAM,CAAC,CAAD,CAJ3B;AAAA,kBAKUtB,MAAM,CAAC6B,IAAP,KAAgB7B,MAAM,CAAC8B,YAAP,KAAwB,CALlD;AAAA,aAMKR,MAAM,CAAC,CAAD,CANX;AAAA,aAOKtB,MAAM,CAACN,IAAI,CAACL,MAAD,CAAJ,CAAaQ,CAAb,CAAD,CAAN,GAA2BG,MAAM,CAAC6B,IAAP,KAAgB7B,MAAM,CAAC8B,YAAP,EAAjB,GAA0C;AAPzE,SADD,GAUG,IAtBN,CADF;AA0BD;;;;EAtCyB3C,K;;gBAAtBwC,a,iBACiB,W;;AAwCvB,IAAMI,SAAS,GAAGlD,aAAa,CAACqC,aAAD,CAA/B;AACA,IAAMc,SAAS,GAAGnD,aAAa,CAAC8C,aAAD,CAA/B;AAEA,SAASI,SAAT,EAAoBC,SAApB","sourcesContent":["import React from 'react';\nimport { Component, sstyled } from '@semcore/core';\nimport createElement from './createElement';\nimport trottle from '@semcore/utils/lib/rafTrottle';\nimport { scaleOfBandwidth, getIndexFromData, eventToPoint, invert } from './utils';\n\nimport style from './style/hover.shadow.css';\n\nclass Hover extends Component {\n static style = style;\n\n state = {\n xIndex: null,\n yIndex: null,\n };\n\n hoverRef = React.createRef();\n\n handlerMouseMoveRoot = trottle((e) => {\n const { eventEmitter, data, scale, x, y, rootRef } = this.asProps;\n const [xScale, yScale] = scale;\n const [pX, pY] = eventToPoint(e, rootRef.current);\n const vX = invert(xScale, pX);\n const vY = invert(yScale, pY);\n const xIndex =\n x === undefined || vX === undefined ? null : getIndexFromData(data, xScale, x, vX);\n const yIndex =\n y === undefined || vY === undefined ? null : getIndexFromData(data, yScale, y, vY);\n const state = { xIndex, yIndex };\n this.setState(state, () => {\n eventEmitter.emit(\n 'onTooltipVisible',\n xIndex !== null || yIndex !== null,\n state,\n this.hoverRef.current,\n );\n });\n });\n\n handlerMouseLeaveRoot = trottle(() => {\n const state = {\n xIndex: null,\n yIndex: null,\n };\n this.setState(state, () => {\n this.asProps.eventEmitter.emit('onTooltipVisible', false, state);\n });\n });\n\n componentDidMount() {\n const { eventEmitter } = this.asProps;\n this.unsubscribeMouseMoveRoot = eventEmitter.subscribe('onMouseMoveRoot', (e) => {\n e.persist();\n this.handlerMouseMoveRoot(e);\n });\n this.unsubscribeMouseLeaveRoot = eventEmitter.subscribe(\n 'onMouseLeaveRoot',\n this.handlerMouseLeaveRoot,\n );\n }\n\n componentWillUnmount() {\n if (this.unsubscribeMouseMoveRoot) {\n this.unsubscribeMouseMoveRoot();\n }\n if (this.unsubscribeMouseLeaveRoot) {\n this.unsubscribeMouseLeaveRoot();\n }\n }\n}\n\nclass HoverLineRoot extends Hover {\n static displayName = 'HoverLine';\n\n render() {\n const SHoverLine = this.Element;\n const { styles, x, y, data, scale } = this.asProps;\n const { xIndex, yIndex } = this.state;\n const [xScale, yScale] = scale;\n\n const xRange = xScale.range();\n const yRange = yScale.range();\n const x1 = xIndex !== null ? scaleOfBandwidth(xScale, data[xIndex][x]) : undefined;\n const y1 = yIndex !== null ? scaleOfBandwidth(yScale, data[yIndex][y]) : undefined;\n\n return sstyled(styles)(\n <>\n {xIndex !== null ? (\n <SHoverLine\n render=\"line\"\n ref={this.hoverRef}\n index={xIndex}\n x1={x1}\n y1={yRange[0]}\n x2={x1}\n y2={yRange[1]}\n />\n ) : null}\n {yIndex !== null ? (\n <SHoverLine\n render=\"line\"\n ref={this.hoverRef}\n index={yIndex}\n x1={xRange[0]}\n y1={y1}\n x2={xRange[1]}\n y2={y1}\n />\n ) : null}\n </>,\n );\n }\n}\n\nclass HoverRectRoot extends Hover {\n static displayName = 'HoverRect';\n\n render() {\n const SHoverRect = this.Element;\n const { styles, x, y, data, scale } = this.asProps;\n const { xIndex, yIndex } = this.state;\n const [xScale, yScale] = scale;\n\n const xRange = xScale.range();\n const yRange = yScale.range();\n\n return sstyled(styles)(\n <>\n {xIndex !== null ? (\n <SHoverRect\n render=\"rect\"\n ref={this.hoverRef}\n index={xIndex}\n width={xScale.step() - xScale.paddingInner() / 2}\n height={yRange[0] - yRange[1]}\n x={xScale(data[xIndex][x]) - (xScale.step() * xScale.paddingInner()) / 2}\n y={yRange[1]}\n />\n ) : null}\n {yIndex !== null ? (\n <SHoverRect\n render=\"rect\"\n ref={this.hoverRef}\n index={yIndex}\n width={xRange[1] - xRange[0]}\n height={yScale.step() - yScale.paddingInner() / 2}\n x={xRange[0]}\n y={yScale(data[yIndex][y]) - (yScale.step() * yScale.paddingInner()) / 2}\n />\n ) : null}\n </>,\n );\n }\n}\n\nconst HoverLine = createElement(HoverLineRoot);\nconst HoverRect = createElement(HoverRectRoot);\n\nexport { HoverLine, HoverRect };\n"],"file":"Hover.js"}
|
package/lib/es6/Line.js
CHANGED
|
@@ -5,7 +5,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
5
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
import
|
|
8
|
+
import { sstyled as _sstyled } from "@semcore/core";
|
|
9
9
|
|
|
10
10
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
11
|
|
|
@@ -13,30 +13,29 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
13
13
|
|
|
14
14
|
import React from 'react';
|
|
15
15
|
import { curveLinear, line as d3Line } from 'd3-shape';
|
|
16
|
-
import { Component,
|
|
16
|
+
import { Component, sstyled } from '@semcore/core';
|
|
17
17
|
import createElement from './createElement';
|
|
18
|
-
import { definedData, scaleOfBandwidth, getNullData } from './utils';
|
|
18
|
+
import { definedData, definedNullData, scaleOfBandwidth, getNullData } from './utils';
|
|
19
19
|
import Dots from './Dots';
|
|
20
|
+
import ClipPath from './ClipPath';
|
|
21
|
+
import uniqueIDEnhancement from '@semcore/utils/lib/uniqueID';
|
|
20
22
|
|
|
21
23
|
/*__reshadow-styles__:"./style/line.shadow.css"*/
|
|
22
|
-
var
|
|
24
|
+
var style = (
|
|
23
25
|
/*__reshadow_css_start__*/
|
|
24
|
-
|
|
26
|
+
_sstyled.insert(
|
|
25
27
|
/*__inner_css_start__*/
|
|
26
|
-
".
|
|
28
|
+
".___SLine_d1qcq_gg_{fill:transparent;stroke-width:3;stroke:var(--color_153xqfw);transition-property:d;transition-duration:var(--duration_153xqfw);transition-timing-function:ease-in-out}.___SLine_d1qcq_gg_.__hide_d1qcq_gg_{display:none}.___SNull_d1qcq_gg_{fill:transparent;stroke:#98aaaf;stroke-dasharray:4}.___SNull_d1qcq_gg_.__hide_d1qcq_gg_{display:none}"
|
|
27
29
|
/*__inner_css_end__*/
|
|
28
|
-
, "
|
|
30
|
+
, "153xqfw_gg_")
|
|
29
31
|
/*__reshadow_css_end__*/
|
|
30
32
|
, {
|
|
31
|
-
"__SLine": "
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"__SNull": "
|
|
36
|
-
})
|
|
37
|
-
style = _extends({}, _ref);
|
|
38
|
-
|
|
39
|
-
var styled_c8 = create([]);
|
|
33
|
+
"__SLine": "___SLine_d1qcq_gg_",
|
|
34
|
+
"--color": "--color_153xqfw",
|
|
35
|
+
"--duration": "--duration_153xqfw",
|
|
36
|
+
"_hide": "__hide_d1qcq_gg_",
|
|
37
|
+
"__SNull": "___SNull_d1qcq_gg_"
|
|
38
|
+
});
|
|
40
39
|
|
|
41
40
|
var LineRoot = /*#__PURE__*/function (_Component) {
|
|
42
41
|
_inherits(LineRoot, _Component);
|
|
@@ -56,18 +55,21 @@ var LineRoot = /*#__PURE__*/function (_Component) {
|
|
|
56
55
|
x = _this$asProps.x,
|
|
57
56
|
y = _this$asProps.y,
|
|
58
57
|
d3 = _this$asProps.d3,
|
|
59
|
-
color = _this$asProps.color
|
|
58
|
+
color = _this$asProps.color,
|
|
59
|
+
duration = _this$asProps.duration;
|
|
60
60
|
return {
|
|
61
61
|
x: x,
|
|
62
62
|
y: y,
|
|
63
63
|
d3: d3,
|
|
64
|
-
|
|
64
|
+
color: color,
|
|
65
|
+
delay: duration
|
|
65
66
|
};
|
|
66
67
|
}
|
|
67
68
|
}, {
|
|
68
69
|
key: "getNullProps",
|
|
69
70
|
value: function getNullProps() {
|
|
70
71
|
var _this$asProps2 = this.asProps,
|
|
72
|
+
x = _this$asProps2.x,
|
|
71
73
|
y = _this$asProps2.y,
|
|
72
74
|
d3 = _this$asProps2.d3,
|
|
73
75
|
color = _this$asProps2.color,
|
|
@@ -75,26 +77,43 @@ var LineRoot = /*#__PURE__*/function (_Component) {
|
|
|
75
77
|
return {
|
|
76
78
|
d3: d3,
|
|
77
79
|
// TODO: vertical
|
|
78
|
-
data: getNullData(data,
|
|
79
|
-
|
|
80
|
+
data: getNullData(data, definedNullData(x, y), y),
|
|
81
|
+
color: color
|
|
80
82
|
};
|
|
81
83
|
}
|
|
82
84
|
}, {
|
|
83
85
|
key: "render",
|
|
84
86
|
value: function render() {
|
|
87
|
+
var _ref;
|
|
88
|
+
|
|
85
89
|
var SLine = this.Element;
|
|
86
90
|
var _this$asProps3 = this.asProps,
|
|
87
91
|
styles = _this$asProps3.styles,
|
|
88
92
|
hide = _this$asProps3.hide,
|
|
89
93
|
color = _this$asProps3.color,
|
|
94
|
+
uid = _this$asProps3.uid,
|
|
95
|
+
size = _this$asProps3.size,
|
|
90
96
|
d3 = _this$asProps3.d3,
|
|
91
|
-
data = _this$asProps3.data
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
data = _this$asProps3.data,
|
|
98
|
+
duration = _this$asProps3.duration;
|
|
99
|
+
return _ref = sstyled(styles), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SLine, _ref.cn("SLine", {
|
|
100
|
+
"clipPath": "url(#".concat(uid, ")"),
|
|
101
|
+
"render": "path",
|
|
102
|
+
"hide": hide,
|
|
103
|
+
"color": color,
|
|
104
|
+
"d": d3(data),
|
|
105
|
+
"use:duration": "".concat(duration, "ms")
|
|
106
|
+
})), duration && /*#__PURE__*/React.createElement(ClipPath, _ref.cn("ClipPath", {
|
|
107
|
+
"setAttributeTag": function setAttributeTag(rect) {
|
|
108
|
+
rect.setAttribute('width', size[0]);
|
|
109
|
+
},
|
|
110
|
+
"id": uid,
|
|
111
|
+
"x": "0",
|
|
112
|
+
"y": "0",
|
|
113
|
+
"width": 0,
|
|
114
|
+
"height": size[1],
|
|
115
|
+
"transition": "width ".concat(duration, "ms ease-in-out")
|
|
116
|
+
})));
|
|
98
117
|
}
|
|
99
118
|
}]);
|
|
100
119
|
|
|
@@ -103,12 +122,16 @@ var LineRoot = /*#__PURE__*/function (_Component) {
|
|
|
103
122
|
|
|
104
123
|
_defineProperty(LineRoot, "displayName", 'Line');
|
|
105
124
|
|
|
106
|
-
_defineProperty(LineRoot, "
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
125
|
+
_defineProperty(LineRoot, "style", style);
|
|
126
|
+
|
|
127
|
+
_defineProperty(LineRoot, "enhance", [uniqueIDEnhancement()]);
|
|
128
|
+
|
|
129
|
+
_defineProperty(LineRoot, "defaultProps", function (_ref3) {
|
|
130
|
+
var x = _ref3.x,
|
|
131
|
+
y = _ref3.y,
|
|
132
|
+
$rootProps = _ref3.$rootProps,
|
|
133
|
+
_ref3$curve = _ref3.curve,
|
|
134
|
+
curve = _ref3$curve === void 0 ? curveLinear : _ref3$curve;
|
|
112
135
|
|
|
113
136
|
var _$rootProps$scale = _slicedToArray($rootProps.scale, 2),
|
|
114
137
|
xScale = _$rootProps$scale[0],
|
|
@@ -120,25 +143,24 @@ _defineProperty(LineRoot, "defaultProps", function (_ref2) {
|
|
|
120
143
|
}).y(function (p) {
|
|
121
144
|
return scaleOfBandwidth(yScale, p[y]);
|
|
122
145
|
}),
|
|
123
|
-
color: '#50aef4'
|
|
146
|
+
color: '#50aef4',
|
|
147
|
+
duration: 500
|
|
124
148
|
};
|
|
125
149
|
});
|
|
126
150
|
|
|
127
|
-
_defineProperty(LineRoot, "style", style);
|
|
128
|
-
|
|
129
|
-
var styled_12c = create([]);
|
|
130
|
-
|
|
131
151
|
function Null(props) {
|
|
152
|
+
var _ref2;
|
|
153
|
+
|
|
132
154
|
var SNull = props.Element,
|
|
133
155
|
styles = props.styles,
|
|
134
156
|
d3 = props.d3,
|
|
135
157
|
data = props.data,
|
|
136
158
|
hide = props.hide;
|
|
137
|
-
return
|
|
138
|
-
render: "path",
|
|
139
|
-
d: d3(data),
|
|
140
|
-
hide: hide
|
|
141
|
-
}))
|
|
159
|
+
return _ref2 = sstyled(styles), /*#__PURE__*/React.createElement(SNull, _ref2.cn("SNull", {
|
|
160
|
+
"render": "path",
|
|
161
|
+
"d": d3(data),
|
|
162
|
+
"hide": hide
|
|
163
|
+
}));
|
|
142
164
|
}
|
|
143
165
|
|
|
144
166
|
export default createElement(LineRoot, {
|