(t)
| 20 | } |
| 21 | |
| 22 | function 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 | |
| 35 | function paint(ctx, w, h) { |
| 36 | // Cream paper background. |