From 17d04f396fc498ddd2016fe27d7f80d4afd3a5bf Mon Sep 17 00:00:00 2001 From: Joshua Date: Thu, 25 Feb 2016 18:43:58 -0300 Subject: [PATCH] starting 0.2.0 release --- .Rbuildignore | 2 - DESCRIPTION | 4 +- NAMESPACE | 3 + NEWS.md | 29 +- R/api-hc-extras.R | 6 +- R/data-usgeojson.R | 13 + R/hchart.R | 36 +- R/shortcuts.R | 32 +- cran-comments.md | 10 +- data/usgeojson.rda | Bin 0 -> 13744 bytes man/hc_add_series_map.Rd | 29 ++ man/hc_add_series_treemap.Rd | 2 +- man/hc_defs.Rd | 2 +- man/usgeojson.Rd | 19 + no_build/data.R | 30 ++ no_build/get-issues.R | 22 + no_build/index.R | 104 ----- no_build/test-hchart.R | 5 + vignettes/replicating-highcharts-demos.Rmd | 520 ++++++++++----------- 19 files changed, 473 insertions(+), 395 deletions(-) create mode 100644 R/data-usgeojson.R create mode 100644 data/usgeojson.rda create mode 100644 man/usgeojson.Rd create mode 100644 no_build/get-issues.R diff --git a/.Rbuildignore b/.Rbuildignore index b3789fdb..740c5d1f 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -4,6 +4,4 @@ tests/ no_build/ ^\.travis\.yml$ -^NEWS$ -^NEWS\.md$ fort.6 diff --git a/DESCRIPTION b/DESCRIPTION index 986fa3c8..4d511579 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,12 +1,12 @@ Package: highcharter -Version: 0.1.0.9000 +Version: 0.2.0 Type: Package Title: A Wrapper for the 'Highcharts' Library Description: A wrapper for the 'Highcharts' library including shortcut functions to plot R objects. 'Highcharts' is a charting library offering numerous chart types with a simple configuration syntax. -Date: 2016-01-12 +Date: 2016-02-25 Author: Joshua Kunst Maintainer: Joshua Kunst License: MIT + file LICENSE diff --git a/NAMESPACE b/NAMESPACE index 1feb9349..7d2db12c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -96,6 +96,7 @@ importFrom(dplyr,select) importFrom(dplyr,select_) importFrom(dplyr,tbl_df) importFrom(grDevices,colorRampPalette) +importFrom(graphics,hist) importFrom(htmlwidgets,JS) importFrom(htmlwidgets,createWidget) importFrom(htmlwidgets,shinyRenderWidget) @@ -110,6 +111,7 @@ importFrom(rlist,list.merge) importFrom(rlist,list.parse) importFrom(stats,ecdf) importFrom(stats,is.ts) +importFrom(stats,qnorm) importFrom(stats,time) importFrom(stringr,str_extract) importFrom(stringr,str_replace) @@ -117,6 +119,7 @@ importFrom(stringr,str_replace_all) importFrom(stringr,str_to_lower) importFrom(stringr,str_trim) importFrom(tidyr,gather) +importFrom(utils,tail) importFrom(viridisLite,viridis) importFrom(xts,is.xts) importFrom(zoo,as.Date) diff --git a/NEWS.md b/NEWS.md index e333eb99..374b0dac 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,31 @@ -# highcharter 0.1 +# highcharter 0.2.0 + +* Implemenation of highcharts with boost module `highchart2()` (#43). +This include highcharts.js, exporting.js and boost-module.js. + +* Highstock implementation/support (#10) + +* Highmaps implementation/support (#25) + +* Adding themes (#35): 538, economis, dotabuff, google, theme null (#19) + +* Plugins: Add font awesome integration (#45), fill-pattern (#31), +draggable-points (#28) + +* New `hchart` function. Generic function to chart acf, forecast, +ts, stl, xts, ohcl objects (#2) (#27) + +* In highmaps prevent scrolling when cursor is over the map (#38) + +* Import rex-export %>% (#15) + +* Heigth scale in the container in rstudio IDE (#14) + +* Avoid duplicate css calls (#6) + +* Add uscountygeojson, usgeojson, worldgeojson, unemployment data + +# highcharter 0.1.0 * Data: city temp. favorite bars, favorite pies. diff --git a/R/api-hc-extras.R b/R/api-hc-extras.R index b7e4b56f..6bd2f371 100644 --- a/R/api-hc-extras.R +++ b/R/api-hc-extras.R @@ -216,7 +216,7 @@ hc_mapNavigation <- function(hc, ...) { #' #' #' @param hc A \code{highchart} \code{htmlwidget} object. -#' @param ... Arguments defined in \url{https://github.com/highcharts/pattern-fillhc}. +#' @param ... Arguments defined in \url{http://www.highcharts.com/plugin-registry/single/9/Pattern-Fill}. #' #' @export hc_defs <- function(hc, ...) { @@ -234,5 +234,7 @@ hc_defs <- function(hc, ...) { #' #' @export hc_annotations <- function(hc, ...) { - highcharter:::.hc_opt(hc, "annotations", ...) + + .hc_opt(hc, "annotations", ...) + } diff --git a/R/data-usgeojson.R b/R/data-usgeojson.R new file mode 100644 index 00000000..119a4c5a --- /dev/null +++ b/R/data-usgeojson.R @@ -0,0 +1,13 @@ +#' US States map in Geojson format (list) +#' +#' This data comes from the \url{https://code.highcharts.com/mapdata/countries/us/us-all.js} +#' and is used in highmaps examples. +#' +#' @docType data +#' @name usgeojson +#' @usage usgeojson +#' @format A \code{list} in geojson format. +#' @examples +#' data(usgeojson) +#' usgeojson +NULL diff --git a/R/hchart.R b/R/hchart.R index 7b469833..342ee6b1 100644 --- a/R/hchart.R +++ b/R/hchart.R @@ -23,6 +23,7 @@ hchart.default <- function(object, ...) { " are not supported by hchart (yet).", call. = FALSE) } +#' @importFrom graphics hist #' @export hchart.numeric <- function(object, breaks = "FD", ...) { @@ -109,6 +110,7 @@ hchart.forecast <- function(object, fillOpacity = 0.3, ...){ } +#' @importFrom stats qnorm #' @export hchart.acf <- function(object, ...){ @@ -161,7 +163,7 @@ hchart.mts <- function(object, ...) { } #' @export -hchart.stl <- function(object, widths = c(2, 1, 1, 1), sep = 0.01) { +hchart.stl <- function(object, ..., widths = c(2, 1, 1, 1), sep = 0.01) { tss <- object$time.series ncomp <- ncol(tss) @@ -205,6 +207,8 @@ hchart.dist <- function(object, ...) { df <- as.data.frame(as.matrix(object), stringsAsFactors = FALSE) + dist <- NULL + x <- y <- names(df) df <- tbl_df(cbind(x = y, df)) %>% @@ -238,27 +242,29 @@ hchart.dist <- function(object, ...) { hc_colorAxis(arg = "") } -# #' @importFrom seasonal original final trend outlier -# #' @export -# hchart.seas <- function(object, outliers = TRUE, trend = FALSE, ...) { -# -# hc <- highchart() %>% -# hc_add_serie_ts(original(object), name = "original", zIndex = 3, id = "original") %>% -# hc_add_serie_ts(final(object), name = "adjusted", zIndex = 2, id = "adjusted") -# +# # @export +# hchart.seas <- function(object, ..., outliers = TRUE, trend = FALSE) { +# +# hc <- highchart() %>% +# hc_add_serie_ts(seasonal::original(object), +# name = "original", +# zIndex = 3, id = "original") %>% +# hc_add_serie_ts(seasonal::final(object), +# name = "adjusted", +# zIndex = 2, id = "adjusted") +# # if (trend) { -# hc <- hc %>% hc_add_serie_ts(trend(object), name = "trend", zIndex = 1) +# hc <- hc %>% hc_add_serie_ts(seasonal::trend(object), name = "trend", zIndex = 1) # } -# +# # if (outliers) { -# ol.ts <- outlier(object) +# ol.ts <- seasonal::outlier(object) # ixd.nna <- !is.na(ol.ts) # text <- as.character(ol.ts)[!is.na(ol.ts)] # dates <- zoo::as.Date(time(ol.ts))[!is.na(ol.ts)] # hc <- hc %>% hc_add_series_flags(dates, text, text, zIndex = 4, -# name = "outiliers", id = "adjusted") +# name = "outiliers", id = "adjusted") # } -# +# # hc -# # } diff --git a/R/shortcuts.R b/R/shortcuts.R index 1d324b85..92722d0d 100644 --- a/R/shortcuts.R +++ b/R/shortcuts.R @@ -174,7 +174,7 @@ hc_add_serie_labels_values <- hc_add_series_labels_values #' (\url{http://api.highcharts.com/highcharts#series}). #' #' @examples -#' +#' #' \dontrun{ #' #' library("treemap") @@ -269,6 +269,33 @@ hc_add_serie_treemap <- hc_add_series_treemap #' #' @examples #' +#' library("dplyr") +#' library("viridisLite") +#' +#' data("USArrests", package = "datasets") +#' data("usgeojson") +#' +#' USArrests <- USArrests %>% +#' mutate(state = rownames(.)) +#' +#' n <- 4 +#' colstops <- data.frame(q = 0:n/n, +#' c = substring(viridis(n + 1, option = "A"), 0, 7)) %>% +#' list.parse2() +#' +#' highchart() %>% +#' hc_title(text = "Violent Crime Rates by US State") %>% +#' hc_subtitle(text = "Source: USArrests data") %>% +#' hc_add_series_map(usgeojson, USArrests, name = "Murder arrests (per 100,000)", +#' value = "Murder", joinBy = c("woename", "state"), +#' dataLabels = list(enabled = TRUE, +#' format = '{point.properties.postalcode}')) %>% +#' hc_colorAxis(stops = colstops) %>% +#' hc_legend(valueDecimals = 0, valueSuffix = "%") %>% +#' hc_mapNavigation(enabled = TRUE) +#' +#' \dontrun{ +#' #' library("viridisLite") #' library("dplyr") #' data(unemployment) @@ -289,6 +316,9 @@ hc_add_serie_treemap <- hc_add_series_treemap #' valueSuffix = "%") %>% #' hc_mapNavigation(enabled = TRUE) #' +#' } +#' +#' @importFrom utils tail #' @export hc_add_series_map <- function(hc, map, df, value, joinBy, ...) { diff --git a/cran-comments.md b/cran-comments.md index 1df814c5..ba0066d8 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,9 +1,7 @@ -## Resubmission +## Resubmitting new version 0.2.0 -This is a resubmission. In this version I fix/have: +Adding imports: hist, qnomr, tail -* More dateiled descriptions in manual pages. -* Adding examples for every exported function (whithout \dontrun). -* Adding "<>" to link highcharts.com in the description. +Modify examples which take too long -Thanks. Regards, +thanks a lot again! diff --git a/data/usgeojson.rda b/data/usgeojson.rda new file mode 100644 index 0000000000000000000000000000000000000000..2558eb28d2b939e0fa3ab7fe0493e4c3211a9d6b GIT binary patch literal 13744 zcmV;hHBZX@H+ooF0004LBHlIv03iV!0000G&sfajS>iQwT>vQ&2UJ%gRpOV<( z8GtbNUF2l<+B;F?T=IUnlgmr9eQ~L-BYncR8kj|%a@}`xm*_=hbFu2xbmd?CeXc1+ z9(X8+Y(ae9XFK74D@r6u+~>HP=Vw=PXL0g{rWlpnd!Ym4SVKFJMDY zF0qIuE(#!l87VMBs;8)At^LKz9C{9Fd)2`Ethb-7M}i$uFT;#P4vW?B5hMn5?Bo93 zo@RQb?T28KG~J1X!5P}A0ELKm)iq4)XrS{iMWcw|KdGKJOe(9~Yrf9YmIWdi`JA|O z2nZm;q3KVuD_l+?5aqoJ1y%xNaGV}djk-e{AfWuP>*?y!V%BsSNx$|nkKGGEFc5r2 zt^Y!JL`qH^oYei6%Q^Xr;fS$2#rPeUYFM(<-@LK*9y1u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x3?*8>jwDr9x@uM>HHHb-sP@m|7D{QzHhm18 z^H-N6c&4DrIi@tx<(8Xrn=Bf@etWgjeo0f>mkM85@C>BYaY~LjK3BHFo^vFZ)DZ_U zf$Z*bLXH(r(31vli%^VJ0&|<5`rea4!HcF};=5wM%B;TJ0Du)m{|ca%PcEPoi1HS# zTTP-1r~%rJ0LS=iSzjndBuHMBPmk%=HLL@#@REAsF0qUh&S^1*Ti)lTkpAavx-$WD zj~+p&*dXsVwa<+yXQG^j6|tI;uYF(H3@XbzDc*sQXOc$5?eGcmYPkoQ*Dg&3&A(mE zQjSnC3PZlh_6ObIsC$nT)_BB~a@P&rJ<)E-Zx_&tDzUFL@XLD>FX<_`z~=J(lC7tf zAhI~|G<#mZMXYBKMV&Mi4`z2wNgt0p6{f zS~r>i^KM?FJ*dMT@RP!TIo1mv+Kl-t=H@lw=t)6WV|jENY{7tyK7+HjKmY*5>*&b< a0gG$nvk3r9W6+B}Fb#_W000000a;phDv#U% literal 0 HcmV?d00001 diff --git a/man/hc_add_series_map.Rd b/man/hc_add_series_map.Rd index 8be33139..0130e3a9 100644 --- a/man/hc_add_series_map.Rd +++ b/man/hc_add_series_map.Rd @@ -30,6 +30,33 @@ from the package \code{treemap}. } \examples{ +library("dplyr") +library("viridisLite") + +data("USArrests", package = "datasets") +data("usgeojson") + +USArrests <- USArrests \%>\% + mutate(state = rownames(.)) + +n <- 4 +colstops <- data.frame(q = 0:n/n, + c = substring(viridis(n + 1, option = "A"), 0, 7)) \%>\% +list.parse2() + +highchart() \%>\% + hc_title(text = "Violent Crime Rates by US State") \%>\% + hc_subtitle(text = "Source: USArrests data") \%>\% + hc_add_series_map(usgeojson, USArrests, name = "Murder arrests (per 100,000)", + value = "Murder", joinBy = c("woename", "state"), + dataLabels = list(enabled = TRUE, + format = '{point.properties.postalcode}')) \%>\% + hc_colorAxis(stops = colstops) \%>\% + hc_legend(valueDecimals = 0, valueSuffix = "\%") \%>\% + hc_mapNavigation(enabled = TRUE) + +\dontrun{ + library("viridisLite") library("dplyr") data(unemployment) @@ -50,4 +77,6 @@ highchart() \%>\% hc_mapNavigation(enabled = TRUE) } + +} diff --git a/man/hc_add_series_treemap.Rd b/man/hc_add_series_treemap.Rd index 5489b9a3..8b85e0e7 100644 --- a/man/hc_add_series_treemap.Rd +++ b/man/hc_add_series_treemap.Rd @@ -22,7 +22,7 @@ This function helps to create higcharts treemaps from \code{treemap} objects from the package \code{treemap}. } \examples{ - + \dontrun{ library("treemap") diff --git a/man/hc_defs.Rd b/man/hc_defs.Rd index fdc84e61..6617049e 100644 --- a/man/hc_defs.Rd +++ b/man/hc_defs.Rd @@ -9,7 +9,7 @@ hc_defs(hc, ...) \arguments{ \item{hc}{A \code{highchart} \code{htmlwidget} object.} -\item{...}{Arguments defined in \url{https://github.com/highcharts/pattern-fillhc}.} +\item{...}{Arguments defined in \url{http://www.highcharts.com/plugin-registry/single/9/Pattern-Fill}.} } \description{ Helper function to use the fill patter plugin http://www.highcharts.com/plugin-registry/single/9/Pattern-Fill. diff --git a/man/usgeojson.Rd b/man/usgeojson.Rd new file mode 100644 index 00000000..7535d16e --- /dev/null +++ b/man/usgeojson.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data-usgeojson.R +\docType{data} +\name{usgeojson} +\alias{usgeojson} +\title{US States map in Geojson format (list)} +\format{A \code{list} in geojson format.} +\usage{ +usgeojson +} +\description{ +This data comes from the \url{https://code.highcharts.com/mapdata/countries/us/us-all.js} +and is used in highmaps examples. +} +\examples{ +data(usgeojson) +usgeojson +} + diff --git a/no_build/data.R b/no_build/data.R index c84e8da4..29848e2d 100644 --- a/no_build/data.R +++ b/no_build/data.R @@ -91,6 +91,36 @@ counties save(uscountygeojson, file = "data/uscountygeojson.rda", compress = "xz") +#### usgeojson all all #### +url <- "https://code.highcharts.com/mapdata/countries/us/us-all.js" +tmpfile <- tempfile(fileext = ".json") +download.file(url, tmpfile) +usgeojson <- readLines(tmpfile) +usgeojson <- gsub(".* = ", "", usgeojson) +usgeojson <- jsonlite::fromJSON(usgeojson, simplifyVector = FALSE) + +usgeojson$features[52] <- NULL + +usgeojson$features <- map(usgeojson$features, function(x){ + # x <- uscountygeojson$features[[10]] + x$properties$code <- x$properties$`hc-key` + x$properties <- x$properties[!grepl("hc", names(x$properties))] + names(x$properties) <- gsub("-", "", names(x$properties)) + names(x$properties) <- gsub("isoa", "iso", names(x$properties)) + x$properties$name <- ifelse(x$properties$code == "us-nm-013", "Dona Ana", x$properties$name) + x +}) + +states <- map_df(usgeojson$features, function(x){ + as.data.frame(x$properties, stringsAsFactors = FALSE) +}) + +states + +save(usgeojson, file = "data/usgeojson.rda", compress = "xz") + + + #### fontawesome #### library("stringr") library("dplyr") diff --git a/no_build/get-issues.R b/no_build/get-issues.R new file mode 100644 index 00000000..6b8a134e --- /dev/null +++ b/no_build/get-issues.R @@ -0,0 +1,22 @@ +rm(list = ls()) +library("dplyr") +library("purrr") +library("httr") + +issues <- GET("https://api.github.com/repos/jbkunst/highcharter/issues", + query = list(state = "closed", milestone = 1)) %>% + content() + +names(issues) + +jsonview::json_tree_view(issues) + +dfissues <- map_df(issues, function(x){ + data_frame( + x$title, + x$number, + substr(x$body, 0, 100) + ) +}) + +dfissues diff --git a/no_build/index.R b/no_build/index.R index de6071d1..906ae312 100644 --- a/no_build/index.R +++ b/no_build/index.R @@ -8,110 +8,6 @@ #' toc: yes #' --- -#' -#+ echo=FALSE -## Styles page #### -#' -#' -#' -#' -#' Back to Top -#' -#' [![travis-status](https://api.travis-ci.org/jbkunst/highcharter.svg)](https://travis-ci.org/jbkunst/highcharter) -#' [![codecov.io](https://codecov.io/github/jbkunst/highcharter/coverage.svg?branch=master)](https://codecov.io/github/jbkunst/highcharter?branch=master) -#' [![version](http://www.r-pkg.org/badges/version/highcharter)](http://www.r-pkg.org/pkg/highcharter) -#' [![downloads](http://cranlogs.r-pkg.org/badges/highcharter)](http://www.r-pkg.org/pkg/highcharter) - #+ echo=FALSE options(digits = 3, knitr.table.format = "markdown") library("printr") diff --git a/no_build/test-hchart.R b/no_build/test-hchart.R index 9aaebabb..1bd61126 100644 --- a/no_build/test-hchart.R +++ b/no_build/test-hchart.R @@ -37,6 +37,11 @@ class(x) plot(x) hchart(x) +#' ### lst +x <- stl(co2, "per") +plot(x) +hchart(x) + #' ### xts quantmod package library("quantmod") x <- getSymbols("USD/JPY", src = "oanda", auto.assign = FALSE) diff --git a/vignettes/replicating-highcharts-demos.Rmd b/vignettes/replicating-highcharts-demos.Rmd index dc038b9d..9e2ce1c3 100644 --- a/vignettes/replicating-highcharts-demos.Rmd +++ b/vignettes/replicating-highcharts-demos.Rmd @@ -1,260 +1,260 @@ ---- -title: "Replicating Highcharts Demos" -author: "Joshua Kunst" -output: rmarkdown::html_vignette -vignette: > - %\VignetteIndexEntry{Vignette Title} - %\VignetteEngine{knitr::rmarkdown} - %\VignetteEncoding{UTF-8} ---- - -Let's replicate the [line-lables](http://www.highcharts.com/demo/line-labels) demo. If you click -*View Options* button you'll see the code to create that chart in a html file via javascript. Let's -take a look to the options which are: - -``` -{ - chart: { - type: 'line' - }, - title: { - text: 'Monthly Average Temperature' - }, - subtitle: { - text: 'Source: WorldClimate.com' - }, - xAxis: { - categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] - }, - yAxis: { - title: { - text: 'Temperature (C)' - } - }, - plotOptions: { - line: { - dataLabels: { - enabled: true - }, - enableMouseTracking: false - } - }, - series: [{ - name: 'Tokyo', - data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6] - }, { - name: 'London', - data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8] - }] -} -``` - -The previous code is a javascript object. It's like a dictionary, or if we want we can say is like a named -list. `highcharter` have the implementation of each option in highcharts like `chart`, `title`, etc. With -each of them you can add the requiered parameters to get the chart what you want. First of all we need -to create the `highchart` object and then add very option what we want. - -```{r} -library("highcharter") - -highchart() %>% - hc_chart(type = "line") %>% - hc_title(text = "Monthly Average Temperature") %>% - hc_subtitle(text = "Source: WorldClimate.com") %>% - hc_xAxis(categories = c('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', - 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')) %>% - hc_yAxis(title = list(text = "Temperature (C)")) %>% - hc_plotOptions(line = list( - dataLabels = list(enabled = TRUE), - enableMouseTracking = FALSE) - ) %>% - hc_series( - list( - name = "Tokyo", - data = c(7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6) - ), - list( - name = "London", - data = c(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8) - ) - ) -``` - -Now, let's try other example: [area stacked percent](http://www.highcharts.com/demo/area-stacked-percent). The -options used are: - -``` -{ - chart: { - type: 'area' - }, - title: { - text: 'Historic and Estimated Worldwide Population Distribution by Region' - }, - subtitle: { - text: 'Source: Wikipedia.org' - }, - xAxis: { - categories: ['1750', '1800', '1850', '1900', '1950', '1999', '2050'], - tickmarkPlacement: 'on', - title: { - enabled: false - } - }, - yAxis: { - title: { - text: 'Percent' - } - }, - tooltip: { - pointFormat: '{series.name}: - {point.percentage:.1f}% ({point.y:,.0f} millions)
', - shared: true - }, - plotOptions: { - area: { - stacking: 'percent', - lineColor: '#ffffff', - lineWidth: 1, - marker: { - lineWidth: 1, - lineColor: '#ffffff' - } - } - }, - series: [{ - name: 'Asia', - data: [502, 635, 809, 947, 1402, 3634, 5268] - }, { - name: 'Africa', - data: [106, 107, 111, 133, 221, 767, 1766] - }, { - name: 'Europe', - data: [163, 203, 276, 408, 547, 729, 628] - }, { - name: 'America', - data: [18, 31, 54, 156, 339, 818, 1201] - }, { - name: 'Oceania', - data: [2, 2, 2, 6, 13, 30, 46] - }] -} -``` - -In this example we'll use the `hc_add_series()` to add every series one by one. - -```{r} -hc <- highchart() %>% - hc_chart(type = "area") %>% - hc_title(text = "Historic and Estimated Worldwide Population Distribution by Region") %>% - hc_subtitle(text = "Source: Wikipedia.org") %>% - hc_xAxis(categories = c('1750', '1800', '1850', '1900', '1950', '1999', '2050'), - tickmarkPlacement = 'on', - title = list(enabled = FALSE)) %>% - hc_yAxis(title = list(text = "Percent")) %>% - hc_tooltip(pointFormat = '{series.name}: - {point.percentage:.1f}% ({point.y:,.0f} millions)
', - shared = TRUE) %>% - hc_plotOptions(area = list( - stacking = "percent", - lineColor = "#ffffff", - lineWidth = 1, - marker = list( - lineWidth = 1, - lineColor = "#ffffff" - )) - ) %>% - hc_add_series(name = "Asia", data = c(502, 635, 809, 947, 1402, 3634, 5268)) %>% - hc_add_series(name = "Africa", data = c(106, 107, 111, 133, 221, 767, 1766)) %>% - hc_add_series(name = "Europe", data = c(163, 203, 276, 408, 547, 729, 628)) %>% - hc_add_series(name = "America", data = c(18, 31, 54, 156, 339, 818, 1201)) %>% - hc_add_series(name = "Oceania", data = c(2, 2, 2, 6, 13, 30, 46)) - -hc - -``` - -A third and slightly more complicated example is the [spiderweb](http://www.highcharts.com/demo/polar-spider) chart. - -``` -{ - chart: { - polar: true, - type: 'line' - }, - title: { - text: 'Budget vs spending', - x: -80 - }, - pane: { - size: '80%' - }, - xAxis: { - categories: ['Sales', 'Marketing', 'Development', 'Customer Support', 'Information Technology', 'Administration'], - tickmarkPlacement: 'on', - lineWidth: 0 - }, - yAxis: { - gridLineInterpolation: 'polygon', - lineWidth: 0, - min: 0 - }, - tooltip: { - shared: true, - pointFormat: '{series.name}: ${point.y:,.0f}
' - }, - legend: { - align: 'right', - verticalAlign: 'top', - y: 70, - layout: 'vertical' - }, - series: [{ - name: 'Allocated Budget', - data: [43000, 19000, 60000, 35000, 17000, 10000], - pointPlacement: 'on' - }, { - name: 'Actual Spending', - data: [50000, 39000, 42000, 31000, 26000, 14000], - pointPlacement: 'on' - }] -} -``` - -Here's the code for the `highchart` object: - -```{r} -highchart() %>% - hc_chart(polar = TRUE, type = "line") %>% - hc_title(text = "Budget vs Spending") %>% - hc_xAxis(categories = c('Sales', 'Marketing', 'Development', 'Customer Support', - 'Information Technology', 'Administration'), - tickmarkPlacement = 'on', - lineWidth = 0) %>% - hc_yAxis(gridLineInterpolation = 'polygon', - lineWidth = 0, - min = 0) %>% - hc_series( - list( - name = "Allocated Budget", - data = c(43000, 19000, 60000, 35000, 17000, 10000), - pointPlacement = 'on' - ), - list( - name = "Actual Spending", - data = c(50000, 39000, 42000, 31000, 26000, 14000), - pointPlacement = 'on' - ) - ) -``` - - -If you don't get what you hope to get you must check if you passed all the arguments correctly. -You can compare the javascript object with: - -```{r} -library("jsonlite") - -toJSON(hc$x$hc_opts, pretty = TRUE, auto_unbox = TRUE) -``` - +--- +title: "Replicating Highcharts Demos" +author: "Joshua Kunst" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Replicating Highcharts Demos} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +Let's replicate the [line-lables](http://www.highcharts.com/demo/line-labels) demo. If you click +*View Options* button you'll see the code to create that chart in a html file via javascript. Let's +take a look to the options which are: + +``` +{ + chart: { + type: 'line' + }, + title: { + text: 'Monthly Average Temperature' + }, + subtitle: { + text: 'Source: WorldClimate.com' + }, + xAxis: { + categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] + }, + yAxis: { + title: { + text: 'Temperature (C)' + } + }, + plotOptions: { + line: { + dataLabels: { + enabled: true + }, + enableMouseTracking: false + } + }, + series: [{ + name: 'Tokyo', + data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6] + }, { + name: 'London', + data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8] + }] +} +``` + +The previous code is a javascript object. It's like a dictionary, or if we want we can say is like a named +list. `highcharter` have the implementation of each option in highcharts like `chart`, `title`, etc. With +each of them you can add the requiered parameters to get the chart what you want. First of all we need +to create the `highchart` object and then add very option what we want. + +```{r} +library("highcharter") + +highchart() %>% + hc_chart(type = "line") %>% + hc_title(text = "Monthly Average Temperature") %>% + hc_subtitle(text = "Source: WorldClimate.com") %>% + hc_xAxis(categories = c('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', + 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')) %>% + hc_yAxis(title = list(text = "Temperature (C)")) %>% + hc_plotOptions(line = list( + dataLabels = list(enabled = TRUE), + enableMouseTracking = FALSE) + ) %>% + hc_series( + list( + name = "Tokyo", + data = c(7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6) + ), + list( + name = "London", + data = c(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8) + ) + ) +``` + +Now, let's try other example: [area stacked percent](http://www.highcharts.com/demo/area-stacked-percent). The +options used are: + +``` +{ + chart: { + type: 'area' + }, + title: { + text: 'Historic and Estimated Worldwide Population Distribution by Region' + }, + subtitle: { + text: 'Source: Wikipedia.org' + }, + xAxis: { + categories: ['1750', '1800', '1850', '1900', '1950', '1999', '2050'], + tickmarkPlacement: 'on', + title: { + enabled: false + } + }, + yAxis: { + title: { + text: 'Percent' + } + }, + tooltip: { + pointFormat: '{series.name}: + {point.percentage:.1f}% ({point.y:,.0f} millions)
', + shared: true + }, + plotOptions: { + area: { + stacking: 'percent', + lineColor: '#ffffff', + lineWidth: 1, + marker: { + lineWidth: 1, + lineColor: '#ffffff' + } + } + }, + series: [{ + name: 'Asia', + data: [502, 635, 809, 947, 1402, 3634, 5268] + }, { + name: 'Africa', + data: [106, 107, 111, 133, 221, 767, 1766] + }, { + name: 'Europe', + data: [163, 203, 276, 408, 547, 729, 628] + }, { + name: 'America', + data: [18, 31, 54, 156, 339, 818, 1201] + }, { + name: 'Oceania', + data: [2, 2, 2, 6, 13, 30, 46] + }] +} +``` + +In this example we'll use the `hc_add_series()` to add every series one by one. + +```{r} +hc <- highchart() %>% + hc_chart(type = "area") %>% + hc_title(text = "Historic and Estimated Worldwide Population Distribution by Region") %>% + hc_subtitle(text = "Source: Wikipedia.org") %>% + hc_xAxis(categories = c('1750', '1800', '1850', '1900', '1950', '1999', '2050'), + tickmarkPlacement = 'on', + title = list(enabled = FALSE)) %>% + hc_yAxis(title = list(text = "Percent")) %>% + hc_tooltip(pointFormat = '{series.name}: + {point.percentage:.1f}% ({point.y:,.0f} millions)
', + shared = TRUE) %>% + hc_plotOptions(area = list( + stacking = "percent", + lineColor = "#ffffff", + lineWidth = 1, + marker = list( + lineWidth = 1, + lineColor = "#ffffff" + )) + ) %>% + hc_add_series(name = "Asia", data = c(502, 635, 809, 947, 1402, 3634, 5268)) %>% + hc_add_series(name = "Africa", data = c(106, 107, 111, 133, 221, 767, 1766)) %>% + hc_add_series(name = "Europe", data = c(163, 203, 276, 408, 547, 729, 628)) %>% + hc_add_series(name = "America", data = c(18, 31, 54, 156, 339, 818, 1201)) %>% + hc_add_series(name = "Oceania", data = c(2, 2, 2, 6, 13, 30, 46)) + +hc + +``` + +A third and slightly more complicated example is the [spiderweb](http://www.highcharts.com/demo/polar-spider) chart. + +``` +{ + chart: { + polar: true, + type: 'line' + }, + title: { + text: 'Budget vs spending', + x: -80 + }, + pane: { + size: '80%' + }, + xAxis: { + categories: ['Sales', 'Marketing', 'Development', 'Customer Support', 'Information Technology', 'Administration'], + tickmarkPlacement: 'on', + lineWidth: 0 + }, + yAxis: { + gridLineInterpolation: 'polygon', + lineWidth: 0, + min: 0 + }, + tooltip: { + shared: true, + pointFormat: '{series.name}: ${point.y:,.0f}
' + }, + legend: { + align: 'right', + verticalAlign: 'top', + y: 70, + layout: 'vertical' + }, + series: [{ + name: 'Allocated Budget', + data: [43000, 19000, 60000, 35000, 17000, 10000], + pointPlacement: 'on' + }, { + name: 'Actual Spending', + data: [50000, 39000, 42000, 31000, 26000, 14000], + pointPlacement: 'on' + }] +} +``` + +Here's the code for the `highchart` object: + +```{r} +highchart() %>% + hc_chart(polar = TRUE, type = "line") %>% + hc_title(text = "Budget vs Spending") %>% + hc_xAxis(categories = c('Sales', 'Marketing', 'Development', 'Customer Support', + 'Information Technology', 'Administration'), + tickmarkPlacement = 'on', + lineWidth = 0) %>% + hc_yAxis(gridLineInterpolation = 'polygon', + lineWidth = 0, + min = 0) %>% + hc_series( + list( + name = "Allocated Budget", + data = c(43000, 19000, 60000, 35000, 17000, 10000), + pointPlacement = 'on' + ), + list( + name = "Actual Spending", + data = c(50000, 39000, 42000, 31000, 26000, 14000), + pointPlacement = 'on' + ) + ) +``` + + +If you don't get what you hope to get you must check if you passed all the arguments correctly. +You can compare the javascript object with: + +```{r} +library("jsonlite") + +toJSON(hc$x$hc_opts, pretty = TRUE, auto_unbox = TRUE) +``` +