Skip to content

aesh-charts: Viewport shows inconsistent number of data points when scrolling #597

Description

@stalep

When viewport scrolling is active, the number of visible data points changes between scroll positions. This makes it difficult to visually compare data across different parts of the series because the chart's visual density and spacing changes with each scroll.

Example: With 21 data points and viewportSize=10:

  • Position A: shows 10 points
  • After scrollRight: shows 7 points
  • After scrollRight: shows 10 points again

Expected: Every scroll position should show exactly viewportSize data points (except at the edges where fewer points remain). The X-axis range should adjust to always span the same number of points.

Impact: When the visible point count changes, the X-axis scale changes too, making a flat trend look like a spike or vice versa. This undermines the purpose of scrolling through data to compare values.

Suggested fix: In the viewport calculation during render(), ensure effectiveEnd - effectiveStart is always equal to viewportSize, clamped at data boundaries:

int effectiveStart = Math.max(0, Math.min(viewportStart, maxDataSize - viewportSize));
int effectiveEnd = Math.min(effectiveStart + viewportSize, maxDataSize);
// If at the end, shift start back to maintain consistent size
if (effectiveEnd - effectiveStart < viewportSize && effectiveStart > 0) {
    effectiveStart = Math.max(0, effectiveEnd - viewportSize);
}

Related to #594 (viewport scrolling implementation).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions