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).
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:Expected: Every scroll position should show exactly
viewportSizedata 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(), ensureeffectiveEnd - effectiveStartis always equal toviewportSize, clamped at data boundaries:Related to #594 (viewport scrolling implementation).