@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/Venn.js
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
8
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
9
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
10
|
+
import { sstyled as _sstyled } from "@semcore/core";
|
|
11
|
+
|
|
12
|
+
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); }; }
|
|
13
|
+
|
|
14
|
+
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; } }
|
|
15
|
+
|
|
16
|
+
import React from 'react';
|
|
17
|
+
import { venn, normalizeSolution, scaleSolution, intersectionAreaPath } from '@upsetjs/venn.js';
|
|
18
|
+
import { Component, sstyled } from '@semcore/core';
|
|
19
|
+
import canUseDOM from '@semcore/utils/lib/canUseDOM';
|
|
20
|
+
import { FadeInOut } from '@semcore/animation';
|
|
21
|
+
import createElement from './createElement';
|
|
22
|
+
import { CONSTANT } from './utils';
|
|
23
|
+
|
|
24
|
+
/*__reshadow-styles__:"./style/venn.shadow.css"*/
|
|
25
|
+
var style = (
|
|
26
|
+
/*__reshadow_css_start__*/
|
|
27
|
+
_sstyled.insert(
|
|
28
|
+
/*__inner_css_start__*/
|
|
29
|
+
".___SCircle_1qcib_gg_{fill:var(--color_v23pgz);stroke:#fff;stroke-width:2px;fill-opacity:.5;transition-property:cx,cy;transition-duration:var(--duration_v23pgz);transition-timing-function:ease-in-out}.___SCircle_1qcib_gg_:hover{fill-opacity:.7}.___SIntersection_1qcib_gg_{stroke:#fff;stroke-width:2px;fill-opacity:0}.___SIntersection_1qcib_gg_:hover{fill-opacity:.1}"
|
|
30
|
+
/*__inner_css_end__*/
|
|
31
|
+
, "v23pgz_gg_")
|
|
32
|
+
/*__reshadow_css_end__*/
|
|
33
|
+
, {
|
|
34
|
+
"__SCircle": "___SCircle_1qcib_gg_",
|
|
35
|
+
"--color": "--color_v23pgz",
|
|
36
|
+
"--duration": "--duration_v23pgz",
|
|
37
|
+
"__SIntersection": "___SIntersection_1qcib_gg_"
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
var VennRoot = /*#__PURE__*/function (_Component) {
|
|
41
|
+
_inherits(VennRoot, _Component);
|
|
42
|
+
|
|
43
|
+
var _super = _createSuper(VennRoot);
|
|
44
|
+
|
|
45
|
+
function VennRoot() {
|
|
46
|
+
var _this;
|
|
47
|
+
|
|
48
|
+
_classCallCheck(this, VennRoot);
|
|
49
|
+
|
|
50
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
51
|
+
args[_key] = arguments[_key];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
55
|
+
|
|
56
|
+
_defineProperty(_assertThisInitialized(_this), "virtualElement", canUseDOM() ? document.createElement('div') : {});
|
|
57
|
+
|
|
58
|
+
_defineProperty(_assertThisInitialized(_this), "bindHandlerTooltip", function (visible, props) {
|
|
59
|
+
return function (_ref3) {
|
|
60
|
+
var x = _ref3.clientX,
|
|
61
|
+
y = _ref3.clientY;
|
|
62
|
+
var eventEmitter = _this.asProps.eventEmitter;
|
|
63
|
+
_this.virtualElement.getBoundingClientRect = _this.generateGetBoundingClientRect(x, y);
|
|
64
|
+
_this.virtualElement[CONSTANT.VIRTUAL_ELEMENT] = true;
|
|
65
|
+
eventEmitter.emit('onTooltipVisible', visible, props, _this.virtualElement);
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
_defineProperty(_assertThisInitialized(_this), "renderElement", /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
70
|
+
return /*#__PURE__*/React.createElement(FadeInOut, _extends({
|
|
71
|
+
ref: ref,
|
|
72
|
+
tag: "g",
|
|
73
|
+
visible: true
|
|
74
|
+
}, props));
|
|
75
|
+
}));
|
|
76
|
+
|
|
77
|
+
return _this;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
_createClass(VennRoot, [{
|
|
81
|
+
key: "generateGetBoundingClientRect",
|
|
82
|
+
value: function generateGetBoundingClientRect() {
|
|
83
|
+
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
84
|
+
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
85
|
+
return function () {
|
|
86
|
+
return {
|
|
87
|
+
width: 0,
|
|
88
|
+
height: 0,
|
|
89
|
+
top: y,
|
|
90
|
+
right: x,
|
|
91
|
+
bottom: y,
|
|
92
|
+
left: x
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
97
|
+
key: "getVennData",
|
|
98
|
+
value: function getVennData() {
|
|
99
|
+
var _this$asProps = this.asProps,
|
|
100
|
+
data = _this$asProps.data,
|
|
101
|
+
orientation = _this$asProps.orientation,
|
|
102
|
+
orientationOrder = _this$asProps.orientationOrder,
|
|
103
|
+
size = _this$asProps.size;
|
|
104
|
+
|
|
105
|
+
var _size = _slicedToArray(size, 2),
|
|
106
|
+
width = _size[0],
|
|
107
|
+
height = _size[1];
|
|
108
|
+
|
|
109
|
+
var vennData = Object.entries(data).map(function (_ref4) {
|
|
110
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
|
111
|
+
dataKey = _ref5[0],
|
|
112
|
+
size = _ref5[1];
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
sets: dataKey.split('/'),
|
|
116
|
+
size: size
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
return scaleSolution(normalizeSolution(venn(vennData), orientation, orientationOrder), width, height, 10);
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
key: "getCircleProps",
|
|
123
|
+
value: function getCircleProps(props) {
|
|
124
|
+
return {
|
|
125
|
+
duration: this.asProps.duration,
|
|
126
|
+
data: this.vennData[props.dataKey],
|
|
127
|
+
onMouseMove: this.bindHandlerTooltip(true, props),
|
|
128
|
+
onMouseLeave: this.bindHandlerTooltip(false, props)
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}, {
|
|
132
|
+
key: "getIntersectionProps",
|
|
133
|
+
value: function getIntersectionProps(props) {
|
|
134
|
+
var duration = this.asProps.duration;
|
|
135
|
+
var dataKeys = props.dataKey.split('/');
|
|
136
|
+
return {
|
|
137
|
+
duration: duration,
|
|
138
|
+
delay: duration,
|
|
139
|
+
data: Object.values(this.vennData).filter(function (d) {
|
|
140
|
+
return dataKeys.includes(d.setid);
|
|
141
|
+
}),
|
|
142
|
+
onMouseMove: this.bindHandlerTooltip(true, props),
|
|
143
|
+
onMouseLeave: this.bindHandlerTooltip(false, props)
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}, {
|
|
147
|
+
key: "render",
|
|
148
|
+
value: function render() {
|
|
149
|
+
var Element = this.Element;
|
|
150
|
+
this.vennData = this.getVennData();
|
|
151
|
+
return /*#__PURE__*/React.createElement(Element, {
|
|
152
|
+
render: this.renderElement,
|
|
153
|
+
childrenPosition: "inside",
|
|
154
|
+
vennData: this.vennData
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}]);
|
|
158
|
+
|
|
159
|
+
return VennRoot;
|
|
160
|
+
}(Component);
|
|
161
|
+
|
|
162
|
+
_defineProperty(VennRoot, "displayName", 'Venn');
|
|
163
|
+
|
|
164
|
+
_defineProperty(VennRoot, "style", style);
|
|
165
|
+
|
|
166
|
+
_defineProperty(VennRoot, "defaultProps", {
|
|
167
|
+
orientation: Math.PI / 2,
|
|
168
|
+
orientationOrder: function orientationOrder(c1, c2) {
|
|
169
|
+
return c2.radius - c1.radius;
|
|
170
|
+
},
|
|
171
|
+
duration: 500
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
function Circle(_ref6) {
|
|
175
|
+
var _ref;
|
|
176
|
+
|
|
177
|
+
var SCircle = _ref6.Element,
|
|
178
|
+
styles = _ref6.styles,
|
|
179
|
+
_ref6$color = _ref6.color,
|
|
180
|
+
color = _ref6$color === void 0 ? '#3AB011' : _ref6$color,
|
|
181
|
+
data = _ref6.data,
|
|
182
|
+
duration = _ref6.duration;
|
|
183
|
+
return _ref = sstyled(styles), /*#__PURE__*/React.createElement(SCircle, _ref.cn("SCircle", {
|
|
184
|
+
"render": "circle",
|
|
185
|
+
"color": color,
|
|
186
|
+
"cx": data.x,
|
|
187
|
+
"cy": data.y,
|
|
188
|
+
"r": data.radius,
|
|
189
|
+
"use:duration": "".concat(duration, "ms")
|
|
190
|
+
}));
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function Intersection(props) {
|
|
194
|
+
var _ref2;
|
|
195
|
+
|
|
196
|
+
var SIntersection = props.Element,
|
|
197
|
+
styles = props.styles,
|
|
198
|
+
data = props.data;
|
|
199
|
+
var renderIntersection = React.useCallback( /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
200
|
+
return /*#__PURE__*/React.createElement(FadeInOut, _extends({
|
|
201
|
+
ref: ref,
|
|
202
|
+
tag: "path",
|
|
203
|
+
visible: true
|
|
204
|
+
}, props));
|
|
205
|
+
}), [props]);
|
|
206
|
+
return _ref2 = sstyled(styles), /*#__PURE__*/React.createElement(SIntersection, _ref2.cn("SIntersection", {
|
|
207
|
+
"render": renderIntersection,
|
|
208
|
+
"d": intersectionAreaPath(data)
|
|
209
|
+
}));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
var Venn = createElement(VennRoot, {
|
|
213
|
+
Circle: Circle,
|
|
214
|
+
Intersection: Intersection
|
|
215
|
+
});
|
|
216
|
+
export default Venn;
|
|
217
|
+
//# sourceMappingURL=Venn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/Venn.js"],"names":["React","venn","normalizeSolution","scaleSolution","intersectionAreaPath","Component","sstyled","canUseDOM","FadeInOut","createElement","CONSTANT","VennRoot","document","visible","props","x","clientX","y","clientY","eventEmitter","asProps","virtualElement","getBoundingClientRect","generateGetBoundingClientRect","VIRTUAL_ELEMENT","emit","forwardRef","ref","width","height","top","right","bottom","left","data","orientation","orientationOrder","size","vennData","Object","entries","map","dataKey","sets","split","duration","onMouseMove","bindHandlerTooltip","onMouseLeave","dataKeys","delay","values","filter","d","includes","setid","Element","getVennData","renderElement","style","Math","PI","c1","c2","radius","Circle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EA,eAAeI,IAAf","sourcesContent":["import React from 'react';\nimport { venn, normalizeSolution, scaleSolution, intersectionAreaPath } from '@upsetjs/venn.js';\nimport { Component, sstyled } from '@semcore/core';\nimport canUseDOM from '@semcore/utils/lib/canUseDOM';\nimport { FadeInOut } from '@semcore/animation';\n\nimport createElement from './createElement';\nimport { CONSTANT } from './utils';\n\nimport style from './style/venn.shadow.css';\n\nclass VennRoot extends Component {\n static displayName = 'Venn';\n static style = style;\n\n static defaultProps = {\n orientation: Math.PI / 2,\n orientationOrder: (c1, c2) => c2.radius - c1.radius,\n duration: 500,\n };\n\n virtualElement = canUseDOM() ? document.createElement('div') : {};\n\n generateGetBoundingClientRect(x = 0, y = 0) {\n return () => ({ width: 0, height: 0, top: y, right: x, bottom: y, left: x });\n }\n\n bindHandlerTooltip = (visible, props) => ({ clientX: x, clientY: y }) => {\n const { eventEmitter } = this.asProps;\n this.virtualElement.getBoundingClientRect = this.generateGetBoundingClientRect(x, y);\n this.virtualElement[CONSTANT.VIRTUAL_ELEMENT] = true;\n eventEmitter.emit('onTooltipVisible', visible, props, this.virtualElement);\n };\n\n getVennData() {\n const { data, orientation, orientationOrder, size } = this.asProps;\n const [width, height] = size;\n const vennData = Object.entries(data).map(([dataKey, size]) => ({\n sets: dataKey.split('/'),\n size,\n }));\n return scaleSolution(\n normalizeSolution(venn(vennData), orientation, orientationOrder),\n width,\n height,\n 10,\n );\n }\n\n getCircleProps(props) {\n return {\n duration: this.asProps.duration,\n data: this.vennData[props.dataKey],\n onMouseMove: this.bindHandlerTooltip(true, props),\n onMouseLeave: this.bindHandlerTooltip(false, props),\n };\n }\n\n getIntersectionProps(props) {\n const { duration } = this.asProps;\n const dataKeys = props.dataKey.split('/');\n return {\n duration,\n delay: duration,\n data: Object.values(this.vennData).filter((d) => dataKeys.includes(d.setid)),\n onMouseMove: this.bindHandlerTooltip(true, props),\n onMouseLeave: this.bindHandlerTooltip(false, props),\n };\n }\n\n renderElement = React.forwardRef((props, ref) => {\n return <FadeInOut ref={ref} tag=\"g\" visible {...props} />;\n });\n\n render() {\n const Element = this.Element;\n this.vennData = this.getVennData();\n return (\n <Element render={this.renderElement} childrenPosition=\"inside\" vennData={this.vennData} />\n );\n }\n}\n\nfunction Circle({ Element: SCircle, styles, color = '#3AB011', data, duration }) {\n return sstyled(styles)(\n <SCircle\n render=\"circle\"\n color={color}\n cx={data.x}\n cy={data.y}\n r={data.radius}\n use:duration={`${duration}ms`}\n />,\n );\n}\n\nfunction Intersection(props) {\n const { Element: SIntersection, styles, data } = props;\n const renderIntersection = React.useCallback(\n React.forwardRef((props, ref) => {\n return <FadeInOut ref={ref} tag=\"path\" visible {...props} />;\n }),\n [props],\n );\n return sstyled(styles)(\n <SIntersection render={renderIntersection} d={intersectionAreaPath(data)} />,\n );\n}\n\nconst Venn = createElement(VennRoot, { Circle, Intersection });\n\nexport default Venn;\n"],"file":"Venn.js"}
|
package/lib/es6/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export { default as StackBar } from './StackBar';
|
|
|
8
8
|
export { default as Area } from './Area';
|
|
9
9
|
export { default as StackedArea } from './StackedArea';
|
|
10
10
|
export { default as Donut } from './Donut';
|
|
11
|
+
export { default as Venn } from './Venn';
|
|
11
12
|
export { default as Tooltip } from './Tooltip';
|
|
12
13
|
export { default as ResponsiveContainer } from './ResponsiveContainer';
|
|
13
14
|
export { HoverLine, HoverRect } from './Hover';
|
package/lib/es6/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.js"],"names":["default","Plot","XAxis","YAxis","Line","Bar","HorizontalBar","GroupBar","StackBar","Area","StackedArea","Donut","Tooltip","ResponsiveContainer","HoverLine","HoverRect","minMax","colors"],"mappings":"AAAA,SAASA,OAAO,IAAIC,IAApB,QAAgC,QAAhC;AAEA,SAASC,KAAT,EAAgBC,KAAhB,QAA6B,QAA7B;AAEA,SAASH,OAAO,IAAII,IAApB,QAAgC,QAAhC;AAEA,SAASJ,OAAO,IAAIK,GAApB,QAA+B,OAA/B;AACA,SAASL,OAAO,IAAIM,aAApB,QAAyC,iBAAzC;AACA,SAASN,OAAO,IAAIO,QAApB,QAAoC,YAApC;AACA,SAASP,OAAO,IAAIQ,QAApB,QAAoC,YAApC;AACA,SAASR,OAAO,IAAIS,IAApB,QAAgC,QAAhC;AACA,SAAST,OAAO,IAAIU,WAApB,QAAuC,eAAvC;AACA,SAASV,OAAO,IAAIW,KAApB,QAAiC,SAAjC;
|
|
1
|
+
{"version":3,"sources":["../../src/index.js"],"names":["default","Plot","XAxis","YAxis","Line","Bar","HorizontalBar","GroupBar","StackBar","Area","StackedArea","Donut","Venn","Tooltip","ResponsiveContainer","HoverLine","HoverRect","minMax","colors"],"mappings":"AAAA,SAASA,OAAO,IAAIC,IAApB,QAAgC,QAAhC;AAEA,SAASC,KAAT,EAAgBC,KAAhB,QAA6B,QAA7B;AAEA,SAASH,OAAO,IAAII,IAApB,QAAgC,QAAhC;AAEA,SAASJ,OAAO,IAAIK,GAApB,QAA+B,OAA/B;AACA,SAASL,OAAO,IAAIM,aAApB,QAAyC,iBAAzC;AACA,SAASN,OAAO,IAAIO,QAApB,QAAoC,YAApC;AACA,SAASP,OAAO,IAAIQ,QAApB,QAAoC,YAApC;AACA,SAASR,OAAO,IAAIS,IAApB,QAAgC,QAAhC;AACA,SAAST,OAAO,IAAIU,WAApB,QAAuC,eAAvC;AACA,SAASV,OAAO,IAAIW,KAApB,QAAiC,SAAjC;AACA,SAASX,OAAO,IAAIY,IAApB,QAAgC,QAAhC;AAEA,SAASZ,OAAO,IAAIa,OAApB,QAAmC,WAAnC;AAEA,SAASb,OAAO,IAAIc,mBAApB,QAA+C,uBAA/C;AAEA,SAASC,SAAT,EAAoBC,SAApB,QAAqC,SAArC;AAEA,SAASC,MAAT,QAAuB,SAAvB;AACA,SAASC,MAAT,QAAuB,SAAvB","sourcesContent":["export { default as Plot } from './Plot';\n\nexport { XAxis, YAxis } from './Axis';\n\nexport { default as Line } from './Line';\n\nexport { default as Bar } from './Bar';\nexport { default as HorizontalBar } from './HorizontalBar';\nexport { default as GroupBar } from './GroupBar';\nexport { default as StackBar } from './StackBar';\nexport { default as Area } from './Area';\nexport { default as StackedArea } from './StackedArea';\nexport { default as Donut } from './Donut';\nexport { default as Venn } from './Venn';\n\nexport { default as Tooltip } from './Tooltip';\n\nexport { default as ResponsiveContainer } from './ResponsiveContainer';\n\nexport { HoverLine, HoverRect } from './Hover';\n\nexport { minMax } from './utils';\nexport { colors } from './color';\n"],"file":"index.js"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
SArea {
|
|
2
|
+
fill: var(--color);
|
|
3
|
+
fill-opacity: 0.4;
|
|
2
4
|
}
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
stroke
|
|
6
|
-
stroke:
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
SDot[hide] {
|
|
11
|
-
display: none;
|
|
6
|
+
SAreaLine {
|
|
7
|
+
stroke: var(--color);
|
|
8
|
+
stroke-width: 3;
|
|
9
|
+
fill: transparent;
|
|
12
10
|
}
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
SArea,
|
|
13
|
+
SAreaLine {
|
|
14
|
+
transition-property: d;
|
|
15
|
+
transition-duration: var(--duration);
|
|
16
|
+
transition-timing-function: ease-in-out;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
SNull {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
@import '@semcore/utils/style/var.css';
|
|
2
|
+
|
|
3
|
+
SDot {
|
|
4
|
+
stroke-width: 2px;
|
|
5
|
+
stroke: #fff;
|
|
6
|
+
r: 6px;
|
|
7
|
+
fill: var(--color);
|
|
8
|
+
transition-property: cx, cy;
|
|
9
|
+
transition-duration: var(--duration);
|
|
10
|
+
transition-timing-function: ease-in-out;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
SDot[hide] {
|
|
14
|
+
display: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
SDot[active] {
|
|
18
|
+
r: 8px;
|
|
19
|
+
}
|
|
@@ -3,27 +3,16 @@
|
|
|
3
3
|
SLine {
|
|
4
4
|
fill: transparent;
|
|
5
5
|
stroke-width: 3;
|
|
6
|
-
|
|
6
|
+
stroke: var(--color);
|
|
7
|
+
transition-property: d;
|
|
8
|
+
transition-duration: var(--duration);
|
|
9
|
+
transition-timing-function: ease-in-out;
|
|
7
10
|
}
|
|
8
11
|
|
|
9
12
|
SLine[hide] {
|
|
10
13
|
display: none;
|
|
11
14
|
}
|
|
12
15
|
|
|
13
|
-
SDot {
|
|
14
|
-
stroke-width: 2px;
|
|
15
|
-
stroke: #fff;
|
|
16
|
-
r: 6px;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
SDot[hide] {
|
|
20
|
-
display: none;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
SDot[active] {
|
|
24
|
-
r: 8px;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
16
|
SNull {
|
|
28
17
|
fill: transparent;
|
|
29
18
|
stroke: var(--mist);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
SCircle {
|
|
2
|
+
fill: var(--color);
|
|
3
|
+
stroke: #fff;
|
|
4
|
+
stroke-width: 2px;
|
|
5
|
+
fill-opacity: 0.5;
|
|
6
|
+
transition-property: cx, cy;
|
|
7
|
+
transition-duration: var(--duration);
|
|
8
|
+
transition-timing-function: ease-in-out;
|
|
9
|
+
|
|
10
|
+
&:hover {
|
|
11
|
+
fill-opacity: 0.7;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
SIntersection {
|
|
16
|
+
stroke: #fff;
|
|
17
|
+
stroke-width: 2px;
|
|
18
|
+
fill-opacity: 0;
|
|
19
|
+
|
|
20
|
+
&:hover {
|
|
21
|
+
fill-opacity: 0.1;
|
|
22
|
+
}
|
|
23
|
+
}
|
package/lib/es6/utils.js
CHANGED
|
@@ -21,11 +21,16 @@ export function invert(scale, value) {
|
|
|
21
21
|
var domain = scale.domain();
|
|
22
22
|
return scaleQuantize().domain(range[0] <= range[1] ? range : range.slice().reverse()).range(range[0] <= range[1] ? domain : domain.slice().reverse())(value);
|
|
23
23
|
}
|
|
24
|
-
export function
|
|
24
|
+
export function definedNullData(x, y) {
|
|
25
25
|
return function (p) {
|
|
26
26
|
return p[x] !== null && p[y] !== null;
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
+
export function definedData(x, y) {
|
|
30
|
+
return function (p) {
|
|
31
|
+
return p[x] !== null && p[x] !== undefined && p[y] !== null && p[y] !== undefined;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
29
34
|
export function scaleOfBandwidth(scale, value) {
|
|
30
35
|
return scale.bandwidth ? scale(value) + scale.bandwidth() / 2 : scale(value);
|
|
31
36
|
}
|
package/lib/es6/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils.js"],"names":["extent","bisector","scaleQuantize","CONSTANT","VIRTUAL_ELEMENT","Symbol","eventToPoint","event","svgRoot","node","currentTarget","target","rect","getBoundingClientRect","clientX","left","clientLeft","clientY","top","clientTop","invert","scale","value","range","domain","slice","reverse","
|
|
1
|
+
{"version":3,"sources":["../../src/utils.js"],"names":["extent","bisector","scaleQuantize","CONSTANT","VIRTUAL_ELEMENT","Symbol","eventToPoint","event","svgRoot","node","currentTarget","target","rect","getBoundingClientRect","clientX","left","clientLeft","clientY","top","clientTop","invert","scale","value","range","domain","slice","reverse","definedNullData","x","y","p","definedData","undefined","scaleOfBandwidth","bandwidth","minMax","data","key","d","getNullData","defined","name","reduce","acc","i","push","prev","next","defNext","find","length","defPrev","getIndexFromData","bisect","center","step","index","findIndex","console","warn"],"mappings":";;;;;;AAAA,SAASA,MAAT,EAAiBC,QAAjB,QAAiC,UAAjC;AACA,SAASC,aAAT,QAA8B,UAA9B;AAEA,IAAMC,QAAQ,GAAG;AACfC,EAAAA,eAA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GpB,IAAI,CAACqB,SAAL,CAAe,UAACnB,CAAD;AAAA,eAAOA,CAAC,CAACD,GAAD,CAAD,KAAWf,KAAlB;AAAA,OAAf,CAAd;AACA,aAAOkC,KAAK,IAAI,CAAT,GAAaA,KAAb,GAAqB,IAA5B;AACD,KAHI,MAGE;AACLE,MAAAA,OAAO,CAACC,IAAR,CAAa,uEAAb;AACA,aAAO,IAAP;AACD;AACF","sourcesContent":["import { extent, bisector } from 'd3-array';\nimport { scaleQuantize } from 'd3-scale';\n\nconst CONSTANT = {\n VIRTUAL_ELEMENT: Symbol('VIRTUAL_ELEMENT'),\n};\n\nexport { CONSTANT };\n\nexport function eventToPoint(event, svgRoot) {\n const node = event.currentTarget || event.target;\n const rect = svgRoot.getBoundingClientRect();\n return [event.clientX - rect.left - node.clientLeft, event.clientY - rect.top - node.clientTop];\n}\n\nexport function invert(scale, value) {\n if (scale.invert) return scale.invert(value);\n\n const range = scale.range();\n const domain = scale.domain();\n\n return scaleQuantize()\n .domain(range[0] <= range[1] ? range : range.slice().reverse())\n .range(range[0] <= range[1] ? domain : domain.slice().reverse())(value);\n}\n\nexport function definedNullData(x, y) {\n return (p) => p[x] !== null && p[y] !== null;\n}\n\nexport function definedData(x, y) {\n return (p) => {\n return p[x] !== null && p[x] !== undefined && (p[y] !== null && p[y] !== undefined);\n };\n}\n\nexport function scaleOfBandwidth(scale, value) {\n return scale.bandwidth ? scale(value) + scale.bandwidth() / 2 : scale(value);\n}\n\nexport function minMax(data, key) {\n if (typeof key === 'string') {\n return extent(data, (d) => d[key]);\n }\n return extent(data, key);\n}\n\nexport function getNullData(data, defined, name) {\n return data.reduce((acc, d, i, data) => {\n if (defined(d)) {\n acc.push({\n [name]: null,\n });\n } else {\n const prev = data[i - 1];\n const next = data[i + 1];\n\n if (i === 0) {\n const defNext = data.find(defined);\n acc.push({\n ...d,\n [name]: defNext ? defNext[name] : null,\n });\n }\n\n // prev\n if (prev && defined(prev)) {\n acc.push(prev);\n }\n\n // next\n if (next && defined(next)) {\n acc.push(next);\n }\n\n if (data.length - 1 === i) {\n const defPrev = data\n .slice()\n .reverse()\n .find(defined);\n acc.push({\n ...d,\n [name]: defPrev ? defPrev[name] : null,\n });\n }\n }\n return acc;\n }, []);\n}\n\nexport function getIndexFromData(data, scale, key, value) {\n // detect line chart\n if ('invert' in scale && typeof scale.invert === 'function') {\n const bisect = bisector((d) => d[key]).center;\n return bisect(data, value);\n }\n // detect bar chart\n else if ('step' in scale && typeof scale.step !== 'undefined') {\n const index = data.findIndex((d) => d[key] === value);\n return index >= 0 ? index : null;\n } else {\n console.warn('[d3-chart/utils/getIndexFromData] encountered incompatible scale type');\n return null;\n }\n}\n"],"file":"utils.js"}
|
package/lib/types/Area.d.ts
CHANGED
|
@@ -3,20 +3,21 @@ import IContext from './context';
|
|
|
3
3
|
import { CurveFactory } from 'd3-shape';
|
|
4
4
|
|
|
5
5
|
export interface IAreaProps extends IContext {
|
|
6
|
-
/** Field from data for
|
|
6
|
+
/** Field from data for XAxis */
|
|
7
7
|
x?: string;
|
|
8
|
-
/** Field from data for
|
|
8
|
+
/** Field from data for YAxis*/
|
|
9
9
|
y?: string;
|
|
10
|
-
/**
|
|
10
|
+
/** Line color
|
|
11
11
|
* @default '#50aef4'*/
|
|
12
12
|
color?: string;
|
|
13
|
-
/** Area color
|
|
14
|
-
* @default '#50aef450'*/
|
|
15
|
-
fill?: string;
|
|
16
13
|
/** Element hide property */
|
|
17
14
|
hide?: boolean;
|
|
18
15
|
/** Curve method */
|
|
19
16
|
curve?: CurveFactory;
|
|
17
|
+
/** Animation duration in ms
|
|
18
|
+
* @default 500
|
|
19
|
+
*/
|
|
20
|
+
duration?: number;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export interface IAreaDotsProps extends IContext {
|
|
@@ -24,8 +25,6 @@ export interface IAreaDotsProps extends IContext {
|
|
|
24
25
|
display?: boolean;
|
|
25
26
|
/** Hide property */
|
|
26
27
|
hide?: boolean;
|
|
27
|
-
/** Index active of element */
|
|
28
|
-
activeIndex?: number;
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
export interface IAreaDotsContext {
|
package/lib/types/Axis.d.ts
CHANGED
|
@@ -4,22 +4,22 @@ import IContext from './context';
|
|
|
4
4
|
export interface IXAxisProps extends IContext {
|
|
5
5
|
/** The position of the axis relative chart
|
|
6
6
|
* @default 'button' */
|
|
7
|
-
position?: 'top' | 'right' | 'bottom' | 'left';
|
|
7
|
+
position?: 'top' | 'right' | 'bottom' | 'left' | number;
|
|
8
8
|
/** Element hide property
|
|
9
9
|
* @default false */
|
|
10
10
|
hide?: boolean;
|
|
11
|
-
/** Values
|
|
11
|
+
/** Values for axis ticks */
|
|
12
12
|
ticks?: any[];
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export interface IYAxisProps extends IContext {
|
|
16
16
|
/** The position of the axis relative chart
|
|
17
17
|
* @default 'left' */
|
|
18
|
-
position?: 'top' | 'right' | 'bottom' | 'left';
|
|
18
|
+
position?: 'top' | 'right' | 'bottom' | 'left' | number;
|
|
19
19
|
/** Element hide property
|
|
20
20
|
* @default true */
|
|
21
21
|
hide?: boolean;
|
|
22
|
-
/** Values
|
|
22
|
+
/** Values for axis ticks */
|
|
23
23
|
ticks?: any[];
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -28,12 +28,12 @@ export interface IAxisTicksProps extends IContext {
|
|
|
28
28
|
position?: 'top' | 'right' | 'bottom' | 'left';
|
|
29
29
|
/** Element hide property */
|
|
30
30
|
hide?: boolean;
|
|
31
|
-
/** Values
|
|
31
|
+
/** Values for axis ticks */
|
|
32
32
|
ticks?: any[];
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export interface IAxisGridProps extends IContext {
|
|
36
|
-
/** Values
|
|
36
|
+
/** Values for axis ticks */
|
|
37
37
|
ticks?: any[];
|
|
38
38
|
}
|
|
39
39
|
|
package/lib/types/Bar.d.ts
CHANGED
|
@@ -2,15 +2,19 @@ import { CProps, ReturnEl } from '@semcore/core';
|
|
|
2
2
|
import IContext from './context';
|
|
3
3
|
|
|
4
4
|
export interface IBarProps extends IContext {
|
|
5
|
-
/** Field from data for
|
|
5
|
+
/** Field from data for XAxis */
|
|
6
6
|
x?: string;
|
|
7
|
-
/** Field from data for
|
|
7
|
+
/** Field from data for YAxis */
|
|
8
8
|
y?: string;
|
|
9
|
-
/**
|
|
9
|
+
/** Line color
|
|
10
10
|
* @default '#50aef4'*/
|
|
11
11
|
color?: string;
|
|
12
12
|
/** Element hide property */
|
|
13
13
|
hide?: boolean;
|
|
14
|
+
/** Animation duration in ms
|
|
15
|
+
* @default 500
|
|
16
|
+
*/
|
|
17
|
+
duration?: number;
|
|
14
18
|
}
|
|
15
19
|
|
|
16
20
|
export interface IBarContext {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CProps, ReturnEl } from '@semcore/core';
|
|
3
|
+
|
|
4
|
+
export interface IClipPath {
|
|
5
|
+
/**
|
|
6
|
+
* HTML tag name for the displayed item
|
|
7
|
+
* @default rect
|
|
8
|
+
*/
|
|
9
|
+
tag?: string;
|
|
10
|
+
/**
|
|
11
|
+
* HTML selector
|
|
12
|
+
*/
|
|
13
|
+
id?: string;
|
|
14
|
+
/**
|
|
15
|
+
* CSS property
|
|
16
|
+
*/
|
|
17
|
+
transition?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Function which run after mounted clipPath
|
|
20
|
+
*/
|
|
21
|
+
setAttributeTag?: (rect: React.ReactNode) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare const ClipPath: <T>(props: CProps<IClipPath & T>) => ReturnEl;
|
|
25
|
+
|
|
26
|
+
export default ClipPath;
|
package/lib/types/Donut.d.ts
CHANGED
|
@@ -2,13 +2,23 @@ import { CProps, ReturnEl } from '@semcore/core';
|
|
|
2
2
|
import IContext from './context';
|
|
3
3
|
|
|
4
4
|
export interface IDonutProps extends IContext {
|
|
5
|
-
|
|
5
|
+
/** Inner radius
|
|
6
|
+
* @default 0
|
|
7
|
+
* */
|
|
6
8
|
innerRadius?: number;
|
|
7
|
-
|
|
9
|
+
/** Semi donut */
|
|
8
10
|
halfsize?: boolean;
|
|
11
|
+
/** Animation duration in ms
|
|
12
|
+
* @default 500
|
|
13
|
+
*/
|
|
14
|
+
duration?: number;
|
|
9
15
|
}
|
|
10
16
|
|
|
11
17
|
export interface IPieProps extends IContext {
|
|
18
|
+
/**
|
|
19
|
+
* Name of the field in the data
|
|
20
|
+
* */
|
|
21
|
+
dataKey: string;
|
|
12
22
|
/** Color pie
|
|
13
23
|
@default #50aef4
|
|
14
24
|
**/
|
package/lib/types/GroupBar.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ import { IHorizontalBarProps } from './HorizontalBar';
|
|
|
4
4
|
import IContext from './context';
|
|
5
5
|
|
|
6
6
|
export interface IGroupBarProps extends IContext {
|
|
7
|
-
/** Field from data for
|
|
7
|
+
/** Field from data for XAxis */
|
|
8
8
|
x?: string;
|
|
9
|
-
/** Field from data for
|
|
9
|
+
/** Field from data for YAxis */
|
|
10
10
|
y?: string;
|
|
11
11
|
/** Scale for group bars */
|
|
12
12
|
scaleGroup?: any;
|
|
@@ -3,13 +3,17 @@ import IContext from './context';
|
|
|
3
3
|
import { IBarContext, IBackgroundProps } from './Bar';
|
|
4
4
|
|
|
5
5
|
export interface IHorizontalBarProps extends IContext {
|
|
6
|
-
/** Field from data for
|
|
6
|
+
/** Field from data for XAxis */
|
|
7
7
|
x?: string;
|
|
8
|
-
/** Field from data for
|
|
8
|
+
/** Field from data for YAxis */
|
|
9
9
|
y?: string;
|
|
10
|
-
/**
|
|
10
|
+
/** Line color
|
|
11
11
|
* @default '#50aef4'*/
|
|
12
12
|
color?: string;
|
|
13
|
+
/** Animation duration in ms
|
|
14
|
+
* @default 500
|
|
15
|
+
*/
|
|
16
|
+
duration?: number;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
declare const HorizontalBar: (<T>(
|
package/lib/types/Hover.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { CProps, ReturnEl } from '@semcore/core';
|
|
|
2
2
|
import IContext from './context';
|
|
3
3
|
|
|
4
4
|
export interface IHoverProps extends IContext {
|
|
5
|
-
/** Field from data for
|
|
5
|
+
/** Field from data for XAxis */
|
|
6
6
|
x?: string;
|
|
7
|
-
/** Field from data for
|
|
7
|
+
/** Field from data for YAxis */
|
|
8
8
|
y?: string;
|
|
9
9
|
}
|
|
10
10
|
|