Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e56312b

Browse files
added showcase for js libby
1 parent 0fcfd18 commit e56312b

File tree

24 files changed

+163
-34
lines changed

24 files changed

+163
-34
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"has_thumbnail": false,
33
"name": "Showcase",
4-
"relative_url": "javascript-graphing-library/showcase/"
4+
"relative_url": "showcase"
55
}

reports/test-report.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ Complete examples:
162162
shiny-ggplot2
163163
shiny-r
164164
show-legend
165+
showcase-example-placeholder
165166
simple-3d-scatter
166167
simple-annotation
167168
simple-contour

test-published/api-docs/chart-types/bar/gg-basic-bar/ggplot2/code.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ library(plotly)
33
# Learn about API authentication here: {{BASE_URL}}/r/getting-started
44
# Find your api_key here: {{BASE_URL}}/settings/api
55

6+
py <- plotly()
7+
68
# Consider the following data frame
79
researchers <- data.frame(
810
country = c("Canada", "Canada", "Germany", "USA"),
@@ -13,5 +15,6 @@ researchers <- data.frame(
1315
# Let us plot the number of papers (y) per name (x)
1416
plt <- ggplot(researchers, aes(x = name, y = papers)) + geom_bar(stat = "identity")
1517

16-
out <- py$ggplotly(plt)
18+
out <- py$ggplotly(plt, kwargs=list(filename="gg-basic-bar", fileopt="overwrite"))
19+
1720
plotly_url <- out$response$url

test-published/api-docs/chart-types/facets/facet_wrap/ggplot2/code.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ require(lattice)
44
# Learn about API authentication here: {{BASE_URL}}/r/getting-started
55
# Find your api_key here: {{BASE_URL}}/settings/api
66

7+
py <- plotly()
8+
79
w <- ggplot(data=barley, aes(x=yield, y=variety, color=year)) +
8-
geom_point() +
9-
facet_wrap(~site)
10+
geom_point() +
11+
facet_wrap(~site)
1012

11-
out <- py$ggplotly(w)
13+
out <- py$ggplotly(w, kwargs=list(filename="facet_wrap", fileopt="overwrite"))
1214
plotly_url <- out$response$url

test-published/api-docs/chart-types/functions/x-squared/ggplot2/code.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ library(plotly)
33
# Learn about API authentication here: {{BASE_URL}}/r/getting-started
44
# Find your api_key here: {{BASE_URL}}/settings/api
55

6+
py <- plotly()
7+
68
eq <- function(x) {x*x}
79
tmp <- data.frame(x=1:50, y=eq(1:50))
810

9-
p <- qplot(x, y, data=tmp, xlab="X-axis", ylab="Y-axis")
10-
c <- stat_function(fun=eq)
11+
p <- qplot(x, y, data=tmp, xlab="X-axis", ylab="Y-axis") +
12+
stat_function(fun=eq)
1113

12-
out <- py$ggplotly(p + c)
14+
out <- py$ggplotly(p, kwargs=list(filename="x-squared", fileopt="overwrite"))
1315

1416
plotly_url <- out$response$url

test-published/api-docs/chart-types/geom_polygon/geom_polygon_1/ggplot2/code.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ library(plotly)
33
# Learn about API authentication here: {{BASE_URL}}/r/getting-started
44
# Find your api_key here: {{BASE_URL}}/settings/api
55

6+
py <- plotly()
7+
68
ids <- factor(c("1.1", "2.1", "1.2", "2.2", "1.3", "2.3"))
79

810
values <- data.frame(
@@ -20,7 +22,8 @@ positions <- data.frame(
2022

2123
datapoly <- merge(values, positions, by=c("id"))
2224

23-
(p <- ggplot(datapoly, aes(x=x, y=y)) + geom_polygon(aes(fill=value, group=id)))
25+
p <- ggplot(datapoly, aes(x=x, y=y)) +
26+
geom_polygon(aes(fill=value, group=id))
2427

25-
out <- py$ggplotly(p)
28+
out <- py$ggplotly(p, kwargs=list(filename="geom_polygon_1", fileopt="overwrite"))
2629
plotly_url <- out$response$url

test-published/api-docs/chart-types/gg-themes/few/ggplot2/code.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ library("ggthemes")
44
# Learn about API authentication here: {{BASE_URL}}/r/getting-started
55
# Find your api_key here: {{BASE_URL}}/settings/api
66

7+
py <- plotly()
8+
79
dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
810
few <- (qplot(carat, price, data = dsamp, colour = cut) +
911
theme_few() +
1012
scale_colour_few())
1113

12-
out <- py$ggplotly(few)
14+
out <- py$ggplotly(few, kwargs=list(filename="few", fileopt="overwrite"))
1315
plotly_url <- out$response$url

test-published/api-docs/chart-types/gg-themes/igray/ggplot2/code.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ library("ggthemes")
44
# Learn about API authentication here: {{BASE_URL}}/r/getting-started
55
# Find your api_key here: {{BASE_URL}}/settings/api
66

7+
py <- plotly()
8+
79
dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
810
gray <- (qplot(carat, price, data = dsamp, colour = cut) +
911
theme_igray())
1012

11-
out <- py$ggplotly(gray)
13+
out <- py$ggplotly(gray, kwargs=list(filename="igray", fileopt="overwrite"))
1214
plotly_url <- out$response$url

test-published/api-docs/chart-types/gg-themes/tableau/ggplot2/code.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ library("ggthemes")
44
# Learn about API authentication here: {{BASE_URL}}/r/getting-started
55
# Find your api_key here: {{BASE_URL}}/settings/api
66

7+
py <- plotly()
8+
79
dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
810
tableau <- (qplot(carat, price, data = dsamp, colour = cut) +
911
theme_igray() +
1012
scale_colour_tableau())
1113

12-
out <- py$ggplotly(tableau)
14+
out <- py$ggplotly(tableau, kwargs=list(filename="tableau", fileopt="overwrite"))
1315
plotly_url <- out$response$url

test-published/api-docs/chart-types/histogram/geom_histogram/ggplot2/code.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ library(plotly)
33
# Learn about API authentication here: {{BASE_URL}}/r/getting-started
44
# Find your api_key here: {{BASE_URL}}/settings/api
55

6-
m <- ggplot(movies, aes(x=rating))
7-
out <- py$ggplotly(m + geom_histogram(aes(weight = votes)))
6+
py <- plotly()
7+
8+
m <- ggplot(movies, aes(x=rating)) +
9+
geom_histogram(aes(weight = votes))
10+
11+
out <- py$ggplotly(m, kwargs=list(filename="geom_histogram", fileopt="overwrite"))
812

913
plotly_url <- out$response$url

test-published/api-docs/chart-types/line_and_scatter/gg-alpha/ggplot2/code.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ library(plotly)
33
# Learn about API authentication here: {{BASE_URL}}/r/getting-started
44
# Find your api_key here: {{BASE_URL}}/settings/api
55

6+
py <- plotly()
7+
68
prettyPlot <- ggplot(data=diamonds, aes(x=carat, y=price, colour=clarity))
79
prettyPlot <- prettyPlot + geom_point(alpha = 1/10)
8-
out <- py$ggplotly(prettyPlot)
10+
out <- py$ggplotly(prettyPlot, kwargs=list(filename="gg-alpha", fileopt="overwrite"))
911

1012
plotly_url <- out$response$url

test-published/api-docs/chart-types/line_and_scatter/gg-basic-line/ggplot2/code.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ library(plotly)
33
# Learn about API authentication here: {{BASE_URL}}/r/getting-started
44
# Find your api_key here: {{BASE_URL}}/settings/api
55

6+
py <- plotly()
7+
68
orange <- qplot(
79
age,
810
circumference,
911
data = Orange,
1012
colour = Tree,
1113
geom = "line")
1214

13-
out <- py$ggplotly(orange)
15+
out <- py$ggplotly(orange, kwargs=list(filename="gg-basic-line", fileopt="overwrite"))
1416
plotly_url <- out$response$url

test-published/api-docs/chart-types/line_and_scatter/gg-basic-scatter/ggplot2/code.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ library(plotly)
33
# Learn about API authentication here: {{BASE_URL}}/r/getting-started
44
# Find your api_key here: {{BASE_URL}}/settings/api
55

6+
py <- plotly()
7+
68
ggiris <- qplot(Petal.Width, Sepal.Length, data = iris, color = Species)
79

8-
out <- py$ggplotly(ggiris)
10+
out <- py$ggplotly(ggiris, kwargs=list(filename="gg-basic-scatter", fileopt="overwrite"))
911
plotly_url <- out$response$url

test-published/api-docs/chart-types/line_and_scatter/gg-geom_line/ggplot2/code.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ library(plyr)
44
# Learn about API authentication here: {{BASE_URL}}/r/getting-started
55
# Find your api_key here: {{BASE_URL}}/settings/api
66

7+
py <- plotly()
8+
79
mry <- do.call(rbind, by(movies, round(movies$rating), function(df) {
810
nums <- tapply(df$length, df$year, length)
911
data.frame(rating=round(df$rating[1]), year = as.numeric(names(nums)), number=as.vector(nums))
1012
}))
1113

12-
p <- ggplot(mry, aes(x=year, y=number, group=rating))
13-
out <- py$ggplotly(p + geom_line(aes(colour = rating)) + scale_colour_gradient(low="red"))
14+
p <- ggplot(mry, aes(x=year, y=number, group=rating)) +
15+
geom_line(aes(colour = rating)) +
16+
scale_colour_gradient(low="red")
17+
out <- py$ggplotly(p, kwargs=list(filename="gg-geom_line", fileopt="overwrite"))
1418

1519
plotly_url <- out$response$url

test-published/api-docs/chart-types/line_and_scatter/gg-geom_path/ggplot2/code.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ library(plyr)
44
# Learn about API authentication here: {{BASE_URL}}/r/getting-started
55
# Find your api_key here: {{BASE_URL}}/settings/api
66

7+
py <- plotly()
8+
79
myear <- ddply(movies, .(year), colwise(mean, .(length, rating)))
8-
p <- ggplot(myear, aes(length, rating))
9-
out <- py$ggplotly(p + geom_path(colour='green') + scale_size(range = c(1, 3)))
10+
p <- ggplot(myear, aes(length, rating)) +
11+
geom_path(colour='green') +
12+
scale_size(range = c(1, 3))
13+
out <- py$ggplotly(p, kwargs=list(filename="gg-geom_path", fileopt="overwrite"))
1014

1115
plotly_url <- out$response$url

test-published/api-docs/chart-types/line_and_scatter/gg-geom_point/ggplot2/code.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ library(plotly)
33
# Learn about API authentication here: {{BASE_URL}}/r/getting-started
44
# Find your api_key here: {{BASE_URL}}/settings/api
55

6-
p <- ggplot(mtcars, aes(wt, mpg))
7-
out <- py$ggplotly(p + geom_point(aes(colour = factor(cyl))))
6+
py <- plotly()
7+
8+
p <- ggplot(mtcars, aes(wt, mpg)) +
9+
geom_point(aes(colour = factor(cyl)))
10+
out <- py$ggplotly(p, kwargs=list(filename="gg-geom_point", fileopt="overwrite"))
811

912
plotly_url <- out$response$url

test-published/api-docs/chart-types/line_and_scatter/gg-geom_segment/ggplot2/code.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ library(plotly)
33
# Learn about API authentication here: {{BASE_URL}}/r/getting-started
44
# Find your api_key here: {{BASE_URL}}/settings/api
55

6-
p <- ggplot(seals, aes(x = long, y = lat))
6+
py <- plotly()
77

8-
out <- py$ggplotly((p <- p + geom_segment(aes(xend = long + delta_long, yend = lat + delta_lat))))
8+
p <- ggplot(seals, aes(x = long, y = lat)) +
9+
geom_segment(aes(xend = long + delta_long, yend = lat + delta_lat))
10+
out <- py$ggplotly(p, kwargs=list(filename="gg-geom_segment", fileopt="overwrite"))
911
plotly_url <- out$response$url

test-published/api-docs/chart-types/line_and_scatter/gg-line-scatter/ggplot2/code.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ library(plotly)
33
# Learn about API authentication here: {{BASE_URL}}/r/getting-started
44
# Find your api_key here: {{BASE_URL}}/settings/api
55

6+
py <- plotly()
7+
68
model <- lm(mpg ~ wt + factor(cyl), data=mtcars)
79
grid <- with(mtcars, expand.grid(
810
wt = seq(min(wt), max(wt), length = 20),
@@ -11,6 +13,7 @@ grid <- with(mtcars, expand.grid(
1113

1214
grid$mpg <- stats::predict(model, newdata=grid)
1315

14-
viz2 <- qplot(wt, mpg, data=mtcars, colour=factor(cyl)) + geom_line(data=grid)
15-
out <- py$ggplotly(viz2)
16+
viz2 <- qplot(wt, mpg, data=mtcars, colour=factor(cyl)) +
17+
geom_line(data=grid)
18+
out <- py$ggplotly(viz2, kwargs=list(filename="gg-line-scatter", fileopt="overwrite"))
1619
plotly_url <- out$response$url

test-published/api-docs/chart-types/line_shapes/geom_step/ggplot2/code.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ library(plotly)
33
# Learn about API authentication here: {{BASE_URL}}/r/getting-started
44
# Find your api_key here: {{BASE_URL}}/settings/api
55

6+
py <- plotly()
7+
68
df <- data.frame(x=sort(rnorm(47)))
7-
p <- ggplot(df, aes(seq_along(x), x))
9+
p <- ggplot(df, aes(seq_along(x), x)) +
10+
geom_step()
811

9-
out <- py$ggplotly(p + geom_step())
12+
out <- py$ggplotly(p, kwargs=list(filename="geom_step", fileopt="overwrite"))
1013
plotly_url <- out$response$url

test-published/api-docs/chart-types/maps/canadian-cities/ggplot2/code.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ library(plotly)
33
# Learn about API authentication here: {{BASE_URL}}/r/getting-started
44
# Find your api_key here: {{BASE_URL}}/settings/api
55

6+
py <- plotly()
7+
68
data(canada.cities, package="maps")
79
viz <- ggplot(canada.cities, aes(long, lat)) +
8-
borders(regions="canada", name="borders") +
9-
coord_equal() +
10-
geom_point(aes(text=name, size=pop), colour="red", alpha=1/2, name="cities")
10+
borders(regions="canada", name="borders") +
11+
coord_equal() +
12+
geom_point(aes(text=name, size=pop), colour="red", alpha=1/2, name="cities")
1113

12-
out <- py$ggplotly(viz)
14+
out <- py$ggplotly(viz, kwargs=list(filename="canadian-cities", fileopt="overwrite"))
1315
plotly_url <- out$response$url

test-published/api-docs/references/plotly_js.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,34 @@
17291729
"name": "Layout Options",
17301730
"parent": "hard-coded"
17311731
},
1732+
{
1733+
"branches": [
1734+
{
1735+
"branches": [
1736+
{
1737+
"code": "showcase/showcase-subsection-placeholder/showcase-example-placeholder/plotly_js/code.txt",
1738+
"id": "showcase-example-placeholder",
1739+
"languages": [
1740+
"plotly_js"
1741+
],
1742+
"name": "Showcase Example Placeholder",
1743+
"parent": "showcase-subsection-placeholder",
1744+
"type": "model",
1745+
"url": "https://plot.ly/~TestBot/815"
1746+
}
1747+
],
1748+
"has_thumbnail": false,
1749+
"id": "showcase-subsection-placeholder",
1750+
"name": "Showcase",
1751+
"parent": "showcase",
1752+
"relative_url": "javascript-graphing-library/showcase/"
1753+
}
1754+
],
1755+
"has_thumbnail": false,
1756+
"id": "showcase",
1757+
"name": "Showcase",
1758+
"parent": "hard-coded"
1759+
},
17321760
{
17331761
"branches": [
17341762
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var trace1 = {
2+
x: [1, 2, 3, 4],
3+
y: [0, 2, 3, 5],
4+
fill: "tozeroy",
5+
type: "scatter"
6+
};
7+
var trace2 = {
8+
x: [1, 2, 3, 4],
9+
y: [3, 5, 1, 7],
10+
fill: "tonexty",
11+
type: "scatter"
12+
};
13+
var data = [trace1, trace2];
14+
Plotly.plot(divid, data);
Loading

0 commit comments

Comments
 (0)