Skip to content

Massage the data going into download graph #426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 31, 2016

Conversation

TyOverby
Copy link
Contributor

Closes #305

Google graphs does not treat 0-values in a stacked area-graph very well. The default behavior for something like the crates.io download graph is to draw many lines right over the top of eachother, meaning that a recently released version will have its lines drawn over the top of the the other versions.

This can be fixed by passing google graphs a dataset with nulls instead of zeros for areas where the line shouldn't be drawn.

This is an implementation of an algorithm that detects sequences of zeros and removes all the zeroes in the middle of the sequence, replacing them with null.

For example

[1, 2, 0, 0, 0, 0, 5, 10, 0, 0, 0, 3, 0, 0]

will become (spaces indicate null)

[1, 2, 0,  ,  , 0, 5, 10, 0,  , 0, 3, 0, 0]

Leaving the boundary 0s makes the graph look more continuous.

BEFORE

screen shot 2016-08-30 at 1 06 17 pm

# AFTER

screen shot 2016-08-30 at 1 07 45 pm

Google graphs does not treat 0-values in a stacked area-graph very well.
The default behavior for something like the crates.io download graph is
to draw many lines right over the top of eachother, meaning that a
recently released version will have its lines drawn over the top of
the the other versions.

This can be fixed by passing google graphs a dataset with nulls instead
of zeros for areas where the line shouldn't be drawn.

This is an implementation of an algorithm that detects sequences of
zeros and removes all the zeroes in the middle of the sequence,
replacing them with null.

For example
[1, 2, 0, 0, 0, 0, 5, 10, 0, 0, 0, 3, 0, 0]
will become (spaces indicate null)
[1, 2, 0,  ,  , 0, 5, 10, 0,  , 0, 3, 0, 0]

Leaving the boundary 0s makes the graph look more continuous.

See the PR for before/after photos.
@alexcrichton
Copy link
Member

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reverse drawing order of download graph
2 participants