@kwirthmagnify/kwirth-common-front 0.5.11 → 0.5.13
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/MiniGauge.d.ts +8 -0
- package/dist/MiniGauge.js +50 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MiniGauge = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const GAUGE_ZONES = [
|
|
9
|
+
{ size: 0.5, fill: '#5BE12C' },
|
|
10
|
+
{ size: 0.3, fill: '#F5CD19' },
|
|
11
|
+
{ size: 0.2, fill: '#EA4228' },
|
|
12
|
+
];
|
|
13
|
+
const VW = 100, VH = 54;
|
|
14
|
+
const GCX = VW / 2, GCY = VH;
|
|
15
|
+
const G_OUTER = VW * 0.46, G_INNER = G_OUTER * 0.58, G_NEEDLE = G_OUTER * 0.86;
|
|
16
|
+
const ARC_PATHS = (() => {
|
|
17
|
+
let a = Math.PI;
|
|
18
|
+
return GAUGE_ZONES.map(zone => {
|
|
19
|
+
const end = a - zone.size * Math.PI;
|
|
20
|
+
const ox1 = GCX + G_OUTER * Math.cos(a), oy1 = GCY - G_OUTER * Math.sin(a);
|
|
21
|
+
const ox2 = GCX + G_OUTER * Math.cos(end), oy2 = GCY - G_OUTER * Math.sin(end);
|
|
22
|
+
const ix1 = GCX + G_INNER * Math.cos(a), iy1 = GCY - G_INNER * Math.sin(a);
|
|
23
|
+
const ix2 = GCX + G_INNER * Math.cos(end), iy2 = GCY - G_INNER * Math.sin(end);
|
|
24
|
+
const d = `M ${ox1} ${oy1} A ${G_OUTER} ${G_OUTER} 0 0 1 ${ox2} ${oy2} L ${ix2} ${iy2} A ${G_INNER} ${G_INNER} 0 0 0 ${ix1} ${iy1} Z`;
|
|
25
|
+
a = end;
|
|
26
|
+
return { d, fill: zone.fill };
|
|
27
|
+
});
|
|
28
|
+
})();
|
|
29
|
+
const labelStyle = {
|
|
30
|
+
display: 'block',
|
|
31
|
+
fontSize: '0.75rem',
|
|
32
|
+
lineHeight: 1,
|
|
33
|
+
opacity: 0.6,
|
|
34
|
+
textAlign: 'center',
|
|
35
|
+
};
|
|
36
|
+
const MiniGauge = ({ value, max, label, format }) => {
|
|
37
|
+
const display = format ? format(value) : value.toFixed(1);
|
|
38
|
+
const pct = Math.min(value / (max || 1), 1);
|
|
39
|
+
const na = Math.PI * (1 - pct);
|
|
40
|
+
const nx = GCX + G_NEEDLE * Math.cos(na);
|
|
41
|
+
const ny = GCY - G_NEEDLE * Math.sin(na);
|
|
42
|
+
return (react_1.default.createElement("div", { style: { flex: 1, minWidth: 0, textAlign: 'center' } },
|
|
43
|
+
react_1.default.createElement("span", { style: Object.assign(Object.assign({}, labelStyle), { marginBottom: 4 }) }, display),
|
|
44
|
+
react_1.default.createElement("svg", { viewBox: `0 0 ${VW} ${VH}`, style: { width: '100%', display: 'block' } },
|
|
45
|
+
ARC_PATHS.map((p, i) => react_1.default.createElement("path", { key: i, d: p.d, fill: p.fill })),
|
|
46
|
+
react_1.default.createElement("line", { x1: GCX, y1: GCY, x2: nx, y2: ny, stroke: 'currentColor', strokeWidth: 2, strokeLinecap: 'round' }),
|
|
47
|
+
react_1.default.createElement("circle", { cx: GCX, cy: GCY, r: 3, fill: 'currentColor' })),
|
|
48
|
+
react_1.default.createElement("span", { style: Object.assign(Object.assign({}, labelStyle), { marginTop: 4 }) }, label)));
|
|
49
|
+
};
|
|
50
|
+
exports.MiniGauge = MiniGauge;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MarkdownViewer = exports.cleanANSI = exports.MetricDefinition = exports.ENotifyLevel = exports.EChannelRefreshAction = exports.useKeyboard = void 0;
|
|
3
|
+
exports.MiniGauge = exports.MarkdownViewer = exports.cleanANSI = exports.MetricDefinition = exports.ENotifyLevel = exports.EChannelRefreshAction = exports.useKeyboard = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const kwirth_common_1 = require("@kwirthmagnify/kwirth-common");
|
|
6
6
|
Object.defineProperty(exports, "EChannelRefreshAction", { enumerable: true, get: function () { return kwirth_common_1.EChannelRefreshAction; } });
|
|
@@ -41,3 +41,5 @@ const cleanANSI = (text) => text.replace(/\x1b\[[0-9;]*[mKHVfJrcegH]|\x1b\[\d*n/
|
|
|
41
41
|
exports.cleanANSI = cleanANSI;
|
|
42
42
|
var MarkdownViewer_1 = require("./MarkdownViewer");
|
|
43
43
|
Object.defineProperty(exports, "MarkdownViewer", { enumerable: true, get: function () { return MarkdownViewer_1.MarkdownViewer; } });
|
|
44
|
+
var MiniGauge_1 = require("./MiniGauge");
|
|
45
|
+
Object.defineProperty(exports, "MiniGauge", { enumerable: true, get: function () { return MiniGauge_1.MiniGauge; } });
|