Skip to content

Commit

Permalink
doc doc doc doc
Browse files Browse the repository at this point in the history
  • Loading branch information
jbkunst committed Jan 12, 2016
1 parent 4d8a681 commit 8849f56
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 58 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Expand Up @@ -10,6 +10,7 @@ export(hc_add_theme)
export(hc_chart)
export(hc_colorAxis)
export(hc_credits)
export(hc_exporting)
export(hc_get_colors)
export(hc_get_dash_styles)
export(hc_legend)
Expand Down
75 changes: 62 additions & 13 deletions R/api.R
Expand Up @@ -245,6 +245,21 @@ hc_plotOptions <- function(hc, ...) {

}

#' Adding credits options to highchart objects
#'
#' \code{highcarter} by default don't put credits label. You can add credits
#' using these options.
#'
#' @param hc A \code{highchart} \code{htmlwidget} object.
#' @param ... Arguments defined in \url{http://api.highcharts.com/highcharts#credits}.
#'
#' @export
hc_credits <- function(hc, ...) {

.hc_opt(hc, "credits", ...)

}

#' Adding Color Axis options to highchart objects
#'
#' Function to set the axis color to highcharts objects.
Expand All @@ -259,27 +274,61 @@ hc_colorAxis <- function(hc, ...) {

}

