@sailingrotevista/rotevista-dash 4.0.17 → 4.0.19
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/app.js +25 -27
- package/index.js +27 -7
- package/package.json +1 -1
package/app.js
CHANGED
|
@@ -616,6 +616,10 @@ function updateScaleLabels(t, min, max) {
|
|
|
616
616
|
* drawGraph: Disegna i grafici con griglia temporale intelligente
|
|
617
617
|
* Usa un Gradiente Lineare SVG dinamico per eliminare le giunzioni dei poligoni.
|
|
618
618
|
*/
|
|
619
|
+
/**
|
|
620
|
+
* drawGraph: Disegna i grafici con griglia temporale intelligente
|
|
621
|
+
* Versione bilanciata: 1.5px per allarmi critici, 1px per il resto.
|
|
622
|
+
*/
|
|
619
623
|
function drawGraph(d, id, min, max, isTws, isHercules) {
|
|
620
624
|
const svg = document.getElementById(id);
|
|
621
625
|
if (!svg || d.length < 2) return;
|
|
@@ -625,7 +629,7 @@ function drawGraph(d, id, min, max, isTws, isHercules) {
|
|
|
625
629
|
const isDepth = (id === 'depth-graph');
|
|
626
630
|
const samples = CONFIG.graphs.samples;
|
|
627
631
|
|
|
628
|
-
// 1. Griglia
|
|
632
|
+
// 1. Griglia (Sottile 0.5px)
|
|
629
633
|
let grids = "";
|
|
630
634
|
[0.25, 0.5, 0.75].forEach(p => {
|
|
631
635
|
grids += `<line x1="0" y1="${h-(p*h)}" x2="${w}" y2="${h-(p*h)}" stroke="rgba(0,0,0,0.12)" stroke-width="0.5" />`;
|
|
@@ -636,7 +640,7 @@ function drawGraph(d, id, min, max, isTws, isHercules) {
|
|
|
636
640
|
grids += `<line x1="${x}" y1="0" x2="${x}" y2="${h}" stroke="rgba(0,0,0,0.08)" stroke-width="0.5" />`;
|
|
637
641
|
}
|
|
638
642
|
|
|
639
|
-
// 2. Colori
|
|
643
|
+
// 2. Tavolozza Colori Vividi
|
|
640
644
|
const baseColorTws = "#2c3e50";
|
|
641
645
|
const baseColorDepth = "#0088cc";
|
|
642
646
|
|
|
@@ -656,49 +660,43 @@ function drawGraph(d, id, min, max, isTws, isHercules) {
|
|
|
656
660
|
let areaPath = `M 0 ${h} `;
|
|
657
661
|
|
|
658
662
|
for (let i = 1; i < d.length; i++) {
|
|
659
|
-
// Calcolo Percentuali per il gradiente
|
|
660
663
|
const percentPrev = ((i - 1) / (samples - 1)) * 100;
|
|
661
664
|
const percentCurr = (i / (samples - 1)) * 100;
|
|
662
665
|
|
|
663
|
-
// Coordinate geometriche
|
|
664
666
|
const x1 = ((i - 1) / (samples - 1)) * w;
|
|
665
667
|
const y1 = h - (Math.max(0, Math.min(1, (d[i - 1] - min) / range)) * h);
|
|
666
668
|
const x2 = (i / (samples - 1)) * w;
|
|
667
669
|
const y2 = h - (Math.max(0, Math.min(1, (d[i] - min) / range)) * h);
|
|
668
670
|
|
|
669
671
|
const color = getColor(d[i]);
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
strokeWidth = "2.5"; // Manteniamo la linea spessa per leggerla bene
|
|
683
|
-
}
|
|
672
|
+
|
|
673
|
+
// Logica Opacità e Spessore (Tua configurazione)
|
|
674
|
+
let fillOpacity = "0.15";
|
|
675
|
+
let strokeWidth = "1";
|
|
676
|
+
|
|
677
|
+
if (color === "#ff3b30") {
|
|
678
|
+
fillOpacity = "0.85"; // Rosso: Molto visibile
|
|
679
|
+
strokeWidth = "1.5"; // Rosso: Più marcato
|
|
680
|
+
} else if (color === "#ff9800") {
|
|
681
|
+
fillOpacity = "0.45"; // Arancio: Velo medio
|
|
682
|
+
strokeWidth = "1"; // Arancio: Sottile
|
|
683
|
+
}
|
|
684
684
|
|
|
685
|
-
//
|
|
685
|
+
// Costruzione Gradiente (stacchi netti tra i colori)
|
|
686
686
|
gradientStops += `<stop offset="${percentPrev}%" stop-color="${color}" stop-opacity="${fillOpacity}" />`;
|
|
687
687
|
gradientStops += `<stop offset="${percentCurr}%" stop-color="${color}" stop-opacity="${fillOpacity}" />`;
|
|
688
688
|
|
|
689
|
-
//
|
|
689
|
+
// Disegno Linea con precisione geometrica
|
|
690
690
|
lines += `<line x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}"
|
|
691
|
-
style="stroke: ${color}; stroke-width: ${strokeWidth}; stroke-linecap: round;" />`;
|
|
691
|
+
style="stroke: ${color}; stroke-width: ${strokeWidth}; stroke-linecap: round; shape-rendering: geometricPrecision;" />`;
|
|
692
692
|
|
|
693
|
-
// AGGIORNAMENTO PATH UNICO
|
|
694
693
|
if (i === 1) areaPath += `L ${x1} ${y1} `;
|
|
695
694
|
areaPath += `L ${x2} ${y2} `;
|
|
696
695
|
}
|
|
697
696
|
|
|
698
|
-
// Chiusura del path dell'area
|
|
699
697
|
areaPath += `L ${w} ${h} Z`;
|
|
700
698
|
|
|
701
|
-
// 4. Iniezione del
|
|
699
|
+
// 4. Iniezione del Gradiente
|
|
702
700
|
const gradId = `grad-${id}`;
|
|
703
701
|
const defs = `
|
|
704
702
|
<defs>
|
|
@@ -709,12 +707,12 @@ function drawGraph(d, id, min, max, isTws, isHercules) {
|
|
|
709
707
|
`;
|
|
710
708
|
|
|
711
709
|
// 5. Render Finale
|
|
712
|
-
// Se è Depth o Tws applichiamo il gradiente, altrimenti colore standard fisso (per SOG/STW)
|
|
713
710
|
if (isTws || isDepth) {
|
|
714
711
|
svg.innerHTML = `${defs}${grids}<path d="${areaPath}" fill="url(#${gradId})" stroke="none" />${lines}`;
|
|
715
712
|
} else {
|
|
716
|
-
|
|
717
|
-
|
|
713
|
+
// Per STW/SOG usiamo il colore dell'ultimo punto con area fissa 0.15
|
|
714
|
+
const currentPathColor = getColor(d[d.length - 1]);
|
|
715
|
+
svg.innerHTML = `${grids}<path d="${areaPath}" fill="${currentPathColor}" fill-opacity="0.15" stroke="none" />${lines}`;
|
|
718
716
|
}
|
|
719
717
|
}
|
|
720
718
|
|
package/index.js
CHANGED
|
@@ -12,20 +12,40 @@ module.exports = function (app) {
|
|
|
12
12
|
plugin.name = 'Rotevista Dash Configuration';
|
|
13
13
|
plugin.description = 'Configure boat-specific tactical and safety parameters for the Dashboard';
|
|
14
14
|
|
|
15
|
+
let currentConfig = {};
|
|
16
|
+
let routeRegistered = false;
|
|
17
|
+
|
|
15
18
|
/**
|
|
16
|
-
* plugin.start: Inizializza il plugin
|
|
19
|
+
* plugin.start: Inizializza il plugin.
|
|
20
|
+
* Viene chiamato all'avvio e OGNI VOLTA che clicchi "Save" nelle impostazioni.
|
|
17
21
|
*/
|
|
18
22
|
plugin.start = function (options) {
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
// 1. Aggiorna la configurazione in memoria (per l'endpoint pubblico)
|
|
24
|
+
currentConfig = options;
|
|
25
|
+
|
|
26
|
+
// 2. Log di debug nel server Signal K
|
|
27
|
+
app.debug(`${plugin.name} started/updated with new options`);
|
|
23
28
|
|
|
24
|
-
|
|
29
|
+
// 3. Registra la rotta API solo la prima volta
|
|
30
|
+
if (!routeRegistered) {
|
|
31
|
+
app.get('/rotevista-config', (req, res) => {
|
|
32
|
+
res.json(currentConfig);
|
|
33
|
+
});
|
|
34
|
+
routeRegistered = true;
|
|
35
|
+
app.debug('Public API endpoint registered at /rotevista-config');
|
|
36
|
+
}
|
|
25
37
|
};
|
|
26
38
|
|
|
39
|
+
/**
|
|
40
|
+
* plugin.stop: Chiamato quando il plugin viene disattivato o prima di un aggiornamento.
|
|
41
|
+
*/
|
|
27
42
|
plugin.stop = function () {
|
|
28
|
-
|
|
43
|
+
app.debug(`${plugin.name} stopped`);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Se desideri avere una funzione plugin.debug personalizzata (opzionale)
|
|
47
|
+
plugin.debug = function(msg) {
|
|
48
|
+
app.debug(msg);
|
|
29
49
|
};
|
|
30
50
|
|
|
31
51
|
/**
|