Skip to content

Commit

Permalink
adding citytemp data and index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
jbkunst committed Dec 17, 2015
1 parent a0dede8 commit a8acf82
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 15 deletions.
24 changes: 24 additions & 0 deletions R/data-citytemp.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#' City temperatures from a year
#'
#' This data comes from the \url{http://www.highcharts.com/} examples.
#'
#' @section Variables:
#'
#' \itemize{
#'
#' \item \code{month}: The months.
#' \item \code{tokyo}: Tokyo's temperatures.
#' \item \code{new_york}: New york's temperatures.
#' \item \code{berlin}: Berlin's temperatures.
#' \item \code{london}: Londo's temperatures.
#'
#' }
#'
#' @docType data
#' @name citytemp
#' @usage citytemp
#' @format A \code{data frame} with 12 observations and 5 variables.
#' @examples
#' data(citytemp)
#' citytemp
NULL
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ We know there exist:
- https://github.com/jcizel/highchartR
- https://github.com/metagraf/rHighcharts

Anyway, I want to try to get all the HC API funcionalities in this package. That is: Every chart in http://www.highcharts.com/demo you can do it in R (may be there will be some exceptions like [this](http://www.highcharts.com/demo/combo-timeline)).
Anyway, I want to try to:

Basically is write the json parameter in via R and get similar funcionalities that exists in https://github.com/hrbrmstr/metricsgraphics
- Get all the HC API funcionalities in this package. That is: Every chart in http://www.highcharts.com/demo you can do it in R (may be there will be some exceptions like [this](http://www.highcharts.com/demo/combo-timeline)).
- Get similar funcionalities that exists in [metricsgraphics](https://github.com/hrbrmstr/metricsgraphics) and [dygraphs](http://rstudio.github.io/dygraphs/) using [magrittr](https://cran.r-project.org/web/packages/magrittr/vignettes/magrittr.html)

## WIP

Expand Down
Binary file added data/citytemp.rda
Binary file not shown.
31 changes: 31 additions & 0 deletions man/citytemp.Rd

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

9 changes: 9 additions & 0 deletions no_build/data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
library("dplyr")
citytemp <- data_frame(
month = month.abb,
tokyo = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6),
new_york = c(-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5),
berlin = c(-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0),
london = 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))

save(citytemp, file = "data/citytemp.rda")
120 changes: 107 additions & 13 deletions no_build/index.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
#' </script>
#' <style>
#' h1, h2, h3, h4, .TOC > li {
#' color: #1A237E;
#' color: #1FA67A;
#' }
#'
#' a {
#' color: #1A237E;
#' color: #1FA67A;
#' }
#'
#' .level2 {
Expand All @@ -51,7 +51,7 @@
#' right: 0px;
#' text-decoration: none;
#' color : white;
#' background-color : #1A237E;
#' background-color : #1FA67A;
#' font-size: 12px;
#' padding: 1em;
#' display: none;
Expand Down Expand Up @@ -88,7 +88,9 @@ knitr::opts_chunk$set(collapse = TRUE, warning = FALSE)
#'
#' This is just another wrapper for [highcharts](www.higcharts.com) javascript library for R.
#' The mainly motivation to this packages is get a the all the power from HCs API *with no
#' restrictions*.
#' restrictions* and write the plots using the pipe operator just like
#' [metricsgraphics](https://github.com/hrbrmstr/metricsgraphics) and
#' [dygraphs](http://rstudio.github.io/dygraphs/).
#'
#' Highcharts is very mature javascript charting library and it has a great and powerful API
#' to get a very style of charts and highly customized (see http://www.highcharts.com/demo).
Expand All @@ -98,12 +100,14 @@ knitr::opts_chunk$set(collapse = TRUE, warning = FALSE)
#' you can create your chart manually with all the requiriments what you need. That's the
#' package offer.
#'

##' # Installation ####
#'
#' You can install the package via devtools: `devtools::install_github("jbkunst/rchess")`.
#'
#' # Quick Demo
#' Let's start doing a simple column chart (for HC a bar plot is a colum chart with a `cord_flip`).

##' # Quick Demo ####
#' Let's start doing a simple column chart:
#'
library("highcharter")
library("magrittr")
Expand All @@ -113,9 +117,8 @@ hc <- highchart() %>%
hc_chart(type = "column") %>%
hc_xAxis(categories = c("Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec")) %>%
hc_add_serie(name = "some data",
data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2,
26.5, 23.3, 18.3, 13.9, 9.6))
hc_add_serie(data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2,
26.5, 23.3, 18.3, 13.9, 9.6))

hc

Expand All @@ -130,7 +133,7 @@ hc <- hc %>%
hc_title(text = "I like this new title") %>%
hc_subtitle(text = "I want to add a subtitle too with style",
style = list(color = "#B71C1C", fontWeight = "bold")) %>%
hc_add_serie(name = "A another data", type = "line", color = "#1A237E",
hc_add_serie(name = "A another data", type = "line", color = "#1FA67A",
dataLabels = list(align = "center", enabled = TRUE),
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))
Expand All @@ -157,11 +160,102 @@ hc <- hc %>%

hc



#' Easy right? Well, it's just the Highcharts API. Thanks to the HC team.
#'
#' # API

##' # Function to work with HC API ####
#'
#' *Premise*: There's not default arguments. All arguments need to be named.
#'
#' Let's use a simple plot to show how do with the differentes funcions from the package.
#'
data(citytemp)

citytemp

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

hc

##' ## hc_chart ####

#' With `hc_chart` you can define general chart options.

hc %>%
hc_chart(type = "column",
borderColor = '#EBBA95',
borderRadius = 10,
borderWidth = 2,
backgroundColor = list(
linearGradient = c(0, 0, 500, 500),
stops = list(
list(0, 'rgb(255, 255, 255)'),
list(1, 'rgb(200, 200, 255)')
)))

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

##' ## hc_legend ####

hc

##' ## hc_title and hc_subtitle ####

#' Options to add the chart's main title and subtitle.

hc %>%
hc_title(text = "This is a title with <i>margin</i> at <b>bottom</b>",
useHTML = TRUE,
margin = 50,
align = "left",
style = list(color = "#90ed7d")) %>%
hc_subtitle(text = "A detailed description",
align = "right",
style = list(color = "#2b908f", fontWeight = "bold"))

##' ## hc_tooltip ####

hc

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

hc

##' ## hc_plotOptions ####

hc %>%
hc_plotOptions(series = list(stacking = "normal"))

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

hc

##' ## hc_exporting ####

hc

##' ## hc_credits ####

hc

#'
#' # Demos

##' ## Scatter plot ####

##' ## Column and Bar ####

##' ## Time Series ####

#'
#' # Shorcuts & Utils



#'
#' # Using highcharts without the highcharter functions
File renamed without changes.

0 comments on commit a8acf82

Please sign in to comment.