#' Adding credits options to highchart objects
#' Exporting options for higcharts objects
#'
#' \code{highcarter} by default don't put credits label. You can add credits
#' using these options.
#' Exporting options for higcharts objects. You can define the file's name
#' or the output format.
#'
#' @param hc A \code{highchart} \code{htmlwidget} object.
#' @param ... Arguments defined in \url{http://api.highcharts.com/highcharts#credits}.
#'
#' @param ... Arguments defined in \url{http://api.highcharts.com/highcharts#exporting}.
#'
#' @examples
#'
#' require("dplyr")
#'
#' data("citytemp")
#'
#' highchart() %>%
#' hc_xAxis(categories = citytemp$month) %>%
#' hc_add_serie(name = "Tokyo", data = citytemp$tokyo) %>%
#' hc_add_serie(name = "London", data = citytemp$london) %>%
#' hc_exporting(enabled = FALSE)
#'
#'
#' highchart() %>%
#' hc_xAxis(categories = citytemp$month) %>%
#' hc_add_serie(name = "Tokyo", data = citytemp$tokyo) %>%
#' hc_add_serie(name = "London", data = citytemp$london) %>%
#' hc_exporting(filename = "custom-file-name")
#'
#' @export
hc_credits <- function(hc, ...) {
hc_exporting <- function(hc, ...) {

.hc_opt(hc, "credits", ...)
.hc_opt(hc, "exporting", ...)

}

#' Adding series to highchart objects
#' Adding and removing series from highchart objects
#'
#' Arguments are defined in \url{http://api.highcharts.com/highcharts#chart}
#'
#' @param hc A \code{highchart} \code{htmlwidget} object.
#' @param ... Arguments defined in \url{http://api.highcharts.com/highcharts}.
#' @param ... Arguments defined in \url{http://api.highcharts.com/highcharts#chart}.
#'
#' @examples
#'
#' require("dplyr")
#'
#' data("citytemp")
#'
#' hc <- highchart() %>%
#' hc_xAxis(categories = citytemp$month) %>%
#' hc_add_serie(name = "Tokyo", data = citytemp$tokyo) %>%
#' hc_add_serie(name = "New York", data = citytemp$new_york)
#'
#' hc
#'
#' hc %>%
#' hc_add_serie(name = "London", data = citytemp$london, type = "area") %>%
#' hc_rm_serie(name = "New York")
#'
#' @export
hc_add_serie <- function(hc, ...) {
Expand All @@ -292,10 +341,10 @@ hc_add_serie <- function(hc, ...) {

#' Removing series to highchart objects
#'
#' Arguments are defined in \url{http://api.highcharts.com/highcharts#chart}
#'
#' @param hc A \code{highchart} \code{htmlwidget} object.
#' @param name The serie's name to delete.
#'
#' @rdname hc_add_serie
#'
#' @export
hc_rm_serie <- function(hc, name = NULL) {
Expand Down
3 changes: 2 additions & 1 deletion R/shortcuts.R
Expand Up @@ -271,7 +271,8 @@ hc_add_serie_labels_values <- function(hc, labels, values, colors = NULL, ...) {
#'
#' tm <- treemap(GNI2010, index = c("continent", "iso3"),
#' vSize = "population", vColor = "GNI",
#' type = "comp", palette = rev(viridis(6)))
#' type = "comp", palette = rev(viridis(6)),
#' draw = FALSE)
#'
#' highchart(height = 800) %>%
#' hc_add_serie_treemap(tm, allowDrillToNode = TRUE,
Expand Down
33 changes: 30 additions & 3 deletions man/hc_add_serie.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/hc_add_serie_treemap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions man/hc_exporting.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 0 additions & 17 deletions man/hc_rm_serie.Rd

This file was deleted.

53 changes: 30 additions & 23 deletions no_build/index.R
Expand Up @@ -237,25 +237,6 @@ hc

hc <- hc_chart(hc, type = "line", options3d = list(enabled = FALSE))

##' ## hc_title, hc_subtitle, hc_credits and hc_legend, hc_tooltip ####

#' Functions to modify the chart's main title, subtitle, credits, legend and tooltip.

hc %>%
hc_title(text = "This is a title with <i>margin</i> and <b>Strong or bold text</b>",
margin = 20, align = "left",
style = list(color = "#90ed7d", useHTML = TRUE)) %>%
hc_subtitle(text = "And this is a subtitle with more information",
align = "left",
style = list(color = "#2b908f", fontWeight = "bold")) %>%
hc_credits(enabled = TRUE,
text = "www.lonk.tomy.site",
href = "http://jkunst.com") %>%
hc_legend(align = "left", verticalAlign = "top",
layout = "vertical", x = 0, y = 100) %>%
hc_tooltip(crosshairs = TRUE, backgroundColor = "#FCFFC5",
shared = TRUE, borderWidth = 5)

##' ## hc_xAxis and hc_yAxis ####

#' This functions allow between other things:
Expand Down Expand Up @@ -283,13 +264,39 @@ hc %>%
list(from = 25, to = htmlwidgets::JS("Infinity"), color = "rgba(100, 0, 0, 0.1)",
label = list(text = "So hot here in the plotBand"))))

##' ## hc_plotOptions ####
##' ## hc_add_serie and hc_rm_serie ####

hc
hc <- highchart() %>%
hc_xAxis(categories = citytemp$month) %>%
hc_add_serie(name = "Tokyo", data = citytemp$tokyo) %>%
hc_add_serie(name = "New York", data = citytemp$new_york)

##' ## hc_add_serie and hc_rm_serie ####
hc

hc
hc %>%
hc_add_serie(name = "London", data = citytemp$london, type = "area") %>%
hc_rm_serie(name = "New York")


##' ## hc_title, hc_subtitle, hc_credits and hc_legend, hc_tooltip, hc_exporting ####

#' Functions to modify the chart's main title, subtitle, credits, legend and tooltip.

hc %>%
hc_title(text = "This is a title with <i>margin</i> and <b>Strong or bold text</b>",
margin = 20, align = "left",
style = list(color = "#90ed7d", useHTML = TRUE)) %>%
hc_subtitle(text = "And this is a subtitle with more information",
align = "left",
style = list(color = "#2b908f", fontWeight = "bold")) %>%
hc_credits(enabled = TRUE, # add credits
text = "www.lonk.tomy.site",
href = "http://jkunst.com") %>%
hc_legend(align = "left", verticalAlign = "top",
layout = "vertical", x = 0, y = 100) %>%
hc_tooltip(crosshairs = TRUE, backgroundColor = "#FCFFC5",
shared = TRUE, borderWidth = 5) %>%
hc_exporting(enabled = FALSE) # disable exporting option

##' # Shorcuts for add Data (data series) ####

Expand Down

0 comments on commit 8849f56

Please sign in to comment.