Skip to content

Commit ae22322

Browse files
committed
path different from line
1 parent 64d14f8 commit ae22322

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

R/ggplotly.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ toBasic <-
113113
})
114114
g$geom <- "path"
115115
group2NA(g)
116-
},polygon=group2NA,line=group2NA,ribbon=function(g){
116+
},polygon=group2NA,line=function(g){
117+
g$data <- g$data[order(g$data$x),]
118+
group2NA(g)
119+
},ribbon=function(g){
117120
stop("TODO")
118121
})
119122

inst/tests/test-ggplot-path.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
context("path")
2+
3+
df <- data.frame(x=c(1, 3, 2),
4+
y=c(0, 0, 1))
5+
6+
test_that("lines are different from paths", {
7+
p <- qplot(x, y, data=df, geom="path")
8+
p.tr <- gg2list(p)[[1]]
9+
expect_identical(p.tr$x, c(1, 3, 2))
10+
expect_identical(p.tr$y, c(0, 0, 1))
11+
l <- qplot(x, y, data=df, geom="line")
12+
l.tr <- gg2list(l)[[1]]
13+
expect_identical(l.tr$x, c(1, 2, 3))
14+
expect_identical(l.tr$y, c(0, 1, 0))
15+
})

0 commit comments

Comments
 (0)