Skip to content

🐛 Y-axis minRange floor skipped for tiny nonzero spans (can freeze tab) #18

Description

@itsdiay

Summary

In computeRange (and the candle range helper), the absolute Y floor uses a falsy coalesce:

const minRange = rawRange * 0.1 || 0.4

Because || only falls through when the left side is exactly 0 / falsy, any tiny nonzero rawRange skips the 0.4 floor.

Impact

Near-flat or micro-priced series (common for low-priced tokens) produce a denormal-scale Y domain. That domain is then used by the Y-grid drawing loop (drawGrid / pickInterval). With a step size smaller than the floating-point ULP of the current value, val += fine never advances and the main thread hangs → browser “Page Unresponsive”.

Expected

  • When rawRange > 0 and finite, use the relative minimum span (rawRange * k).
  • Apply the absolute floor (0.4, or 0.04 in exaggerate mode) only when the span is zero / non-finite.
  • Avoid forcing 0.4 for all tiny nonzero spans (that over-pads and flattens real micro volatility).

Suggested fix direction

Replace the || pattern with an explicit check, e.g.:

const relativeMin = rawRange * (exaggerate ? 0.02 : 0.1)
const absoluteFloor = exaggerate ? 0.04 : 0.4
const minRange =
  rawRange > 0 && Number.isFinite(rawRange) ? relativeMin : absoluteFloor

Apply the same change to the candle range helper that currently uses range * 0.1 || 0.4.

Related

Grid-loop hardening (guards in pickInterval / drawGrid) is a useful defense-in-depth companion, but this floor bug is the primary domain-side cause of the hang for micro ranges.

Environment

Seen with liveline@0.0.7 in a React web app plotting USD prices around 1e-41e-5 with small relative moves.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions