@semcore/mini-chart 16.0.0-prerelease.2 → 16.0.0-prerelease.21
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 +19 -1
- package/lib/cjs/component/score/Donut.js +4 -2
- package/lib/cjs/component/score/Donut.js.map +1 -1
- package/lib/cjs/component/score/Line.js +4 -2
- package/lib/cjs/component/score/Line.js.map +1 -1
- package/lib/cjs/component/trend/Bar.js +4 -2
- package/lib/cjs/component/trend/Bar.js.map +1 -1
- package/lib/cjs/component/trend/Line.js +4 -2
- package/lib/cjs/component/trend/Line.js.map +1 -1
- package/lib/es6/component/score/Donut.js +4 -2
- package/lib/es6/component/score/Donut.js.map +1 -1
- package/lib/es6/component/score/Line.js +4 -2
- package/lib/es6/component/score/Line.js.map +1 -1
- package/lib/es6/component/trend/Bar.js +4 -2
- package/lib/es6/component/trend/Bar.js.map +1 -1
- package/lib/es6/component/trend/Line.js +4 -2
- package/lib/es6/component/trend/Line.js.map +1 -1
- package/lib/esm/component/score/Donut.mjs +102 -82
- package/lib/esm/component/score/Line.mjs +99 -76
- package/lib/esm/component/score/donut.shadow.css +17 -0
- package/lib/esm/component/score/line.shadow.css +62 -0
- package/lib/esm/component/skeleton/skeleton.shadow.css +24 -0
- package/lib/esm/component/trend/Bar.mjs +83 -67
- package/lib/esm/component/trend/Line.mjs +117 -98
- package/lib/esm/component/trend/Trend.mjs +47 -35
- package/lib/esm/index.mjs +13 -13
- package/package.json +3 -3
|
@@ -1,39 +1,44 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { sstyled
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { Trend
|
|
12
|
-
import { Box
|
|
13
|
-
import { extractAriaProps
|
|
14
|
-
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
8
|
+
import { sstyled, createComponent, assignProps } from "@semcore/core";
|
|
9
|
+
import React from "react";
|
|
10
|
+
import resolveColorEnhance from "@semcore/core/lib/utils/enhances/resolveColorEnhance";
|
|
11
|
+
import { Trend } from "./Trend.mjs";
|
|
12
|
+
import { Box } from "@semcore/flex-box";
|
|
13
|
+
import { extractAriaProps } from "@semcore/core/lib/utils/ariaProps";
|
|
14
|
+
/*!__reshadow-styles__:"../skeleton/skeleton.shadow.css"*/
|
|
15
|
+
var style = (
|
|
15
16
|
/*__reshadow_css_start__*/
|
|
16
|
-
(
|
|
17
|
+
(sstyled.insert(
|
|
17
18
|
/*__inner_css_start__*/
|
|
18
19
|
"@keyframes pulse_7jer1{0%,to{opacity:1}50%{opacity:.4}}.___SDonutContainer_7jer1_gg_.__loading_7jer1_gg_,.___SLineGauge_7jer1_gg_.__loading_7jer1_gg_,.___STrendBar_7jer1_gg_.__loading_7jer1_gg_,.___STrendLine_7jer1_gg_.__loading_7jer1_gg_{animation-name:pulse_7jer1;animation-iteration-count:infinite;animation-timing-function:ease-in-out;animation-duration:1.6s;will-change:opacity}",
|
|
20
|
+
/*__inner_css_end__*/
|
|
19
21
|
"7jer1_gg_"
|
|
20
|
-
),
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
), /*__reshadow_css_end__*/
|
|
23
|
+
{
|
|
24
|
+
"__SLineGauge": "___SLineGauge_7jer1_gg_",
|
|
25
|
+
"_loading": "__loading_7jer1_gg_",
|
|
26
|
+
"__SDonutContainer": "___SDonutContainer_7jer1_gg_",
|
|
27
|
+
"__STrendLine": "___STrendLine_7jer1_gg_",
|
|
28
|
+
"__STrendBar": "___STrendBar_7jer1_gg_",
|
|
26
29
|
"@pulse": "pulse_7jer1"
|
|
27
30
|
})
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
);
|
|
32
|
+
var TrendBarRoot = /* @__PURE__ */ function(_Trend) {
|
|
33
|
+
_inherits(TrendBarRoot2, _Trend);
|
|
34
|
+
var _super = _createSuper(TrendBarRoot2);
|
|
35
|
+
function TrendBarRoot2() {
|
|
36
|
+
_classCallCheck(this, TrendBarRoot2);
|
|
37
|
+
return _super.apply(this, arguments);
|
|
33
38
|
}
|
|
34
|
-
|
|
39
|
+
_createClass(TrendBarRoot2, [{
|
|
35
40
|
key: "defaultData",
|
|
36
|
-
get: function() {
|
|
41
|
+
get: function get() {
|
|
37
42
|
return [{
|
|
38
43
|
value: 20
|
|
39
44
|
}, {
|
|
@@ -46,60 +51,71 @@ var W = (
|
|
|
46
51
|
}
|
|
47
52
|
}, {
|
|
48
53
|
key: "data",
|
|
49
|
-
get: function() {
|
|
50
|
-
var
|
|
51
|
-
|
|
54
|
+
get: function get() {
|
|
55
|
+
var _this$asProps = this.asProps, data = _this$asProps.data, loading = _this$asProps.loading;
|
|
56
|
+
if (loading) {
|
|
57
|
+
return this.defaultData;
|
|
58
|
+
}
|
|
59
|
+
return data;
|
|
52
60
|
}
|
|
53
61
|
}, {
|
|
54
62
|
key: "render",
|
|
55
|
-
value: function() {
|
|
56
|
-
var
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
63
|
+
value: function render() {
|
|
64
|
+
var _ref = this.asProps, _ref2, _this = this;
|
|
65
|
+
var STrendBar = Box;
|
|
66
|
+
var _this$asProps2 = this.asProps, styles = _this$asProps2.styles, resolveColor = _this$asProps2.resolveColor, isHistogram = _this$asProps2.isHistogram, animate = _this$asProps2.animate, loading = _this$asProps2.loading;
|
|
67
|
+
var step = this.defaultWidth / this.data.length;
|
|
68
|
+
var _extractAriaProps = extractAriaProps(this.asProps), __excludeProps = _extractAriaProps.__excludeProps, extractedAriaProps = _extractAriaProps.extractedAriaProps;
|
|
69
|
+
return _ref2 = sstyled(styles), /* @__PURE__ */ React.createElement(STrendBar, _ref2.cn("STrendBar", _objectSpread({}, assignProps({
|
|
70
|
+
"ref": this.containerRef,
|
|
71
|
+
"__excludeProps": ["data"].concat(_toConsumableArray(__excludeProps))
|
|
72
|
+
}, _ref))), /* @__PURE__ */ React.createElement("svg", _ref2.cn("svg", _objectSpread({
|
|
73
|
+
"width": "100%",
|
|
74
|
+
"height": "100%",
|
|
75
|
+
"viewBox": "0 0 ".concat(this.svgWidth, " ").concat(this.svgHeight),
|
|
76
|
+
"role": "img"
|
|
77
|
+
}, extractedAriaProps)), this.data.map(function(barItem, index) {
|
|
78
|
+
var color = resolveColor("chart-palette-order-other-data");
|
|
79
|
+
if (barItem.color) {
|
|
80
|
+
color = resolveColor(barItem.color);
|
|
81
|
+
}
|
|
82
|
+
return /* @__PURE__ */ React.createElement("rect", {
|
|
83
|
+
key: index,
|
|
84
|
+
x: step * index,
|
|
85
|
+
y: _this.defaultHeight - barItem.value,
|
|
86
|
+
width: isHistogram ? step : step * 0.8,
|
|
87
|
+
height: barItem.value,
|
|
88
|
+
fill: color
|
|
89
|
+
}, animate && !loading && /* @__PURE__ */ React.createElement("animate", {
|
|
75
90
|
attributeName: "y",
|
|
76
|
-
values: "".concat(
|
|
91
|
+
values: "".concat(_this.defaultHeight, ";").concat(_this.defaultHeight - barItem.value),
|
|
77
92
|
dur: "500ms"
|
|
78
93
|
}));
|
|
79
94
|
})));
|
|
80
95
|
}
|
|
81
|
-
}])
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
96
|
+
}]);
|
|
97
|
+
return TrendBarRoot2;
|
|
98
|
+
}(Trend);
|
|
99
|
+
_defineProperty(TrendBarRoot, "enhance", [resolveColorEnhance()]);
|
|
100
|
+
_defineProperty(TrendBarRoot, "style", style);
|
|
101
|
+
_defineProperty(TrendBarRoot, "defaultProps", {
|
|
102
|
+
animate: true
|
|
87
103
|
});
|
|
88
|
-
var
|
|
89
|
-
|
|
90
|
-
var
|
|
104
|
+
var TrendBar = createComponent(TrendBarRoot);
|
|
105
|
+
TrendBar.displayName = "MiniChart.TrendBar";
|
|
106
|
+
var TrendHistogram = createComponent(TrendBarRoot, {}, {
|
|
91
107
|
enhancements: [function() {
|
|
92
108
|
return {
|
|
93
|
-
wrapperProps: function(
|
|
94
|
-
return
|
|
95
|
-
isHistogram:
|
|
109
|
+
wrapperProps: function wrapperProps(props) {
|
|
110
|
+
return assignProps(props, {
|
|
111
|
+
isHistogram: true
|
|
96
112
|
});
|
|
97
113
|
}
|
|
98
114
|
};
|
|
99
115
|
}]
|
|
100
116
|
});
|
|
101
|
-
|
|
117
|
+
TrendBar.displayName = "MiniChart.TrendHistogram";
|
|
102
118
|
export {
|
|
103
|
-
|
|
104
|
-
|
|
119
|
+
TrendBar,
|
|
120
|
+
TrendHistogram
|
|
105
121
|
};
|
|
@@ -1,139 +1,158 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { sstyled
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { Trend
|
|
13
|
-
import { Box
|
|
14
|
-
import { extractAriaProps
|
|
15
|
-
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
8
|
+
import { sstyled, createComponent, assignProps } from "@semcore/core";
|
|
9
|
+
import React from "react";
|
|
10
|
+
import resolveColorEnhance from "@semcore/core/lib/utils/enhances/resolveColorEnhance";
|
|
11
|
+
import uniqueIDEnhancement from "@semcore/core/lib/utils/uniqueID";
|
|
12
|
+
import { Trend } from "./Trend.mjs";
|
|
13
|
+
import { Box } from "@semcore/flex-box";
|
|
14
|
+
import { extractAriaProps } from "@semcore/core/lib/utils/ariaProps";
|
|
15
|
+
/*!__reshadow-styles__:"../skeleton/skeleton.shadow.css"*/
|
|
16
|
+
var style = (
|
|
16
17
|
/*__reshadow_css_start__*/
|
|
17
|
-
(
|
|
18
|
+
(sstyled.insert(
|
|
18
19
|
/*__inner_css_start__*/
|
|
19
20
|
"@keyframes pulse_7jer1{0%,to{opacity:1}50%{opacity:.4}}.___SDonutContainer_7jer1_gg_.__loading_7jer1_gg_,.___SLineGauge_7jer1_gg_.__loading_7jer1_gg_,.___STrendBar_7jer1_gg_.__loading_7jer1_gg_,.___STrendLine_7jer1_gg_.__loading_7jer1_gg_{animation-name:pulse_7jer1;animation-iteration-count:infinite;animation-timing-function:ease-in-out;animation-duration:1.6s;will-change:opacity}",
|
|
21
|
+
/*__inner_css_end__*/
|
|
20
22
|
"7jer1_gg_"
|
|
21
|
-
),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
), /*__reshadow_css_end__*/
|
|
24
|
+
{
|
|
25
|
+
"__SLineGauge": "___SLineGauge_7jer1_gg_",
|
|
26
|
+
"_loading": "__loading_7jer1_gg_",
|
|
27
|
+
"__SDonutContainer": "___SDonutContainer_7jer1_gg_",
|
|
28
|
+
"__STrendLine": "___STrendLine_7jer1_gg_",
|
|
29
|
+
"__STrendBar": "___STrendBar_7jer1_gg_",
|
|
27
30
|
"@pulse": "pulse_7jer1"
|
|
28
31
|
})
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
);
|
|
33
|
+
var TrendLineRoot = /* @__PURE__ */ function(_Trend) {
|
|
34
|
+
_inherits(TrendLineRoot2, _Trend);
|
|
35
|
+
var _super = _createSuper(TrendLineRoot2);
|
|
36
|
+
function TrendLineRoot2() {
|
|
37
|
+
_classCallCheck(this, TrendLineRoot2);
|
|
38
|
+
return _super.apply(this, arguments);
|
|
34
39
|
}
|
|
35
|
-
|
|
40
|
+
_createClass(TrendLineRoot2, [{
|
|
36
41
|
key: "defaultData",
|
|
37
|
-
get: function() {
|
|
42
|
+
get: function get() {
|
|
38
43
|
return [15, 70, 20, 85, 20];
|
|
39
44
|
}
|
|
40
45
|
}, {
|
|
41
46
|
key: "lastPointRadius",
|
|
42
|
-
get: function() {
|
|
43
|
-
var
|
|
44
|
-
return (
|
|
47
|
+
get: function get() {
|
|
48
|
+
var _this$asProps$lastPoi;
|
|
49
|
+
return (_this$asProps$lastPoi = this.asProps.lastPointRadius) !== null && _this$asProps$lastPoi !== void 0 ? _this$asProps$lastPoi : 6;
|
|
45
50
|
}
|
|
46
51
|
}, {
|
|
47
52
|
key: "data",
|
|
48
|
-
get: function() {
|
|
49
|
-
var
|
|
50
|
-
|
|
53
|
+
get: function get() {
|
|
54
|
+
var _this$asProps = this.asProps, data = _this$asProps.data, loading = _this$asProps.loading;
|
|
55
|
+
if (loading) {
|
|
56
|
+
return this.defaultData;
|
|
57
|
+
}
|
|
58
|
+
return data;
|
|
51
59
|
}
|
|
52
60
|
}, {
|
|
53
61
|
key: "svgWidth",
|
|
54
|
-
get: function() {
|
|
62
|
+
get: function get() {
|
|
55
63
|
return this.asProps.lastPointColor ? this.defaultWidth + this.lastPointRadius : this.defaultWidth;
|
|
56
64
|
}
|
|
57
65
|
}, {
|
|
58
66
|
key: "svgHeight",
|
|
59
|
-
get: function() {
|
|
67
|
+
get: function get() {
|
|
60
68
|
return this.asProps.lastPointColor ? this.defaultHeight + this.lastPointRadius : this.defaultHeight;
|
|
61
69
|
}
|
|
62
70
|
}, {
|
|
63
71
|
key: "color",
|
|
64
|
-
get: function() {
|
|
65
|
-
var
|
|
66
|
-
|
|
72
|
+
get: function get() {
|
|
73
|
+
var _this$asProps2 = this.asProps, resolveColor = _this$asProps2.resolveColor, _this$asProps2$color = _this$asProps2.color, color = _this$asProps2$color === void 0 ? "chart-palette-order-1" : _this$asProps2$color, loading = _this$asProps2.loading;
|
|
74
|
+
if (loading) {
|
|
75
|
+
return resolveColor("skeleton-bg");
|
|
76
|
+
}
|
|
77
|
+
return resolveColor(color);
|
|
67
78
|
}
|
|
68
79
|
}, {
|
|
69
80
|
key: "render",
|
|
70
|
-
value: function() {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
var
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
fill:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
81
|
+
value: function render() {
|
|
82
|
+
var _ref = this.asProps, _ref2;
|
|
83
|
+
var STrendLine = Box;
|
|
84
|
+
var _this$asProps3 = this.asProps, uid = _this$asProps3.uid, withArea = _this$asProps3.withArea, animate = _this$asProps3.animate, lastPointColor = _this$asProps3.lastPointColor, resolveColor = _this$asProps3.resolveColor, loading = _this$asProps3.loading, styles = _this$asProps3.styles;
|
|
85
|
+
var points = [];
|
|
86
|
+
var length = this.data.length;
|
|
87
|
+
var step = this.defaultWidth / (length - 1);
|
|
88
|
+
for (var i = 0; i < length; i++) {
|
|
89
|
+
points.push("".concat(step * i, ",").concat(this.defaultHeight - this.data[i]));
|
|
90
|
+
}
|
|
91
|
+
var _extractAriaProps = extractAriaProps(this.asProps), __excludeProps = _extractAriaProps.__excludeProps, extractedAriaProps = _extractAriaProps.extractedAriaProps;
|
|
92
|
+
return _ref2 = sstyled(styles), /* @__PURE__ */ React.createElement(STrendLine, _ref2.cn("STrendLine", _objectSpread({}, assignProps({
|
|
93
|
+
"ref": this.containerRef,
|
|
94
|
+
"__excludeProps": ["data"].concat(_toConsumableArray(__excludeProps))
|
|
95
|
+
}, _ref))), /* @__PURE__ */ React.createElement("svg", _ref2.cn("svg", _objectSpread({
|
|
96
|
+
"width": "100%",
|
|
97
|
+
"height": "100%",
|
|
98
|
+
"viewBox": "0 0 ".concat(this.svgWidth, " ").concat(this.svgHeight),
|
|
99
|
+
"role": "img"
|
|
100
|
+
}, extractedAriaProps)), /* @__PURE__ */ React.createElement("polyline", _ref2.cn("polyline", {
|
|
101
|
+
"points": points.join(" "),
|
|
102
|
+
"stroke": this.color,
|
|
103
|
+
"strokeWidth": "4",
|
|
104
|
+
"fill": "none",
|
|
105
|
+
"clipPath": "url(#".concat(uid, ")")
|
|
106
|
+
})), withArea && /* @__PURE__ */ React.createElement("polyline", _ref2.cn("polyline", {
|
|
107
|
+
"points": "0,".concat(this.defaultHeight, " ").concat(points.join(" "), " ").concat(this.defaultWidth, ",").concat(this.defaultHeight),
|
|
108
|
+
"fill": this.color,
|
|
109
|
+
"fillOpacity": 0.2,
|
|
110
|
+
"clipPath": "url(#".concat(uid, ")")
|
|
111
|
+
})), lastPointColor && !loading && /* @__PURE__ */ React.createElement("circle", _ref2.cn("circle", {
|
|
112
|
+
"cx": step * (length - 1),
|
|
113
|
+
"cy": this.defaultHeight - this.data[length - 1],
|
|
114
|
+
"r": this.lastPointRadius,
|
|
115
|
+
"fill": resolveColor(lastPointColor),
|
|
116
|
+
"stroke": resolveColor("chart-grid-border"),
|
|
117
|
+
"strokeWidth": 4,
|
|
118
|
+
"clipPath": "url(#".concat(uid, ")")
|
|
119
|
+
})), animate && !loading && /* @__PURE__ */ React.createElement("clipPath", _ref2.cn("clipPath", {
|
|
120
|
+
"id": uid
|
|
121
|
+
}), /* @__PURE__ */ React.createElement("rect", _ref2.cn("rect", {
|
|
122
|
+
"x": "0",
|
|
123
|
+
"y": "0",
|
|
124
|
+
"width": "100%",
|
|
125
|
+
"height": "100%",
|
|
126
|
+
"fill": "black"
|
|
127
|
+
}), /* @__PURE__ */ React.createElement("animate", _ref2.cn("animate", {
|
|
128
|
+
"dur": "500ms",
|
|
129
|
+
"attributeName": "width",
|
|
130
|
+
"values": "0;100%"
|
|
113
131
|
}))))));
|
|
114
132
|
}
|
|
115
|
-
}])
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
133
|
+
}]);
|
|
134
|
+
return TrendLineRoot2;
|
|
135
|
+
}(Trend);
|
|
136
|
+
_defineProperty(TrendLineRoot, "enhance", [resolveColorEnhance(), uniqueIDEnhancement()]);
|
|
137
|
+
_defineProperty(TrendLineRoot, "style", style);
|
|
138
|
+
_defineProperty(TrendLineRoot, "defaultProps", {
|
|
139
|
+
animate: true
|
|
121
140
|
});
|
|
122
|
-
var
|
|
123
|
-
|
|
124
|
-
var
|
|
141
|
+
var TrendLine = createComponent(TrendLineRoot);
|
|
142
|
+
TrendLine.displayName = "MiniChart.TrendLine";
|
|
143
|
+
var TrendArea = createComponent(TrendLineRoot, {}, {
|
|
125
144
|
enhancements: [function() {
|
|
126
145
|
return {
|
|
127
|
-
wrapperProps: function(
|
|
128
|
-
return
|
|
129
|
-
withArea:
|
|
146
|
+
wrapperProps: function wrapperProps(props) {
|
|
147
|
+
return assignProps(props, {
|
|
148
|
+
withArea: true
|
|
130
149
|
});
|
|
131
150
|
}
|
|
132
151
|
};
|
|
133
152
|
}]
|
|
134
153
|
});
|
|
135
|
-
|
|
154
|
+
TrendArea.displayName = "MiniChart.TrendArea";
|
|
136
155
|
export {
|
|
137
|
-
|
|
138
|
-
|
|
156
|
+
TrendArea,
|
|
157
|
+
TrendLine
|
|
139
158
|
};
|
|
@@ -1,66 +1,78 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { Component
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { Component } from "@semcore/core";
|
|
9
|
+
var Trend = /* @__PURE__ */ function(_Component) {
|
|
10
|
+
_inherits(Trend2, _Component);
|
|
11
|
+
var _super = _createSuper(Trend2);
|
|
12
|
+
function Trend2() {
|
|
13
|
+
var _this;
|
|
14
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
15
|
+
args[_key] = arguments[_key];
|
|
16
|
+
}
|
|
17
|
+
_classCallCheck(this, Trend2);
|
|
18
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
19
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
16
20
|
width: 200,
|
|
17
21
|
height: 100
|
|
18
|
-
})
|
|
22
|
+
});
|
|
23
|
+
_defineProperty(_assertThisInitialized(_this), "containerRef", /* @__PURE__ */ React.createRef());
|
|
24
|
+
return _this;
|
|
19
25
|
}
|
|
20
|
-
|
|
26
|
+
_createClass(Trend2, [{
|
|
21
27
|
key: "componentDidMount",
|
|
22
|
-
value: function() {
|
|
28
|
+
value: function componentDidMount() {
|
|
23
29
|
this.setSizes();
|
|
24
30
|
}
|
|
25
31
|
}, {
|
|
26
32
|
key: "componentDidUpdate",
|
|
27
|
-
value: function(
|
|
28
|
-
(
|
|
33
|
+
value: function componentDidUpdate(prevProps) {
|
|
34
|
+
if (prevProps.w !== this.props.w || prevProps.h !== this.props.h || prevProps.data !== this.props.data) {
|
|
35
|
+
this.setSizes();
|
|
36
|
+
}
|
|
29
37
|
}
|
|
30
38
|
}, {
|
|
31
39
|
key: "defaultWidth",
|
|
32
|
-
get: function() {
|
|
33
|
-
var
|
|
34
|
-
return
|
|
40
|
+
get: function get() {
|
|
41
|
+
var _this$state = this.state, width = _this$state.width, height = _this$state.height;
|
|
42
|
+
return width / height * this.defaultHeight;
|
|
35
43
|
}
|
|
36
44
|
}, {
|
|
37
45
|
key: "defaultHeight",
|
|
38
|
-
get: function() {
|
|
46
|
+
get: function get() {
|
|
39
47
|
return 100;
|
|
40
48
|
}
|
|
41
49
|
}, {
|
|
42
50
|
key: "svgWidth",
|
|
43
|
-
get: function() {
|
|
51
|
+
get: function get() {
|
|
44
52
|
return this.defaultWidth;
|
|
45
53
|
}
|
|
46
54
|
}, {
|
|
47
55
|
key: "svgHeight",
|
|
48
|
-
get: function() {
|
|
56
|
+
get: function get() {
|
|
49
57
|
return this.defaultHeight;
|
|
50
58
|
}
|
|
51
59
|
}, {
|
|
52
60
|
key: "setSizes",
|
|
53
|
-
value: function() {
|
|
61
|
+
value: function setSizes() {
|
|
54
62
|
if (this.containerRef.current) {
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
var boundingClientRect = this.containerRef.current.getBoundingClientRect();
|
|
64
|
+
var width = boundingClientRect.width, height = boundingClientRect.height;
|
|
65
|
+
if (width > 0 && height > 0) {
|
|
66
|
+
this.setState({
|
|
67
|
+
width,
|
|
68
|
+
height
|
|
69
|
+
});
|
|
70
|
+
}
|
|
60
71
|
}
|
|
61
72
|
}
|
|
62
|
-
}])
|
|
63
|
-
|
|
73
|
+
}]);
|
|
74
|
+
return Trend2;
|
|
75
|
+
}(Component);
|
|
64
76
|
export {
|
|
65
|
-
|
|
77
|
+
Trend
|
|
66
78
|
};
|
package/lib/esm/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { ScoreSemiDonut
|
|
2
|
-
import { ScoreLine
|
|
3
|
-
import { TrendLine
|
|
4
|
-
import { TrendBar
|
|
5
|
-
var
|
|
6
|
-
TrendLine
|
|
7
|
-
TrendArea
|
|
8
|
-
TrendBar
|
|
9
|
-
TrendHistogram
|
|
10
|
-
ScoreSemiDonut
|
|
11
|
-
ScoreDonut
|
|
12
|
-
ScoreLine
|
|
1
|
+
import { ScoreSemiDonut, ScoreDonut } from "./component/score/Donut.mjs";
|
|
2
|
+
import { ScoreLine } from "./component/score/Line.mjs";
|
|
3
|
+
import { TrendLine, TrendArea } from "./component/trend/Line.mjs";
|
|
4
|
+
import { TrendBar, TrendHistogram } from "./component/trend/Bar.mjs";
|
|
5
|
+
var miniCharts = {
|
|
6
|
+
TrendLine,
|
|
7
|
+
TrendArea,
|
|
8
|
+
TrendBar,
|
|
9
|
+
TrendHistogram,
|
|
10
|
+
ScoreSemiDonut,
|
|
11
|
+
ScoreDonut,
|
|
12
|
+
ScoreLine
|
|
13
13
|
};
|
|
14
14
|
export {
|
|
15
|
-
|
|
15
|
+
miniCharts as default
|
|
16
16
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/mini-chart",
|
|
3
3
|
"description": "Semrush MiniChart Component",
|
|
4
|
-
"version": "16.0.0-prerelease.
|
|
4
|
+
"version": "16.0.0-prerelease.21",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"types": "./lib/types/index.d.ts"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@semcore/base-components": "^16.0.0-prerelease.
|
|
18
|
-
"@semcore/flex-box": "^16.0.0-prerelease.
|
|
17
|
+
"@semcore/base-components": "^16.0.0-prerelease.21",
|
|
18
|
+
"@semcore/flex-box": "^16.0.0-prerelease.21"
|
|
19
19
|
},
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|