Skip to content

Commit

Permalink
adopting base pipe in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jbkunst committed Aug 8, 2022
1 parent 40ace71 commit dfb092b
Show file tree
Hide file tree
Showing 57 changed files with 996 additions and 779 deletions.
890 changes: 504 additions & 386 deletions R/highcharts-api.R

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions dev/examples-api/annotations.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Ex 1
highchart() %>%
highchart() |>
hc_add_series(
data = c(29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4)
) %>%
) |>
hc_xAxis(
tickInterval = 0.5,
gridLineWidth = 1
) %>%
) |>
hc_annotations(
list(
labels =
Expand Down Expand Up @@ -37,8 +37,8 @@ df <- data.frame(
y = 1:10
)

highchart() %>%
hc_add_series(data = df, hcaes(x = x, y = y), type = "area") %>%
highchart() |>
hc_add_series(data = df, hcaes(x = x, y = y), type = "area") |>
hc_annotations(
list(
labels = list(
Expand Down
50 changes: 25 additions & 25 deletions dev/examples-api/boost.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ x <- round(x, 3)

plot(x)

hc1 <- highchart() %>%
hc_chart(zoomType = "x") %>%
hc_add_series(data = x) %>%
hc_title(text = "No boost") %>%
hc1 <- highchart() |>
hc_chart(zoomType = "x") |>
hc_add_series(data = x) |>
hc_title(text = "No boost") |>
hc_boost(
enabled = FALSE # Default
)
Expand All @@ -23,10 +23,10 @@ hc1
# some of the standard Highcharts features (such as animation), and focuses
# on pushing as many points as possible as quickly as possible.

hc2 <- highchart() %>%
hc_chart(zoomType = "x") %>%
hc_add_series(data = x) %>%
hc_title(text = "With boost") %>%
hc2 <- highchart() |>
hc_chart(zoomType = "x") |>
hc_add_series(data = x) |>
hc_title(text = "With boost") |>
hc_boost(enabled = TRUE)

hc2
Expand All @@ -48,36 +48,36 @@ hc2
# # unnamed list
# ds <- list_parse2(as.data.frame(mvr))
#
# highchart() %>%
# hc_chart(zoomType = "xy") %>%
# hc_xAxis(min = -vx, max = vx) %>%
# hc_yAxis(min = -vy, max = vy) %>%
# highchart() |>
# hc_chart(zoomType = "xy") |>
# hc_xAxis(min = -vx, max = vx) |>
# hc_yAxis(min = -vy, max = vy) |>
# hc_add_series(
# data = ds, #list
# type = "scatter",
# name = "A lot of points!",
# color = 'rgba(0,0,0,0.1)',
# marker = list(radius = 2)
# ) %>%
# ) |>
# hc_boost(
# enabled = TRUE
# )
#
# dat <- as.data.frame(mvr)
# names(dat) <- c("x", "y")
#
# highchart() %>%
# hc_chart(zoomType = "xy") %>%
# hc_xAxis(min = -vx, max = vx) %>%
# hc_yAxis(min = -vy, max = vy) %>%
# highchart() |>
# hc_chart(zoomType = "xy") |>
# hc_xAxis(min = -vx, max = vx) |>
# hc_yAxis(min = -vy, max = vy) |>
# hc_add_series(
# data = dat,
# type = "scatter",
# hcaes(x, y),
# name = "A lot of points!",
# color = 'rgba(0,0,0,0.1)',
# marker = list(radius = 2)
# ) %>%
# ) |>
# hc_boost(enabled = TRUE)
#
# # Ex3
Expand All @@ -87,13 +87,13 @@ hc2
# s <- s/(max(s) + min(s))
# s <- round(s, 2)
#
# series <- s %>%
# purrr::map(~ stats::arima.sim(round(N/n), model = list(ar = .x)) + .x * n * 20) %>%
# purrr::map(as.vector) %>%
# purrr::map(round, 2) %>%
# series <- s |>
# purrr::map(~ stats::arima.sim(round(N/n), model = list(ar = .x)) + .x * n * 20) |>
# purrr::map(as.vector) |>
# purrr::map(round, 2) |>
# purrr::map(~ list(data = .x))
#
# highchart() %>%
# hc_add_series_list(series) %>%
# hc_chart(zoomType = "x") %>%
# highchart() |>
# hc_add_series_list(series) |>
# hc_chart(zoomType = "x") |>
# hc_boost(enabled = TRUE)
10 changes: 5 additions & 5 deletions dev/examples-api/caption.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
highchart() %>%
hc_title(text= "Chart with a caption") %>%
hc_subtitle(text= "This is the subtitle") %>%
hc_xAxis(categories = c("Apples", "Pears", "Banana", "Orange")) %>%
highchart() |>
hc_title(text= "Chart with a caption") |>
hc_subtitle(text= "This is the subtitle") |>
hc_xAxis(categories = c("Apples", "Pears", "Banana", "Orange")) |>
hc_add_series(
data = c(1, 4, 3, 5),
type = "column",
name = "Fruits"
) %>%
) |>
hc_caption(
text = "<b>The caption renders in the bottom, and is part of the exported
chart.</b><br><em>Lorem ipsum dolor sit amet, consectetur adipiscing elit,
Expand Down
10 changes: 5 additions & 5 deletions dev/examples-api/chart.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
hc <- highchart() %>%
hc_xAxis(categories = month.abb) %>%
hc_add_series(name = "Tokyo", data = sample(1:12)) %>%
hc <- highchart() |>
hc_xAxis(categories = month.abb) |>
hc_add_series(name = "Tokyo", data = sample(1:12)) |>
hc_add_series(name = "London", data = sample(1:12) + 10)

hc

hc %>%
hc |>
hc_chart(
type = "column",
options3d = list(enabled = TRUE, beta = 15, alpha = 15)
)


hc %>%
hc |>
hc_chart(
borderColor = "#EBBA95",
borderRadius = 10,
Expand Down
19 changes: 9 additions & 10 deletions dev/examples-api/colorAxis.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ library(dplyr)

data(mpg, package = "ggplot2")

mpgman2 <- mpg %>%
group_by(manufacturer, year) %>%
mpgman2 <- mpg |>
group_by(manufacturer, year) |>
dplyr::summarise(
n = dplyr::n(),
displ = mean(displ)
displ = mean(displ),
.groups = "drop"
)

mpgman2
Expand All @@ -16,19 +17,17 @@ hchart(
colorKey = "displ",
# color = c("#FCA50A", "#FCFFA4"),
name = c("Year 1999", "Year 2008")
) %>%
) |>
hc_colorAxis(min = 0, max = 5)


# defaults to yAxis
hchart(iris, "point", hcaes(Sepal.Length, Sepal.Width)) %>%
hchart(iris, "point", hcaes(Sepal.Length, Sepal.Width)) |>
hc_colorAxis(
minColor = "red",
maxColor = "blue"
)



# Ex2
n <- 5

Expand All @@ -42,9 +41,9 @@ stops <- list_parse2(stops)

M <- round(matrix(rnorm(50*50), ncol = 50), 2)

hchart(M) %>%
hchart(M) |>
hc_colorAxis(stops = stops)

# Ex3
# hchart(volcano) %>%
# hc_colorAxis(stops = stops, max = 200)
hchart(volcano) |>
hc_colorAxis(stops = stops, max = 200)
8 changes: 4 additions & 4 deletions dev/examples-api/colors.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ library(viridisLite)
cols <- viridis(3)
cols <- substr(cols, 0, 7)

highchart() %>%
hc_add_series(data = sample(1:12)) %>%
hc_add_series(data = sample(1:12) + 10) %>%
hc_add_series(data = sample(1:12) + 20) %>%
highchart() |>
hc_add_series(data = sample(1:12)) |>
hc_add_series(data = sample(1:12) + 10) |>
hc_add_series(data = sample(1:12) + 20) |>
hc_colors(cols)
6 changes: 3 additions & 3 deletions dev/examples-api/credits.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
highchart() %>%
hc_xAxis(categories = citytemp$month) %>%
hc_add_series(name = "Tokyo", data = sample(1:12)) %>%
highchart() |>
hc_xAxis(categories = citytemp$month) |>
hc_add_series(name = "Tokyo", data = sample(1:12)) |>
hc_credits(
enabled = TRUE,
text = "htmlwidgets.org",
Expand Down
12 changes: 6 additions & 6 deletions dev/examples-api/drilldown.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ df <- tibble(

df

hc <- highchart() %>%
hc_title(text = "Basic drilldown") %>%
hc_xAxis(type = "category") %>%
hc_legend(enabled = FALSE) %>%
hc <- highchart() |>
hc_title(text = "Basic drilldown") |>
hc_xAxis(type = "category") |>
hc_legend(enabled = FALSE) |>
hc_plotOptions(
series = list(
boderWidth = 0,
dataLabels = list(enabled = TRUE)
)
) %>%
) |>
hc_add_series(
data = df,
type = "column",
Expand All @@ -43,7 +43,7 @@ dsan <- list_parse2(dfan)

dsfru <- list_parse2(dffru)

hc <- hc %>%
hc <- hc |>
hc_drilldown(
allowPointDrilldown = TRUE,
series = list(
Expand Down
6 changes: 3 additions & 3 deletions dev/examples-api/exporting.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
highchart() %>%
hc_xAxis(categories = month.abb) %>%
hc_add_series(name = "Tokyo", data = sample(1:12)) %>%
highchart() |>
hc_xAxis(categories = month.abb) |>
hc_add_series(name = "Tokyo", data = sample(1:12)) |>
hc_exporting(
enabled = TRUE, # always enabled
filename = "custom-file-name"
Expand Down
4 changes: 2 additions & 2 deletions dev/examples-api/labels.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
highchart() %>%
hc_add_series(data = sample(1:12)) %>%
highchart() |>
hc_add_series(data = sample(1:12)) |>
hc_labels(
items = list(
list(
Expand Down
10 changes: 5 additions & 5 deletions dev/examples-api/legend.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
highchart() %>%
hc_xAxis(categories = month.abb) %>%
hc_add_series(name = "Tokyo", data = sample(1:12)) %>%
hc_add_series(name = "London", data = sample(1:12) + 10) %>%
hc_add_series(name = "Other City", data = sample(1:12) + 20) %>%
highchart() |>
hc_xAxis(categories = month.abb) |>
hc_add_series(name = "Tokyo", data = sample(1:12)) |>
hc_add_series(name = "London", data = sample(1:12) + 10) |>
hc_add_series(name = "Other City", data = sample(1:12) + 20) |>
hc_legend(
align = "left",
verticalAlign = "top",
Expand Down
2 changes: 1 addition & 1 deletion dev/examples-api/loading.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
highcharts_demo() %>%
highcharts_demo() |>
hc_loading(
hideDuration = 1000,
showDuration = 1000
Expand Down
2 changes: 1 addition & 1 deletion dev/examples-api/mapNavigation.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
hcmap(download_map_data = FALSE) %>%
hcmap(download_map_data = FALSE) |>
hc_mapNavigation(
enabled = TRUE,
enableMouseWheelZoom = TRUE,
Expand Down
6 changes: 3 additions & 3 deletions dev/examples-api/navigator.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
highchart(type = "stock") %>%
hc_add_series(AirPassengers) %>%
hc_rangeSelector(selected = 4) %>%
highchart(type = "stock") |>
hc_add_series(AirPassengers) |>
hc_rangeSelector(selected = 4) |>
hc_navigator(
outlineColor = "gray",
outlineWidth = 2,
Expand Down
10 changes: 5 additions & 5 deletions dev/examples-api/pane.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
highchart() %>%
highchart() |>
hc_chart(
type = "gauge",
plotBackgroundColor = NULL,
plotBackgroundImage = NULL,
plotBorderWidth = 0,
plotShadow = FALSE
) %>%
) |>
hc_title(
text = "Speedometer"
) %>%
) |>
hc_pane(
startAngle = -150,
endAngle = 150,
Expand Down Expand Up @@ -40,10 +40,10 @@ highchart() %>%
outerRadius = "105%",
innerRadius = "103%"
))
) %>%
) |>
hc_add_series(
data = list(80), name = "speed", tooltip = list(valueSuffix = " km/h")
) %>%
) |>


hc_yAxis(
Expand Down
4 changes: 2 additions & 2 deletions dev/examples-api/plotOptions.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
highchart() %>%
highchart() |>
hc_add_series(
data = c(29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4)
) %>%
) |>
hc_plotOptions(
line = list(
color = "blue",
Expand Down
6 changes: 3 additions & 3 deletions dev/examples-api/rangeSelector.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
hc <- highchart(type = "stock") %>%
hc <- highchart(type = "stock") |>
hc_add_series(AirPassengers)

hc

hc %>%
hc |>
hc_rangeSelector(enabled = FALSE)

hc %>%
hc |>
hc_rangeSelector(
verticalAlign = "bottom",
selected = 4
Expand Down
4 changes: 2 additions & 2 deletions dev/examples-api/responsive.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ leg_900_opts <- list(align = "right", verticalAlign = "middle", layout = "verti


# change the with of the container/windows to see the effect
highchart() %>%
hc_add_series(data = cumsum(rnorm(100))) %>%
highchart() |>
hc_add_series(data = cumsum(rnorm(100))) |>
hc_responsive(
rules = list(
# remove legend if there is no much space
Expand Down
Loading

0 comments on commit dfb092b

Please sign in to comment.