Status Chart: Avoid emitting consecutive zeros #1895
Merged
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.
cxx20
line is constantly zero. I want it to simply vanish, as the C++17 line did (which was manually recorded in weekly_table.js, so we just stopped recording data points). To do this in a general way, I'm splitting the daily table generation into two phases. First, we calculate all of the data points (this part takes a bit of time, so there's a progress bar). Then, we determine which data points should be kept - this requires looking at the previous and next values, so it has to be a separate phase.should_emit_data_point()
will keep a value if it's nonzero (which we definitely need!), if the previous value exists and was nonzero (because when we fall to zero, we want to record a single zero before stopping), or if the next value exists and will be nonzero (to properly display liftoff from zero).?.
makes this look very nice because the bounds checks are implicit. Inrows[i - 1]?.[key] > 0
, wheni === 0
, thenrows[i - 1]
will beundefined
; the optional chaining operator will short-circuit instead of attempting to access the[key]
(which would otherwise be an error) and returnundefined
. Thenundefined > 0
isfalse
, which is what we want - at the beginning of the dataset, there is no previous value to consider, so we'll consider only the current and next data point.begin_cxx23
.📉 Live preview: stephantlavavej.github.io/STL/
Note: To avoid merge conflicts, this doesn't update
daily_table.js
, thus the effect of dropping zeros can't be seen yet. It affects the beginning of thebug
line, and the end of thecxx20
line.