Skip to content

fix(dashboard): chart Avg windows flat-line at 0 on wide ranges (#168 downsampling regression)#228

Merged
VijitSingh97 merged 1 commit into
mainfrom
chart-downsample-perwindow
Jun 12, 2026
Merged

fix(dashboard): chart Avg windows flat-line at 0 on wide ranges (#168 downsampling regression)#228
VijitSingh97 merged 1 commit into
mainfrom
chart-downsample-perwindow

Conversation

@VijitSingh97

Copy link
Copy Markdown
Collaborator

The bug

On the 24h / 1w / 1mo ranges, selecting any Avg window other than the default 10 Min — i.e. 1 Min / 1 Hr / 12 Hr / 24 Hr — renders a flat line at zero (with the y-axis then auto-scaling to the tiny Shares-marker range, ~1.4). The 1h range works for all windows.

Reported from gouda:

Range Avg Result
1 Hr 1 Min ✅ real data (37–48 kH/s)
24 Hr 1 Min ❌ flat at 0, y-axis maxes at ~1.4

Root cause

build_chart downsamples whenever a range has more points than its canvas tier (_downsample_history, #47). The downsampler bucket-averaged only the legacy v / v_p2pool / v_xvb columns and silently dropped the per-window columns added in #168 (v_p2pool_1m, v_xvb_1m, v_*_1h, v_*_12h, v_*_24h). _split_values then looks up e.g. v_p2pool_1m on the downsampled row, finds nothing → 0, and the v-fallback only rescues the default 10m window. So every non-default Avg window collapses to 0 on any range wide enough to downsample. The 1h range (≤ point tier) keeps native rows, so it's unaffected — which is exactly the observed pattern.

Not missing data — verified on gouda's DB: the last 24h holds 1,896 non-zero v_p2pool_1m points (max 47,681 H/s), yet the chart drew zero.

Fix

_downsample_history now carries every value column through, derived from HASHRATE_WINDOW_COLUMNS so a newly-added averaging window is averaged automatically and can't regress the same way:

_DOWNSAMPLE_VALUE_COLUMNS = tuple(dict.fromkeys(
    ("v",) + tuple(col for cols in HASHRATE_WINDOW_COLUMNS.values() for col in cols)
))
# ...bucket-average each column in _DOWNSAMPLE_VALUE_COLUMNS

Display only — no change to data capture, the algorithm, or the default 10m series.

Tests

  • test_downsample_preserves_per_window_columns — asserts the bucket-averaged rows keep every per-window column.
  • test_wide_range_keeps_nondefault_avg_nonzero — end-to-end build_chart(24h, avg=1m) over a downsampled series stays non-zero (fails before this fix).
  • Full pytest 518 passed; make test-inventory regenerated; drift guard green. The Fake-daemon mini-stack CI job rebuilds + loads the dashboard.

(Answers the "grey out empty selections?" question too: the selections aren't empty — the data was being dropped — so fixing the plot is the right call rather than disabling the buttons. The 12h/24h Avg windows still legitimately need that much uptime to fill, which #168 already signposts.)

🤖 Generated with Claude Code

…sion)

The chart downsampler (_downsample_history, used whenever a range exceeds
its canvas point tier — i.e. the 24h / 1w / 1mo ranges) bucket-averaged
only the legacy v / v_p2pool / v_xvb columns and dropped the per-window
columns added in #168. So selecting any non-default Avg window (1m / 1h /
12h / 24h) on a wide range plotted a flat-zero line — the y-axis then
auto-scaling to the Shares markers — even though the data was present.
Only the default 10m window survived, because it reads v_p2pool/v_xvb
(which were carried) plus the legacy `v` fallback.

Confirmed on gouda: the last 24h held 1,896 non-zero v_p2pool_1m points
(max 47.7 kH/s), yet the 24h/1Min chart rendered flat at 0.

The downsampler now carries EVERY value column through, derived from
HASHRATE_WINDOW_COLUMNS so a future averaging window can't regress the
same way.

- views.py: _DOWNSAMPLE_VALUE_COLUMNS (from the window map) + loop over it.
- tests: direct _downsample_history column-preservation test + an
  end-to-end build_chart(24h, avg=1m) non-zero assertion (would fail before
  the fix); test-inventory regenerated.
- CHANGELOG: Fixed entry.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@VijitSingh97
VijitSingh97 force-pushed the chart-downsample-perwindow branch from cab81a5 to d270baf Compare June 12, 2026 14:11
@VijitSingh97
VijitSingh97 merged commit 45b4975 into main Jun 12, 2026
12 checks passed
@VijitSingh97
VijitSingh97 deleted the chart-downsample-perwindow branch June 12, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant