fix(chart): don't render bars without a computed layout position#29
Open
dalley wants to merge 1 commit into
Open
fix(chart): don't render bars without a computed layout position#29dalley wants to merge 1 commit into
dalley wants to merge 1 commit into
Conversation
A task whose date normalization was skipped — an unscheduled task, or any task without a start date — never gets numeric $x/$w coordinates. The layout math leaves them NaN, taskStyle() then emits left/width values like "NaNpx", the browser rejects the invalid declarations, and a ghost bar renders at the chart origin, auto-sized by its own label text. To a user this reads as a real (and very wrong) schedule. Repro: add a task with no start/end to any demo dataset — a bar appears at the chart start whose 'duration' is the pixel length of its title. Guard the main bar and the baseline bar on Number.isFinite of their computed positions: the row still appears in the grid, but nothing is painted on the timeline until the task has real coordinates.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #30
Problem
A task that never received a computed layout position still renders a
wx-barelement, producing a confusing "ghost bar":unscheduled: true, or any task without astartdate — the layout math leaves$x/$wasNaN.taskStyle()then emitsleft: "NaNpx",width: "NaNpx"; the browser rejects the invalid declarations.top/height, so it sits at the chart origin and auto-sizes to its label text. To a user this reads as a real (and very wrong) schedule — the bar's apparent "duration" is the pixel length of its own title.Repro
Add a dateless task to any demo dataset, e.g. in
demos/data.js:A bar appears at the chart start spanning roughly six "days" — the width of the label.
This is easy to hit from the MIT package:
unscheduledTasksis disabled in the store'sinit(), butnormalizeDatesstill honors the per-taskunscheduledflag (andcalcDatesis a no-op for tasks with nostart), so any dateless task paints a ghost bar with no way to opt out.Fix
Guard the main bar and the baseline element on
Number.isFinite()of their computed positions ($x/$x_base). The row still appears in the grid; nothing is painted on the timeline until the task has real coordinates.!= nullis not sufficient — the skipped-normalization path producesNaN, notundefined.Verification
Ran the demos with the repro task above: before — ghost bar at the origin; after — the grid row is present and the timeline row is empty, while all scheduled bars, milestones, summaries and baselines render unchanged.
🤖 Generated with Claude Code