@semcore/mini-chart 16.0.0-prerelease.6 → 16.0.0-prerelease.7
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/lib/esm/component/score/Donut.mjs +98 -81
- package/lib/esm/component/score/Line.mjs +95 -75
- package/lib/esm/component/trend/Bar.mjs +79 -66
- package/lib/esm/component/trend/Line.mjs +113 -97
- package/lib/esm/component/trend/Trend.mjs +47 -35
- package/lib/esm/index.mjs +13 -13
- package/package.json +3 -3
|
@@ -1,102 +1,119 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { sstyled
|
|
8
|
-
import
|
|
9
|
-
import { Box
|
|
10
|
-
import
|
|
11
|
-
import { extractAriaProps
|
|
12
|
-
var
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
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 { sstyled, createComponent, assignProps, Component } from "@semcore/core";
|
|
8
|
+
import React from "react";
|
|
9
|
+
import { Box } from "@semcore/flex-box";
|
|
10
|
+
import resolveColorEnhance from "@semcore/core/lib/utils/enhances/resolveColorEnhance";
|
|
11
|
+
import { extractAriaProps } from "@semcore/core/lib/utils/ariaProps";
|
|
12
|
+
var style = (
|
|
13
13
|
/*__reshadow_css_start__*/
|
|
14
|
-
(
|
|
14
|
+
(sstyled.insert(
|
|
15
15
|
/*__inner_css_start__*/
|
|
16
16
|
"@keyframes pulse_1cm94{0%,to{opacity:1}50%{opacity:.4}}.___SDonutContainer_1cm94_gg_.__loading_1cm94_gg_,.___SLineGauge_1cm94_gg_.__loading_1cm94_gg_,.___STrendBar_1cm94_gg_.__loading_1cm94_gg_,.___STrendLine_1cm94_gg_.__loading_1cm94_gg_{animation-name:pulse_1cm94;animation-iteration-count:infinite;animation-timing-function:ease-in-out;animation-duration:1.6s;will-change:opacity}.___SDonutContainer_1cm94_gg_.__semi_1cm94_gg_ g{transform:rotate(180deg) translate(-24px,-24px)}.___SDonutContainer_1cm94_gg_ g{transform:rotate(-90deg) translate(-24px)}.___SDonutContainer_1cm94_gg_.__animate_1cm94_gg_ circle{transition:all var(--intergalactic-duration-extra-slow, 500) ease-in-out}",
|
|
17
17
|
"1cm94_gg_"
|
|
18
18
|
), {
|
|
19
|
-
__SLineGauge: "___SLineGauge_1cm94_gg_",
|
|
20
|
-
_loading: "__loading_1cm94_gg_",
|
|
21
|
-
__SDonutContainer: "___SDonutContainer_1cm94_gg_",
|
|
22
|
-
__STrendLine: "___STrendLine_1cm94_gg_",
|
|
23
|
-
__STrendBar: "___STrendBar_1cm94_gg_",
|
|
19
|
+
"__SLineGauge": "___SLineGauge_1cm94_gg_",
|
|
20
|
+
"_loading": "__loading_1cm94_gg_",
|
|
21
|
+
"__SDonutContainer": "___SDonutContainer_1cm94_gg_",
|
|
22
|
+
"__STrendLine": "___STrendLine_1cm94_gg_",
|
|
23
|
+
"__STrendBar": "___STrendBar_1cm94_gg_",
|
|
24
24
|
"@pulse": "pulse_1cm94",
|
|
25
|
-
_animate: "__animate_1cm94_gg_",
|
|
26
|
-
_semi: "__semi_1cm94_gg_"
|
|
25
|
+
"_animate": "__animate_1cm94_gg_",
|
|
26
|
+
"_semi": "__semi_1cm94_gg_"
|
|
27
27
|
})
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
);
|
|
29
|
+
var DonutRoot = /* @__PURE__ */ function(_Component) {
|
|
30
|
+
_inherits(DonutRoot2, _Component);
|
|
31
|
+
var _super = _createSuper(DonutRoot2);
|
|
32
|
+
function DonutRoot2() {
|
|
33
|
+
_classCallCheck(this, DonutRoot2);
|
|
34
|
+
return _super.apply(this, arguments);
|
|
33
35
|
}
|
|
34
|
-
|
|
36
|
+
_createClass(DonutRoot2, [{
|
|
35
37
|
key: "render",
|
|
36
|
-
value: function() {
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
var $ =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
})),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
38
|
+
value: function render() {
|
|
39
|
+
var _ref = this.asProps, _ref2;
|
|
40
|
+
var SDonutContainer = Box;
|
|
41
|
+
var _this$asProps = this.asProps, value = _this$asProps.value, styles = _this$asProps.styles, _this$asProps$baseBgC = _this$asProps.baseBgColor, baseBgColor = _this$asProps$baseBgC === void 0 ? "chart-grid-bar-chart-base-bg" : _this$asProps$baseBgC, _this$asProps$color = _this$asProps.color, color = _this$asProps$color === void 0 ? "chart-palette-order-1" : _this$asProps$color, resolveColor = _this$asProps.resolveColor, isSemiDonut = _this$asProps.isSemiDonut, loading = _this$asProps.loading;
|
|
42
|
+
var strokeWidth = isSemiDonut ? 6 : 4;
|
|
43
|
+
var radius = isSemiDonut ? 9 : 10;
|
|
44
|
+
var baseStrokeDasharray = isSemiDonut ? Math.PI * radius : Math.PI * 2 * radius;
|
|
45
|
+
var valueStrokeDasharray = baseStrokeDasharray * (value / 100);
|
|
46
|
+
var greyStrokeDasharray = baseStrokeDasharray * ((100 - value) / 100);
|
|
47
|
+
var offsetPoint = isSemiDonut ? baseStrokeDasharray / (100 / 3) : baseStrokeDasharray / 100;
|
|
48
|
+
var strokeDasharrayBetweenSpaces = "".concat(greyStrokeDasharray - 2 * offsetPoint, " ").concat(offsetPoint);
|
|
49
|
+
var spaceStrokeDasharray = "".concat(offsetPoint, " ").concat(value < 99 ? "".concat(strokeDasharrayBetweenSpaces) : "", " ").concat(baseStrokeDasharray);
|
|
50
|
+
if (isSemiDonut) {
|
|
51
|
+
spaceStrokeDasharray = "".concat(offsetPoint, " ").concat(value < 95 ? "".concat(strokeDasharrayBetweenSpaces) : "", " ").concat(baseStrokeDasharray);
|
|
52
|
+
}
|
|
53
|
+
var viewBox = isSemiDonut ? "0 0 24 12" : "0 0 24 24";
|
|
54
|
+
var strokeDashoffsetBase = -1 * (valueStrokeDasharray + (isSemiDonut ? offsetPoint : 0));
|
|
55
|
+
var _extractAriaProps = extractAriaProps(this.asProps), __excludeProps = _extractAriaProps.__excludeProps, extractedAriaProps = _extractAriaProps.extractedAriaProps;
|
|
56
|
+
return _ref2 = sstyled(styles), /* @__PURE__ */ React.createElement(SDonutContainer, _ref2.cn("SDonutContainer", _objectSpread({}, assignProps({
|
|
57
|
+
"semi": isSemiDonut,
|
|
58
|
+
"__excludeProps": __excludeProps
|
|
59
|
+
}, _ref))), /* @__PURE__ */ React.createElement("svg", _ref2.cn("svg", _objectSpread({
|
|
60
|
+
"width": "100%",
|
|
61
|
+
"height": "100%",
|
|
62
|
+
"viewBox": viewBox,
|
|
63
|
+
"fill": "none",
|
|
64
|
+
"role": "img"
|
|
65
|
+
}, extractedAriaProps)), /* @__PURE__ */ React.createElement("g", _ref2.cn("g", {}), /* @__PURE__ */ React.createElement("circle", _ref2.cn("circle", {
|
|
66
|
+
"cx": "12",
|
|
67
|
+
"cy": "12",
|
|
68
|
+
"r": radius,
|
|
69
|
+
"strokeWidth": strokeWidth,
|
|
70
|
+
"stroke": resolveColor(baseBgColor),
|
|
71
|
+
"strokeDasharray": loading ? void 0 : "".concat(greyStrokeDasharray, " ").concat(baseStrokeDasharray),
|
|
72
|
+
"strokeDashoffset": strokeDashoffsetBase
|
|
73
|
+
})), !loading && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("circle", _ref2.cn("circle", {
|
|
74
|
+
"cx": "12",
|
|
75
|
+
"cy": "12",
|
|
76
|
+
"r": radius,
|
|
77
|
+
"strokeWidth": strokeWidth,
|
|
78
|
+
"stroke": resolveColor(color),
|
|
79
|
+
"strokeDasharray": "".concat(valueStrokeDasharray, " ").concat(baseStrokeDasharray),
|
|
80
|
+
"strokeDashoffset": valueStrokeDasharray
|
|
81
|
+
}), /* @__PURE__ */ React.createElement("animate", _ref2.cn("animate", {
|
|
82
|
+
"attributeName": "stroke-dashoffset",
|
|
83
|
+
"values": "0;".concat(valueStrokeDasharray)
|
|
84
|
+
}))), value !== 100 && !isSemiDonut && /* @__PURE__ */ React.createElement("circle", _ref2.cn("circle", {
|
|
85
|
+
"cx": "12",
|
|
86
|
+
"cy": "12",
|
|
87
|
+
"r": radius,
|
|
88
|
+
"strokeWidth": strokeWidth,
|
|
89
|
+
"stroke": resolveColor("chart-grid-border"),
|
|
90
|
+
"strokeDasharray": spaceStrokeDasharray,
|
|
91
|
+
"strokeDashoffset": -1 * valueStrokeDasharray
|
|
76
92
|
}))))));
|
|
77
93
|
}
|
|
78
|
-
}])
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
94
|
+
}]);
|
|
95
|
+
return DonutRoot2;
|
|
96
|
+
}(Component);
|
|
97
|
+
_defineProperty(DonutRoot, "enhance", [resolveColorEnhance()]);
|
|
98
|
+
_defineProperty(DonutRoot, "style", style);
|
|
99
|
+
_defineProperty(DonutRoot, "defaultProps", {
|
|
100
|
+
animate: true
|
|
84
101
|
});
|
|
85
|
-
var
|
|
86
|
-
|
|
87
|
-
var
|
|
102
|
+
var ScoreDonut = createComponent(DonutRoot);
|
|
103
|
+
ScoreDonut.displayName = "MiniChart.ScoreDonut";
|
|
104
|
+
var ScoreSemiDonut = createComponent(DonutRoot, {}, {
|
|
88
105
|
enhancements: [function() {
|
|
89
106
|
return {
|
|
90
|
-
wrapperProps: function(
|
|
91
|
-
return
|
|
92
|
-
isSemiDonut:
|
|
107
|
+
wrapperProps: function wrapperProps(props) {
|
|
108
|
+
return assignProps(props, {
|
|
109
|
+
isSemiDonut: true
|
|
93
110
|
});
|
|
94
111
|
}
|
|
95
112
|
};
|
|
96
113
|
}]
|
|
97
114
|
});
|
|
98
|
-
|
|
115
|
+
ScoreSemiDonut.displayName = "MiniChart.ScoreSemiDonut";
|
|
99
116
|
export {
|
|
100
|
-
|
|
101
|
-
|
|
117
|
+
ScoreDonut,
|
|
118
|
+
ScoreSemiDonut
|
|
102
119
|
};
|
|
@@ -1,103 +1,123 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { sstyled
|
|
8
|
-
import
|
|
9
|
-
import { Box
|
|
10
|
-
import
|
|
11
|
-
var
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
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 { sstyled, createComponent, assignProps, Component } from "@semcore/core";
|
|
8
|
+
import React from "react";
|
|
9
|
+
import { Box, Flex } from "@semcore/flex-box";
|
|
10
|
+
import resolveColorEnhance from "@semcore/core/lib/utils/enhances/resolveColorEnhance";
|
|
11
|
+
var style = (
|
|
12
12
|
/*__reshadow_css_start__*/
|
|
13
|
-
(
|
|
13
|
+
(sstyled.insert(
|
|
14
14
|
/*__inner_css_start__*/
|
|
15
15
|
"@keyframes pulse_2vm7d{0%,to{opacity:1}50%{opacity:.4}}@keyframes move-line_2vm7d{0%{transform:translateX(0)}to{transform:translateX(100%)}}.___SDonutContainer_2vm7d_gg_.__loading_2vm7d_gg_,.___SLineGauge_2vm7d_gg_.__loading_2vm7d_gg_,.___STrendBar_2vm7d_gg_.__loading_2vm7d_gg_,.___STrendLine_2vm7d_gg_.__loading_2vm7d_gg_{animation-name:pulse_2vm7d;animation-iteration-count:infinite;animation-timing-function:ease-in-out;animation-duration:1.6s;will-change:opacity}.___SLineGauge_2vm7d_gg_{height:8px;background-color:var(--base-bg-color_2vm7d, var(--intergalactic-chart-grid-bar-chart-base-bg, #e0e1e9));border-radius:var(--intergalactic-chart-rounded, 2px);overflow:hidden;position:relative}.___SLineValue_2vm7d_gg_{height:8px;border-radius:var(--intergalactic-chart-rounded, 2px)0 0 var(--intergalactic-chart-rounded, 2px)}.___SLineValue_2vm7d_gg_.__percent_2vm7d_gg_{width:var(--percent_2vm7d)}.___SLineSegmentItem_2vm7d_gg_.__color_2vm7d_gg_,.___SLineValue_2vm7d_gg_.__color_2vm7d_gg_{background-color:var(--color_2vm7d, var(--intergalactic-chart-palette-order-1, #2bb3ff))}.___SLineGauge_2vm7d_gg_.__segments_2vm7d_gg_{border-radius:var(--intergalactic-progress-bar-rounded, 6px)}.___SAnimationLine_2vm7d_gg_,.___SLineGaugeSegment_2vm7d_gg_{position:absolute;top:0;left:0;right:0;bottom:0}.___SLineSegmentItem_2vm7d_gg_:last-child{margin-right:0;border-right:none}.___SLineSegmentItem_2vm7d_gg_{height:8px;background:0 0;border-right-color:var(--intergalactic-chart-grid-border, #ffffff);border-right-style:solid;border-right-width:1px;box-sizing:content-box}.___SAnimationLine_2vm7d_gg_{background-color:var(--intergalactic-chart-grid-bar-chart-base-bg, #e0e1e9);transition:all var(--intergalactic-duration-extra-slow, 500) ease-in-out;animation-name:move-line_2vm7d;animation-duration:.5s;animation-timing-function:ease-in-out;animation-fill-mode:forwards}",
|
|
16
16
|
"2vm7d_gg_"
|
|
17
17
|
), {
|
|
18
|
-
__SLineGauge: "___SLineGauge_2vm7d_gg_",
|
|
19
|
-
_loading: "__loading_2vm7d_gg_",
|
|
20
|
-
__SDonutContainer: "___SDonutContainer_2vm7d_gg_",
|
|
21
|
-
__STrendLine: "___STrendLine_2vm7d_gg_",
|
|
22
|
-
__STrendBar: "___STrendBar_2vm7d_gg_",
|
|
18
|
+
"__SLineGauge": "___SLineGauge_2vm7d_gg_",
|
|
19
|
+
"_loading": "__loading_2vm7d_gg_",
|
|
20
|
+
"__SDonutContainer": "___SDonutContainer_2vm7d_gg_",
|
|
21
|
+
"__STrendLine": "___STrendLine_2vm7d_gg_",
|
|
22
|
+
"__STrendBar": "___STrendBar_2vm7d_gg_",
|
|
23
23
|
"@pulse": "pulse_2vm7d",
|
|
24
24
|
"--base-bg-color": "--base-bg-color_2vm7d",
|
|
25
|
-
__SLineValue: "___SLineValue_2vm7d_gg_",
|
|
26
|
-
_percent: "__percent_2vm7d_gg_",
|
|
25
|
+
"__SLineValue": "___SLineValue_2vm7d_gg_",
|
|
26
|
+
"_percent": "__percent_2vm7d_gg_",
|
|
27
27
|
"--percent": "--percent_2vm7d",
|
|
28
|
-
_color: "__color_2vm7d_gg_",
|
|
29
|
-
__SLineSegmentItem: "___SLineSegmentItem_2vm7d_gg_",
|
|
28
|
+
"_color": "__color_2vm7d_gg_",
|
|
29
|
+
"__SLineSegmentItem": "___SLineSegmentItem_2vm7d_gg_",
|
|
30
30
|
"--color": "--color_2vm7d",
|
|
31
|
-
_segments: "__segments_2vm7d_gg_",
|
|
32
|
-
__SLineGaugeSegment: "___SLineGaugeSegment_2vm7d_gg_",
|
|
33
|
-
__SAnimationLine: "___SAnimationLine_2vm7d_gg_",
|
|
31
|
+
"_segments": "__segments_2vm7d_gg_",
|
|
32
|
+
"__SLineGaugeSegment": "___SLineGaugeSegment_2vm7d_gg_",
|
|
33
|
+
"__SAnimationLine": "___SAnimationLine_2vm7d_gg_",
|
|
34
34
|
"@move-line": "move-line_2vm7d"
|
|
35
35
|
})
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
);
|
|
37
|
+
var LineRoot = /* @__PURE__ */ function(_Component) {
|
|
38
|
+
_inherits(LineRoot2, _Component);
|
|
39
|
+
var _super = _createSuper(LineRoot2);
|
|
40
|
+
function LineRoot2() {
|
|
41
|
+
_classCallCheck(this, LineRoot2);
|
|
42
|
+
return _super.apply(this, arguments);
|
|
41
43
|
}
|
|
42
|
-
|
|
44
|
+
_createClass(LineRoot2, [{
|
|
43
45
|
key: "getSegmentProps",
|
|
44
|
-
value: function(
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
value: function getSegmentProps(segmentProps) {
|
|
47
|
+
var _this$asProps = this.asProps, children = _this$asProps.children, resolveColor = _this$asProps.resolveColor;
|
|
48
|
+
var sum = 0;
|
|
49
|
+
React.Children.forEach(children, function(child) {
|
|
50
|
+
if (/* @__PURE__ */ React.isValidElement(child)) {
|
|
51
|
+
sum = sum + child.props.value;
|
|
52
|
+
}
|
|
48
53
|
});
|
|
49
|
-
var
|
|
54
|
+
var width = sum > 0 ? 100 * segmentProps.value / sum : 0;
|
|
50
55
|
return {
|
|
51
|
-
w: "".concat(
|
|
52
|
-
"use:color":
|
|
56
|
+
w: "".concat(width, "%"),
|
|
57
|
+
"use:color": resolveColor(segmentProps.color)
|
|
53
58
|
};
|
|
54
59
|
}
|
|
55
60
|
}, {
|
|
56
61
|
key: "render",
|
|
57
|
-
value: function() {
|
|
58
|
-
var
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
value: function render() {
|
|
63
|
+
var _ref = this.asProps, _ref5;
|
|
64
|
+
var SLineGauge = Box;
|
|
65
|
+
var SLineValue = Box;
|
|
66
|
+
var SAnimationLine = Box;
|
|
67
|
+
var SLineGaugeSegment = Flex;
|
|
68
|
+
var SLineSegmentItem = Box;
|
|
69
|
+
var _this$asProps2 = this.asProps, value = _this$asProps2.value, styles = _this$asProps2.styles, _this$asProps2$color = _this$asProps2.color, color = _this$asProps2$color === void 0 ? "chart-palette-order-1" : _this$asProps2$color, baseBgColor = _this$asProps2.baseBgColor, resolveColor = _this$asProps2.resolveColor, loading = _this$asProps2.loading, children = _this$asProps2.children, Children = _this$asProps2.Children, animate = _this$asProps2.animate;
|
|
70
|
+
if (children !== void 0) {
|
|
71
|
+
var _ref3;
|
|
72
|
+
return _ref3 = sstyled(styles), /* @__PURE__ */ React.createElement(SLineGauge, _ref3.cn("SLineGauge", _objectSpread({}, assignProps({
|
|
73
|
+
"segments": true,
|
|
74
|
+
"base-bg-color": resolveColor(baseBgColor)
|
|
75
|
+
}, _ref))), /* @__PURE__ */ React.createElement(SLineGaugeSegment, _ref3.cn("SLineGaugeSegment", {}), /* @__PURE__ */ React.createElement(Children, _ref3.cn("Children", {}))), animate && /* @__PURE__ */ React.createElement(SAnimationLine, _ref3.cn("SAnimationLine", {})));
|
|
65
76
|
}
|
|
66
|
-
var
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
var segments = this.asProps.segments;
|
|
78
|
+
var SegmentItems = [];
|
|
79
|
+
if (segments) {
|
|
80
|
+
for (var i = 0; i < segments; i++) {
|
|
81
|
+
var _ref4;
|
|
82
|
+
var width = "calc((100% - ".concat(segments - 1, "px) / ").concat(segments, ")");
|
|
83
|
+
SegmentItems.push((_ref4 = sstyled(styles), /* @__PURE__ */ React.createElement(SLineSegmentItem, _ref4.cn("SLineSegmentItem", {
|
|
84
|
+
"key": i,
|
|
85
|
+
"color": i < value ? resolveColor(color) : void 0,
|
|
86
|
+
"w": width
|
|
74
87
|
}))));
|
|
75
88
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
89
|
+
}
|
|
90
|
+
var percent = "".concat(value, "%");
|
|
91
|
+
if (segments) {
|
|
92
|
+
percent = "".concat(value / segments * 100, "%");
|
|
93
|
+
}
|
|
94
|
+
return _ref5 = sstyled(styles), /* @__PURE__ */ React.createElement(SLineGauge, _ref5.cn("SLineGauge", _objectSpread({}, assignProps({
|
|
95
|
+
"base-bg-color": resolveColor(baseBgColor)
|
|
96
|
+
}, _ref))), !loading && /* @__PURE__ */ React.createElement(SLineValue, _ref5.cn("SLineValue", {
|
|
97
|
+
"w": percent,
|
|
98
|
+
"color": resolveColor(color)
|
|
99
|
+
})), Boolean(SegmentItems.length) && /* @__PURE__ */ React.createElement(SLineGaugeSegment, _ref5.cn("SLineGaugeSegment", {}), SegmentItems), animate && /* @__PURE__ */ React.createElement(SAnimationLine, _ref5.cn("SAnimationLine", {})));
|
|
83
100
|
}
|
|
84
|
-
}])
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
101
|
+
}]);
|
|
102
|
+
return LineRoot2;
|
|
103
|
+
}(Component);
|
|
104
|
+
_defineProperty(LineRoot, "enhance", [resolveColorEnhance()]);
|
|
105
|
+
_defineProperty(LineRoot, "displayName", "ScoreLine");
|
|
106
|
+
_defineProperty(LineRoot, "style", style);
|
|
107
|
+
_defineProperty(LineRoot, "defaultProps", {
|
|
108
|
+
animate: true
|
|
91
109
|
});
|
|
92
|
-
function
|
|
93
|
-
var
|
|
94
|
-
|
|
110
|
+
function Segment(props) {
|
|
111
|
+
var _ref2 = arguments[0], _ref6;
|
|
112
|
+
var styles = props.styles;
|
|
113
|
+
var SLineSegmentItem = Box;
|
|
114
|
+
return _ref6 = sstyled(styles), /* @__PURE__ */ React.createElement(SLineSegmentItem, _ref6.cn("SLineSegmentItem", _objectSpread({}, assignProps({}, _ref2))));
|
|
95
115
|
}
|
|
96
|
-
|
|
97
|
-
var
|
|
98
|
-
Segment
|
|
116
|
+
Segment.displayName = "Segment";
|
|
117
|
+
var ScoreLine = createComponent(LineRoot, {
|
|
118
|
+
Segment
|
|
99
119
|
});
|
|
100
|
-
|
|
120
|
+
ScoreLine.displayName = "MiniChart.ScoreLine";
|
|
101
121
|
export {
|
|
102
|
-
|
|
122
|
+
ScoreLine
|
|
103
123
|
};
|
|
@@ -1,39 +1,41 @@
|
|
|
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
|
-
var
|
|
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
|
+
var style = (
|
|
15
15
|
/*__reshadow_css_start__*/
|
|
16
|
-
(
|
|
16
|
+
(sstyled.insert(
|
|
17
17
|
/*__inner_css_start__*/
|
|
18
18
|
"@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}",
|
|
19
19
|
"7jer1_gg_"
|
|
20
20
|
), {
|
|
21
|
-
__SLineGauge: "___SLineGauge_7jer1_gg_",
|
|
22
|
-
_loading: "__loading_7jer1_gg_",
|
|
23
|
-
__SDonutContainer: "___SDonutContainer_7jer1_gg_",
|
|
24
|
-
__STrendLine: "___STrendLine_7jer1_gg_",
|
|
25
|
-
__STrendBar: "___STrendBar_7jer1_gg_",
|
|
21
|
+
"__SLineGauge": "___SLineGauge_7jer1_gg_",
|
|
22
|
+
"_loading": "__loading_7jer1_gg_",
|
|
23
|
+
"__SDonutContainer": "___SDonutContainer_7jer1_gg_",
|
|
24
|
+
"__STrendLine": "___STrendLine_7jer1_gg_",
|
|
25
|
+
"__STrendBar": "___STrendBar_7jer1_gg_",
|
|
26
26
|
"@pulse": "pulse_7jer1"
|
|
27
27
|
})
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
);
|
|
29
|
+
var TrendBarRoot = /* @__PURE__ */ function(_Trend) {
|
|
30
|
+
_inherits(TrendBarRoot2, _Trend);
|
|
31
|
+
var _super = _createSuper(TrendBarRoot2);
|
|
32
|
+
function TrendBarRoot2() {
|
|
33
|
+
_classCallCheck(this, TrendBarRoot2);
|
|
34
|
+
return _super.apply(this, arguments);
|
|
33
35
|
}
|
|
34
|
-
|
|
36
|
+
_createClass(TrendBarRoot2, [{
|
|
35
37
|
key: "defaultData",
|
|
36
|
-
get: function() {
|
|
38
|
+
get: function get() {
|
|
37
39
|
return [{
|
|
38
40
|
value: 20
|
|
39
41
|
}, {
|
|
@@ -46,60 +48,71 @@ var W = (
|
|
|
46
48
|
}
|
|
47
49
|
}, {
|
|
48
50
|
key: "data",
|
|
49
|
-
get: function() {
|
|
50
|
-
var
|
|
51
|
-
|
|
51
|
+
get: function get() {
|
|
52
|
+
var _this$asProps = this.asProps, data = _this$asProps.data, loading = _this$asProps.loading;
|
|
53
|
+
if (loading) {
|
|
54
|
+
return this.defaultData;
|
|
55
|
+
}
|
|
56
|
+
return data;
|
|
52
57
|
}
|
|
53
58
|
}, {
|
|
54
59
|
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
|
-
|
|
60
|
+
value: function render() {
|
|
61
|
+
var _ref = this.asProps, _ref2, _this = this;
|
|
62
|
+
var STrendBar = Box;
|
|
63
|
+
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;
|
|
64
|
+
var step = this.defaultWidth / this.data.length;
|
|
65
|
+
var _extractAriaProps = extractAriaProps(this.asProps), __excludeProps = _extractAriaProps.__excludeProps, extractedAriaProps = _extractAriaProps.extractedAriaProps;
|
|
66
|
+
return _ref2 = sstyled(styles), /* @__PURE__ */ React.createElement(STrendBar, _ref2.cn("STrendBar", _objectSpread({}, assignProps({
|
|
67
|
+
"ref": this.containerRef,
|
|
68
|
+
"__excludeProps": ["data"].concat(_toConsumableArray(__excludeProps))
|
|
69
|
+
}, _ref))), /* @__PURE__ */ React.createElement("svg", _ref2.cn("svg", _objectSpread({
|
|
70
|
+
"width": "100%",
|
|
71
|
+
"height": "100%",
|
|
72
|
+
"viewBox": "0 0 ".concat(this.svgWidth, " ").concat(this.svgHeight),
|
|
73
|
+
"role": "img"
|
|
74
|
+
}, extractedAriaProps)), this.data.map(function(barItem, index) {
|
|
75
|
+
var color = resolveColor("chart-palette-order-other-data");
|
|
76
|
+
if (barItem.color) {
|
|
77
|
+
color = resolveColor(barItem.color);
|
|
78
|
+
}
|
|
79
|
+
return /* @__PURE__ */ React.createElement("rect", {
|
|
80
|
+
key: index,
|
|
81
|
+
x: step * index,
|
|
82
|
+
y: _this.defaultHeight - barItem.value,
|
|
83
|
+
width: isHistogram ? step : step * 0.8,
|
|
84
|
+
height: barItem.value,
|
|
85
|
+
fill: color
|
|
86
|
+
}, animate && !loading && /* @__PURE__ */ React.createElement("animate", {
|
|
75
87
|
attributeName: "y",
|
|
76
|
-
values: "".concat(
|
|
88
|
+
values: "".concat(_this.defaultHeight, ";").concat(_this.defaultHeight - barItem.value),
|
|
77
89
|
dur: "500ms"
|
|
78
90
|
}));
|
|
79
91
|
})));
|
|
80
92
|
}
|
|
81
|
-
}])
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
93
|
+
}]);
|
|
94
|
+
return TrendBarRoot2;
|
|
95
|
+
}(Trend);
|
|
96
|
+
_defineProperty(TrendBarRoot, "enhance", [resolveColorEnhance()]);
|
|
97
|
+
_defineProperty(TrendBarRoot, "style", style);
|
|
98
|
+
_defineProperty(TrendBarRoot, "defaultProps", {
|
|
99
|
+
animate: true
|
|
87
100
|
});
|
|
88
|
-
var
|
|
89
|
-
|
|
90
|
-
var
|
|
101
|
+
var TrendBar = createComponent(TrendBarRoot);
|
|
102
|
+
TrendBar.displayName = "MiniChart.TrendBar";
|
|
103
|
+
var TrendHistogram = createComponent(TrendBarRoot, {}, {
|
|
91
104
|
enhancements: [function() {
|
|
92
105
|
return {
|
|
93
|
-
wrapperProps: function(
|
|
94
|
-
return
|
|
95
|
-
isHistogram:
|
|
106
|
+
wrapperProps: function wrapperProps(props) {
|
|
107
|
+
return assignProps(props, {
|
|
108
|
+
isHistogram: true
|
|
96
109
|
});
|
|
97
110
|
}
|
|
98
111
|
};
|
|
99
112
|
}]
|
|
100
113
|
});
|
|
101
|
-
|
|
114
|
+
TrendBar.displayName = "MiniChart.TrendHistogram";
|
|
102
115
|
export {
|
|
103
|
-
|
|
104
|
-
|
|
116
|
+
TrendBar,
|
|
117
|
+
TrendHistogram
|
|
105
118
|
};
|
|
@@ -1,139 +1,155 @@
|
|
|
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
|
-
var
|
|
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
|
+
var style = (
|
|
16
16
|
/*__reshadow_css_start__*/
|
|
17
|
-
(
|
|
17
|
+
(sstyled.insert(
|
|
18
18
|
/*__inner_css_start__*/
|
|
19
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
20
|
"7jer1_gg_"
|
|
21
21
|
), {
|
|
22
|
-
__SLineGauge: "___SLineGauge_7jer1_gg_",
|
|
23
|
-
_loading: "__loading_7jer1_gg_",
|
|
24
|
-
__SDonutContainer: "___SDonutContainer_7jer1_gg_",
|
|
25
|
-
__STrendLine: "___STrendLine_7jer1_gg_",
|
|
26
|
-
__STrendBar: "___STrendBar_7jer1_gg_",
|
|
22
|
+
"__SLineGauge": "___SLineGauge_7jer1_gg_",
|
|
23
|
+
"_loading": "__loading_7jer1_gg_",
|
|
24
|
+
"__SDonutContainer": "___SDonutContainer_7jer1_gg_",
|
|
25
|
+
"__STrendLine": "___STrendLine_7jer1_gg_",
|
|
26
|
+
"__STrendBar": "___STrendBar_7jer1_gg_",
|
|
27
27
|
"@pulse": "pulse_7jer1"
|
|
28
28
|
})
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
);
|
|
30
|
+
var TrendLineRoot = /* @__PURE__ */ function(_Trend) {
|
|
31
|
+
_inherits(TrendLineRoot2, _Trend);
|
|
32
|
+
var _super = _createSuper(TrendLineRoot2);
|
|
33
|
+
function TrendLineRoot2() {
|
|
34
|
+
_classCallCheck(this, TrendLineRoot2);
|
|
35
|
+
return _super.apply(this, arguments);
|
|
34
36
|
}
|
|
35
|
-
|
|
37
|
+
_createClass(TrendLineRoot2, [{
|
|
36
38
|
key: "defaultData",
|
|
37
|
-
get: function() {
|
|
39
|
+
get: function get() {
|
|
38
40
|
return [15, 70, 20, 85, 20];
|
|
39
41
|
}
|
|
40
42
|
}, {
|
|
41
43
|
key: "lastPointRadius",
|
|
42
|
-
get: function() {
|
|
43
|
-
var
|
|
44
|
-
return (
|
|
44
|
+
get: function get() {
|
|
45
|
+
var _this$asProps$lastPoi;
|
|
46
|
+
return (_this$asProps$lastPoi = this.asProps.lastPointRadius) !== null && _this$asProps$lastPoi !== void 0 ? _this$asProps$lastPoi : 6;
|
|
45
47
|
}
|
|
46
48
|
}, {
|
|
47
49
|
key: "data",
|
|
48
|
-
get: function() {
|
|
49
|
-
var
|
|
50
|
-
|
|
50
|
+
get: function get() {
|
|
51
|
+
var _this$asProps = this.asProps, data = _this$asProps.data, loading = _this$asProps.loading;
|
|
52
|
+
if (loading) {
|
|
53
|
+
return this.defaultData;
|
|
54
|
+
}
|
|
55
|
+
return data;
|
|
51
56
|
}
|
|
52
57
|
}, {
|
|
53
58
|
key: "svgWidth",
|
|
54
|
-
get: function() {
|
|
59
|
+
get: function get() {
|
|
55
60
|
return this.asProps.lastPointColor ? this.defaultWidth + this.lastPointRadius : this.defaultWidth;
|
|
56
61
|
}
|
|
57
62
|
}, {
|
|
58
63
|
key: "svgHeight",
|
|
59
|
-
get: function() {
|
|
64
|
+
get: function get() {
|
|
60
65
|
return this.asProps.lastPointColor ? this.defaultHeight + this.lastPointRadius : this.defaultHeight;
|
|
61
66
|
}
|
|
62
67
|
}, {
|
|
63
68
|
key: "color",
|
|
64
|
-
get: function() {
|
|
65
|
-
var
|
|
66
|
-
|
|
69
|
+
get: function get() {
|
|
70
|
+
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;
|
|
71
|
+
if (loading) {
|
|
72
|
+
return resolveColor("skeleton-bg");
|
|
73
|
+
}
|
|
74
|
+
return resolveColor(color);
|
|
67
75
|
}
|
|
68
76
|
}, {
|
|
69
77
|
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
|
-
|
|
78
|
+
value: function render() {
|
|
79
|
+
var _ref = this.asProps, _ref2;
|
|
80
|
+
var STrendLine = Box;
|
|
81
|
+
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;
|
|
82
|
+
var points = [];
|
|
83
|
+
var length = this.data.length;
|
|
84
|
+
var step = this.defaultWidth / (length - 1);
|
|
85
|
+
for (var i = 0; i < length; i++) {
|
|
86
|
+
points.push("".concat(step * i, ",").concat(this.defaultHeight - this.data[i]));
|
|
87
|
+
}
|
|
88
|
+
var _extractAriaProps = extractAriaProps(this.asProps), __excludeProps = _extractAriaProps.__excludeProps, extractedAriaProps = _extractAriaProps.extractedAriaProps;
|
|
89
|
+
return _ref2 = sstyled(styles), /* @__PURE__ */ React.createElement(STrendLine, _ref2.cn("STrendLine", _objectSpread({}, assignProps({
|
|
90
|
+
"ref": this.containerRef,
|
|
91
|
+
"__excludeProps": ["data"].concat(_toConsumableArray(__excludeProps))
|
|
92
|
+
}, _ref))), /* @__PURE__ */ React.createElement("svg", _ref2.cn("svg", _objectSpread({
|
|
93
|
+
"width": "100%",
|
|
94
|
+
"height": "100%",
|
|
95
|
+
"viewBox": "0 0 ".concat(this.svgWidth, " ").concat(this.svgHeight),
|
|
96
|
+
"role": "img"
|
|
97
|
+
}, extractedAriaProps)), /* @__PURE__ */ React.createElement("polyline", _ref2.cn("polyline", {
|
|
98
|
+
"points": points.join(" "),
|
|
99
|
+
"stroke": this.color,
|
|
100
|
+
"strokeWidth": "4",
|
|
101
|
+
"fill": "none",
|
|
102
|
+
"clipPath": "url(#".concat(uid, ")")
|
|
103
|
+
})), withArea && /* @__PURE__ */ React.createElement("polyline", _ref2.cn("polyline", {
|
|
104
|
+
"points": "0,".concat(this.defaultHeight, " ").concat(points.join(" "), " ").concat(this.defaultWidth, ",").concat(this.defaultHeight),
|
|
105
|
+
"fill": this.color,
|
|
106
|
+
"fillOpacity": 0.2,
|
|
107
|
+
"clipPath": "url(#".concat(uid, ")")
|
|
108
|
+
})), lastPointColor && !loading && /* @__PURE__ */ React.createElement("circle", _ref2.cn("circle", {
|
|
109
|
+
"cx": step * (length - 1),
|
|
110
|
+
"cy": this.defaultHeight - this.data[length - 1],
|
|
111
|
+
"r": this.lastPointRadius,
|
|
112
|
+
"fill": resolveColor(lastPointColor),
|
|
113
|
+
"stroke": resolveColor("chart-grid-border"),
|
|
114
|
+
"strokeWidth": 4,
|
|
115
|
+
"clipPath": "url(#".concat(uid, ")")
|
|
116
|
+
})), animate && !loading && /* @__PURE__ */ React.createElement("clipPath", _ref2.cn("clipPath", {
|
|
117
|
+
"id": uid
|
|
118
|
+
}), /* @__PURE__ */ React.createElement("rect", _ref2.cn("rect", {
|
|
119
|
+
"x": "0",
|
|
120
|
+
"y": "0",
|
|
121
|
+
"width": "100%",
|
|
122
|
+
"height": "100%",
|
|
123
|
+
"fill": "black"
|
|
124
|
+
}), /* @__PURE__ */ React.createElement("animate", _ref2.cn("animate", {
|
|
125
|
+
"dur": "500ms",
|
|
126
|
+
"attributeName": "width",
|
|
127
|
+
"values": "0;100%"
|
|
113
128
|
}))))));
|
|
114
129
|
}
|
|
115
|
-
}])
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
130
|
+
}]);
|
|
131
|
+
return TrendLineRoot2;
|
|
132
|
+
}(Trend);
|
|
133
|
+
_defineProperty(TrendLineRoot, "enhance", [resolveColorEnhance(), uniqueIDEnhancement()]);
|
|
134
|
+
_defineProperty(TrendLineRoot, "style", style);
|
|
135
|
+
_defineProperty(TrendLineRoot, "defaultProps", {
|
|
136
|
+
animate: true
|
|
121
137
|
});
|
|
122
|
-
var
|
|
123
|
-
|
|
124
|
-
var
|
|
138
|
+
var TrendLine = createComponent(TrendLineRoot);
|
|
139
|
+
TrendLine.displayName = "MiniChart.TrendLine";
|
|
140
|
+
var TrendArea = createComponent(TrendLineRoot, {}, {
|
|
125
141
|
enhancements: [function() {
|
|
126
142
|
return {
|
|
127
|
-
wrapperProps: function(
|
|
128
|
-
return
|
|
129
|
-
withArea:
|
|
143
|
+
wrapperProps: function wrapperProps(props) {
|
|
144
|
+
return assignProps(props, {
|
|
145
|
+
withArea: true
|
|
130
146
|
});
|
|
131
147
|
}
|
|
132
148
|
};
|
|
133
149
|
}]
|
|
134
150
|
});
|
|
135
|
-
|
|
151
|
+
TrendArea.displayName = "MiniChart.TrendArea";
|
|
136
152
|
export {
|
|
137
|
-
|
|
138
|
-
|
|
153
|
+
TrendArea,
|
|
154
|
+
TrendLine
|
|
139
155
|
};
|
|
@@ -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.7",
|
|
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.7",
|
|
18
|
+
"@semcore/flex-box": "^16.0.0-prerelease.7"
|
|
19
19
|
},
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|