myio-js-library 0.1.550 → 0.1.551
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/{chunk-YLNG7CFO.js → chunk-2SHSBMIF.js} +69 -0
- package/dist/index.cjs +418 -136
- package/dist/index.d.cts +25 -1
- package/dist/index.d.ts +25 -1
- package/dist/index.js +350 -137
- package/dist/myio-js-library.umd.js +418 -136
- package/dist/myio-js-library.umd.min.js +1 -1
- package/dist/tooltips.cjs +69 -0
- package/dist/tooltips.d.cts +10 -0
- package/dist/tooltips.d.ts +10 -0
- package/dist/tooltips.js +1 -1
- package/package.json +1 -1
|
@@ -992,8 +992,77 @@ function buildLegend(total) {
|
|
|
992
992
|
}).join("");
|
|
993
993
|
return `<div class="myio-col-summary__legend">${rows}</div>`;
|
|
994
994
|
}
|
|
995
|
+
function buildAverageInner() {
|
|
996
|
+
if (!_state) return "";
|
|
997
|
+
const { data, fmt } = _state;
|
|
998
|
+
const measure = data.measureLabel || "Temperatura";
|
|
999
|
+
const all = data.devices.map((d, idx) => ({ d, idx }));
|
|
1000
|
+
const online = all.filter((v) => !v.d.offline && Number.isFinite(Number(v.d.value)));
|
|
1001
|
+
const offline = all.filter((v) => !online.includes(v));
|
|
1002
|
+
const values = online.map((v) => Number(v.d.value));
|
|
1003
|
+
const avg = values.length ? values.reduce((a, b) => a + b, 0) / values.length : null;
|
|
1004
|
+
const desc = online.slice().sort((a, b) => Number(b.d.value) - Number(a.d.value));
|
|
1005
|
+
const maxV = desc[0];
|
|
1006
|
+
const minV = desc[desc.length - 1];
|
|
1007
|
+
const dash = "\u2014";
|
|
1008
|
+
const periodRow = data.periodLabel ? `<div class="myio-col-summary__kpi">
|
|
1009
|
+
<span class="myio-col-summary__kpi-label">Per\xEDodo</span>
|
|
1010
|
+
<span class="myio-col-summary__kpi-value">${esc(data.periodLabel)}</span>
|
|
1011
|
+
</div>` : "";
|
|
1012
|
+
const note = "M\xE9dia, m\xEDnima e m\xE1xima consideram apenas dispositivos online (com leitura).";
|
|
1013
|
+
const kpis = `<div class="myio-col-summary__kpis">
|
|
1014
|
+
${periodRow}
|
|
1015
|
+
<div class="myio-col-summary__kpi">
|
|
1016
|
+
<span class="myio-col-summary__kpi-label">Dispositivos
|
|
1017
|
+
<span class="myio-col-summary__info" title="${esc(note)}" aria-label="${esc(note)}"
|
|
1018
|
+
style="display:inline-flex;align-items:center;justify-content:center;width:13px;height:13px;margin-left:4px;border-radius:50%;background:#3e1a7d;color:#fff;font-size:9px;font-weight:700;font-style:italic;font-family:Georgia,serif;cursor:help;vertical-align:middle;">i</span>
|
|
1019
|
+
</span>
|
|
1020
|
+
<span class="myio-col-summary__kpi-value">${online.length} online \xB7 ${offline.length} offline</span>
|
|
1021
|
+
</div>
|
|
1022
|
+
<div class="myio-col-summary__kpi">
|
|
1023
|
+
<span class="myio-col-summary__kpi-label">${esc(measure)} m\xE9dia</span>
|
|
1024
|
+
<span class="myio-col-summary__kpi-value myio-col-summary__kpi-value--accent">${avg === null ? dash : esc(fmt(avg))}</span>
|
|
1025
|
+
</div>
|
|
1026
|
+
<div class="myio-col-summary__kpi">
|
|
1027
|
+
<span class="myio-col-summary__kpi-label">M\xEDnima \xB7 M\xE1xima</span>
|
|
1028
|
+
<span class="myio-col-summary__kpi-value">${minV ? esc(fmt(Number(minV.d.value))) : dash} \xB7 ${maxV ? esc(fmt(Number(maxV.d.value))) : dash}</span>
|
|
1029
|
+
</div>
|
|
1030
|
+
</div>`;
|
|
1031
|
+
if (!data.devices.length) {
|
|
1032
|
+
return `${kpis}<div class="myio-col-summary__empty">Nenhum dispositivo.</div>`;
|
|
1033
|
+
}
|
|
1034
|
+
const near3 = avg === null ? [] : online.slice().sort((a, b) => Math.abs(Number(a.d.value) - avg) - Math.abs(Number(b.d.value) - avg)).slice(0, 3);
|
|
1035
|
+
const row = (v) => `
|
|
1036
|
+
<div class="myio-col-summary__row">
|
|
1037
|
+
<span class="myio-col-summary__name" title="${esc(v.d.name)}">${esc(v.d.name)}</span>
|
|
1038
|
+
<span class="myio-col-summary__val">${esc(fmt(Number(v.d.value) || 0))}</span>
|
|
1039
|
+
</div>`;
|
|
1040
|
+
const offRow = (v) => `
|
|
1041
|
+
<div class="myio-col-summary__row">
|
|
1042
|
+
<span class="myio-col-summary__name" title="${esc(v.d.name)}">${esc(v.d.name)}</span>
|
|
1043
|
+
<span class="myio-col-summary__val" style="color:#94a3b8;">sem leitura</span>
|
|
1044
|
+
</div>`;
|
|
1045
|
+
const group = (label, list, r = row) => list.length ? `<div class="myio-col-summary__group">
|
|
1046
|
+
<span class="myio-col-summary__group-label">${label}</span>
|
|
1047
|
+
${list.map(r).join("")}
|
|
1048
|
+
</div>` : "";
|
|
1049
|
+
return `${kpis}
|
|
1050
|
+
<div class="myio-col-summary__body">
|
|
1051
|
+
<div class="myio-col-summary__lists">
|
|
1052
|
+
${group("\u25B2 3 maiores", desc.slice(0, 3))}
|
|
1053
|
+
${group("\u25BC 3 menores", desc.slice(-3).reverse())}
|
|
1054
|
+
${group("\u25CF 3 na m\xE9dia", near3)}
|
|
1055
|
+
${group(`\u26AA Offline / sem leitura (${offline.length})`, offline, offRow)}
|
|
1056
|
+
</div>
|
|
1057
|
+
</div>
|
|
1058
|
+
<div class="myio-col-summary__footer">
|
|
1059
|
+
<span class="myio-col-summary__footer-label">${esc(measure)} m\xE9dia \xB7 ${online.length} online</span>
|
|
1060
|
+
<span class="myio-col-summary__footer-value">${avg === null ? dash : esc(fmt(avg))}</span>
|
|
1061
|
+
</div>`;
|
|
1062
|
+
}
|
|
995
1063
|
function buildInner() {
|
|
996
1064
|
if (!_state) return "";
|
|
1065
|
+
if (_state.data.mode === "average") return buildAverageInner();
|
|
997
1066
|
const { data, fmt, pd } = _state;
|
|
998
1067
|
const visible = visibleDevices();
|
|
999
1068
|
const count = visible.length;
|