[tor-commits] [metrics-web/master] Fix direct users graph showing censorship events.
karsten at torproject.org
karsten at torproject.org
Tue Jun 19 06:29:48 UTC 2012
commit 3ad9bb84db872d07ed571e9b094f09e1abf7eb45
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date: Tue Jun 19 08:09:30 2012 +0200
Fix direct users graph showing censorship events.
The problem was that a graph that didn't have *any* upturns or downturns
showed these events for *every* single data point. R/ggplot2 sure can do
unexpected things.
Fixes (part of) #6170.
---
rserve/graphs.R | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/rserve/graphs.R b/rserve/graphs.R
index f5575c3..30413b8 100644
--- a/rserve/graphs.R
+++ b/rserve/graphs.R
@@ -696,10 +696,14 @@ plot_direct_users <- function(start, end, country, events, path, nocutoff,
downturns <- r[r$users < r$minusers, 1:2]
plot <- plot +
geom_ribbon(data = r, aes(ymin = minusers, ymax = maxusers),
- fill = "gray") +
- geom_point(data = upturns, aes(x = date, y = users), size = 5,
- colour = "dodgerblue2") +
- geom_point(data = downturns, aes(x = date, y = users), size = 5,
+ fill = "gray")
+ if (length(upturns$date) > 0)
+ plot <- plot +
+ geom_point(data = upturns, aes(x = date, y = users), size = 5,
+ colour = "dodgerblue2")
+ if (length(downturns$date) > 0)
+ plot <- plot +
+ geom_point(data = downturns, aes(x = date, y = users), size = 5,
colour = "firebrick2")
}
plot <- plot +
More information about the tor-commits
mailing list