MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / trend_dir

Function trend_dir

app/rcc/scripts/painter/sparklines.js:22–33  ·  view source on GitHub ↗
(t)

Source from the content-addressed store, hash-verified

20}
21
22function trend_dir(t) {
23 if (!t || t.length < 8) return 0;
24 const tail = t.slice(-8);
25 const a = tail[0];
26 const b = tail[tail.length - 1];
27 const span = Math.max(...tail) - Math.min(...tail);
28 if (span === 0) return 0;
29 const delta = (b - a) / span;
30 if (delta > 0.15) return 1;
31 if (delta < -0.15) return -1;
32 return 0;
33}
34
35function paint(ctx, w, h) {
36 // Cream paper background.

Callers 1

paintFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected