@cloudtower/eagle 0.29.25 → 0.29.28
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/dist/cjs/coreX/BarChart/index.js +73 -17
- package/dist/cjs/stats1.html +1 -1
- package/dist/components.css +3196 -3195
- package/dist/esm/coreX/BarChart/index.js +74 -18
- package/dist/esm/stats1.html +1 -1
- package/dist/src/coreX/BarChart/index.d.ts +1 -0
- package/dist/stories/docs/coreX/BarChart.stories.d.ts +1 -0
- package/dist/style.css +3081 -3081
- package/package.json +3 -3
|
@@ -9,7 +9,46 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
9
9
|
|
|
10
10
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
11
11
|
|
|
12
|
+
var __defProp = Object.defineProperty;
|
|
13
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
14
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
15
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
16
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
value
|
|
21
|
+
}) : obj[key] = value;
|
|
22
|
+
var __spreadValues = (a, b) => {
|
|
23
|
+
for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
24
|
+
if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) {
|
|
25
|
+
if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
26
|
+
}
|
|
27
|
+
return a;
|
|
28
|
+
};
|
|
12
29
|
const StackBar = "E_skwah65";
|
|
30
|
+
const useShapeStyle = (shape, color) => {
|
|
31
|
+
return React.useMemo(() => {
|
|
32
|
+
switch (shape) {
|
|
33
|
+
case "stripes":
|
|
34
|
+
return {
|
|
35
|
+
backgroundImage: `linear-gradient(-45deg,
|
|
36
|
+
${color} 25%,
|
|
37
|
+
transparent 25%,
|
|
38
|
+
transparent 50%,
|
|
39
|
+
${color} 50%,
|
|
40
|
+
${color} 75%,
|
|
41
|
+
transparent 75%,
|
|
42
|
+
transparent)`,
|
|
43
|
+
backgroundSize: "4px 4px"
|
|
44
|
+
};
|
|
45
|
+
default:
|
|
46
|
+
return {
|
|
47
|
+
backgroundColor: color
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}, [color, shape]);
|
|
51
|
+
};
|
|
13
52
|
function getWidth(input) {
|
|
14
53
|
const {
|
|
15
54
|
value,
|
|
@@ -17,27 +56,44 @@ function getWidth(input) {
|
|
|
17
56
|
} = tower.formatPercent(input);
|
|
18
57
|
return value + unit;
|
|
19
58
|
}
|
|
59
|
+
const BarItem = props => {
|
|
60
|
+
const {
|
|
61
|
+
color,
|
|
62
|
+
shape,
|
|
63
|
+
style,
|
|
64
|
+
className
|
|
65
|
+
} = props;
|
|
66
|
+
const shapeStyle = useShapeStyle(shape, color);
|
|
67
|
+
return /* @__PURE__ */React__default.default.createElement("div", {
|
|
68
|
+
className,
|
|
69
|
+
style: __spreadValues(__spreadValues({}, shapeStyle), style)
|
|
70
|
+
});
|
|
71
|
+
};
|
|
20
72
|
const BarChart = ({
|
|
21
73
|
data,
|
|
22
74
|
total
|
|
23
|
-
}) =>
|
|
24
|
-
className: StackBar
|
|
25
|
-
}, (data || []).map((item, index) => {
|
|
26
|
-
const {
|
|
27
|
-
value,
|
|
28
|
-
color
|
|
29
|
-
} = item;
|
|
30
|
-
const width = total === 0 ? 0 : getWidth(100 * value / total);
|
|
75
|
+
}) => {
|
|
31
76
|
return /* @__PURE__ */React__default.default.createElement("div", {
|
|
32
|
-
className:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
77
|
+
className: StackBar
|
|
78
|
+
}, (data || []).map((item, index) => {
|
|
79
|
+
const {
|
|
80
|
+
value,
|
|
81
|
+
color,
|
|
82
|
+
shape = "fill"
|
|
83
|
+
} = item;
|
|
84
|
+
const width = total === 0 ? 0 : getWidth(100 * value / total);
|
|
85
|
+
return /* @__PURE__ */React__default.default.createElement(BarItem, {
|
|
86
|
+
className: "stack-bar-item",
|
|
87
|
+
key: index,
|
|
88
|
+
shape,
|
|
89
|
+
color,
|
|
90
|
+
style: {
|
|
91
|
+
width,
|
|
92
|
+
display: value === 0 || total === 0 ? "none" : "inline-block"
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}));
|
|
96
|
+
};
|
|
41
97
|
var BarChart$1 = BarChart;
|
|
42
98
|
|
|
43
99
|
exports.default = BarChart$1;
|