@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/cjs/Bar.js
CHANGED
|
@@ -21,35 +21,38 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
|
|
|
21
21
|
|
|
22
22
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _core = require("@semcore/core");
|
|
25
25
|
|
|
26
26
|
var _react = _interopRequireDefault(require("react"));
|
|
27
27
|
|
|
28
|
-
var _core = require("@semcore/core");
|
|
29
|
-
|
|
30
28
|
var _createElement = _interopRequireDefault(require("./createElement"));
|
|
31
29
|
|
|
30
|
+
var _ClipPath = _interopRequireDefault(require("./ClipPath"));
|
|
31
|
+
|
|
32
|
+
var _uniqueID = _interopRequireDefault(require("@semcore/utils/lib/uniqueID"));
|
|
33
|
+
|
|
34
|
+
var _d3Transition = require("d3-transition");
|
|
35
|
+
|
|
32
36
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
33
37
|
|
|
34
38
|
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; } }
|
|
35
39
|
|
|
36
40
|
/*__reshadow-styles__:"./style/bar.shadow.css"*/
|
|
37
|
-
var
|
|
41
|
+
var style = (
|
|
38
42
|
/*__reshadow_css_start__*/
|
|
39
|
-
|
|
43
|
+
_core.sstyled.insert(
|
|
40
44
|
/*__inner_css_start__*/
|
|
41
|
-
".
|
|
45
|
+
".___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}"
|
|
42
46
|
/*__inner_css_end__*/
|
|
43
|
-
, "
|
|
47
|
+
, "10kcl1b_gg_")
|
|
44
48
|
/*__reshadow_css_end__*/
|
|
45
49
|
, {
|
|
46
|
-
"__SBar": "
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
var styled_c8 = (0, _core.create)([]);
|
|
50
|
+
"__SBar": "___SBar_1u1r9_gg_",
|
|
51
|
+
"--color": "--color_10kcl1b",
|
|
52
|
+
"--duration": "--duration_10kcl1b",
|
|
53
|
+
"_hide": "__hide_1u1r9_gg_",
|
|
54
|
+
"__SBackground": "___SBackground_1u1r9_gg_"
|
|
55
|
+
});
|
|
53
56
|
|
|
54
57
|
var BarRoot = /*#__PURE__*/function (_Component) {
|
|
55
58
|
(0, _inherits2["default"])(BarRoot, _Component);
|
|
@@ -72,42 +75,83 @@ var BarRoot = /*#__PURE__*/function (_Component) {
|
|
|
72
75
|
};
|
|
73
76
|
}
|
|
74
77
|
}, {
|
|
75
|
-
key: "
|
|
76
|
-
value: function
|
|
77
|
-
var SBar = this.Element;
|
|
78
|
+
key: "animationBar",
|
|
79
|
+
value: function animationBar() {
|
|
78
80
|
var _this$asProps2 = this.asProps,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
duration = _this$asProps2.duration,
|
|
82
|
+
uid = _this$asProps2.uid;
|
|
83
|
+
var selectRect = (0, _d3Transition.transition)().selection().selectAll("#".concat(uid, " rect"));
|
|
84
|
+
var selectRectNode = selectRect.node();
|
|
85
|
+
|
|
86
|
+
if (duration > 0 && selectRectNode && selectRectNode.getAttribute('y') !== '0') {
|
|
87
|
+
selectRect.transition().duration(duration).attr('y', 0);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
key: "componentDidUpdate",
|
|
92
|
+
value: function componentDidUpdate() {
|
|
93
|
+
this.animationBar();
|
|
94
|
+
}
|
|
95
|
+
}, {
|
|
96
|
+
key: "componentDidMount",
|
|
97
|
+
value: function componentDidMount() {
|
|
98
|
+
this.animationBar();
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
key: "renderBar",
|
|
102
|
+
value: function renderBar(d, i) {
|
|
103
|
+
var _ref, _d$y, _d$y2;
|
|
104
|
+
|
|
105
|
+
var SBar = this.Element;
|
|
106
|
+
var _this$asProps3 = this.asProps,
|
|
107
|
+
styles = _this$asProps3.styles,
|
|
108
|
+
color = _this$asProps3.color,
|
|
109
|
+
x = _this$asProps3.x,
|
|
110
|
+
y = _this$asProps3.y,
|
|
111
|
+
y0 = _this$asProps3.y0,
|
|
112
|
+
scale = _this$asProps3.scale,
|
|
113
|
+
hide = _this$asProps3.hide,
|
|
114
|
+
offset = _this$asProps3.offset,
|
|
115
|
+
duration = _this$asProps3.duration,
|
|
116
|
+
uid = _this$asProps3.uid;
|
|
88
117
|
|
|
89
118
|
var _scale = (0, _slicedToArray2["default"])(scale, 2),
|
|
90
119
|
xScale = _scale[0],
|
|
91
120
|
yScale = _scale[1];
|
|
92
121
|
|
|
93
|
-
return
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
122
|
+
return _ref = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SBar, _ref.cn("SBar", {
|
|
123
|
+
"key": "bar-".concat(i),
|
|
124
|
+
"render": "rect",
|
|
125
|
+
"clipPath": "url(#".concat(uid, ")"),
|
|
126
|
+
"__excludeProps": ['data', 'scale', 'value'],
|
|
127
|
+
"childrenPosition": "above",
|
|
128
|
+
"value": d,
|
|
129
|
+
"index": i,
|
|
130
|
+
"hide": hide,
|
|
131
|
+
"color": color,
|
|
132
|
+
"width": xScale.bandwidth(),
|
|
133
|
+
"height": Math.abs(yScale(d[y]) - Math.min(yScale(yScale.domain()[0]), yScale((_d$y = d[y0]) !== null && _d$y !== void 0 ? _d$y : 0))),
|
|
134
|
+
"x": xScale(d[x]) + offset[0],
|
|
135
|
+
"y": yScale(Math.max((_d$y2 = d[y0]) !== null && _d$y2 !== void 0 ? _d$y2 : 0, d[y])) + offset[1],
|
|
136
|
+
"use:duration": "".concat(duration, "ms")
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
}, {
|
|
140
|
+
key: "render",
|
|
141
|
+
value: function render() {
|
|
142
|
+
var _this$asProps4 = this.asProps,
|
|
143
|
+
data = _this$asProps4.data,
|
|
144
|
+
uid = _this$asProps4.uid,
|
|
145
|
+
size = _this$asProps4.size,
|
|
146
|
+
duration = _this$asProps4.duration;
|
|
147
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, data.map(this.renderBar.bind(this)), duration && /*#__PURE__*/_react["default"].createElement(_ClipPath["default"], {
|
|
148
|
+
key: "".concat(uid, "-animation"),
|
|
149
|
+
id: uid,
|
|
150
|
+
x: "0",
|
|
151
|
+
y: size[1],
|
|
152
|
+
width: size[0],
|
|
153
|
+
height: "".concat(size[1], "px")
|
|
154
|
+
}));
|
|
111
155
|
}
|
|
112
156
|
}]);
|
|
113
157
|
return BarRoot;
|
|
@@ -115,13 +159,16 @@ var BarRoot = /*#__PURE__*/function (_Component) {
|
|
|
115
159
|
|
|
116
160
|
(0, _defineProperty2["default"])(BarRoot, "displayName", 'Bar');
|
|
117
161
|
(0, _defineProperty2["default"])(BarRoot, "style", style);
|
|
162
|
+
(0, _defineProperty2["default"])(BarRoot, "enhance", [(0, _uniqueID["default"])()]);
|
|
118
163
|
(0, _defineProperty2["default"])(BarRoot, "defaultProps", {
|
|
119
164
|
color: '#50aef4',
|
|
120
|
-
offset: [0, 0]
|
|
165
|
+
offset: [0, 0],
|
|
166
|
+
duration: 500
|
|
121
167
|
});
|
|
122
|
-
var styled_12c = (0, _core.create)([]);
|
|
123
168
|
|
|
124
169
|
function Background(props) {
|
|
170
|
+
var _ref2;
|
|
171
|
+
|
|
125
172
|
var SBackground = props.Element,
|
|
126
173
|
styles = props.styles,
|
|
127
174
|
scale = props.scale,
|
|
@@ -132,14 +179,14 @@ function Background(props) {
|
|
|
132
179
|
yScale = _scale2[1];
|
|
133
180
|
|
|
134
181
|
var yRange = yScale.range();
|
|
135
|
-
return
|
|
136
|
-
render: "rect",
|
|
137
|
-
childrenPosition: "above",
|
|
138
|
-
width: xScale.bandwidth(),
|
|
139
|
-
height: yRange[0] - yRange[1],
|
|
140
|
-
x: xScale(value),
|
|
141
|
-
y: yRange[1]
|
|
142
|
-
}))
|
|
182
|
+
return _ref2 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SBackground, _ref2.cn("SBackground", {
|
|
183
|
+
"render": "rect",
|
|
184
|
+
"childrenPosition": "above",
|
|
185
|
+
"width": xScale.bandwidth(),
|
|
186
|
+
"height": yRange[0] - yRange[1],
|
|
187
|
+
"x": xScale(value),
|
|
188
|
+
"y": yRange[1]
|
|
189
|
+
}));
|
|
143
190
|
}
|
|
144
191
|
|
|
145
192
|
var _default = (0, _createElement["default"])(BarRoot, {
|
package/lib/cjs/Bar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Bar.js"],"names":["BarRoot","props","index","asProps","x","data","value","SBar","Element","styles","color","y","y0","scale","hide","offset","xScale","yScale","
|
|
1
|
+
{"version":3,"sources":["../../src/Bar.js"],"names":["BarRoot","props","index","asProps","x","data","value","duration","uid","selectRect","selection","selectAll","selectRectNode","node","getAttribute","transition","attr","animationBar","d","i","SBar","Element","styles","color","y","y0","scale","hide","offset","xScale","yScale","bandwidth","Math","abs","min","domain","max","size","map","renderBar","bind","Component","style","Background","SBackground","yRange","range"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;;AADA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;IAIMA,O;;;;;;;;;;;;WAWJ,4BAAmBC,KAAnB,EAA0BC,KAA1B,EAAiC;AAAA,0BACX,KAAKC,OADM;AAAA,UACvBC,CADuB,iBACvBA,CADuB;AAAA,UACpBC,IADoB,iBACpBA,IADoB;AAE/B,aAAO;AACLC,QAAAA,KAAK,EAAED,IAAI,CAACH,KAAD,CAAJ,CAAYE,CAAZ;AADF,OAAP;AAGD;;;WAED,wBAAe;AAAA,2BACa,KAAKD,OADlB;AAAA,UACLI,QADK,kBACLA,QADK;AAAA,UACKC,GADL,kBACKA,GADL;AAEb,UAAMC,UAAU,GAAG,gCAChBC,SADgB,GAEhBC,SAFgB,YAEFH,GAFE,WAAnB;AAGA,UAAMI,cAAc,GAAGH,UAAU,CAACI,IAAX,EAAvB;;AAEA,UAAIN,QAAQ,GAAG,CAAX,IAAgBK,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C;;AAkFxB,SAASoC,UAAT,CAAoB1C,KAApB,EAA2B;AAAA;;AAAA,MACR2C,WADQ,GAC8B3C,KAD9B,CACjBoB,OADiB;AAAA,MACKC,MADL,GAC8BrB,KAD9B,CACKqB,MADL;AAAA,MACaI,KADb,GAC8BzB,KAD9B,CACayB,KADb;AAAA,MACoBpB,KADpB,GAC8BL,KAD9B,CACoBK,KADpB;;AAAA,gDAGAoB,KAHA;AAAA,MAGlBG,MAHkB;AAAA,MAGVC,MAHU;;AAIzB,MAAMe,MAAM,GAAGf,MAAM,CAACgB,KAAP,EAAf;AAEA,iBAAO,mBAAQxB,MAAR,CAAP,eACE,gCAAC,WAAD;AAAA,cACS,MADT;AAAA,wBAEmB,OAFnB;AAAA,aAGSO,MAAM,CAACE,SAAP,EAHT;AAAA,cAIUc,MAAM,CAAC,CAAD,CAAN,GAAYA,MAAM,CAAC,CAAD,CAJ5B;AAAA,SAKKhB,MAAM,CAACvB,KAAD,CALX;AAAA,SAMKuC,MAAM,CAAC,CAAD;AANX,KADF;AAUD;;eAEc,+BAAc7C,OAAd,EAAuB;AAAE2C,EAAAA,UAAU,EAAVA;AAAF,CAAvB,C","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';\nimport { transition } from 'd3-transition';\n\nimport style from './style/bar.shadow.css';\n\nclass BarRoot extends Component {\n static displayName = 'Bar';\n static style = style;\n static enhance = [uniqueIDEnhancement()];\n\n static defaultProps = {\n color: '#50aef4',\n offset: [0, 0],\n duration: 500,\n };\n\n getBackgroundProps(props, index) {\n const { x, data } = this.asProps;\n return {\n value: data[index][x],\n };\n }\n\n animationBar() {\n const { duration, uid } = this.asProps;\n const selectRect = transition()\n .selection()\n .selectAll(`#${uid} rect`);\n const selectRectNode = selectRect.node();\n\n if (duration > 0 && selectRectNode && selectRectNode.getAttribute('y') !== '0') {\n selectRect\n .transition()\n .duration(duration)\n .attr('y', 0);\n }\n }\n\n componentDidUpdate() {\n this.animationBar();\n }\n\n componentDidMount() {\n this.animationBar();\n }\n\n renderBar(d, i) {\n const SBar = this.Element;\n const { styles, color, x, y, y0, scale, hide, offset, duration, uid } = this.asProps;\n\n const [xScale, yScale] = scale;\n\n return sstyled(styles)(\n <SBar\n key={`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 // TODO: https://github.com/airbnb/visx/blob/2fa674e7d7fdc9cffea13e8bf644d46dd6f0db5b/packages/visx-shape/src/util/getBandwidth.ts#L3\n width={xScale.bandwidth()}\n height={Math.abs(yScale(d[y]) - Math.min(yScale(yScale.domain()[0]), yScale(d[y0] ?? 0)))}\n x={xScale(d[x]) + offset[0]}\n y={yScale(Math.max(d[y0] ?? 0, d[y])) + offset[1]}\n use:duration={`${duration}ms`}\n />,\n );\n }\n render() {\n const { data, uid, size, duration } = this.asProps;\n return (\n <>\n {data.map(this.renderBar.bind(this))}\n {duration && (\n <ClipPath\n key={`${uid}-animation`}\n id={uid}\n x=\"0\"\n y={size[1]}\n width={size[0]}\n height={`${size[1]}px`}\n />\n )}\n </>\n );\n }\n}\n\nfunction Background(props) {\n const { Element: SBackground, styles, scale, value } = props;\n\n const [xScale, yScale] = scale;\n const yRange = yScale.range();\n\n return sstyled(styles)(\n <SBackground\n render=\"rect\"\n childrenPosition=\"above\"\n width={xScale.bandwidth()}\n height={yRange[0] - yRange[1]}\n x={xScale(value)}\n y={yRange[1]}\n />,\n );\n}\n\nexport default createElement(BarRoot, { Background });\n"],"file":"Bar.js"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports["default"] = void 0;
|
|
11
|
+
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
14
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
|
+
|
|
16
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
17
|
+
|
|
18
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
19
|
+
|
|
20
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
21
|
+
|
|
22
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
23
|
+
|
|
24
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
25
|
+
|
|
26
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
27
|
+
|
|
28
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
29
|
+
|
|
30
|
+
var _react = _interopRequireDefault(require("react"));
|
|
31
|
+
|
|
32
|
+
var _core = _interopRequireWildcard(require("@semcore/core"));
|
|
33
|
+
|
|
34
|
+
var _propsForElement = _interopRequireDefault(require("@semcore/utils/lib/propsForElement"));
|
|
35
|
+
|
|
36
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
37
|
+
|
|
38
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
39
|
+
|
|
40
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
41
|
+
|
|
42
|
+
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; } }
|
|
43
|
+
|
|
44
|
+
var ClipPath = /*#__PURE__*/function (_Component) {
|
|
45
|
+
(0, _inherits2["default"])(ClipPath, _Component);
|
|
46
|
+
|
|
47
|
+
var _super = _createSuper(ClipPath);
|
|
48
|
+
|
|
49
|
+
function ClipPath() {
|
|
50
|
+
var _this;
|
|
51
|
+
|
|
52
|
+
(0, _classCallCheck2["default"])(this, ClipPath);
|
|
53
|
+
|
|
54
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
55
|
+
args[_key] = arguments[_key];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
59
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "refClipPath", /*#__PURE__*/_react["default"].createRef());
|
|
60
|
+
return _this;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
(0, _createClass2["default"])(ClipPath, [{
|
|
64
|
+
key: "componentDidMount",
|
|
65
|
+
value: function componentDidMount() {
|
|
66
|
+
var _this$asProps = this.asProps,
|
|
67
|
+
id = _this$asProps.id,
|
|
68
|
+
tag = _this$asProps.tag,
|
|
69
|
+
setAttributeTag = _this$asProps.setAttributeTag;
|
|
70
|
+
if (!document || !document.querySelector("#".concat(id))) return;
|
|
71
|
+
var svg = document.querySelector("#".concat(id)).closest('svg');
|
|
72
|
+
Array.from(svg.querySelectorAll("[clip-path=\"url(#".concat(id, ")\"]"))).forEach(function (node) {
|
|
73
|
+
node && node.getTotalLength && node.getTotalLength();
|
|
74
|
+
});
|
|
75
|
+
setAttributeTag && Array.from(document.querySelectorAll("#".concat(id, " ").concat(tag))).forEach(setAttributeTag);
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
key: "render",
|
|
79
|
+
value: function render() {
|
|
80
|
+
var _this$asProps2 = this.asProps,
|
|
81
|
+
id = _this$asProps2.id,
|
|
82
|
+
transition = _this$asProps2.transition,
|
|
83
|
+
Tag = _this$asProps2.tag,
|
|
84
|
+
style = _this$asProps2.style,
|
|
85
|
+
className = _this$asProps2.className,
|
|
86
|
+
other = (0, _objectWithoutProperties2["default"])(_this$asProps2, ["id", "transition", "tag", "style", "className"]);
|
|
87
|
+
return /*#__PURE__*/_react["default"].createElement("clipPath", {
|
|
88
|
+
ref: this.refClipPath,
|
|
89
|
+
id: id
|
|
90
|
+
}, /*#__PURE__*/_react["default"].createElement(Tag, (0, _extends2["default"])({
|
|
91
|
+
style: _objectSpread(_objectSpread({}, style), {}, {
|
|
92
|
+
transition: transition
|
|
93
|
+
})
|
|
94
|
+
}, (0, _propsForElement["default"])(other, Tag))));
|
|
95
|
+
}
|
|
96
|
+
}]);
|
|
97
|
+
return ClipPath;
|
|
98
|
+
}(_core.Component);
|
|
99
|
+
|
|
100
|
+
(0, _defineProperty2["default"])(ClipPath, "defaultProps", {
|
|
101
|
+
tag: 'rect',
|
|
102
|
+
id: '',
|
|
103
|
+
transition: '',
|
|
104
|
+
setAttributeTag: null
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
var _default = (0, _core["default"])(ClipPath);
|
|
108
|
+
|
|
109
|
+
exports["default"] = _default;
|
|
110
|
+
//# sourceMappingURL=ClipPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ClipPath.js"],"names":["ClipPath","React","createRef","asProps","id","tag","setAttributeTag","document","querySelector","svg","closest","Array","from","querySelectorAll","forEach","node","getTotalLength","transition","Tag","style","className","other","refClipPath","Component"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;;;;;;;;;IAEMA,Q;;;;;;;;;;;;;;;iHAQUC,kBAAMC,SAAN,E;;;;;;WAEd,6BAAoB;AAAA,0BACmB,KAAKC,OADxB;AAAA,UACVC,EADU,iBACVA,EADU;AAAA,UACNC,GADM,iBACNA,GADM;AAAA,UACDC,eADC,iBACDA,eADC;AAElB,UAAI,CAACC,QAAD,IAAa,CAACA,QAAQ,CAACC,aAAT,YAA2BJ,EAA3B,EAAlB,EAAoD;AACpD,UAAMK,GAAG,GAAGF,QAAQ,CAACC,aAAT,YAA2BJ,EAA3B,GAAiCM,OAAjC,CAAyC,KAAzC,CAAZ;AACAC,MAAAA,KAAK,CAACC,IAAN,CAAWH,GAAG,CAACI,gBAAJ,6BAAyCT,EAAzC,UAAX,EAA8DU,OAA9D,CAAsE,UAACC,IAAD,EAAU;AAC9EA,QAAAA,IAAI,IAAIA,IAAI,CAACC,cAAb,IAA+BD,IAAI,CAACC,cAAL,EAA/B;AACD,OAFD;AAGAV,MAAAA,eAAe,IACbK,KAAK,CAACC,IAAN,CAAWL,QAAQ,CAACM,gBAAT,YAA8BT,EAA9B,cAAoCC,GAApC,EAAX,EAAuDS,OAAvD,CAA+DR,eAA/D,CADF;AAED;;;WAED,kBAAS;AAAA,2BAC0D,KAAKH,OAD/D;AAAA,UACCC,EADD,kBACCA,EADD;AAAA,UACKa,UADL,kBACKA,UADL;AAAA,UACsBC,GADtB,kBACiBb,GADjB;AAAA,UAC2Bc,KAD3B,kBAC2BA,KAD3B;AAAA,UACkCC,SADlC,kBACkCA,SADlC;AAAA,UACgDC,KADhD;AAEP,0BACE;AAAU,QAAA,GAAG,EAAE,KAAKC,WAApB;AAAiC,QAAA,EAAE,EAAElB;AAArC,sBACE,gCAAC,GAAD;AAAK,QAAA,KAAK,kCAAOe,KAAP;AAAcF,UAAAA,UAAU,EAAVA;AAAd;AAAV,SAA0C,iCAAgBI,KAAhB,EAAuBH,GAAvB,CAA1C,EADF,CADF;AAKD;;;EA5BoBK,e;;iCAAjBvB,Q,kBACkB;AACpBK,EAAAA,GAAG,EAAE,MADe;AAEpBD,EAAAA,EAAE,EAAE,EAFgB;AAGpBa,EAAAA,UAAU,EAAE,EAHQ;AAIpBX,EAAAA,eAAe,EAAE;AAJG,C;;eA8BT,sBAAgBN,QAAhB,C","sourcesContent":["import React from 'react';\nimport createComponent, { Component } from '@semcore/core';\nimport propsForElement from '@semcore/utils/lib/propsForElement';\n\nclass ClipPath extends Component {\n static defaultProps = {\n tag: 'rect',\n id: '',\n transition: '',\n setAttributeTag: null,\n };\n\n refClipPath = React.createRef();\n\n componentDidMount() {\n const { id, tag, setAttributeTag } = this.asProps;\n if (!document || !document.querySelector(`#${id}`)) return;\n const svg = document.querySelector(`#${id}`).closest('svg');\n Array.from(svg.querySelectorAll(`[clip-path=\"url(#${id})\"]`)).forEach((node) => {\n node && node.getTotalLength && node.getTotalLength();\n });\n setAttributeTag &&\n Array.from(document.querySelectorAll(`#${id} ${tag}`)).forEach(setAttributeTag);\n }\n\n render() {\n const { id, transition, tag: Tag, style, className, ...other } = this.asProps;\n return (\n <clipPath ref={this.refClipPath} id={id}>\n <Tag style={{ ...style, transition }} {...propsForElement(other, Tag)} />\n </clipPath>\n );\n }\n}\n\nexport default createComponent(ClipPath);\n"],"file":"ClipPath.js"}
|