-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathlayers.R
78 lines (70 loc) · 2.22 KB
/
layers.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
70
71
72
73
74
75
76
77
78
library(rcdimple)
library(dplyr)
#get data used by dimple for all of its examples as a first test
ex_data <- read.delim(
"http://pmsi-alignalytics.github.io/dimple/data/example_data.tsv"
)
#eliminate . to avoid confusion in javascript
colnames(ex_data) <- gsub("[.]","", colnames(ex_data))
#recreate http://dimplejs.org/advanced_examples_viewer.html?id=advanced_price_range_lollipop
ex_data %>%
filter(Channel=="Hypermarkets") %>%
dimple(
SalesValue ~ Brand,
type = "bar",
storyboard = "Date"
) %>%
xAxis(orderRule = list(ordering = "SalesValue",desc=TRUE)) %>%
add_series(
x = "Brand",
y = "Price",
type = "bubble",
aggregate = "dimple.aggregateMethod.avg",
yAxis = list(hidden = FALSE)
) %>%
add_series(
x = "Brand",
y = "Price",
type = "bubble",
aggregate = "dimple.aggregateMethod.min"
) %>%
add_series(
x = "Brand",
y = "Price",
type = "bubble",
aggregate = "dimple.aggregateMethod.max"
)
# more testing
mtcars$name <- rownames(mtcars)
mtcars %>%
dimple(mpg ~ cyl, type = "bar", groups = "cyl") %>%
add_series(x = "cyl", y = "mpg", type = "line", yAxis = list(hidden=FALSE) ) %>%
# hidden = FALSE so we can compare
add_series(x = "cyl", y = "mpg", groups = "name", type = "bubble") %>%
add_series(x = "cyl", y = "mpg", groups = "cyl", type = "bubble")
# try to use specify axis
mtcars %>%
dimple(mpg ~ cyl, type = "bar", groups = "cyl") %>%
# give the y axis a name if we plan to reuse
yAxis(name = "y1") %>%
add_series(
x = "cyl", y = "mpg", type = "line",
yAxis = list(useAxis = "y1")
) %>%
# hidden = FALSE so we can compare
add_series(
x = "cyl", y = "mpg", groups = "name", type = "bubble",
yAxis = list(useAxis = "y1")
) %>%
add_series(
x = "cyl", y = "mpg", groups = "cyl", type = "bubble",
yAxis = list(useAxis = "y1")
)
# try it with facets
mtcars %>%
dimple(mpg ~ cyl, type = "bar", groups = "cyl") %>%
facet(x="gear",removeAxes= TRUE) %>%
add_series(x = "cyl", y = "mpg", type = "line", yAxis = list(hidden=FALSE) ) %>%
# hidden = FALSE so we can compare
add_series(x = "cyl", y = "mpg", groups = "name", type = "bubble") %>%
add_series(x = "cyl", y = "mpg", groups = "cyl", type = "bubble")