Commit 7fef7b1
committed
Massage the data going into download graph
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.1 parent 65eefe1 commit 7fef7b1
1 file changed
+47
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
23 | 70 | | |
24 | 71 | | |
25 | 72 | | |
| |||
0 commit comments