├── R ├── zzz.R ├── imports.R ├── group2series.R ├── proxies.R ├── force_.R ├── echarts.R ├── helpers.R ├── force.R ├── axis.R ├── toolbox.R ├── add.R ├── utils.R └── options.R ├── LICENSE ├── .gitignore ├── .Rbuildignore ├── .travis.yml ├── inst └── htmlwidgets │ └── echarts.yaml ├── man ├── edata.Rd ├── etoolbox_full.Rd ├── etoolbox_zoom.Rd ├── reexports.Rd ├── igraph2eforce.Rd ├── etoolbox_restore.Rd ├── echart.Rd ├── etoolbox_view.Rd ├── etoolbox_save.Rd ├── etoolbox_mark.Rd ├── eoptions.Rd ├── emap_coords.Rd ├── emap_choropleth.Rd ├── etheme.Rd ├── etoolbox_feature.Rd ├── egrid.Rd ├── evenn.Rd ├── etoolbox_magic.Rd ├── echarts-shiny.Rd ├── emap_line_effect.Rd ├── earea.Rd ├── etreemap.Rd ├── emap_heat.Rd ├── eload.Rd ├── ezoom.Rd ├── eheatmap.Rd ├── etoolbox.Rd ├── etitle.Rd ├── elegend.Rd ├── emark_point.Rd ├── ecloud.Rd ├── elinks.Rd ├── candlestick.Rd ├── efunnel.Rd ├── egauge.Rd ├── emap_roam.Rd ├── ebar.Rd ├── eanimation.Rd ├── epie.Rd ├── emark_line.Rd ├── eradar.Rd ├── etooltip.Rd ├── escatter.Rd ├── eforce.Rd ├── emap_points.Rd ├── xAxis.Rd ├── enodes.Rd ├── echord.Rd ├── yAxis.Rd ├── ecolorbar.Rd ├── proxies.Rd ├── eline.Rd ├── emap.Rd └── emap_lines.Rd ├── echarts.Rproj ├── DESCRIPTION ├── cran-comments.md ├── NEWS.md ├── appveyor.yml ├── README.md └── NAMESPACE /R/zzz.R: -------------------------------------------------------------------------------- 1 | data_env <- new.env(hash = TRUE) 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2017 2 | COPYRIGHT HOLDER: John Coene 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | billboard.Rproj 5 | 6 | -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^appveyor\.yml$ 4 | ^\.travis\.yml$ 5 | ^echarts\.png$ 6 | ^cran-comments\.md$ 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # R for travis: see documentation at https://docs.travis-ci.com/user/languages/r 2 | 3 | language: R 4 | sudo: false 5 | cache: packages 6 | -------------------------------------------------------------------------------- /inst/htmlwidgets/echarts.yaml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - name: echarts 3 | version: 2.2.7 4 | src: htmlwidgets/lib/echarts-2.2.7 5 | script: echarts-all.js 6 | -------------------------------------------------------------------------------- /R/imports.R: -------------------------------------------------------------------------------- 1 | #' @importFrom magrittr %>% 2 | #' @export 3 | magrittr::`%>%` 4 | 5 | #' @importFrom dplyr group_by 6 | #' @export 7 | dplyr::group_by 8 | 9 | #' @importFrom dplyr group_by_ 10 | #' @export 11 | dplyr::group_by_ 12 | -------------------------------------------------------------------------------- /man/edata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R, R/add_.R 3 | \name{edata} 4 | \alias{edata} 5 | \alias{edata} 6 | \alias{edata_} 7 | \title{Add data} 8 | \usage{ 9 | edata(p, data, x) 10 | 11 | edata_(p, data, x) 12 | } 13 | \arguments{ 14 | \item{p}{an echart object.} 15 | 16 | \item{data}{data.frame.} 17 | 18 | \item{x}{x variable.} 19 | } 20 | \description{ 21 | Add a dataset. 22 | } 23 | \seealso{ 24 | \code{emap} 25 | } 26 | -------------------------------------------------------------------------------- /echarts.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: No 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageRoxygenize: rd,collate,namespace 22 | -------------------------------------------------------------------------------- /man/etoolbox_full.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/toolbox.R 3 | \name{etoolbox_full} 4 | \alias{etoolbox_full} 5 | \title{Add all elements of toolbox} 6 | \usage{ 7 | etoolbox_full(p, ...) 8 | } 9 | \arguments{ 10 | \item{p}{an echart object.} 11 | 12 | \item{...}{any other option to pass to \code{\link{etoolbox}}.} 13 | } 14 | \description{ 15 | Adds toolbok mark, restor, save, and view. 16 | } 17 | \details{ 18 | Adds mark, restore, save, view and zoom buttons 19 | } 20 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: echarts 2 | Title: EChart htmlwidget 3 | Version: 0.0.3 4 | Authors@R: person("John", "Coene", email = "jcoenep@gmail.com", role = c("aut", "cre")) 5 | Description: htmlwidget for ECharts 2. 6 | Depends: 7 | R (>= 3.3.2) 8 | License: MIT + file LICENSE 9 | Encoding: UTF-8 10 | LazyData: true 11 | Imports: 12 | htmlwidgets, 13 | magrittr, 14 | dplyr, 15 | methods, 16 | igraph 17 | RoxygenNote: 6.0.1 18 | URL: http://john-coene.com/htmlwidgets/echarts/ 19 | BugReports: https://github.com/JohnCoene/echarts/issues 20 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## Test environments 2 | * local OS X install, R 3.4.3 3 | * ubuntu 12.04 (on travis-ci), R 3.4.3 4 | * win-builder (devel and release) 5 | 6 | ## R CMD check results 7 | 8 | 0 errors | 0 warnings | 1 note 9 | 10 | * This is a new release. 11 | 12 | ## Reverse dependencies 13 | 14 | This is a new release, so there are no reverse dependencies. 15 | 16 | --- 17 | 18 | * I have run R CMD check on the NUMBER downstream dependencies. 19 | (Summary at ...). 20 | 21 | * FAILURE SUMMARY 22 | 23 | * All revdep maintainers were notified of the release on RELEASE DATE. 24 | -------------------------------------------------------------------------------- /man/etoolbox_zoom.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/toolbox.R 3 | \name{etoolbox_zoom} 4 | \alias{etoolbox_zoom} 5 | \title{Add toolbox zoom button} 6 | \usage{ 7 | etoolbox_zoom(p, show = TRUE, title = list(dataZoom = "Area Zoom", 8 | dataZoomReset = "Reset")) 9 | } 10 | \arguments{ 11 | \item{p}{an echart object.} 12 | 13 | \item{show}{whether to show zoom.} 14 | 15 | \item{title}{button title.} 16 | } 17 | \description{ 18 | Add zoom feature. 19 | } 20 | \examples{ 21 | mtcars \%>\% 22 | echart(qsec) \%>\% 23 | ebar(mpg) \%>\% 24 | etoolbox() \%>\% 25 | etoolbox_zoom() 26 | 27 | } 28 | -------------------------------------------------------------------------------- /man/reexports.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/imports.R 3 | \docType{import} 4 | \name{reexports} 5 | \alias{reexports} 6 | \alias{\%>\%} 7 | \alias{reexports} 8 | \alias{group_by} 9 | \alias{reexports} 10 | \alias{group_by_} 11 | \title{Objects exported from other packages} 12 | \keyword{internal} 13 | \description{ 14 | These objects are imported from other packages. Follow the links 15 | below to see their documentation. 16 | 17 | \describe{ 18 | \item{dplyr}{\code{\link[dplyr]{group_by}}, \code{\link[dplyr]{group_by_}}} 19 | 20 | \item{magrittr}{\code{\link[magrittr]{\%>\%}}} 21 | }} 22 | 23 | -------------------------------------------------------------------------------- /man/igraph2eforce.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/force_.R 3 | \name{igraph2eforce} 4 | \alias{igraph2eforce} 5 | \alias{igraph_nodes} 6 | \alias{igraph_links} 7 | \title{Plot igraph} 8 | \usage{ 9 | igraph_nodes(g) 10 | 11 | igraph_links(g) 12 | } 13 | \arguments{ 14 | \item{g}{igraph object} 15 | } 16 | \description{ 17 | Plot a network from an igraph object. 18 | } 19 | \examples{ 20 | g <- igraph::make_directed_graph(LETTERS) 21 | 22 | nodes <- igraph_nodes(g) 23 | links <- igraph_links(g) 24 | 25 | echart() \%>\% 26 | eforce_() \%>\% 27 | enodes_(nodes, "name", ) \%>\% 28 | elinks_(links, "source", "target") 29 | 30 | } 31 | -------------------------------------------------------------------------------- /man/etoolbox_restore.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/toolbox.R 3 | \name{etoolbox_restore} 4 | \alias{etoolbox_restore} 5 | \title{Add toolbox restore button} 6 | \usage{ 7 | etoolbox_restore(p, show = TRUE, title = "Reset") 8 | } 9 | \arguments{ 10 | \item{p}{an echart object.} 11 | 12 | \item{show}{whether to show button.} 13 | 14 | \item{title}{title of button.} 15 | } 16 | \description{ 17 | Add toolbox restore button. 18 | } 19 | \examples{ 20 | mtcars \%>\% 21 | echart(disp) \%>\% 22 | ebar(mpg, stack = "grp") \%>\% # stack 23 | ebar(qsec, stack = "grp") \%>\% # stack 24 | ebar(wt) \%>\% # not stacked 25 | etoolbox_restore() 26 | 27 | } 28 | -------------------------------------------------------------------------------- /man/echart.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/echarts.R 3 | \name{echart} 4 | \alias{echart} 5 | \alias{echart_} 6 | \title{Initiate an echart} 7 | \usage{ 8 | echart(data, x, width = NULL, height = NULL, elementId = NULL) 9 | 10 | echart_(data, x, width = NULL, height = NULL, elementId = NULL) 11 | } 12 | \arguments{ 13 | \item{data}{data.frame containing data to plot.} 14 | 15 | \item{x}{variable column.} 16 | 17 | \item{width, height}{dimensions of chart.} 18 | 19 | \item{elementId}{id of div containing chart.} 20 | } 21 | \description{ 22 | Initiate an echart graph. 23 | } 24 | \examples{ 25 | mtcars \%>\% 26 | echart(mpg) \%>\% 27 | eline(drat) 28 | 29 | } 30 | -------------------------------------------------------------------------------- /man/etoolbox_view.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/toolbox.R 3 | \name{etoolbox_view} 4 | \alias{etoolbox_view} 5 | \title{Add toolbox data view} 6 | \usage{ 7 | etoolbox_view(p, show = TRUE, title = "View", readOnly = FALSE, 8 | lang = list("Data View", "close", "refresh"), ...) 9 | } 10 | \arguments{ 11 | \item{p}{an echart object.} 12 | 13 | \item{show}{whether to show data view.} 14 | 15 | \item{title}{button title.} 16 | 17 | \item{readOnly}{set as read-only.} 18 | 19 | \item{lang}{default text.} 20 | 21 | \item{...}{any other parameters to pass to data view.} 22 | } 23 | \description{ 24 | Enables viewing data table. 25 | } 26 | \examples{ 27 | mtcars \%>\% 28 | echart(qsec) \%>\% 29 | ebar(mpg) \%>\% 30 | etoolbox() \%>\% 31 | etoolbox_view() 32 | 33 | } 34 | -------------------------------------------------------------------------------- /man/etoolbox_save.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/toolbox.R 3 | \name{etoolbox_save} 4 | \alias{etoolbox_save} 5 | \title{Add toolbox save as image button} 6 | \usage{ 7 | etoolbox_save(p, show = TRUE, title = "Save as image", type = "png", 8 | name = "echarts", lang = "Save") 9 | } 10 | \arguments{ 11 | \item{p}{an echart object.} 12 | 13 | \item{show}{whether to show the button.} 14 | 15 | \item{title}{title of button.} 16 | 17 | \item{type}{image type} 18 | 19 | \item{name}{of file.} 20 | 21 | \item{lang}{text.} 22 | } 23 | \description{ 24 | Add save as image button. 25 | } 26 | \examples{ 27 | mtcars \%>\% 28 | echart(disp) \%>\% 29 | ebar(mpg, stack = "grp") \%>\% # stack 30 | ebar(qsec, stack = "grp") \%>\% # stack 31 | etoolbox() \%>\% 32 | etoolbox_save() 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /R/group2series.R: -------------------------------------------------------------------------------- 1 | # group2series 2 | map_grps_ <- function(data){ 3 | 4 | row.names(data) <- NULL 5 | 6 | if(dplyr::is.grouped_df(data)){ 7 | 8 | # deparse groups to get grp column 9 | g.col <- dplyr::groups(data) 10 | g.col <- unlist(lapply(g.col, deparse)) 11 | 12 | data <- dplyr::ungroup(data) 13 | data <- apply(data, 2, na2ec) 14 | data <- as.data.frame(data) 15 | row.names(data) <- NULL 16 | 17 | grps <- unique(data[,g.col]) # get unique grps 18 | 19 | # fun to filter grps 20 | filter_grp <- function(grps){ 21 | data[data[, g.col] == grps,] 22 | } 23 | 24 | data <- Map(filter_grp, grps) 25 | names(data) <- grps 26 | 27 | } else { 28 | row.names(data) <- NULL 29 | data <- na2ec(data) 30 | data <- list(as.data.frame(data)) 31 | } 32 | 33 | return(data) 34 | 35 | } 36 | -------------------------------------------------------------------------------- /man/etoolbox_mark.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/toolbox.R 3 | \name{etoolbox_mark} 4 | \alias{etoolbox_mark} 5 | \title{Add toolbox feature mark button} 6 | \usage{ 7 | etoolbox_mark(p, show = TRUE, title = list(mark = "Mark", markUndo = "Undo", 8 | markClear = "Clear"), lineStyle = list(color = "#1e90ff", typed = "dashed", 9 | width = 2, shadowColor = "rgba(0,0,0,0)", shadowBlur = 5, shadowOffsetX = 3, 10 | shadowOffsetY = 3)) 11 | } 12 | \arguments{ 13 | \item{p}{an echart object.} 14 | 15 | \item{show}{whether to show mark.} 16 | 17 | \item{title}{mark button title.} 18 | 19 | \item{lineStyle}{style of marked line.} 20 | } 21 | \description{ 22 | Enable marking chart. 23 | } 24 | \examples{ 25 | mtcars \%>\% 26 | echart(qsec) \%>\% 27 | ebar(mpg) \%>\% 28 | etoolbox() \%>\% 29 | etoolbox_mark() 30 | 31 | } 32 | -------------------------------------------------------------------------------- /man/eoptions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/options.R 3 | \name{eoptions} 4 | \alias{eoptions} 5 | \title{Add global options} 6 | \usage{ 7 | eoptions(p, backgroundColor = NULL, renderAsImage = FALSE, 8 | calculable = FALSE, color = NULL, symbolList = NULL, ...) 9 | } 10 | \arguments{ 11 | \item{p}{an echart object.} 12 | 13 | \item{backgroundColor}{background color.} 14 | 15 | \item{renderAsImage}{allows rendering as image.} 16 | 17 | \item{calculable}{specifies whether the drag-recalculate feature will be enabled.} 18 | 19 | \item{color}{colors to use in chart.} 20 | 21 | \item{symbolList}{list of default symbols.} 22 | 23 | \item{...}{any other options.} 24 | } 25 | \description{ 26 | Add global options. 27 | } 28 | \examples{ 29 | mtcars \%>\% 30 | echart(mpg) \%>\% 31 | eline(qsec) \%>\% 32 | eoptions(backgroundColor = "black") 33 | 34 | } 35 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # echarts 0.0.3 2 | 3 | - Multiple bug fixes:mainly with force networks 4 | - `eload` added 5 | - `igraph2eforce` added 6 | - More sensible input tests 7 | 8 | # echarts 0.0.2 9 | 10 | - Multiple bug fixes 11 | 12 | # echarts 0.0.1 13 | 14 | Checklist: 15 | 16 | - ~~functions documentation~~ 17 | - ~~echart knit dimensions~~ 18 | - ~~tooltip default delay reduce~~ 19 | - add input tests ~~some done~~ 20 | - add eventriver and treemap 21 | - proper evaluation NSE **Important** 22 | - pie charts/radar/gauge/treemap arrange when passing grouped data 23 | - tests / testthat 24 | - ~~build - Travis & appveyor~~ 25 | - ~~clean helpers mess~~ 26 | - add timeline 27 | - ~~titles in examples~~ 28 | - ~~elinks NSE weight arg fix~~ 29 | - ~~datarange for scatter~~ 30 | - ~~change default datarange colors~~ 31 | - ~~add roam controller for maps~~ 32 | - Rework axis inputs - make more intuitive 33 | - ~~add grid API~~ 34 | 35 | -------------------------------------------------------------------------------- /man/emap_coords.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R, R/add_.R 3 | \name{emap_coords} 4 | \alias{emap_coords} 5 | \alias{emap_coords} 6 | \alias{emap_coords_} 7 | \title{Add map coordinates} 8 | \usage{ 9 | emap_coords(p, lon, lat) 10 | 11 | emap_coords_(p, lon, lat) 12 | } 13 | \arguments{ 14 | \item{p}{an echart object} 15 | 16 | \item{lon, lat}{coordinates to plot.} 17 | } 18 | \description{ 19 | Add coordinates to map. 20 | } 21 | \examples{ 22 | coords <- data.frame(city = c("London", "New York", "Beijing", "Sydney"), 23 | lon = c(-0.1167218, -73.98002, 116.3883, 151.18518), 24 | lat = c(51.49999, 40.74998, 39.92889, -33.92001)) 25 | 26 | edges <- data.frame(source = c("Beijing", "Beijing", "New York"), 27 | target = c("Sydney", "London", "London")) 28 | 29 | coords \%>\% 30 | echart(city) \%>\% 31 | emap() \%>\% 32 | emap_coords(lon, lat) \%>\% 33 | emap_lines(edges, source, target) 34 | 35 | } 36 | -------------------------------------------------------------------------------- /man/emap_choropleth.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R, R/add_.R 3 | \name{emap_choropleth} 4 | \alias{emap_choropleth} 5 | \alias{emap_choropleth} 6 | \alias{emap_choropleth_} 7 | \title{Add choropleth} 8 | \usage{ 9 | emap_choropleth(p, serie) 10 | 11 | emap_choropleth_(p, serie) 12 | } 13 | \arguments{ 14 | \item{p}{an echart object.} 15 | 16 | \item{serie}{values to plot.} 17 | } 18 | \description{ 19 | Add choropleth 20 | } 21 | \examples{ 22 | choropleth <- data.frame(countries = c("France", "Brazil", "China", "Russia", "Canada", "India"), 23 | values = round(runif(6, 10, 25))) 24 | 25 | choropleth \%>\% 26 | echart(countries) \%>\% 27 | emap() \%>\% 28 | emap_choropleth(values) 29 | 30 | choropleth \%>\% 31 | echart(countries) \%>\% 32 | emap() \%>\% 33 | emap_choropleth(values) \%>\% 34 | ecolorbar(color = list("red", "yellow"), calculable = TRUE) 35 | 36 | } 37 | \seealso{ 38 | \code{\link{ecolorbar}} 39 | } 40 | -------------------------------------------------------------------------------- /man/etheme.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/options.R 3 | \name{etheme} 4 | \alias{etheme} 5 | \title{Add theme} 6 | \usage{ 7 | etheme(p, theme = "default") 8 | } 9 | \arguments{ 10 | \item{p}{an echart object.} 11 | 12 | \item{theme, }{see details for valid values.} 13 | } 14 | \description{ 15 | Add a theme. 16 | } 17 | \details{ 18 | valid themes: 19 | \itemize{ 20 | \item{\code{default}} 21 | \item{\code{mint}} 22 | \item{\code{macarons}} 23 | \item{\code{macarons2}} 24 | \item{\code{green}} 25 | \item{\code{blue}} 26 | \item{\code{dark}} 27 | \item{\code{gray}} 28 | \item{\code{helianthus}} 29 | \item{\code{red}} 30 | \item{\code{wef}} 31 | \item{\code{roma}} 32 | \item{\code{sakura}} 33 | \item{\code{shine}} 34 | \item{\code{infographic}} 35 | \item{\code{solarlight}} 36 | } 37 | } 38 | \examples{ 39 | mtcars \%>\% 40 | echart(disp) \%>\% 41 | ebar(qsec) \%>\% 42 | ebar(mpg) \%>\% 43 | etheme("roma") 44 | 45 | } 46 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # DO NOT CHANGE the "init" and "install" sections below 2 | 3 | # Download script file from GitHub 4 | init: 5 | ps: | 6 | $ErrorActionPreference = "Stop" 7 | Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1" 8 | Import-Module '..\appveyor-tool.ps1' 9 | 10 | install: 11 | ps: Bootstrap 12 | 13 | # Adapt as necessary starting from here 14 | 15 | build_script: 16 | - travis-tool.sh install_deps 17 | 18 | test_script: 19 | - travis-tool.sh run_tests 20 | 21 | on_failure: 22 | - 7z a failure.zip *.Rcheck\* 23 | - appveyor PushArtifact failure.zip 24 | 25 | artifacts: 26 | - path: '*.Rcheck\**\*.log' 27 | name: Logs 28 | 29 | - path: '*.Rcheck\**\*.out' 30 | name: Logs 31 | 32 | - path: '*.Rcheck\**\*.fail' 33 | name: Logs 34 | 35 | - path: '*.Rcheck\**\*.Rout' 36 | name: Logs 37 | 38 | - path: '\*_*.tar.gz' 39 | name: Bits 40 | 41 | - path: '\*_*.zip' 42 | name: Bits 43 | -------------------------------------------------------------------------------- /man/etoolbox_feature.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/toolbox.R 3 | \name{etoolbox_feature} 4 | \alias{etoolbox_feature} 5 | \title{Add toolbox feature} 6 | \usage{ 7 | etoolbox_feature(p, mark, dataZoom, dataView, magicType, restore, saveAsImage) 8 | } 9 | \arguments{ 10 | \item{p}{an echart object.} 11 | 12 | \item{mark}{markLine icons see \code{\link{etoolbox_mark}}.} 13 | 14 | \item{dataZoom}{dataZoom icons \code{\link{etoolbox_zoom}}.} 15 | 16 | \item{dataView}{dataView icons \code{\link{etoolbox_view}}.} 17 | 18 | \item{magicType}{magicType icons \code{\link{etoolbox_magic}}.} 19 | 20 | \item{restore}{restore icon \code{\link{etoolbox_restore}}.} 21 | 22 | \item{saveAsImage}{saveAsImage icon \code{\link{etoolbox_save}}.} 23 | } 24 | \description{ 25 | Add toolbox feature. 26 | } 27 | \examples{ 28 | mtcars \%>\% 29 | echart(qsec) \%>\% 30 | ebar(mpg) \%>\% 31 | etoolbox() \%>\% 32 | etoolbox_magic(type = list("line", "bar")) \%>\% 33 | etoolbox_feature(restore = list(show = TRUE)) 34 | 35 | } 36 | -------------------------------------------------------------------------------- /man/egrid.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/options.R 3 | \name{egrid} 4 | \alias{egrid} 5 | \title{Customise grid} 6 | \usage{ 7 | egrid(p, backgroundColor = NULL, borderWidth = 1, borderColor = NULL, 8 | width = NULL, height = NULL, z = 0, zlevel = 0, x = 80, y = 60, 9 | x2 = 80, y2 = 80) 10 | } 11 | \arguments{ 12 | \item{p}{an echart object.} 13 | 14 | \item{backgroundColor}{background color.} 15 | 16 | \item{borderWidth}{border width.} 17 | 18 | \item{borderColor}{border color.} 19 | 20 | \item{width, height}{dimensions of grid.} 21 | 22 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 23 | 24 | \item{x, y}{ordinate on upper left corner.} 25 | 26 | \item{x2, y2}{ordinate on upper right corner.} 27 | } 28 | \description{ 29 | Customise grid 30 | } 31 | \examples{ 32 | df <- data.frame(x = 1:20, y = runif(20, 5, 20)) 33 | 34 | df \%>\% 35 | echart(x) \%>\% 36 | eline(x) \%>\% 37 | egrid(borderWidth = 5, borderColor = "red", backgroundColor = "yellow") 38 | 39 | } 40 | \seealso{ 41 | \href{http://echarts.baidu.com/echarts2/doc/option-en.html#title~grid.width}{official grid docs} 42 | } 43 | -------------------------------------------------------------------------------- /man/evenn.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R, R/add_.R 3 | \name{evenn} 4 | \alias{evenn} 5 | \alias{evenn} 6 | \alias{evenn_} 7 | \title{Add venn} 8 | \usage{ 9 | evenn(p, serie, name = NULL, clickable = TRUE, z = 2, zlevel = 0, 10 | tooltip = NULL, ...) 11 | 12 | evenn_(p, serie, name = NULL, clickable = TRUE, z = 2, zlevel = 0, 13 | tooltip = NULL, ...) 14 | } 15 | \arguments{ 16 | \item{p}{an echart object.} 17 | 18 | \item{serie}{a named vector, see details.} 19 | 20 | \item{name}{name of serie.} 21 | 22 | \item{clickable}{whether ciorcles are clickable.} 23 | 24 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 25 | 26 | \item{tooltip}{cutomise tooltip.} 27 | 28 | \item{...}{any other argument to pass to funnel.} 29 | } 30 | \description{ 31 | Add venn diagram 32 | } 33 | \examples{ 34 | venn <- data.frame(name = c("banana", "pineapple", "overlap"), 35 | values = c(20, 50, 10)) 36 | 37 | venn \%>\% 38 | echart(name) \%>\% 39 | evenn(values) \%>\% 40 | etheme("macarons2") 41 | 42 | } 43 | \seealso{ 44 | \href{http://echarts.baidu.com/echarts2/doc/option-en.html#series-i(venn)}{official venn docs} 45 | } 46 | -------------------------------------------------------------------------------- /man/etoolbox_magic.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/toolbox.R 3 | \name{etoolbox_magic} 4 | \alias{etoolbox_magic} 5 | \title{Add toolbox magic buttons} 6 | \usage{ 7 | etoolbox_magic(p, show = TRUE, type = list(), title, ...) 8 | } 9 | \arguments{ 10 | \item{p}{an echart object.} 11 | 12 | \item{show}{wehtehr to show magic buttons.} 13 | 14 | \item{type}{chart types, see details.} 15 | 16 | \item{title}{titles of charts.} 17 | 18 | \item{...}{any other options to pass to magic feature.} 19 | } 20 | \description{ 21 | Enable changing chart type. 22 | } 23 | \details{ 24 | Pass a \code{list} to \code{type}, valid values are: 25 | 26 | \itemize{ 27 | \item{\code{line}} 28 | \item{\code{bar}} 29 | \item{\code{stack}} 30 | \item{\code{tiled}} 31 | \item{\code{force}} 32 | \item{\code{chord}} 33 | \item{\code{pie}} 34 | \item{\code{funnel}} 35 | } 36 | } 37 | \examples{ 38 | mtcars \%>\% 39 | echart(disp) \%>\% 40 | ebar(mpg, stack = "grp") \%>\% # stack 41 | ebar(qsec, stack = "grp") \%>\% # stack 42 | ebar(wt) \%>\% # not stacked 43 | etooltip() \%>\% 44 | elegend() \%>\% 45 | etoolbox() \%>\% 46 | etoolbox_magic(type = list("bar", "line", "stack", "tiled")) 47 | 48 | } 49 | -------------------------------------------------------------------------------- /man/echarts-shiny.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/echarts.R 3 | \name{echarts-shiny} 4 | \alias{echarts-shiny} 5 | \alias{echartsOutput} 6 | \alias{renderEcharts} 7 | \alias{echartsProxy} 8 | \title{Shiny bindings for echarts} 9 | \usage{ 10 | echartsOutput(outputId, width = "100\%", height = "400px") 11 | 12 | renderEcharts(expr, env = parent.frame(), quoted = FALSE) 13 | 14 | echartsProxy(id, session = shiny::getDefaultReactiveDomain()) 15 | } 16 | \arguments{ 17 | \item{outputId}{output variable to read from} 18 | 19 | \item{width, height}{Must be a valid CSS unit (like \code{'100\%'}, 20 | \code{'400px'}, \code{'auto'}) or a number, which will be coerced to a 21 | string and have \code{'px'} appended.} 22 | 23 | \item{expr}{An expression that generates a echarts} 24 | 25 | \item{env}{The environment in which to evaluate \code{expr}.} 26 | 27 | \item{quoted}{Is \code{expr} a quoted expression (with \code{quote()})? This 28 | is useful if you want to save an expression in a variable.} 29 | 30 | \item{id}{target chart id.} 31 | 32 | \item{session}{shiny session} 33 | } 34 | \description{ 35 | Output and render functions for using echarts within Shiny 36 | applications and interactive Rmd documents. 37 | } 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UNMAINTAINED 2 | 3 | ![version](https://img.shields.io/github/release/JohnCoene/echarts.svg) 4 | [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/JohnCoene/echarts?branch=master&svg=true)](https://ci.appveyor.com/project/JohnCoene/echarts) 5 | [![Travis-CI Build Status](https://travis-ci.org/JohnCoene/echarts.svg?branch=master)](https://travis-ci.org/JohnCoene/echarts) 6 | 7 | # echarts 8 | 9 | ![sticker](https://raw.githubusercontent.com/JohnCoene/projects/master/img/echarts_sticker2.png) 10 | 11 | R htmlwidget for Baidu's [ECharts](http://echarts.baidu.com) 2.2.7 12 | 13 | # Check out echarts for ECharts version 4: [echarts4r](https://github.com/JohnCoene/echarts4r) 14 | 15 | ## Installation 16 | 17 | You can install echarts from github with: 18 | 19 | ```R 20 | # install.packages("devtools") 21 | devtools::install_github("JohnCoene/echarts") 22 | ``` 23 | 24 | ## Features 25 | 26 | 1. bar charts 27 | 2. line charts 28 | 3. area charts 29 | 4. pie & donut charts 30 | 5. heatmaps 31 | 6. chord diagrams 32 | 7. venn diagrams 33 | 8. gauges 34 | 9. force networks 35 | 10. word-clouds 36 | 11. maps 37 | 12. candlestick charts 38 | 13. themes 39 | 14. responsive 40 | 15. animations 41 | 16. data loading effects 42 | 17. tons of options 43 | -------------------------------------------------------------------------------- /man/emap_line_effect.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \name{emap_line_effect} 4 | \alias{emap_line_effect} 5 | \title{emap line effect} 6 | \usage{ 7 | emap_line_effect(show = TRUE, loop = TRUE, period = 30, scaleSize = 1, 8 | color = "#fff", shadowBlur = 10, shadowColor = NULL, ...) 9 | } 10 | \arguments{ 11 | \item{show}{set to \code{TRUE} to show effect.} 12 | 13 | \item{loop}{set to \code{TRUE} to loop animation.} 14 | 15 | \item{period}{period loop.} 16 | 17 | \item{scaleSize}{scale.} 18 | 19 | \item{color}{color.} 20 | 21 | \item{shadowBlur}{blur.} 22 | 23 | \item{shadowColor}{color of shadow.} 24 | 25 | \item{...}{any other option to pass to effect.} 26 | } 27 | \description{ 28 | Effect for emap lines 29 | } 30 | \examples{ 31 | coords <- data.frame(city = c("London", "New York", "Beijing", "Sydney"), 32 | lon = c(-0.1167218, -73.98002, 116.3883, 151.18518), 33 | lat = c(51.49999, 40.74998, 39.92889, -33.92001)) 34 | 35 | edges <- data.frame(source = c("Beijing", "Beijing", "New York"), 36 | target = c("Sydney", "London", "London")) 37 | 38 | coords \%>\% 39 | echart(city) \%>\% 40 | emap() \%>\% 41 | emap_coords(lon, lat) \%>\% 42 | emap_lines(edges, source, target, effect = emap_line_effect()) 43 | 44 | } 45 | -------------------------------------------------------------------------------- /man/earea.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R, R/add_.R 3 | \name{earea} 4 | \alias{earea} 5 | \alias{earea} 6 | \alias{earea_} 7 | \title{Add area} 8 | \usage{ 9 | earea(p, serie, name = NULL, stack = NULL, smooth = TRUE, ...) 10 | 11 | earea_(p, serie, name = NULL, stack = NULL, smooth = TRUE, ...) 12 | } 13 | \arguments{ 14 | \item{p}{an echart object.} 15 | 16 | \item{serie}{value column name to plot.} 17 | 18 | \item{name}{of serie.} 19 | 20 | \item{stack}{name of the stack.} 21 | 22 | \item{smooth}{whether to smooth line.} 23 | 24 | \item{...}{any other argument to pass to the serie. i.e.: same parameters as \code{\link{eline}} or \code{\link{eline_}}} 25 | } 26 | \description{ 27 | Add area serie. 28 | } 29 | \examples{ 30 | \dontrun{ 31 | df <- data.frame(x = LETTERS[1:10], y = runif(10, 30, 70), z = runif(10, 10, 50)) 32 | 33 | df \%>\% 34 | echart_("x") \%>\% 35 | earea_("y", smooth = FALSE, symbol = "emptyRectangle", symbolSize = 5) 36 | 37 | df \%>\% 38 | echart(x) \%>\% 39 | earea(y, stack = "grp") \%>\% 40 | earea(z, stack = "grp") \%>\% 41 | etheme("roma") 42 | 43 | df <- data.frame(x = 1:10, y = runif(10, 30, 70), z = runif(10, 10, 50)) 44 | 45 | df \%>\% 46 | echart(x) \%>\% 47 | earea(z, stack = "grp") \%>\% 48 | earea(y) 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /man/etreemap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R, R/add_.R 3 | \name{etreemap} 4 | \alias{etreemap} 5 | \alias{etreemap} 6 | \alias{etreemap_} 7 | \title{Add Treemap} 8 | \usage{ 9 | etreemap(p, serie, name = NULL, itemStyle = NULL, clickable = FALSE, 10 | center = list("50\%", "50\%"), size = list("80\%", "80\%"), z = 2, 11 | zlevel = 0, ...) 12 | 13 | etreemap_(p, serie, name = NULL, itemStyle = NULL, clickable = FALSE, 14 | center = list("50\%", "50\%"), size = list("80\%", "80\%"), z = 2, 15 | zlevel = 0, ...) 16 | } 17 | \arguments{ 18 | \item{p}{an echart object.} 19 | 20 | \item{serie}{values to plot.} 21 | 22 | \item{name}{name of serie.} 23 | 24 | \item{itemStyle}{style of rectangles.} 25 | 26 | \item{clickable}{whether rectangles are clickable.} 27 | 28 | \item{center}{center of map.} 29 | 30 | \item{size}{size of chart.} 31 | 32 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 33 | 34 | \item{...}{any other option to pass to treemap.} 35 | } 36 | \description{ 37 | Add Treemap 38 | } 39 | \examples{ 40 | df <- data.frame(name = LETTERS[1:10], values = round(runif(10, 1, 10))) 41 | 42 | df \%>\% 43 | echart(name) \%>\% 44 | etreemap(values) \%>\% 45 | etooltip(trigger = "item") \%>\% 46 | etheme("macarons") 47 | 48 | } 49 | -------------------------------------------------------------------------------- /man/emap_heat.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R, R/add_.R 3 | \name{emap_heat} 4 | \alias{emap_heat} 5 | \alias{emap_heat} 6 | \alias{emap_heat_} 7 | \title{Add heat on map} 8 | \usage{ 9 | emap_heat(p, lon, lat, z, blurSize = 30, minAlpha = 0.05, valueScale = 1, 10 | opacity = 1, gradientColors = NULL, ...) 11 | 12 | emap_heat_(p, lon, lat, z, blurSize = 30, minAlpha = 0.05, valueScale = 1, 13 | opacity = 1, gradientColors = NULL, ...) 14 | } 15 | \arguments{ 16 | \item{p}{an echart object.} 17 | 18 | \item{lon, lat}{coordinates.} 19 | 20 | \item{z}{values, heat.} 21 | 22 | \item{blurSize}{blur of points.} 23 | 24 | \item{minAlpha}{minimum transparency.} 25 | 26 | \item{valueScale}{\code{z} multiplier.} 27 | 28 | \item{opacity}{opacity of heatmap.} 29 | 30 | \item{gradientColors}{colors.} 31 | 32 | \item{...}{any other parameter to pass to heatmap.} 33 | } 34 | \description{ 35 | Add heat on map 36 | } 37 | \examples{ 38 | data <- data.frame(lon = runif(300, 90, 120), 39 | lat = runif(300, 30, 39), 40 | z = runif(300, 75, 100)) 41 | 42 | data \%>\% 43 | echart() \%>\% 44 | emap(mapType = "china") \%>\% 45 | emap_heat(lon, lat, z) 46 | 47 | data \%>\% 48 | echart() \%>\% 49 | emap(mapType = "china") \%>\% 50 | emap_heat(lon, lat, z, blurSize = 50, minAlpha = 0.3, opacity = 0.8) 51 | 52 | } 53 | -------------------------------------------------------------------------------- /man/eload.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/options.R 3 | \name{eload} 4 | \alias{eload} 5 | \title{Data loading options} 6 | \usage{ 7 | eload(p, text = "loading", effect = "bubble", x = "center", 8 | y = "center", progress = NULL, ...) 9 | } 10 | \arguments{ 11 | \item{p}{an echart object.} 12 | 13 | \item{text}{the loading text that appears when the chart is set into the loading state, use \code{\\n} for new line.} 14 | 15 | \item{effect}{loading effect, see details for valid values.} 16 | 17 | \item{x, y}{position, takes \code{left}, \code{right}, \code{center}.} 18 | 19 | \item{progress}{specifies the current progress \code{[0~1]}. Applicable to specific effects.} 20 | 21 | \item{...}{any other parameters, i.e.:\code{textStyle}.} 22 | } 23 | \description{ 24 | Customise the data loading options. 25 | } 26 | \details{ 27 | Valid \code{effect} values: 28 | \itemize{ 29 | \item{spin} 30 | \item{bar} 31 | \item{ring} 32 | \item{whirling} 33 | \item{dynamicLine} 34 | \item{bubble} 35 | } 36 | } 37 | \examples{ 38 | # no data 39 | df <- data.frame(x = NA, y = NA) \%>\% 40 | dplyr::filter(!is.na(x)) 41 | 42 | df \%>\% 43 | echart(x) \%>\% 44 | eline(y) 45 | 46 | df \%>\% 47 | echart(x) \%>\% 48 | eline(y) \%>\% 49 | eload(effect = "ring", text = "loading data...") 50 | 51 | df \%>\% 52 | echart(x) \%>\% 53 | eline(y) \%>\% 54 | eload(effect = "dynamicLine") 55 | 56 | } 57 | -------------------------------------------------------------------------------- /man/ezoom.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/options.R 3 | \name{ezoom} 4 | \alias{ezoom} 5 | \title{Add data zoom} 6 | \usage{ 7 | ezoom(p, show = TRUE, zlevel = 0, z = 4, orient = "horizontal", 8 | backgroundColor = "rgba(0,0,0,0)", dataBackgroundColor = "#eee", 9 | fillerColor = "rgba(144,197,237,0.2)", 10 | handleColor = "rgba(70,130,180,0.8)", handleSize = 8, start = 0, 11 | end = 100, showDetail = TRUE, realtime = FALSE, zoomLock = FALSE, ...) 12 | } 13 | \arguments{ 14 | \item{p}{an echart object.} 15 | 16 | \item{show}{whether to show the data zoom.} 17 | 18 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 19 | 20 | \item{orient}{orientation, takes \code{vertical} or \code{horinzontal}.} 21 | 22 | \item{backgroundColor}{background color.} 23 | 24 | \item{dataBackgroundColor}{background color of data zoom.} 25 | 26 | \item{fillerColor}{fill color of selected area.} 27 | 28 | \item{handleColor}{color of data zoom handle.} 29 | 30 | \item{handleSize}{size of handle.} 31 | 32 | \item{start, end}{percent start and end.} 33 | 34 | \item{showDetail}{whether to show detail when dragging.} 35 | 36 | \item{realtime}{set to \code{TRUE} if using real time data.} 37 | 38 | \item{zoomLock}{when set to true, the selected area cannot be zoomed.} 39 | 40 | \item{...}{any other options to pass to data zoom.} 41 | } 42 | \description{ 43 | Add data zoom. 44 | } 45 | \examples{ 46 | mtcars \%>\% 47 | echart(disp) \%>\% 48 | eline(mpg) \%>\% 49 | ezoom() 50 | 51 | } 52 | \seealso{ 53 | \href{http://echarts.baidu.com/echarts2/doc/option-en.html#title~dataZoom}{official dataZoom docs} 54 | } 55 | -------------------------------------------------------------------------------- /man/eheatmap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R, R/add_.R 3 | \name{eheatmap} 4 | \alias{eheatmap} 5 | \alias{eheatmap} 6 | \alias{eheatmap_} 7 | \title{Add heatmap} 8 | \usage{ 9 | eheatmap(p, y, values, name = NULL, clickable = TRUE, blurSize = 30, 10 | minAlpha = 0.5, valueScale = 1, opacity = 1, z = 2, zlevel = 0, 11 | gradientColors, tooltip, ...) 12 | 13 | eheatmap_(p, y, values, name = NULL, clickable = TRUE, blurSize = 30, 14 | minAlpha = 0.5, valueScale = 1, opacity = 1, z = 2, zlevel = 0, 15 | gradientColors, tooltip, ...) 16 | } 17 | \arguments{ 18 | \item{p}{an echart object.} 19 | 20 | \item{y}{yaxis values.} 21 | 22 | \item{values}{heat.} 23 | 24 | \item{name}{name of serie.} 25 | 26 | \item{clickable}{whether chart is clickable.} 27 | 28 | \item{blurSize}{size of points blur.} 29 | 30 | \item{minAlpha}{minimum transparency.} 31 | 32 | \item{valueScale}{\code{values} multiplier.} 33 | 34 | \item{opacity}{opacity of heatmap.} 35 | 36 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 37 | 38 | \item{gradientColors}{colors used for gradient as a \code{list} i.e.:\code{list("red", "blue")}} 39 | 40 | \item{tooltip}{cutomise tooltip.} 41 | 42 | \item{...}{any other options to pass to heatmap.} 43 | } 44 | \description{ 45 | Add heatmap. 46 | } 47 | \examples{ 48 | set.seed(19880525) 49 | matrix <- data.frame(x = runif(150, 10, 500), y = runif(150, 10, 500), z = runif(150, 10 , 200)) 50 | 51 | matrix \%>\% 52 | echart(x) \%>\% 53 | eheatmap(y, z) 54 | 55 | } 56 | \seealso{ 57 | \href{http://echarts.baidu.com/echarts2/doc/option-en.html#series-i(heatmap)}{official heatmap docs} 58 | } 59 | -------------------------------------------------------------------------------- /man/etoolbox.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/toolbox.R 3 | \name{etoolbox} 4 | \alias{etoolbox} 5 | \title{Setup toolbox} 6 | \usage{ 7 | etoolbox(p, show = TRUE, zlevel = 0, z = 6, orient = "horizontal", 8 | x = "right", y = "top", backgroundColor = "rgba(0,0,0,0)", 9 | borderColor = "#ccc", borderWidth = 0, padding = 5, itemGap = 10, 10 | itemSize = 16, color = NULL, disableColor = "#ddd", 11 | effectiveColor = "red", showTitle = TRUE, textStyle = NULL, ...) 12 | } 13 | \arguments{ 14 | \item{p}{an echart object.} 15 | 16 | \item{show}{whether to show the toolbox.} 17 | 18 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 19 | 20 | \item{orient}{toolbox orientation, \code{horizontal} or \code{vertical}.} 21 | 22 | \item{x}{horizontal alignment, \code{left}, \code{right}.} 23 | 24 | \item{y}{vertical alignment, \code{top}, \code{center}, \code{bottom}.} 25 | 26 | \item{backgroundColor}{background color.} 27 | 28 | \item{borderColor}{border color.} 29 | 30 | \item{borderWidth}{border width.} 31 | 32 | \item{padding}{padding.} 33 | 34 | \item{itemGap}{space between toolbox buttons.} 35 | 36 | \item{itemSize}{size of buttons.} 37 | 38 | \item{color}{color of buttons.} 39 | 40 | \item{disableColor}{color of disabled item.} 41 | 42 | \item{effectiveColor}{color of active button.} 43 | 44 | \item{showTitle}{set to \code{TRUE} to show text.} 45 | 46 | \item{textStyle}{style of text.} 47 | 48 | \item{...}{any other options.} 49 | } 50 | \description{ 51 | Setup toolbox 52 | } 53 | \examples{ 54 | mtcars \%>\% 55 | echart(qsec) \%>\% 56 | ebar(mpg) \%>\% 57 | etoolbox() \%>\% 58 | etoolbox_magic(type = list("line", "bar")) 59 | 60 | } 61 | -------------------------------------------------------------------------------- /man/etitle.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/options.R 3 | \name{etitle} 4 | \alias{etitle} 5 | \title{Add title} 6 | \usage{ 7 | etitle(p, text, subtext, link, sublink, target = "blank", 8 | subtarget = "blank", x = "left", y = "top", 9 | backgroundColor = "rgba(0,0,0,0)", borderColor = "#ccc", 10 | borderWidth = 0, padding = 5, itemGap = 5, zlevel = 0, z = 6, 11 | show = TRUE, ...) 12 | } 13 | \arguments{ 14 | \item{p}{an echart object.} 15 | 16 | \item{text}{title.} 17 | 18 | \item{subtext}{subtitle.} 19 | 20 | \item{link}{hyperlink.} 21 | 22 | \item{sublink}{subtext hyperlink.} 23 | 24 | \item{target}{\code{link} opening window: \code{self} or \code{blank}.} 25 | 26 | \item{subtarget}{\code{sublink} opening window: \code{self} or \code{blank}.} 27 | 28 | \item{x}{positon of title, \code{left} or \code{right}.} 29 | 30 | \item{y}{postion of title, \code{top}, \code{bottom} or \code{center}.} 31 | 32 | \item{backgroundColor}{background color.} 33 | 34 | \item{borderColor}{border color.} 35 | 36 | \item{borderWidth}{width of border.} 37 | 38 | \item{padding}{padding.} 39 | 40 | \item{itemGap}{gap between title and subtitle.} 41 | 42 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 43 | 44 | \item{show}{whether to show the title.} 45 | 46 | \item{...}{any other options to pass to title} 47 | } 48 | \description{ 49 | Add chart title and subtitles. 50 | } 51 | \examples{ 52 | mtcars \%>\% 53 | echart(disp) \%>\% 54 | eline(mpg) \%>\% 55 | etitle("MPG vs DISP", "Made with EChart", link = "http://echarts.baidu.com", target = "blank") 56 | 57 | } 58 | \seealso{ 59 | \href{http://echarts.baidu.com/echarts2/doc/option-en.html#title~title}{official title docs} 60 | } 61 | -------------------------------------------------------------------------------- /man/elegend.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/options.R 3 | \name{elegend} 4 | \alias{elegend} 5 | \title{Add legend} 6 | \usage{ 7 | elegend(p, legend, show = TRUE, zlevel = 0, z = 4, 8 | orient = "horizontal", x = "center", y = "top", 9 | backgroundColor = "rgba(0,0,0,0)", borderColor = "#ccc", 10 | borderWidth = 0, padding = 5, itemGap = 10, itemWidth = 20, 11 | itemHeight = 14, formatter = NULL, selectedMode = TRUE, 12 | selected = NULL, textStyle, ...) 13 | } 14 | \arguments{ 15 | \item{p}{an echart object.} 16 | 17 | \item{legend}{legend.} 18 | 19 | \item{show}{wether to show legend.} 20 | 21 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 22 | 23 | \item{orient}{orientation, \code{vertical} or \code{horizontal}.} 24 | 25 | \item{x}{x alignment, \code{center}, \code{left} or \code{right}.} 26 | 27 | \item{y}{y alignment, \code{center}, \code{top} or \code{bottom}.} 28 | 29 | \item{backgroundColor}{background color.} 30 | 31 | \item{borderColor}{border color.} 32 | 33 | \item{borderWidth}{border width.} 34 | 35 | \item{padding}{legend padding.} 36 | 37 | \item{itemGap}{gap between legend items.} 38 | 39 | \item{itemWidth, itemHeight}{width and height of items.} 40 | 41 | \item{formatter}{default formatter.} 42 | 43 | \item{selectedMode}{selection mode.} 44 | 45 | \item{selected}{default selected state.} 46 | 47 | \item{textStyle}{textStyle.} 48 | 49 | \item{...}{any other option to pass to legend.} 50 | } 51 | \description{ 52 | Add legend 53 | } 54 | \examples{ 55 | df <- data.frame(x = LETTERS[1:10], y = runif(10, 0, 10), z = runif(10, 0, 10)) 56 | 57 | df \%>\% 58 | echart(x) \%>\% 59 | ebar(y, name = "y - serie") \%>\% 60 | ebar(z) \%>\% 61 | elegend() 62 | 63 | } 64 | -------------------------------------------------------------------------------- /man/emark_point.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \name{emark_point} 4 | \alias{emark_point} 5 | \title{mark points} 6 | \usage{ 7 | emark_point(p, which = "previous", data = list(), clickable = TRUE, 8 | symbol = "pin", symbolSize = 10, symbolRotate = NULL, large = FALSE, 9 | ...) 10 | } 11 | \arguments{ 12 | \item{p}{an echart object.} 13 | 14 | \item{which}{serie to mark lines of, takes \code{previous}, \code{all} or name of specific serie.} 15 | 16 | \item{data}{data of mark points, points to mark.} 17 | 18 | \item{clickable}{whether marked points are clickable.} 19 | 20 | \item{symbol}{symbol, see details for valid values.} 21 | 22 | \item{symbolSize}{size of symbol.} 23 | 24 | \item{symbolRotate}{symbol rotation angle, i.e.:\code{30}.} 25 | 26 | \item{large}{set to \code{TRUE} to optimise for large datasets.} 27 | 28 | \item{...}{any other options to pass to mark points.} 29 | } 30 | \description{ 31 | mark points 32 | } 33 | \details{ 34 | Valid values for \code{symbol}: 35 | \itemize{ 36 | \item{\code{circle}} 37 | \item{\code{rectangle}} 38 | \item{\code{triangle}} 39 | \item{\code{diamond}} 40 | \item{\code{emptyCircle}} 41 | \item{\code{emptyRectangle}} 42 | \item{\code{emptyTriangle}} 43 | \item{\code{emptyDiamond}} 44 | \item{\code{heart}} 45 | \item{\code{droplet}} 46 | \item{\code{pin}} 47 | \item{\code{arrow}} 48 | \item{\code{star}} 49 | } 50 | } 51 | \examples{ 52 | df <- data.frame(x = 1:150, 53 | y = round(rnorm(150, mean = 5, sd = 1), 2), 54 | z = round(rnorm(150, mean = 7, sd = 1), 2)) 55 | 56 | df \%>\% 57 | echart(x) \%>\% 58 | escatter(y) \%>\% 59 | escatter(z) \%>\% 60 | emark_point(which = "all", data = list(list(type = "min"), list(type = "max"))) 61 | 62 | } 63 | -------------------------------------------------------------------------------- /man/ecloud.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R, R/add_.R 3 | \name{ecloud} 4 | \alias{ecloud} 5 | \alias{ecloud} 6 | \alias{ecloud_} 7 | \title{Add wordcloud} 8 | \usage{ 9 | ecloud(p, freq, color, name = NULL, clickable = TRUE, 10 | center = list("50\%", "50\%"), size = list("100\%", "100\%"), 11 | textRotation = list(0, 90), autoSize = list(enable = TRUE, minSize = 12), 12 | z = 2, zlevel = 0, tooltip, ...) 13 | 14 | ecloud_(p, freq, color = NULL, name = NULL, clickable = TRUE, 15 | center = list("50\%", "50\%"), size = list("100\%", "100\%"), 16 | textRotation = list(0, 90), autoSize = list(enable = TRUE, minSize = 12), 17 | z = 2, zlevel = 0, tooltip, ...) 18 | } 19 | \arguments{ 20 | \item{p}{an echart object.} 21 | 22 | \item{freq}{frequencies.} 23 | 24 | \item{color}{color of terms.} 25 | 26 | \item{name}{name of wordcloud.} 27 | 28 | \item{clickable}{whether terms are clickable.} 29 | 30 | \item{center}{center of cloud.} 31 | 32 | \item{size}{size of cloud.} 33 | 34 | \item{textRotation}{horizontal and vertical text rotation.} 35 | 36 | \item{autoSize}{automatic text size computation.} 37 | 38 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 39 | 40 | \item{tooltip}{cutomise tooltip.} 41 | 42 | \item{...}{any other argument to pass to funnel.} 43 | } 44 | \description{ 45 | Add wordcloud serie. 46 | } 47 | \examples{ 48 | tf <- data.frame(terms = c("ECharts", "htmlwidgets", "rstats", "htmltools"), 49 | freq = c(20, 17, 15, 7), color = c("red", "orange", "yellow", "grey")) 50 | 51 | tf \%>\% 52 | echart(terms) \%>\% 53 | ecloud(freq, color) \%>\% 54 | etooltip() 55 | 56 | } 57 | \seealso{ 58 | \href{http://echarts.baidu.com/echarts2/doc/option-en.html#series-i(wordCloud)}{official wordcloud docs} 59 | } 60 | -------------------------------------------------------------------------------- /man/elinks.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/force.R, R/force_.R 3 | \name{elinks} 4 | \alias{elinks} 5 | \alias{elinks_} 6 | \title{Add edges} 7 | \usage{ 8 | elinks(p, links, source, target, weight = 1) 9 | 10 | elinks_(p, links, source, target, weight = 1) 11 | } 12 | \arguments{ 13 | \item{p}{an echart object.} 14 | 15 | \item{links}{edges data.frame.} 16 | 17 | \item{source}{source column.} 18 | 19 | \item{target}{target column.} 20 | 21 | \item{weight}{edge weight.} 22 | } 23 | \description{ 24 | Add edges for \code{\link{eforce}}. 25 | 26 | Add edges for \code{\link{eforce}}. 27 | } 28 | \examples{ 29 | let <- LETTERS[1:20] 30 | 31 | edges <- data.frame(source = sample(let, 20), target = sample(let, 20), 32 | weight = runif(20, 5, 20)) 33 | 34 | nodes <- data.frame(name = let, value = runif(20, 5, 25), group = rep(LETTERS[1:4], 5)) 35 | 36 | echart() \%>\% 37 | eforce(itemStyle = list(normal = list(label = list(show = TRUE)))) \%>\% # show labels 38 | enodes(nodes, name, value = value, category = group) \%>\% 39 | elinks(edges, source, target) 40 | 41 | echart() \%>\% 42 | eforce(itemStyle = list(normal = list(label = list(show = TRUE)))) \%>\% # show labels 43 | enodes(nodes, name, value = value, category = group) \%>\% 44 | elinks(edges, source, target, weight = 1) 45 | 46 | let <- LETTERS[1:20] 47 | 48 | edges <- data.frame(source = sample(let, 20), target = sample(let, 20), 49 | weight = runif(20, 5, 20)) 50 | 51 | nodes <- data.frame(name = let, value = runif(20, 5, 25), group = rep(LETTERS[1:4], 5)) 52 | 53 | echart() \%>\% 54 | eforce_(itemStyle = list(normal = list(label = list(show = TRUE)))) \%>\% # show labels 55 | enodes_(nodes, "name", value = "value", category = "group") \%>\% 56 | elinks_(edges, "source", "target") 57 | 58 | } 59 | \seealso{ 60 | \code{\link{enodes}} \code{\link{eforce}} 61 | } 62 | -------------------------------------------------------------------------------- /man/candlestick.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R, R/add_.R 3 | \name{ecandle} 4 | \alias{ecandle} 5 | \alias{candlestick} 6 | \alias{ecandle_} 7 | \title{Add candlestick} 8 | \usage{ 9 | ecandle(p, opening, closing, low, high, name = NULL, clickable = TRUE, 10 | z = 2, zlevel = 0, ...) 11 | 12 | ecandle_(p, opening, closing, low, high, name = NULL, clickable = TRUE, 13 | z = 2, zlevel = 0, ...) 14 | } 15 | \arguments{ 16 | \item{p}{an echart object.} 17 | 18 | \item{opening, closing, low, high}{stock prices.} 19 | 20 | \item{name}{name of serie.} 21 | 22 | \item{clickable}{whether serie is clickable.} 23 | 24 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 25 | 26 | \item{...}{any other options to pass to candlessticks.} 27 | } 28 | \description{ 29 | Add candlestick bars. 30 | } 31 | \examples{ 32 | # generate data 33 | date <- c("2017-01-01", "2017-01-02", "2017-01-03", "2017-01-04", "2017-03-05", 34 | "2017-01-06", "2017-01-07") 35 | stock <- data.frame(date = date, 36 | opening = c(200.60, 200.22, 198.43, 199.05, 203.54, 203.40, 208.34), 37 | closing = c(200.72, 198.85, 199.05, 203.73, 204.08, 208.11, 211.88), 38 | low = c(197.82, 198.07, 197.90, 198.10, 202.00, 201.50, 207.60), 39 | high = c(203.32, 200.67, 200.00, 203.95, 204.90, 208.44, 213.17)) 40 | 41 | js <- htmlwidgets::JS("function(params){ 42 | var res = 'opening: ' + params.value[0] + '
' + 'closing: ' + params.value[3]; 43 | return res}") 44 | 45 | stock \%>\% 46 | echart(date) \%>\% 47 | ecandle(opening, closing, low, high, barMaxWidth = 20) \%>\% 48 | etooltip(trigger = "item", formatter = js) \%>\% 49 | etheme("macarons") 50 | 51 | } 52 | \seealso{ 53 | \href{http://echarts.baidu.com/echarts2/doc/option-en.html#title~series-i(k)}{candlestick official docs} 54 | } 55 | -------------------------------------------------------------------------------- /man/efunnel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R, R/add_.R 3 | \name{efunnel} 4 | \alias{efunnel} 5 | \alias{efunnel} 6 | \alias{efunnel_} 7 | \title{Add funnel} 8 | \usage{ 9 | efunnel(p, serie, name = NULL, clickable = TRUE, legendHoverLink = TRUE, 10 | sort = "descending", min = NULL, max = NULL, x = 80, y = 60, 11 | x2 = 80, y2 = 60, width = NULL, height = NULL, 12 | funnelAlign = "center", minSize = "0\%", maxSize = "100\%", gap = 0, 13 | tooltip, ...) 14 | 15 | efunnel_(p, serie, name = NULL, clickable = TRUE, legendHoverLink = TRUE, 16 | sort = "descending", min = 0, max = NULL, x = 80, y = 60, x2 = 80, 17 | y2 = 60, width = NULL, height = NULL, funnelAlign = "center", 18 | minSize = "0\%", maxSize = "100\%", gap = 0, tooltip, ...) 19 | } 20 | \arguments{ 21 | \item{p}{an echart object.} 22 | 23 | \item{serie}{values to plot.} 24 | 25 | \item{name}{name of serie.} 26 | 27 | \item{clickable}{whether segments are clickable.} 28 | 29 | \item{legendHoverLink}{enables legend hover link.} 30 | 31 | \item{sort}{data sorting, takes \code{descending} or \code{ascending}.} 32 | 33 | \item{min, max}{minimum and maximum values of funnel.} 34 | 35 | \item{x, y, x2, y2}{coordinates of funnel.} 36 | 37 | \item{width, height}{width and height of funnel.} 38 | 39 | \item{funnelAlign}{alignment of funnel takes \code{left}, \code{right} and \code{center}.} 40 | 41 | \item{minSize, maxSize}{minimum and maximum size of funnel.} 42 | 43 | \item{gap}{gap between segments.} 44 | 45 | \item{tooltip}{cutomise tooltip.} 46 | 47 | \item{...}{any other argument to pass to funnel.} 48 | } 49 | \description{ 50 | Add funnel 51 | } 52 | \examples{ 53 | funnel <- data.frame(stage = c("View", "Click", "Purchase"), value = c(80, 30, 20)) 54 | 55 | funnel \%>\% 56 | echart(stage) \%>\% 57 | efunnel(value) 58 | 59 | } 60 | \seealso{ 61 | \href{http://echarts.baidu.com/echarts2/doc/option-en.html#series-i(funnel)}{official funnel docs} 62 | } 63 | -------------------------------------------------------------------------------- /man/egauge.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R, R/add_.R 3 | \name{egauge} 4 | \alias{egauge} 5 | \alias{egauge} 6 | \alias{egauge_} 7 | \title{Add gauge} 8 | \usage{ 9 | egauge(p, value, indicator = "", name = NULL, clickable = FALSE, 10 | legendHoverLink = TRUE, center = list("50\%", "50\%"), 11 | radius = list("0\%", "75\%"), startAngle = 225, endAngle = -45, 12 | min = 0, max = 100, splitNumber = 10, z = 2, zlevel = 0, tooltip, 13 | ...) 14 | 15 | egauge_(p, value, indicator = "", name = NULL, clickable = FALSE, 16 | legendHoverLink = TRUE, center = list("50\%", "50\%"), 17 | radius = list("0\%", "75\%"), startAngle = 225, endAngle = -45, 18 | min = 0, max = 100, splitNumber = 10, z = 2, zlevel = 0, tooltip, 19 | ...) 20 | } 21 | \arguments{ 22 | \item{p}{an echart object.} 23 | 24 | \item{value}{value to plot.} 25 | 26 | \item{indicator}{indicator appearing in center of gauge.} 27 | 28 | \item{name}{name of serie.} 29 | 30 | \item{clickable}{whether the item is clickable.} 31 | 32 | \item{legendHoverLink}{enables legend hover link.} 33 | 34 | \item{center}{center of gauge in pixels of percent.} 35 | 36 | \item{radius}{radius of gauge in pixels of percent.} 37 | 38 | \item{startAngle, endAngle}{start and end angles of gauge.} 39 | 40 | \item{min, max}{minimum and maximum of gauge.} 41 | 42 | \item{splitNumber}{number of segments.} 43 | 44 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 45 | 46 | \item{tooltip}{customise tooltip.} 47 | 48 | \item{...}{any other arguments.} 49 | } 50 | \description{ 51 | Add gauge. 52 | } 53 | \examples{ 54 | echart() \%>\% 55 | egauge(85, "SPEED") 56 | 57 | echart() \%>\% 58 | egauge(25, "SPEED") \%>\% 59 | etheme("helianthus") 60 | 61 | echart() \%>\% 62 | egauge(63, "PERCENT") \%>\% 63 | etheme("dark") 64 | 65 | } 66 | \seealso{ 67 | \href{http://echarts.baidu.com/echarts2/doc/option-en.html#series-i(gauge)}{official gauge docs} 68 | } 69 | -------------------------------------------------------------------------------- /man/emap_roam.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/options.R 3 | \name{emap_roam} 4 | \alias{emap_roam} 5 | \title{Add Zoom and roam controller} 6 | \usage{ 7 | emap_roam(p, show = TRUE, zlevel = 0, z = 4, x = "left", y = "top", 8 | width = 80, height = 120, backgroundColor = "rgba(0,0,0,0)", 9 | borderColor = "#ccc", borderWidth = 0, padding = 5, 10 | fillerColor = "#fff", handleColor = "#6495ed", step = 15, 11 | mapTypeControl = NULL, ...) 12 | } 13 | \arguments{ 14 | \item{p}{an echart object.} 15 | 16 | \item{show}{set to \code{TRUE} to show the controller} 17 | 18 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 19 | 20 | \item{x}{x position; \code{left} or \code{right}.} 21 | 22 | \item{y}{y posotion; \code{top} or \code{bottom}.} 23 | 24 | \item{width, height}{dimensions of controller.} 25 | 26 | \item{backgroundColor}{background color.} 27 | 28 | \item{borderColor}{border color.} 29 | 30 | \item{borderWidth}{width of border.} 31 | 32 | \item{padding}{padding.} 33 | 34 | \item{fillerColor}{filler color.} 35 | 36 | \item{handleColor}{color of handle.} 37 | 38 | \item{step}{moving step of the 4 direction roam in px.} 39 | 40 | \item{mapTypeControl}{ou can specify every single mapType when multiple map in a chart at the same time, such as: \code{list({ china = FALSE, world = TRUE})}.} 41 | 42 | \item{...}{any other option to pass to controller.} 43 | } 44 | \description{ 45 | Add zoom and roam controller to map. 46 | } 47 | \examples{ 48 | coords <- data.frame(city = c("London", "New York", "Beijing", "Sydney"), 49 | lon = c(-0.1167218, -73.98002, 116.3883, 151.18518), 50 | lat = c(51.49999, 40.74998, 39.92889, -33.92001), 51 | values = runif(4, 10, 20)) 52 | 53 | coords \%>\% 54 | echart(city) \%>\% 55 | emap() \%>\% 56 | emap_coords(lon, lat) \%>\% 57 | emap_points(values) \%>\% 58 | emap_roam(mapTypeControl = list(world = TRUE)) 59 | 60 | } 61 | \seealso{ 62 | \href{http://echarts.baidu.com/echarts2/doc/option-en.html#title~roamController}{official roam controller docs} 63 | } 64 | -------------------------------------------------------------------------------- /man/ebar.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R, R/add_.R 3 | \name{ebar} 4 | \alias{ebar} 5 | \alias{ebar} 6 | \alias{ebar_} 7 | \title{Add bars} 8 | \usage{ 9 | ebar(p, serie, name = NULL, stack = NULL, clickable = TRUE, 10 | xAxisIndex = 0, yAxisIndex = 0, barGap = "100\%", 11 | barCategoryGap = "20\%", legendHoverLink = TRUE, z = 2, zlevel = 0, 12 | ...) 13 | 14 | ebar_(p, serie, name = NULL, stack = NULL, clickable = TRUE, 15 | xAxisIndex = 0, yAxisIndex = 0, barGap = "100\%", 16 | barCategoryGap = "20\%", legendHoverLink = TRUE, z = 2, zlevel = 0, 17 | ...) 18 | } 19 | \arguments{ 20 | \item{p}{an echart object.} 21 | 22 | \item{serie}{value column name to plot.} 23 | 24 | \item{name}{of serie.} 25 | 26 | \item{stack}{name of the stack.} 27 | 28 | \item{clickable}{whether plot is clickable.} 29 | 30 | \item{xAxisIndex, yAxisIndex}{axis indexes.} 31 | 32 | \item{barGap, barCategoryGap}{distance between each bar.} 33 | 34 | \item{legendHoverLink}{enables legend hover links.} 35 | 36 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 37 | 38 | \item{...}{any other argument to pass to the serie.} 39 | } 40 | \description{ 41 | Add bar serie. 42 | } 43 | \examples{ 44 | \dontrun{ 45 | mtcars \%>\% 46 | echart_("mpg") \%>\% 47 | ebar_("qsec") 48 | 49 | mtcars \%>\% 50 | echart_("disp") \%>\% 51 | ebar_("mpg", stack = "grp") \%>\% # stack 52 | ebar_("qsec", stack = "grp") \%>\% # stack 53 | ebar_("wt", stack = "grp2") \%>\% # not stacked 54 | etooltip(trigger = "item") \%>\% 55 | elegend() \%>\% 56 | etoolbox_magic(type = list("stack", "tiled")) \%>\% 57 | etoolbox_restore() 58 | 59 | df <- data.frame(x = LETTERS[1:4], y = runif(4, 0, 20), z = runif(4, 10, 15), w = runif(4, 15, 30)) 60 | 61 | df \%>\% 62 | echart(x) \%>\% 63 | ebar(y, stack = "grp") \%>\% 64 | ebar(z, stack = "grp") \%>\% 65 | ebar(w, "grp2") \%>\% 66 | etheme("macarons") \%>\% 67 | etooltip(trigger = "axis") \%>\% 68 | etheme("blue") 69 | } 70 | 71 | } 72 | \seealso{ 73 | \href{http://echarts.baidu.com/echarts2/doc/option-en.html#series-i(bar)}{official bar options docs} 74 | } 75 | -------------------------------------------------------------------------------- /man/eanimation.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/options.R 3 | \name{eanimation} 4 | \alias{eanimation} 5 | \title{Add animations} 6 | \usage{ 7 | eanimation(p, animation = TRUE, addDataAnimation = TRUE, 8 | animationThreshold = 2000, animationDuration = 2000, 9 | animationDurationUpdate = 500, animationEasing = "ExponentialOut", ...) 10 | } 11 | \arguments{ 12 | \item{p}{an echart objects.} 13 | 14 | \item{animation}{whether to show the initial animation.} 15 | 16 | \item{addDataAnimation}{specifies whether the dynamic data interface animation will be enabled.} 17 | 18 | \item{animationThreshold}{threshold of animated elements.} 19 | 20 | \item{animationDuration}{duration of animation, in ms.} 21 | 22 | \item{animationDurationUpdate}{duration of the update animation, in ms.} 23 | 24 | \item{animationEasing}{easing effect, see details for valid values.} 25 | 26 | \item{...}{any other options.} 27 | } 28 | \description{ 29 | Add animations 30 | } 31 | \details{ 32 | \itemize{ 33 | \item{\code{linear}} 34 | \item{\code{QuadraticIn}} 35 | \item{\code{QuadraticOut}} 36 | \item{\code{QuadraticInOut}} 37 | \item{\code{CubicIn}} 38 | \item{\code{CubicOut}} 39 | \item{\code{CubicInOut}} 40 | \item{\code{QuarticIn}} 41 | \item{\code{QuarticOut}} 42 | \item{\code{QuarticInOut}} 43 | \item{\code{SinusoidalIn}} 44 | \item{\code{SinusoidalOut}} 45 | \item{\code{SinusoidalInOut}} 46 | \item{\code{ExponentialIn}} 47 | \item{\code{ExponentialOut}} 48 | \item{\code{ExponentialInOut}} 49 | \item{\code{CircularIn}} 50 | \item{\code{CircularOut}} 51 | \item{\code{CircularInOut}} 52 | \item{\code{ElasticIn}} 53 | \item{\code{ElasticOut}} 54 | \item{\code{ElasticInOut}} 55 | \item{\code{BackIn}} 56 | \item{\code{BackOut}} 57 | \item{\code{BackInOut}} 58 | \item{\code{BounceIn}} 59 | \item{\code{BounceOut}} 60 | \item{\code{BounceInOut}} 61 | } 62 | } 63 | \examples{ 64 | mtcars \%>\% 65 | echart(mpg) \%>\% 66 | ebar(qsec) \%>\% 67 | eanimation(animationEasing = "BounceIn") 68 | 69 | mtcars \%>\% 70 | echart(mpg) \%>\% 71 | escatter(qsec, drat, symbolSize = 20) \%>\% 72 | eanimation(animationEasing = "CubicInOut") 73 | 74 | } 75 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export("%>%") 4 | export(eanimation) 5 | export(earea) 6 | export(earea_) 7 | export(ebar) 8 | export(ebar_) 9 | export(ecandle) 10 | export(ecandle_) 11 | export(echart) 12 | export(echart_) 13 | export(echartsOutput) 14 | export(echartsProxy) 15 | export(echord) 16 | export(echord_) 17 | export(ecloud) 18 | export(ecloud_) 19 | export(ecolorbar) 20 | export(edata) 21 | export(edata_) 22 | export(eforce) 23 | export(eforce_) 24 | export(efunnel) 25 | export(efunnel_) 26 | export(egauge) 27 | export(egauge_) 28 | export(egrid) 29 | export(eheatmap) 30 | export(eheatmap_) 31 | export(elegend) 32 | export(eline) 33 | export(eline_) 34 | export(elinks) 35 | export(elinks_) 36 | export(eload) 37 | export(emap) 38 | export(emap_) 39 | export(emap_choropleth) 40 | export(emap_choropleth_) 41 | export(emap_coords) 42 | export(emap_coords_) 43 | export(emap_heat) 44 | export(emap_heat_) 45 | export(emap_line_effect) 46 | export(emap_lines) 47 | export(emap_lines_) 48 | export(emap_points) 49 | export(emap_points_) 50 | export(emap_roam) 51 | export(emark_line) 52 | export(emark_point) 53 | export(enodes) 54 | export(enodes_) 55 | export(eoptions) 56 | export(epie) 57 | export(epie_) 58 | export(eradar) 59 | export(eradar_) 60 | export(escatter) 61 | export(escatter_) 62 | export(etheme) 63 | export(etitle) 64 | export(etoolbox) 65 | export(etoolbox_feature) 66 | export(etoolbox_full) 67 | export(etoolbox_magic) 68 | export(etoolbox_mark) 69 | export(etoolbox_restore) 70 | export(etoolbox_save) 71 | export(etoolbox_view) 72 | export(etoolbox_zoom) 73 | export(etooltip) 74 | export(etreemap) 75 | export(etreemap_) 76 | export(evenn) 77 | export(evenn_) 78 | export(exAxis) 79 | export(exAxis_category) 80 | export(exAxis_log) 81 | export(exAxis_time) 82 | export(exAxis_value) 83 | export(eyAxis) 84 | export(eyAxis_category) 85 | export(eyAxis_log) 86 | export(eyAxis_time) 87 | export(eyAxis_value) 88 | export(ezoom) 89 | export(group_by) 90 | export(group_by_) 91 | export(igraph_links) 92 | export(igraph_nodes) 93 | export(renderEcharts) 94 | import(htmlwidgets) 95 | importFrom(dplyr,group_by) 96 | importFrom(dplyr,group_by_) 97 | importFrom(magrittr,"%>%") 98 | importFrom(methods,is) 99 | -------------------------------------------------------------------------------- /man/epie.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R, R/add_.R 3 | \name{epie} 4 | \alias{epie} 5 | \alias{epie} 6 | \alias{epie_} 7 | \title{Add pie} 8 | \usage{ 9 | epie(p, serie, name = NULL, clickable = TRUE, legendHoverLink = TRUE, 10 | center = list("50\%", "50\%"), radius = list(0, "75\%"), 11 | startAngle = 90, minAngle = 0, clockWise = TRUE, roseType = NULL, 12 | selectedOffset = 10, selectedMode = TRUE, z = 2, zlevel = 0, ...) 13 | 14 | epie_(p, serie, name = NULL, clickable = TRUE, legendHoverLink = TRUE, 15 | center = list("50\%", "50\%"), radius = list(0, "75\%"), 16 | startAngle = 90, minAngle = 0, clockWise = TRUE, roseType = NULL, 17 | selectedOffset = 10, selectedMode = TRUE, z = 2, zlevel = 0, ...) 18 | } 19 | \arguments{ 20 | \item{p}{an echart object.} 21 | 22 | \item{serie}{value column name to plot.} 23 | 24 | \item{name}{of serie.} 25 | 26 | \item{clickable}{whether plot is clickable.} 27 | 28 | \item{legendHoverLink}{enables legend hover links.} 29 | 30 | \item{center}{coordinates of the center.} 31 | 32 | \item{radius}{radius in pixels or percent.} 33 | 34 | \item{startAngle, minAngle}{start and minimum angle.} 35 | 36 | \item{clockWise}{whether to display slices in clockwise direction} 37 | 38 | \item{roseType}{type of pie, takes \code{NULL}, \code{area} or \code{radius}, see examples.} 39 | 40 | \item{selectedOffset}{offset of selected slice.} 41 | 42 | \item{selectedMode}{whether slices are selectable.} 43 | 44 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 45 | 46 | \item{...}{any other option to pass to serie.} 47 | } 48 | \description{ 49 | Add pie chart 50 | } 51 | \examples{ 52 | pie <- data.frame(name = c("banana", "apple", "pineapple", "onion"), 53 | value = c(26, 15, 12, 9)) 54 | 55 | pie \%>\% 56 | echart(name) \%>\% 57 | epie(value) 58 | 59 | pie \%>\% 60 | echart(name) \%>\% 61 | epie(value, roseType = "area") \%>\% 62 | etheme("helianthus") 63 | 64 | pie \%>\% 65 | echart(name) \%>\% 66 | epie(value, roseType = "radius") \%>\% 67 | etheme("blue") 68 | 69 | } 70 | \seealso{ 71 | \href{http://echarts.baidu.com/echarts2/doc/option-en.html#series-i(pie)}{official pie options docs} 72 | } 73 | -------------------------------------------------------------------------------- /man/emark_line.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \name{emark_line} 4 | \alias{emark_line} 5 | \title{mark line} 6 | \usage{ 7 | emark_line(p, which = "previous", data = list(), clickable = TRUE, 8 | symbol = list("circle", "arrow"), symbolSize = list(2, 4), 9 | symbolRotate = NULL, large = FALSE, smooth = FALSE, precision = 2, 10 | bundling = list(enable = FALSE, maxTurningAngle = 45), z = 2, 11 | zlevel = 0, ...) 12 | } 13 | \arguments{ 14 | \item{p}{an echart object.} 15 | 16 | \item{which}{serie to mark lines of, takes \code{previous}, \code{all} or name of specific serie.} 17 | 18 | \item{data}{data of mark points, points to mark.} 19 | 20 | \item{clickable}{whether marked points are clickable.} 21 | 22 | \item{symbol}{symbol, see details for valid values.} 23 | 24 | \item{symbolSize}{size of symbol.} 25 | 26 | \item{symbolRotate}{symbol rotation angle, i.e.:\code{30}.} 27 | 28 | \item{large}{set to \code{TRUE} to optimise for large datasets.} 29 | 30 | \item{smooth}{whether to smooth line.} 31 | 32 | \item{precision}{decimal precision.} 33 | 34 | \item{bundling}{line bundling.} 35 | 36 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 37 | 38 | \item{...}{any other options to pass to mark points.} 39 | } 40 | \description{ 41 | mark line 42 | } 43 | \details{ 44 | Valid values for \code{symbol}: 45 | \itemize{ 46 | \item{\code{circle}} 47 | \item{\code{rectangle}} 48 | \item{\code{triangle}} 49 | \item{\code{diamond}} 50 | \item{\code{emptyCircle}} 51 | \item{\code{emptyRectangle}} 52 | \item{\code{emptyTriangle}} 53 | \item{\code{emptyDiamond}} 54 | \item{\code{heart}} 55 | \item{\code{droplet}} 56 | \item{\code{pin}} 57 | \item{\code{arrow}} 58 | \item{\code{star}} 59 | } 60 | } 61 | \examples{ 62 | df <- data.frame(x = c("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"), 63 | radio = c(320, 332, 301, 334, 390, 330, 320), 64 | social = c(120, 132, 101, 134, 90, 230, 210)) 65 | 66 | df \%>\% 67 | echart(x) \%>\% 68 | ebar(radio, stack = "grp") \%>\% 69 | ebar(social, stack = "grp") \%>\% 70 | emark_line(data = list(list(type = "max")), clickable = FALSE) \%>\% 71 | etooltip(axisPointer = list(type = "shadow")) \%>\% 72 | etoolbox_full() \%>\% 73 | etoolbox_magic(type = list("tiled", "stack", "line", "bar")) 74 | 75 | } 76 | -------------------------------------------------------------------------------- /man/eradar.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R, R/add_.R 3 | \name{eradar} 4 | \alias{eradar} 5 | \alias{eradar} 6 | \alias{eradar_} 7 | \title{Add radar} 8 | \usage{ 9 | eradar(p, serie, name = NULL, clickable = TRUE, symbol = NULL, 10 | symbolSize = 4, symbolRotate = NULL, legendHoverLink = TRUE, 11 | polarIndex = 0, z = 2, zlevel = 0, ...) 12 | 13 | eradar_(p, serie, name = NULL, clickable = TRUE, symbol = NULL, 14 | symbolSize = 4, symbolRotate = NULL, legendHoverLink = TRUE, 15 | polarIndex = 0, z = 2, zlevel = 0, ...) 16 | } 17 | \arguments{ 18 | \item{p}{an echart object.} 19 | 20 | \item{serie}{value column name to plot.} 21 | 22 | \item{name}{of serie.} 23 | 24 | \item{clickable}{whether plot is clickable.} 25 | 26 | \item{symbol}{marker, see details for valid values.} 27 | 28 | \item{symbolSize}{of symbol.} 29 | 30 | \item{symbolRotate}{angle by which symbol is rotated, i.e.: \code{30}.} 31 | 32 | \item{legendHoverLink}{enables legend hover links.} 33 | 34 | \item{polarIndex}{polar coordinates index.} 35 | 36 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 37 | 38 | \item{...}{any other options to pass to the serie.} 39 | } 40 | \description{ 41 | Add radar chart. 42 | } 43 | \details{ 44 | Valid values for \code{symbol}: 45 | \itemize{ 46 | \item{\code{circle}} 47 | \item{\code{rectangle}} 48 | \item{\code{triangle}} 49 | \item{\code{diamond}} 50 | \item{\code{emptyCircle}} 51 | \item{\code{emptyRectangle}} 52 | \item{\code{emptyTriangle}} 53 | \item{\code{emptyDiamond}} 54 | \item{\code{heart}} 55 | \item{\code{droplet}} 56 | \item{\code{pin}} 57 | \item{\code{arrow}} 58 | \item{\code{star}} 59 | } 60 | } 61 | \examples{ 62 | radar <- data.frame(axis = rep(LETTERS[1:6], 4), grp = sample(LETTERS[4:9], 24, replace = TRUE), 63 | value = runif(24, 2, 10)) 64 | 65 | radar \%>\% 66 | group_by(grp) \%>\% 67 | echart(axis) \%>\% 68 | eradar(value, symbolSize = 0) \%>\% 69 | elegend() \%>\% 70 | etheme("macarons") 71 | 72 | radar \%>\% 73 | group_by(grp) \%>\% 74 | echart(axis) \%>\% 75 | eradar(value, symbolSize = htmlwidgets::JS("function(value){return(value)}")) \%>\% 76 | elegend() \%>\% 77 | etheme("roma") 78 | 79 | } 80 | \seealso{ 81 | \href{http://echarts.baidu.com/echarts2/doc/option-en.html#series-i(radar)}{official radar options docs} 82 | } 83 | -------------------------------------------------------------------------------- /man/etooltip.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/options.R 3 | \name{etooltip} 4 | \alias{etooltip} 5 | \title{Add tooltip} 6 | \usage{ 7 | etooltip(p, show = TRUE, trigger = "axis", zlevel = 1, z = 8, 8 | showContent = TRUE, position = NULL, formatter = NULL, 9 | islandFormatter = "{a} < br/>{b} : {c}", showDelay = 20, 10 | hideDelay = 100, transitionDuration = 0.4, enterable = FALSE, 11 | backgroundColor = "rgba(0,0,0,0.7)", borderColor = "#333", 12 | borderRadius = 4, borderWidth = 0, padding = 5, axisPointer, textStyle, 13 | ...) 14 | } 15 | \arguments{ 16 | \item{p}{an echart object.} 17 | 18 | \item{show}{whether to show the tooltip.} 19 | 20 | \item{trigger}{element that triggers the tooltip, takes \code{item} or \code{axis}.} 21 | 22 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 23 | 24 | \item{showContent}{whether to show the content of tooltip.} 25 | 26 | \item{position}{specifies position, pass a \code{list}, like \code{list(10, 10)}, fixed position; pass a function, 27 | like \code{htmlwidgets::JS("function([x, y]) {return [x + 10, y + 10]}")}} 28 | 29 | \item{formatter}{see \href{official documentation}{http://echarts.baidu.com/echarts2/doc/option-en.html#tooltip.formatter} for more details.} 30 | 31 | \item{islandFormatter}{island content formatter.} 32 | 33 | \item{showDelay}{number of milliseconds the tooltip shows.} 34 | 35 | \item{hideDelay}{number of milliseconds to wait until the tooltip is hidden when mouse out from a point or chart.} 36 | 37 | \item{transitionDuration}{duration in seconds of the animated transition.} 38 | 39 | \item{enterable}{whether to let the mouse go into the tip dom.} 40 | 41 | \item{backgroundColor}{background color.} 42 | 43 | \item{borderColor}{border color.} 44 | 45 | \item{borderRadius}{border radius.} 46 | 47 | \item{borderWidth}{border width.} 48 | 49 | \item{padding}{padding.} 50 | 51 | \item{axisPointer}{axis pointer, triggered by axis.} 52 | 53 | \item{textStyle}{tooltip text size.} 54 | 55 | \item{...}{any other options to pass to tooltip.} 56 | } 57 | \description{ 58 | Customise tooltip. 59 | } 60 | \examples{ 61 | mtcars \%>\% 62 | echart(disp) \%>\% 63 | eline(mpg) \%>\% 64 | eline(qsec) \%>\% 65 | etooltip(trigger = "axis") 66 | 67 | } 68 | \seealso{ 69 | \href{http://echarts.baidu.com/echarts2/doc/option-en.html#title~tooltip}{official tooltip docs} 70 | } 71 | -------------------------------------------------------------------------------- /man/escatter.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R, R/add_.R 3 | \name{escatter} 4 | \alias{escatter} 5 | \alias{escatter} 6 | \alias{escatter_} 7 | \title{Add scatter} 8 | \usage{ 9 | escatter(p, serie, size = NULL, name = NULL, clickable = TRUE, 10 | symbol = NULL, symbolSize = 4, symbolRotate = NULL, large = FALSE, 11 | largeThreshold = 2000, legendHoverLink = TRUE, z = 2, zlevel = 0, ...) 12 | 13 | escatter_(p, serie, size = NULL, name = NULL, clickable = TRUE, 14 | symbol = NULL, symbolSize = 4, symbolRotate = NULL, large = FALSE, 15 | largeThreshold = 2000, legendHoverLink = TRUE, z = 2, zlevel = 0, ...) 16 | } 17 | \arguments{ 18 | \item{p}{an echart object.} 19 | 20 | \item{serie}{value column name to plot.} 21 | 22 | \item{size}{size of points/bubble.} 23 | 24 | \item{name}{of serie.} 25 | 26 | \item{clickable}{whether plot is clickable.} 27 | 28 | \item{symbol}{marker, see details for valid values.} 29 | 30 | \item{symbolSize}{of symbol.} 31 | 32 | \item{symbolRotate}{angle by which symbol is rotated, i.e.: \code{30}.} 33 | 34 | \item{large}{enables large scale scatter.} 35 | 36 | \item{largeThreshold}{threshold of large scale scatter anto-switch.} 37 | 38 | \item{legendHoverLink}{enables legend hover links.} 39 | 40 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 41 | 42 | \item{...}{any other options to pass to the serie.} 43 | } 44 | \description{ 45 | Add scatter serie. 46 | } 47 | \details{ 48 | Valid values for \code{symbol}: 49 | \itemize{ 50 | \item{\code{circle}} 51 | \item{\code{rectangle}} 52 | \item{\code{triangle}} 53 | \item{\code{diamond}} 54 | \item{\code{emptyCircle}} 55 | \item{\code{emptyRectangle}} 56 | \item{\code{emptyTriangle}} 57 | \item{\code{emptyDiamond}} 58 | \item{\code{heart}} 59 | \item{\code{droplet}} 60 | \item{\code{pin}} 61 | \item{\code{arrow}} 62 | \item{\code{star}} 63 | } 64 | } 65 | \examples{ 66 | mtcars \%>\% 67 | echart(disp) \%>\% 68 | escatter(mpg, symbol = "emptyCircle") \%>\% 69 | exAxis() 70 | 71 | mtcars \%>\% 72 | echart(disp) \%>\% 73 | escatter(mpg, qsec, symbolSize = 15) \%>\% 74 | exAxis_value(axisLabel = list(show = FALSE)) \%>\% 75 | etheme("mint") \%>\% 76 | eanimation(animationEasing = "ElasticOut") 77 | 78 | } 79 | \seealso{ 80 | \href{http://echarts.baidu.com/echarts2/doc/option-en.html#series-i(scatter)}{official scatter options docs} 81 | } 82 | -------------------------------------------------------------------------------- /man/eforce.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/force.R, R/force_.R 3 | \name{eforce} 4 | \alias{eforce} 5 | \alias{eforce_} 6 | \title{Build force network} 7 | \usage{ 8 | eforce(p, name = NULL, large = FALSE, center = list("50\%", "50\%"), 9 | roam = FALSE, size = "100\%", minRadius = 10, maxRadius = 20, 10 | linkSymbol = "none", linkSymbolSize = list(10, 15), scaling = 1, 11 | gravity = 1, draggable = TRUE, useWorker = TRUE, steps = 1, z = 2, 12 | zlevel = 0, ...) 13 | 14 | eforce_(p, name = NULL, large = FALSE, center = list("50\%", "50\%"), 15 | roam = FALSE, size = "100\%", minRadius = 10, maxRadius = 20, 16 | linkSymbol = "none", linkSymbolSize = list(10, 15), scaling = 1, 17 | gravity = 1, draggable = TRUE, useWorker = TRUE, steps = 1, z = 2, 18 | zlevel = 0, ...) 19 | } 20 | \arguments{ 21 | \item{p}{an echart objects.} 22 | 23 | \item{name}{name of network.} 24 | 25 | \item{large}{set to \code{TRUE} to optimise for large graphs.} 26 | 27 | \item{center}{center of network.} 28 | 29 | \item{roam}{set to \code{TRUE} to enable zoom and drag.} 30 | 31 | \item{size}{size of layout.} 32 | 33 | \item{minRadius, maxRadius}{minimum and maximum radius of nodes.} 34 | 35 | \item{linkSymbol}{can be set to \code{arrow}.} 36 | 37 | \item{linkSymbolSize}{size of \code{symbol}.} 38 | 39 | \item{scaling}{scaling factor.} 40 | 41 | \item{gravity}{centripetal force coefficient.} 42 | 43 | \item{draggable}{set to \code{TRUE} to allow dragging nodes.} 44 | 45 | \item{useWorker}{specifies whether to put layout calculation into web worker when the browser supports web worker.} 46 | 47 | \item{steps}{the number of iterations of each frame layout calculation.} 48 | 49 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 50 | 51 | \item{...}{any other options to pass to serie.} 52 | } 53 | \description{ 54 | Build force network 55 | 56 | Plot force directed graph. 57 | } 58 | \examples{ 59 | let <- LETTERS[1:20] 60 | 61 | edges <- data.frame(source = sample(let, 20), target = sample(let, 20), 62 | weight = runif(20, 5, 20)) 63 | 64 | nodes <- data.frame(name = let, value = runif(20, 5, 25), group = rep(LETTERS[1:4], 5)) 65 | 66 | echart() \%>\% 67 | eforce(itemStyle = list(normal = list(label = list(show = TRUE)))) \%>\% # show labels 68 | enodes(nodes, name, value = value, category = group) \%>\% 69 | elinks(edges, source, target) 70 | 71 | } 72 | \seealso{ 73 | \code{\link{enodes}} \code{\link{eforce}} 74 | } 75 | -------------------------------------------------------------------------------- /man/emap_points.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R, R/add_.R 3 | \name{emap_points} 4 | \alias{emap_points} 5 | \alias{emap_points} 6 | \alias{emap_points_} 7 | \title{Add map points} 8 | \usage{ 9 | emap_points(p, serie, clickable = TRUE, symbol = "pin", symbolSize = 10, 10 | symbolRotate = NULL, large = FALSE, itemStyle = NULL, ...) 11 | 12 | emap_points_(p, serie, clickable = TRUE, symbol = "pin", symbolSize = 10, 13 | symbolRotate = NULL, large = FALSE, itemStyle = NULL, ...) 14 | } 15 | \arguments{ 16 | \item{p}{an echart objects.} 17 | 18 | \item{serie}{values to plot.} 19 | 20 | \item{clickable}{whether points are clickable.} 21 | 22 | \item{symbol}{point symbol, see details for valid values.} 23 | 24 | \item{symbolSize}{size of points.} 25 | 26 | \item{symbolRotate}{angle by which symbol is rotated, i.e.: \code{30}.} 27 | 28 | \item{large}{whether to optimise for large datasets: 2K points +.} 29 | 30 | \item{itemStyle}{cutomise points.} 31 | 32 | \item{...}{any other option to pass to points.} 33 | } 34 | \description{ 35 | Add map points 36 | } 37 | \details{ 38 | Valid values for \code{symbol}: 39 | \itemize{ 40 | \item{\code{circle}} 41 | \item{\code{rectangle}} 42 | \item{\code{triangle}} 43 | \item{\code{diamond}} 44 | \item{\code{emptyCircle}} 45 | \item{\code{emptyRectangle}} 46 | \item{\code{emptyTriangle}} 47 | \item{\code{emptyDiamond}} 48 | \item{\code{heart}} 49 | \item{\code{droplet}} 50 | \item{\code{pin}} 51 | \item{\code{arrow}} 52 | \item{\code{star}} 53 | } 54 | } 55 | \examples{ 56 | \dontrun{ 57 | coords <- data.frame(city = c("London", "New York", "Beijing", "Sydney"), 58 | lon = c(-0.1167218, -73.98002, 116.3883, 151.18518), 59 | lat = c(51.49999, 40.74998, 39.92889, -33.92001), 60 | values = runif(4, 10, 20)) 61 | 62 | coords \%>\% 63 | echart_("city") \%>\% 64 | emap() \%>\% 65 | emap_coords_("lon", "lat") \%>\% 66 | emap_points_("values") 67 | 68 | coords2 <- data.frame(city = "Rio", lon = -43.172896, lat = -22.906847, value = 15) 69 | 70 | coords \%>\% 71 | echart_("city") \%>\% 72 | emap() \%>\% 73 | emap_coords_("lon", "lat") \%>\% 74 | emap_points_("values", symbolSize = 5) \%>\% 75 | edata_(coords2, "city") \%>\% 76 | emap() \%>\% 77 | emap_coords_("lon", "lat") \%>\% 78 | emap_points_("value", symbol = "emptyCircle", effect = list(show = TRUE, shadowBlur = 10)) \%>\% 79 | etheme("helianthus") 80 | } 81 | 82 | } 83 | \seealso{ 84 | \href{http://echarts.baidu.com/echarts2/doc/option-en.html#series-i(map).markPoint}{office map points docs} 85 | } 86 | -------------------------------------------------------------------------------- /man/xAxis.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/axis.R 3 | \name{xAxis} 4 | \alias{xAxis} 5 | \alias{exAxis} 6 | \alias{exAxis_category} 7 | \alias{exAxis_value} 8 | \alias{exAxis_time} 9 | \alias{exAxis_log} 10 | \title{Customise x axis.} 11 | \usage{ 12 | exAxis(p, show = TRUE, type = "value", append = FALSE, ...) 13 | 14 | exAxis_category(p, show = TRUE, zlevel = 0, z = 0, boundaryGap = FALSE, 15 | append = FALSE, ...) 16 | 17 | exAxis_value(p, show = TRUE, min = NULL, max = NULL, zlevel = 0, 18 | z = 0, position = "bottom", name = NULL, nameLocation = "end", 19 | boundaryGap = list(0, 0), scale = FALSE, splitNumber = NULL, 20 | append = FALSE, ...) 21 | 22 | exAxis_time(p, show = TRUE, zlevel = 0, z = 0, position = "bottom", 23 | name = NULL, nameLocation = "end", boundaryGap = list(0, 0), 24 | min = NULL, max = NULL, scale = FALSE, splitNumber = NULL, 25 | append = FALSE, ...) 26 | 27 | exAxis_log(p, show = TRUE, zlevel = 0, z = 0, position = "bottom", 28 | logLabelBase = NULL, logPositive = NULL, append = FALSE, ...) 29 | } 30 | \arguments{ 31 | \item{p}{an echart object.} 32 | 33 | \item{show}{whether to show the axis.} 34 | 35 | \item{type}{type of axis takes, \code{value}, \code{category}, \code{time}, \code{log}.} 36 | 37 | \item{append}{whether to append options to current axis or override.} 38 | 39 | \item{...}{any other parameter to pass to the axis.} 40 | 41 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 42 | 43 | \item{boundaryGap}{whether to plot on axis line or between.} 44 | 45 | \item{min, max}{min and max values.} 46 | 47 | \item{position}{position of axis, takes \code{bottom}, \code{top}, \code{left} or \code{right}.} 48 | 49 | \item{name}{name of the axis.} 50 | 51 | \item{nameLocation}{location of \code{name}, takes \code{start} or \code{end}.} 52 | 53 | \item{scale}{If \code{FALSE}, the value axis must start with 0. If \code{TRUE}, you can set the minimum and maximum value 54 | of value axis as the starting and ending value of your value axis.} 55 | 56 | \item{splitNumber}{number of segments, defaults to auto split along with the min/max.} 57 | 58 | \item{logLabelBase}{base log.} 59 | 60 | \item{logPositive}{if \code{FALSE} negative values are not supported.} 61 | } 62 | \description{ 63 | Customise x axis. 64 | 65 | Customize X axis 66 | } 67 | \examples{ 68 | mtcars$models <- row.names(mtcars) 69 | 70 | mtcars[1:10,] \%>\% 71 | echart(models) \%>\% 72 | eline(mpg) \%>\% 73 | exAxis_category() \%>\% 74 | eyAxis_value(min = 10, append = FALSE, scale = TRUE) 75 | 76 | } 77 | -------------------------------------------------------------------------------- /man/enodes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/force.R, R/force_.R 3 | \name{nodes} 4 | \alias{nodes} 5 | \alias{enodes} 6 | \alias{enodes_} 7 | \title{Add nodes} 8 | \usage{ 9 | enodes(p, nodes, name, label, value, category, symbolSize, depth, 10 | ignore = FALSE, symbol = "circle", fixX = FALSE, fixY = FALSE) 11 | 12 | enodes_(p, nodes, name, label = NULL, value = NULL, category = NULL, 13 | symbolSize = NULL, depth = NULL, ignore = FALSE, symbol = "circle", 14 | fixX = FALSE, fixY = FALSE) 15 | } 16 | \arguments{ 17 | \item{p}{an echart object.} 18 | 19 | \item{nodes}{nodes data.frame.} 20 | 21 | \item{name}{name column.} 22 | 23 | \item{label}{nodes label column.} 24 | 25 | \item{value}{nodes value (size).} 26 | 27 | \item{category}{nodes group column.} 28 | 29 | \item{symbolSize}{nodes symbol size column.} 30 | 31 | \item{depth}{depth of nodes.} 32 | 33 | \item{ignore}{whether to ignore nodes.} 34 | 35 | \item{symbol}{nodes symbol, see details for valid values.} 36 | 37 | \item{fixX, fixY}{whether to fix x and y axis position.} 38 | } 39 | \description{ 40 | Add nodes for \code{\link{eforce}}. 41 | 42 | Add nodes for \code{\link{eforce}}. 43 | } 44 | \details{ 45 | Valid values for \code{symbol}: 46 | \itemize{ 47 | \item{\code{circle}} 48 | \item{\code{rectangle}} 49 | \item{\code{triangle}} 50 | \item{\code{diamond}} 51 | \item{\code{emptyCircle}} 52 | \item{\code{emptyRectangle}} 53 | \item{\code{emptyTriangle}} 54 | \item{\code{emptyDiamond}} 55 | \item{\code{heart}} 56 | \item{\code{droplet}} 57 | \item{\code{pin}} 58 | \item{\code{arrow}} 59 | \item{\code{star}} 60 | } 61 | } 62 | \examples{ 63 | let <- LETTERS[1:20] 64 | 65 | edges <- data.frame(source = sample(let, 20), target = sample(let, 20), 66 | weight = runif(20, 5, 20)) 67 | 68 | nodes <- data.frame(name = let, value = runif(20, 5, 25), group = rep(LETTERS[1:4], 5)) 69 | 70 | echart() \%>\% 71 | eforce(itemStyle = list(normal = list(label = list(show = TRUE)))) \%>\% # show labels 72 | enodes(nodes, name, value = value, category = group) \%>\% 73 | elinks(edges, source, target) 74 | 75 | let <- LETTERS[1:20] 76 | 77 | edges <- data.frame(source = sample(let, 20), target = sample(let, 20), 78 | weight = runif(20, 5, 20)) 79 | 80 | nodes <- data.frame(name = let, value = runif(20, 5, 25), group = rep(LETTERS[1:4], 5)) 81 | 82 | echart() \%>\% 83 | eforce_(itemStyle = list(normal = list(label = list(show = TRUE)))) \%>\% # show labels 84 | enodes_(nodes, "name", value = "value", category = "group") \%>\% 85 | elinks_(edges, "source", "target") 86 | 87 | } 88 | \seealso{ 89 | \code{\link{enodes}} \code{\link{eforce}} 90 | } 91 | -------------------------------------------------------------------------------- /man/echord.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R, R/add_.R 3 | \name{echord} 4 | \alias{echord} 5 | \alias{echord} 6 | \alias{echord_} 7 | \title{Add chord} 8 | \usage{ 9 | echord(p, name = NULL, sort = "none", sortSub = "none", 10 | clickable = TRUE, z = 2, zlevel = 0, symbol = NULL, 11 | symbolSize = NULL, clockWise = FALSE, minRadius = 10, maxRadius = 20, 12 | ribbonType = TRUE, showScale = FALSE, showScaleText = FALSE, 13 | padding = 2, ...) 14 | 15 | echord_(p, name = NULL, sort = "none", sortSub = "none", 16 | clickable = TRUE, z = 2, zlevel = 0, symbol = NULL, 17 | symbolSize = NULL, clockWise = FALSE, minRadius = 10, maxRadius = 20, 18 | ribbonType = TRUE, showScale = FALSE, showScaleText = FALSE, 19 | padding = 2, ...) 20 | } 21 | \arguments{ 22 | \item{p}{an echart object.} 23 | 24 | \item{name}{name of serie.} 25 | 26 | \item{sort, sortSub}{data sorting, \code{none}, \code{ascending} or \code{descending}.} 27 | 28 | \item{clickable}{whether plot is clickable.} 29 | 30 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 31 | 32 | \item{symbol}{marker, see details for valid values.} 33 | 34 | \item{symbolSize}{of symbol.} 35 | 36 | \item{clockWise}{whether links are displayed in clockwise direction.} 37 | 38 | \item{minRadius, maxRadius}{minimum and maximum radius after mapping to symbol size.} 39 | 40 | \item{ribbonType}{set to \code{TRUE} to use ribbons.} 41 | 42 | \item{showScale}{whether the scale will be showed. Only available if ribbonType is true.} 43 | 44 | \item{showScaleText}{whether to show scale text.} 45 | 46 | \item{padding}{distance between each sector.} 47 | 48 | \item{...}{any other options to pass to serie.} 49 | } 50 | \description{ 51 | Add chord chart. 52 | } 53 | \details{ 54 | Valid values for \code{symbol}: 55 | \itemize{ 56 | \item{\code{circle}} 57 | \item{\code{rectangle}} 58 | \item{\code{triangle}} 59 | \item{\code{diamond}} 60 | \item{\code{emptyCircle}} 61 | \item{\code{emptyRectangle}} 62 | \item{\code{emptyTriangle}} 63 | \item{\code{emptyDiamond}} 64 | \item{\code{heart}} 65 | \item{\code{droplet}} 66 | \item{\code{pin}} 67 | \item{\code{arrow}} 68 | \item{\code{star}} 69 | } 70 | } 71 | \examples{ 72 | set.seed(19880525) 73 | matrix <- matrix(sample(0:1, 100, replace = TRUE, prob = c(0.9,0.6)), nc = 10) 74 | 75 | matrix \%>\% 76 | echart(LETTERS[1:10]) \%>\% 77 | echord() 78 | 79 | matrix \%>\% 80 | echart(LETTERS[1:10]) \%>\% 81 | echord(ribbonType = FALSE) 82 | 83 | } 84 | \seealso{ 85 | \href{http://echarts.baidu.com/echarts2/doc/option-en.html#series-i(radar)}{official scatter options docs} 86 | } 87 | -------------------------------------------------------------------------------- /man/yAxis.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/axis.R 3 | \name{yAxis} 4 | \alias{yAxis} 5 | \alias{eyAxis} 6 | \alias{eyAxis_category} 7 | \alias{eyAxis_value} 8 | \alias{eyAxis_time} 9 | \alias{eyAxis_log} 10 | \title{Customise Y axis} 11 | \usage{ 12 | eyAxis(p, show = TRUE, type = "value", append = FALSE, ...) 13 | 14 | eyAxis_category(p, show = TRUE, zlevel = 0, z = 0, boundaryGap = FALSE, 15 | append = FALSE, ...) 16 | 17 | eyAxis_value(p, show = TRUE, zlevel = 0, z = 0, position = "left", 18 | name = NULL, nameLocation = "end", nameTextStyle = list(), 19 | boundaryGap = list(0, 0), min = NULL, max = NULL, scale = FALSE, 20 | splitNumber = NULL, append = FALSE, ...) 21 | 22 | eyAxis_time(p, show = TRUE, zlevel = 0, z = 0, position = "left", 23 | name = NULL, nameLocation = "end", nameTextStyle = list(), 24 | boundaryGap = list(0, 0), min = NULL, max = NULL, scale = FALSE, 25 | splitNumber = NULL, append = FALSE, ...) 26 | 27 | eyAxis_log(p, show = TRUE, zlevel = 0, z = 0, position = "left", 28 | logLabelBase = NULL, logPositive = NULL, append = FALSE, ...) 29 | } 30 | \arguments{ 31 | \item{p}{an echart object.} 32 | 33 | \item{show}{whether to show the axis.} 34 | 35 | \item{type}{type of axis takes, \code{value}, \code{category}, \code{time}, \code{log}.} 36 | 37 | \item{append}{whether to append options to current axis or override.} 38 | 39 | \item{...}{any other parameter to pass to the axis.} 40 | 41 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 42 | 43 | \item{boundaryGap}{whether to plot on axis line or between.} 44 | 45 | \item{position}{position of axis, takes \code{bottom}, \code{top}, \code{left} or \code{right}.} 46 | 47 | \item{name}{name of the axis.} 48 | 49 | \item{nameLocation}{location of \code{name}, takes \code{start} or \code{end}.} 50 | 51 | \item{nameTextStyle}{style \code{name} text.} 52 | 53 | \item{min, max}{min and max values.} 54 | 55 | \item{scale}{If \code{FALSE}, the value axis must start with 0. If \code{TRUE}, you can set the minimum and maximum value 56 | of value axis as the starting and ending value of your value axis.} 57 | 58 | \item{splitNumber}{number of segments, defaults to auto split along with the min/max.} 59 | 60 | \item{logLabelBase}{base log.} 61 | 62 | \item{logPositive}{if \code{FALSE} negative values are not supported.} 63 | } 64 | \description{ 65 | Customise Y axis 66 | } 67 | \examples{ 68 | df <- data.frame(x = c("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"), 69 | y = runif(7, 1, 5)) 70 | 71 | df \%>\% 72 | echart(x) \%>\% 73 | eline(y) \%>\% 74 | exAxis_category(boundaryGap = FALSE) 75 | 76 | df \%>\% 77 | echart(x) \%>\% 78 | ebar(y) \%>\% 79 | eyAxis_log() 80 | 81 | } 82 | -------------------------------------------------------------------------------- /man/ecolorbar.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/options.R 3 | \name{ecolorbar} 4 | \alias{ecolorbar} 5 | \title{Customise colorbar} 6 | \usage{ 7 | ecolorbar(p, min = NULL, max = NULL, which = "previous", show = TRUE, 8 | color = NULL, zlevel = 4, z = 0, orient = "vertical", x = "left", 9 | y = "bottom", backgroundColor = "rgba(0,0,0,0)", borderColor = "#ccc", 10 | borderWidth = 0, padding = 5, itemGap = 10, itemWidth = 20, 11 | itemHeight = 14, precision = 0, splitNumber = 5, splitList = NULL, 12 | range = NULL, selectedMode = TRUE, calculable = FALSE, 13 | hoverLink = TRUE, realtime = FALSE, ...) 14 | } 15 | \arguments{ 16 | \item{p}{an echart object.} 17 | 18 | \item{min, max}{minimum and maximum.} 19 | 20 | \item{which}{series to serie is to be affected, takes the name of a serie, \code{previous} or \code{all}.} 21 | 22 | \item{show}{whether to show the color bar.} 23 | 24 | \item{color}{colors as list from high to low. i.e.: \code{list("red", "blue")}.} 25 | 26 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 27 | 28 | \item{orient}{orientation of bar, \code{vertical} or \code{horizontal}.} 29 | 30 | \item{x}{x position; \code{left} or \code{right}.} 31 | 32 | \item{y}{y posotion; \code{top} or \code{bottom}.} 33 | 34 | \item{backgroundColor}{background color.} 35 | 36 | \item{borderColor}{border color.} 37 | 38 | \item{borderWidth}{width of border.} 39 | 40 | \item{padding}{padding.} 41 | 42 | \item{itemGap}{gap between items on bar.} 43 | 44 | \item{itemWidth}{width of the bar.} 45 | 46 | \item{itemHeight}{height of the bar.} 47 | 48 | \item{precision}{decimal precision.} 49 | 50 | \item{splitNumber}{number of segments.} 51 | 52 | \item{splitList}{see \href{http://echarts.baidu.com/echarts2/doc/option-en.html#dataRange.splitList}{official docs} for details.} 53 | 54 | \item{range}{used to set initial range i.e.: \code{list(start = 10, end = 50)}.} 55 | 56 | \item{selectedMode}{selection mode.} 57 | 58 | \item{calculable}{whether values are calculable.} 59 | 60 | \item{hoverLink}{hoverlink with map.} 61 | 62 | \item{realtime}{set to \code{TRUE} if using real time stream.} 63 | 64 | \item{...}{any other argument to pass to color bar.} 65 | } 66 | \description{ 67 | Customise the colorbar of your chart. 68 | } 69 | \details{ 70 | \code{ecolorbar} refers to \href{http://echarts.baidu.com/echarts2/doc/option-en.html#dataRange.hoverLink}{datarange} in docs. 71 | } 72 | \examples{ 73 | df <- data.frame(x = 1:20, 74 | y = runif(20, 5, 10), 75 | size = runif(20, 5, 15)) 76 | 77 | df \%>\% 78 | echart(x) \%>\% 79 | escatter(y, size, symbolSize = 10, legendHoverLink = TRUE) \%>\% 80 | ecolorbar(color = list("red", "blue"), min = 5, max = 15, calculable = TRUE) 81 | 82 | } 83 | \seealso{ 84 | \href{http://echarts.baidu.com/echarts2/doc/option-en.html#dataRange.hoverLink}{official dataRange docs} 85 | } 86 | -------------------------------------------------------------------------------- /man/proxies.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/proxies.R 3 | \name{eget_options_p} 4 | \alias{eget_options_p} 5 | \alias{edata_p} 6 | \alias{etheme_p} 7 | \alias{emark_point_p} 8 | \title{echarts Shiny proxies} 9 | \usage{ 10 | eget_options_p(proxy) 11 | 12 | edata_p(proxy, index, data, head = FALSE, grow = FALSE) 13 | 14 | etheme_p(proxy, theme) 15 | 16 | emark_point_p(proxy, index, data = list(), clickable = TRUE, 17 | symbol = "pin", symbol.size = 10, symbol.rotate = NULL, large = FALSE, 18 | effect = NULL) 19 | } 20 | \arguments{ 21 | \item{proxy}{as returned by \code{\link{echartsProxy}}} 22 | 23 | \item{theme}{as passed in \code{\link{etheme}}.} 24 | } 25 | \description{ 26 | Shiny proxies for echarts. 27 | } 28 | \examples{ 29 | \dontrun{ 30 | library(shiny) 31 | 32 | ui <- fluidPage( 33 | titlePanel("echarts Proxies"), 34 | fluidRow( 35 | column( 36 | 3, 37 | actionButton("getOptions", "get options") 38 | ), 39 | column( 40 | 3, 41 | selectInput( 42 | "theme", 43 | "change theme", 44 | choices = 45 | c( 46 | "default", 47 | "red", 48 | "mint", 49 | "macarons", 50 | "macarons2", 51 | "green", 52 | "blue", 53 | "dark", 54 | "gray", 55 | "helianthus", 56 | "wef", 57 | "roma", 58 | "sakura", 59 | "shine", 60 | "infographic", 61 | "solarlight" 62 | ) 63 | ) 64 | ), 65 | column( 66 | 3, 67 | actionButton("addData", "add data") 68 | ), 69 | column( 70 | 3, 71 | numericInput( 72 | "markPoint", 73 | "Mark point", 74 | 10 75 | ) 76 | ) 77 | ), 78 | fluidRow( 79 | echartsOutput("chart") 80 | ) 81 | ) 82 | 83 | server <- function(input, output){ 84 | df <- data.frame(x = 1:50, y = runif(50, 5, 10), z = runif(50, 7, 12), w = runif(50, 10, 13)) 85 | 86 | output$chart <- renderEcharts( 87 | df \%>\% 88 | echart(x) \%>\% 89 | earea(y, name = "Metric", stack = "grp1") \%>\% 90 | eline(w, name = "Variable", stack = "grp2") \%>\% 91 | eline(z, name = "Var", stack = "grp3") \%>\% 92 | etitle("echarts", "and its Shiny proxies") 93 | ) 94 | 95 | reactive_1 <- eventReactive(input$addData, { 96 | runif(1, 5, 13) 97 | }) 98 | 99 | reactive_2 <- eventReactive(input$addData, { 100 | runif(1, 5, 13) 101 | }) 102 | 103 | reactive_3 <- eventReactive(input$addData, { 104 | runif(1, 5, 13) 105 | }) 106 | 107 | observeEvent(input$getOptions, { 108 | echartsProxy("chart") \%>\% 109 | egetoptions_p() 110 | }) 111 | 112 | observeEvent(input$theme, { 113 | echartsProxy("chart") \%>\% 114 | etheme_p(input$theme) 115 | }) 116 | 117 | observeEvent(input$addData, { 118 | echartsProxy("chart") \%>\% 119 | edata_p(index = 0, reactive_1()) \%>\% 120 | edata_p(index = 1, reactive_2()) \%>\% 121 | edata_p(index = 2, reactive_3()) 122 | }) 123 | 124 | observeEvent(input$markPoint, { 125 | data = list( 126 | name = "point", 127 | value = input$markPoint, 128 | x = 20, 129 | y = 10 130 | ) 131 | }) 132 | } 133 | 134 | shinyApp(ui, server) 135 | } 136 | 137 | } 138 | \keyword{internal} 139 | -------------------------------------------------------------------------------- /man/eline.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R, R/add_.R 3 | \name{eline} 4 | \alias{eline} 5 | \alias{eline} 6 | \alias{eline_} 7 | \title{Add lines} 8 | \usage{ 9 | eline(p, serie, name = NULL, stack = NULL, clickable = TRUE, 10 | xAxisIndex = 0, yAxisIndex = 0, symbol = NULL, symbolSize = "2 | 4", 11 | symbolRotate = NULL, showAllSymbol = FALSE, smooth = TRUE, 12 | legendHoverLink = TRUE, dataFilter = "nearest", z = 2, zlevel = 0, 13 | tooltip, ...) 14 | 15 | eline_(p, serie, name = NULL, stack = NULL, clickable = TRUE, 16 | xAxisIndex = 0, yAxisIndex = 0, symbol = NULL, symbolSize = "4", 17 | symbolRotate = NULL, showAllSymbol = FALSE, smooth = TRUE, 18 | legendHoverLink = TRUE, dataFilter = "nearest", z = 2, zlevel = 0, 19 | tooltip, ...) 20 | } 21 | \arguments{ 22 | \item{p}{an echart object.} 23 | 24 | \item{serie}{value column name to plot.} 25 | 26 | \item{name}{of serie.} 27 | 28 | \item{stack}{name of the stack.} 29 | 30 | \item{clickable}{whether plot is clickable.} 31 | 32 | \item{xAxisIndex, yAxisIndex}{axis indexes.} 33 | 34 | \item{symbol}{symbol for point marker, see details for valid values.} 35 | 36 | \item{symbolSize}{of symbol.} 37 | 38 | \item{symbolRotate}{angle by which symbol is rotated, i.e.: \code{30}.} 39 | 40 | \item{showAllSymbol}{By default, a symbol will show only when its corresponding axis label does.} 41 | 42 | \item{smooth}{whether to smooth line.} 43 | 44 | \item{legendHoverLink}{enables legend hover link to the chart.} 45 | 46 | \item{dataFilter}{ECharts data filtering strategy, see details.} 47 | 48 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 49 | 50 | \item{tooltip}{style of tooltip.} 51 | 52 | \item{...}{any other argument to pass to the serie.} 53 | } 54 | \description{ 55 | Add line serie. 56 | } 57 | \details{ 58 | Valid values for \code{symbol}: 59 | \itemize{ 60 | \item{\code{circle}} 61 | \item{\code{rectangle}} 62 | \item{\code{triangle}} 63 | \item{\code{diamond}} 64 | \item{\code{emptyCircle}} 65 | \item{\code{emptyRectangle}} 66 | \item{\code{emptyTriangle}} 67 | \item{\code{emptyDiamond}} 68 | \item{\code{heart}} 69 | \item{\code{droplet}} 70 | \item{\code{pin}} 71 | \item{\code{arrow}} 72 | \item{\code{star}} 73 | } 74 | 75 | \code{dataFilter}: ECharts will optimize for the situation when data number is much larger than viewport width. 76 | It will filter the data showed in one pixel width. And this option is for data filtering strategy. 77 | 78 | Valid values for \code{dataFilter} are: 79 | \itemize{ 80 | \item{\code{nearest} (default)} 81 | \item{\code{min}} 82 | \item{\code{max}} 83 | \item{\code{average}} 84 | } 85 | } 86 | \examples{ 87 | \dontrun{ 88 | df <- data.frame(x = 1:50, y = runif(50, 5, 10), z = runif(50, 7, 12), w = runif(50, 10, 13)) 89 | 90 | df \%>\% 91 | echart(x) \%>\% 92 | eline(y) \%>\% 93 | eline(z) 94 | 95 | # JS sizing function 96 | sizing <- htmlwidgets::JS("function(value){ return value[1]/1.5}") 97 | 98 | df \%>\% 99 | echart_("x") \%>\% 100 | eline_("y", "w", 101 | symbolSize = sizing, 102 | showAllSymbol = TRUE, 103 | symbol = "emptyCircle") \%>\% 104 | etooltip() \%>\% 105 | etheme("helianthus") 106 | 107 | df \%>\% 108 | echart_("x") \%>\% 109 | eline_("y", stack = "grp") \%>\% 110 | eline_("z", stack = "grp", symbol = "emptyDroplet", showAllSymbol = TRUE, symbolSize = 5) \%>\% 111 | eline_("w", showAllSymbol = TRUE, symbolSize = 4, symbol = "emptyHeart", stack = "grp2") \%>\% 112 | etooltip() \%>\% 113 | elegend() \%>\% 114 | etoolbox_magic(type = list("line", "bar")) 115 | } 116 | 117 | } 118 | \seealso{ 119 | \href{http://echarts.baidu.com/echarts2/doc/option-en.html#series-i(line)}{official line options docs} 120 | } 121 | -------------------------------------------------------------------------------- /man/emap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R, R/add_.R 3 | \name{emap} 4 | \alias{emap} 5 | \alias{emap} 6 | \alias{emap_} 7 | \title{Add blank map} 8 | \usage{ 9 | emap(p, name = NULL, mapType = "world", clickable = TRUE, z = 2, 10 | zlevel = 0, selectedMode = NULL, hoverable = FALSE, 11 | dataRangeHoverLink = TRUE, mapLocation = list(x = "center", y = "center"), 12 | mapValueCalculation = "sum", mapValuePrecision = 0, 13 | showLegendSymbol = TRUE, roam = FALSE, scaleLimit = NULL, 14 | nameMap = NULL, textFixed = NULL, ...) 15 | 16 | emap_(p, name = NULL, mapType = "world", clickable = TRUE, z = 2, 17 | zlevel = 0, selectedMode = NULL, hoverable = FALSE, 18 | dataRangeHoverLink = TRUE, mapLocation = list(x = "center", y = "center"), 19 | mapValueCalculation = "sum", mapValuePrecision = 0, 20 | showLegendSymbol = TRUE, roam = FALSE, scaleLimit = NULL, 21 | nameMap = NULL, textFixed = NULL, ...) 22 | } 23 | \arguments{ 24 | \item{p}{an echart object.} 25 | 26 | \item{name}{name of serie.} 27 | 28 | \item{mapType}{type of map, see examples.} 29 | 30 | \item{clickable}{whether elements are clickable.} 31 | 32 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 33 | 34 | \item{selectedMode}{whether items can be selected.} 35 | 36 | \item{hoverable}{whether elements are hoverable.} 37 | 38 | \item{dataRangeHoverLink}{enables dataRange hover link to the chart.} 39 | 40 | \item{mapLocation}{x and y location of map on canvas, takes \code{top}, \code{bottom}, \code{left}, \code{right}, \code{center}.} 41 | 42 | \item{mapValueCalculation}{takes \code{sum} or \code{average}.} 43 | 44 | \item{mapValuePrecision}{decimal precision.} 45 | 46 | \item{showLegendSymbol}{whether to show symbol on legend.} 47 | 48 | \item{roam}{enables zoom and drag.} 49 | 50 | \item{scaleLimit}{controls drag and zoom limits.} 51 | 52 | \item{nameMap}{custom name mapping.} 53 | 54 | \item{textFixed}{fixed text location for a region.} 55 | 56 | \item{...}{any other options to pass to map serie.} 57 | } 58 | \description{ 59 | Setup map plot. 60 | } 61 | \examples{ 62 | \dontrun{ 63 | coords <- data.frame(city = c("London", "New York", "Beijing", "Sydney"), 64 | lon = c(-0.1167218, -73.98002, 116.3883, 151.18518), 65 | lat = c(51.49999, 40.74998, 39.92889, -33.92001), 66 | values = runif(4, 10, 20)) 67 | 68 | coords \%>\% 69 | echart_("city") \%>\% # initialise chart 70 | emap_() \%>\% # setup default map 71 | emap_coords_("lon", "lat") \%>\% # add coordinates 72 | emap_points_("values") # plot values on coordinates 73 | 74 | edges <- data.frame(source = c("Beijing", "Beijing", "New York"), 75 | target = c("Sydney", "London", "London")) 76 | 77 | coords \%>\% 78 | echart_("city") \%>\% 79 | emap_() \%>\% 80 | emap_coords_("lon", "lat") \%>\% 81 | emap_lines_(edges, "source", "target") 82 | 83 | data <- data.frame(lon = runif(200, 90, 120), 84 | lat = runif(200, 30, 39), 85 | z = runif(200, 50, 75)) 86 | 87 | data \%>\% 88 | echart_() \%>\% 89 | emap_(mapType = "china") \%>\% 90 | emap_heat_("lon", "lat", "z") 91 | 92 | us_data <- data.frame(state = c("New York", "Los Angeles", "Dallas"), 93 | lat = c(40.730610, 34.052235, 33.940369), 94 | lon = c(-73.935242, -118.243683, -84.692894), 95 | values = round(runif(3, 1, 2))) 96 | 97 | us_data \%>\% 98 | echart_("state") \%>\% 99 | emap(mapType = "world|United States of America") \%>\% 100 | emap_coords_("lon", "lat") \%>\% 101 | emap_points_("values") 102 | } 103 | 104 | } 105 | \seealso{ 106 | \code{\link{emap_coords}}, \code{\link{emap_heat}}, \code{\link{emap_lines}}, \code{emap_choropleth}, 107 | \code{\link{emap_points}}, \href{http://echarts.baidu.com/echarts2/doc/option-en.html#series-i(map)}{official map docs} 108 | } 109 | -------------------------------------------------------------------------------- /man/emap_lines.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R, R/add_.R 3 | \name{emap_lines} 4 | \alias{emap_lines} 5 | \alias{emap_lines} 6 | \alias{emap_lines_} 7 | \title{Add map lines} 8 | \usage{ 9 | emap_lines(p, edges, source, target, name = NULL, clickable = TRUE, 10 | symbol = "arrow", symbolSize = 2, symbolRotate = NULL, large = FALSE, 11 | smooth = TRUE, z = 2, zlevel = 0, smoothness = 0.2, precision = 2, 12 | bundling = list(enable = FALSE, maxTurningAngle = 45), ...) 13 | 14 | emap_lines_(p, edges, source, target, name = NULL, clickable = TRUE, 15 | symbol = "arrow", symbolSize = 2, symbolRotate = NULL, large = FALSE, 16 | smooth = TRUE, z = 2, zlevel = 0, smoothness = 0.2, precision = 2, 17 | bundling = list(enable = FALSE, maxTurningAngle = 45), ...) 18 | } 19 | \arguments{ 20 | \item{p}{an echart object.} 21 | 22 | \item{edges}{edges data.frame.} 23 | 24 | \item{source, target}{source and target columns in edges data.frame.} 25 | 26 | \item{name}{name of serie.} 27 | 28 | \item{clickable}{whether lines are clikable.} 29 | 30 | \item{symbol}{symbol, see valid details for valid values.} 31 | 32 | \item{symbolSize}{of symbol.} 33 | 34 | \item{symbolRotate}{angle by which symbol is rotated, i.e.: \code{30}.} 35 | 36 | \item{large}{optimises for 2'000 data points and over.} 37 | 38 | \item{smooth}{whether to smooth lines.} 39 | 40 | \item{z, zlevel}{first and second grade cascading control, the higher z the closer to the top.} 41 | 42 | \item{smoothness}{line smoothness} 43 | 44 | \item{precision}{for 'average'.} 45 | 46 | \item{bundling}{edge bundling settings, see usage.} 47 | 48 | \item{...}{any other options to pass to line.} 49 | } 50 | \description{ 51 | Add lines on map. 52 | } 53 | \details{ 54 | Valid values for \code{symbol}: 55 | \itemize{ 56 | \item{\code{circle}} 57 | \item{\code{rectangle}} 58 | \item{\code{triangle}} 59 | \item{\code{diamond}} 60 | \item{\code{emptyCircle}} 61 | \item{\code{emptyRectangle}} 62 | \item{\code{emptyTriangle}} 63 | \item{\code{emptyDiamond}} 64 | \item{\code{heart}} 65 | \item{\code{droplet}} 66 | \item{\code{pin}} 67 | \item{\code{arrow}} 68 | \item{\code{star}} 69 | } 70 | } 71 | \examples{ 72 | \dontrun{ 73 | coords <- data.frame(city = c("London", "New York", "Beijing", "Sydney"), 74 | lon = c(-0.1167218, -73.98002, 116.3883, 151.18518), 75 | lat = c(51.49999, 40.74998, 39.92889, -33.92001)) 76 | 77 | edges <- data.frame(source = c("Beijing", "Beijing", "New York"), 78 | target = c("Sydney", "London", "London")) 79 | 80 | coords \%>\% 81 | echart_("city") \%>\% 82 | emap() \%>\% 83 | emap_coords_("lon", "lat") \%>\% 84 | emap_lines_(edges, "source", "target") 85 | 86 | edges2 <- data.frame(source = "London", target = "Sydney") 87 | 88 | coords \%>\% 89 | echart_("city") \%>\% 90 | emap() \%>\% 91 | emap_coords_("lon", "lat") \%>\% 92 | emap_lines_(edges, "source", "target") \%>\% 93 | emap() \%>\% 94 | emap_coords_("lon", "lat") \%>\% 95 | emap_lines_(edges2, "source", "target", effect = emap_line_effect()) \%>\% 96 | etheme("helianthus") 97 | 98 | coords2 <- data.frame(city = "Sydney", lon = 151.18518, lat = -33.92001, value = 20) 99 | 100 | coords \%>\% 101 | echart_("city") \%>\% 102 | emap() \%>\% 103 | emap_coords_("lon", "lat") \%>\% 104 | emap_lines_(edges, "source", "target") \%>\% 105 | edata_(coords2, "city") \%>\% 106 | emap() \%>\% 107 | emap_coords_("lon", "lat") \%>\% 108 | emap_lines_(edges2, "source", "target", effect = emap_line_effect(scaleSize = 2)) \%>\% 109 | emap_coords_("lon", "lat") \%>\% 110 | emap_points_("value", symbol = "emptyCircle", effect = list(show = TRUE, shadowBlur = 10)) \%>\% 111 | etheme("dark") 112 | } 113 | 114 | } 115 | \seealso{ 116 | \code{\link{emap_coords}} \href{http://echarts.baidu.com/echarts2/doc/option-en.html#series-i(map).markLine}{official map line docs} 117 | } 118 | -------------------------------------------------------------------------------- /R/proxies.R: -------------------------------------------------------------------------------- 1 | #' echarts Shiny proxies 2 | #' 3 | #' Shiny proxies for echarts. 4 | #' 5 | #' @param proxy as returned by \code{\link{echartsProxy}} 6 | #' @param theme as passed in \code{\link{etheme}}. 7 | #' 8 | #' @examples 9 | #' \dontrun{ 10 | #' library(shiny) 11 | #' 12 | #' ui <- fluidPage( 13 | #' titlePanel("echarts Proxies"), 14 | #' fluidRow( 15 | #' column( 16 | #' 3, 17 | #' actionButton("getOptions", "get options") 18 | #' ), 19 | #' column( 20 | #' 3, 21 | #' selectInput( 22 | #' "theme", 23 | #' "change theme", 24 | #' choices = 25 | #' c( 26 | #' "default", 27 | #' "red", 28 | #' "mint", 29 | #' "macarons", 30 | #' "macarons2", 31 | #' "green", 32 | #' "blue", 33 | #' "dark", 34 | #' "gray", 35 | #' "helianthus", 36 | #' "wef", 37 | #' "roma", 38 | #' "sakura", 39 | #' "shine", 40 | #' "infographic", 41 | #' "solarlight" 42 | #' ) 43 | #' ) 44 | #' ), 45 | #' column( 46 | #' 3, 47 | #' actionButton("addData", "add data") 48 | #' ), 49 | #' column( 50 | #' 3, 51 | #' numericInput( 52 | #' "markPoint", 53 | #' "Mark point", 54 | #' 10 55 | #' ) 56 | #' ) 57 | #' ), 58 | #' fluidRow( 59 | #' echartsOutput("chart") 60 | #' ) 61 | #' ) 62 | #' 63 | #' server <- function(input, output){ 64 | #' df <- data.frame(x = 1:50, y = runif(50, 5, 10), z = runif(50, 7, 12), w = runif(50, 10, 13)) 65 | #' 66 | #' output$chart <- renderEcharts( 67 | #' df %>% 68 | #' echart(x) %>% 69 | #' earea(y, name = "Metric", stack = "grp1") %>% 70 | #' eline(w, name = "Variable", stack = "grp2") %>% 71 | #' eline(z, name = "Var", stack = "grp3") %>% 72 | #' etitle("echarts", "and its Shiny proxies") 73 | #' ) 74 | #' 75 | #' reactive_1 <- eventReactive(input$addData, { 76 | #' runif(1, 5, 13) 77 | #' }) 78 | #' 79 | #' reactive_2 <- eventReactive(input$addData, { 80 | #' runif(1, 5, 13) 81 | #' }) 82 | #' 83 | #' reactive_3 <- eventReactive(input$addData, { 84 | #' runif(1, 5, 13) 85 | #' }) 86 | #' 87 | #' observeEvent(input$getOptions, { 88 | #' echartsProxy("chart") %>% 89 | #' egetoptions_p() 90 | #' }) 91 | #' 92 | #' observeEvent(input$theme, { 93 | #' echartsProxy("chart") %>% 94 | #' etheme_p(input$theme) 95 | #' }) 96 | #' 97 | #' observeEvent(input$addData, { 98 | #' echartsProxy("chart") %>% 99 | #' edata_p(index = 0, reactive_1()) %>% 100 | #' edata_p(index = 1, reactive_2()) %>% 101 | #' edata_p(index = 2, reactive_3()) 102 | #' }) 103 | #' 104 | #' observeEvent(input$markPoint, { 105 | #' data = list( 106 | #' name = "point", 107 | #' value = input$markPoint, 108 | #' x = 20, 109 | #' y = 10 110 | #' ) 111 | #' }) 112 | #' } 113 | #' 114 | #' shinyApp(ui, server) 115 | #' } 116 | #' 117 | #' @rdname proxies 118 | #' @keywords internal 119 | eget_options_p <- function(proxy){ 120 | 121 | data <- list(id = proxy$id) 122 | 123 | proxy$session$sendCustomMessage("egetoptions_p", data) 124 | 125 | return(proxy) 126 | } 127 | 128 | #' @rdname proxies 129 | edata_p <- function(proxy, index, data, head = FALSE, grow = FALSE){ 130 | 131 | data <- list(id = proxy$id, data = list(list(index, data, head, grow))) 132 | 133 | proxy$session$sendCustomMessage("eadd_line_p", data) 134 | 135 | return(proxy) 136 | } 137 | 138 | #' @rdname proxies 139 | #' @keywords internal 140 | etheme_p <- function(proxy, theme){ 141 | if(tolower(theme) == "grey") theme <- "gray" 142 | 143 | themes <- c("default", "mint", "macarons", "macarons2", "green", "blue", "dark", "blue", "dark", "gray", "helianthus", 144 | "red", "roma", "sakura", "shine", "infographic", "solarlight", "wef") 145 | 146 | if(!tolower(theme) %in% themes) stop("invalid theme", call. = FALSE) 147 | 148 | data <- list(id = proxy$id, theme = theme) 149 | 150 | proxy$session$sendCustomMessage("etheme_p", data) 151 | 152 | return(proxy) 153 | } 154 | 155 | #' @rdname proxies 156 | #' @keywords internal 157 | emark_point_p <- function(proxy, index, data = list(), clickable = TRUE, symbol = "pin", symbol.size = 10, 158 | symbol.rotate = NULL, large = FALSE, effect = NULL){ 159 | 160 | opts <- list() 161 | opts$clickable <- clickable 162 | opts$symbol = symbol 163 | opts$symbolSize <- symbol.size 164 | opts$symbolRotate <- symbol.rotate 165 | opts$large <- large 166 | opts$effect <- effect 167 | opts$data <- data 168 | 169 | data <- list(id = proxy$id, data = opts) 170 | 171 | proxy$session$sendCustomMessage("emark_point_p", data) 172 | 173 | return(proxy) 174 | } 175 | -------------------------------------------------------------------------------- /R/force_.R: -------------------------------------------------------------------------------- 1 | #' Add edges 2 | #' 3 | #' Add edges for \code{\link{eforce}}. 4 | #' 5 | #' @examples 6 | #' let <- LETTERS[1:20] 7 | #' 8 | #' edges <- data.frame(source = sample(let, 20), target = sample(let, 20), 9 | #' weight = runif(20, 5, 20)) 10 | #' 11 | #' nodes <- data.frame(name = let, value = runif(20, 5, 25), group = rep(LETTERS[1:4], 5)) 12 | #' 13 | #' echart() %>% 14 | #' eforce_(itemStyle = list(normal = list(label = list(show = TRUE)))) %>% # show labels 15 | #' enodes_(nodes, "name", value = "value", category = "group") %>% 16 | #' elinks_(edges, "source", "target") 17 | #' 18 | #' @rdname elinks 19 | #' 20 | #' @export 21 | elinks_ <- function(p, links, source, target, weight = 1){ 22 | 23 | previous <- length(p$x$options$series) 24 | 25 | p$x$options$series[[previous]]$links = build_links_(links, source, target, weight) 26 | 27 | p 28 | } 29 | 30 | #' Add nodes 31 | #' 32 | #' Add nodes for \code{\link{eforce}}. 33 | #' 34 | #' @examples 35 | #' let <- LETTERS[1:20] 36 | #' 37 | #' edges <- data.frame(source = sample(let, 20), target = sample(let, 20), 38 | #' weight = runif(20, 5, 20)) 39 | #' 40 | #' nodes <- data.frame(name = let, value = runif(20, 5, 25), group = rep(LETTERS[1:4], 5)) 41 | #' 42 | #' echart() %>% 43 | #' eforce_(itemStyle = list(normal = list(label = list(show = TRUE)))) %>% # show labels 44 | #' enodes_(nodes, "name", value = "value", category = "group") %>% 45 | #' elinks_(edges, "source", "target") 46 | #' 47 | #' @rdname enodes 48 | #' 49 | #' @export 50 | enodes_ <- function(p, nodes, name, label = NULL, value = NULL, category = NULL, 51 | symbolSize = NULL, depth = NULL, ignore = FALSE, 52 | symbol = "circle", fixX = FALSE, fixY = FALSE){ 53 | 54 | 55 | if(missing(name) || missing(nodes)) stop("must pass nodes and name column") 56 | 57 | name <- as.character(nodes[, name]) 58 | ignore <- if(length(ignore) > 1) nodes[, ignore] 59 | symbol <- if(length(symbol) > 1) nodes[, symbol] 60 | fixX <- if(length(fixX) > 1) nodes[, fixX] 61 | fixY <- if(length(fixY) > 1) nodes[, fixY] 62 | 63 | vertices <- data.frame(row.names = 1:length(name)) 64 | vertices$name <- name 65 | vertices$value <- if(!is.null(value)) nodes[, value] 66 | vertices$symbolSize <- if(!is.null(symbolSize)) nodes[, symbolSize] 67 | vertices$label <- if(!is.null(label)) nodes[, label] 68 | vertices$category <- if(!is.null(category)) cat2num(nodes[, category]) 69 | vertices$depth <- if(!is.null(depth)) nodes[, depth] 70 | vertices$ignore <- ignore 71 | vertices$symbol <- symbol 72 | vertices$fixX <- fixX 73 | vertices$fixY <- fixY 74 | 75 | row.names(vertices) <- NULL 76 | vertices <- apply(vertices, 1, as.list) 77 | 78 | # removes inserted white spaces 79 | vertices <- lapply(vertices, function(x){ 80 | lapply(x, function(y){ 81 | trimws(y) 82 | }) 83 | }) 84 | 85 | previous <- length(p$x$options$series) 86 | 87 | 88 | p$x$options$series[[previous]]$categories <- if(!is.null(category)) node_cat(nodes[, category]) 89 | p$x$options$series[[previous]]$nodes <- vertices 90 | 91 | # adapt legend 92 | if(!is.null(category)){ 93 | p$x$options$legend$data <- force_legend(nodes[, category]) 94 | p$x$options$legend$x <- "left" 95 | p$x$options$legend$orient <- "vertical" 96 | } 97 | 98 | p 99 | 100 | } 101 | 102 | #' Build force network 103 | #' 104 | #' Plot force directed graph. 105 | #' 106 | #' @rdname eforce 107 | #' 108 | #' @export 109 | eforce_ <- function(p, name = NULL, large = FALSE, center = list("50%", "50%"), roam = FALSE, size = "100%", 110 | minRadius = 10, maxRadius = 20, linkSymbol = "none", linkSymbolSize = list(10, 15), scaling = 1, 111 | gravity = 1, draggable = TRUE, useWorker = TRUE, steps = 1, z = 2, zlevel = 0, ...){ 112 | 113 | opts <- list(...) 114 | opts$name <- if(!is.null(name)) name 115 | opts$type <- "force" 116 | opts$large <- large 117 | opts$center <- center 118 | opts$roam <- roam 119 | opts$size <- size 120 | opts$minRadius <- minRadius 121 | opts$maxRadius <- maxRadius 122 | opts$linkSymbol <- linkSymbol 123 | opts$linkSymbolSize <- linkSymbolSize 124 | opts$scaling <- scaling 125 | opts$gravity <- gravity 126 | opts$draggable <- draggable 127 | opts$useWorker <- useWorker 128 | opts$steps <- steps 129 | opts$z <- z 130 | opts$zlevel <- zlevel 131 | 132 | p$x$options$xAxis <- NULL 133 | p$x$options$yAxis <- NULL 134 | 135 | p$x$options$series <- append(p$x$options$series, list(opts)) 136 | 137 | p 138 | 139 | } 140 | 141 | #' Plot igraph 142 | #' 143 | #' Plot a network from an igraph object. 144 | #' 145 | #' @param g igraph object 146 | #' 147 | #' @examples 148 | #' g <- igraph::make_directed_graph(LETTERS) 149 | #' 150 | #' nodes <- igraph_nodes(g) 151 | #' links <- igraph_links(g) 152 | #' 153 | #' echart() %>% 154 | #' eforce_() %>% 155 | #' enodes_(nodes, "name", ) %>% 156 | #' elinks_(links, "source", "target") 157 | #' 158 | #' @name igraph2eforce 159 | #' @rdname igraph2eforce 160 | #' @export 161 | igraph_nodes <- function(g){ 162 | data.frame(name = igraph::V(g)$name) 163 | } 164 | 165 | #' @rdname igraph2eforce 166 | #' @export 167 | igraph_links <- function(g){ 168 | df <- as.data.frame(igraph::get.edgelist(g)) 169 | names(df) <- c("source", "target") 170 | df 171 | } 172 | -------------------------------------------------------------------------------- /R/echarts.R: -------------------------------------------------------------------------------- 1 | #' Initiate an echart 2 | #' 3 | #' Initiate an echart graph. 4 | #' 5 | #' @param data data.frame containing data to plot. 6 | #' @param x variable column. 7 | #' @param width,height dimensions of chart. 8 | #' @param elementId id of div containing chart. 9 | #' 10 | #' @examples 11 | #' mtcars %>% 12 | #' echart(mpg) %>% 13 | #' eline(drat) 14 | #' 15 | #' @import htmlwidgets 16 | #' 17 | #' @name echart 18 | #' @rdname echart 19 | #' 20 | #' @importFrom methods is 21 | #' 22 | #' @export 23 | echart <- function(data, x, width = NULL, height = NULL, elementId = NULL) { 24 | 25 | # x 26 | if(!missing(x)){ 27 | xvar <- tryCatch(eval(substitute(x), data), error = function(e) e) 28 | if(is(xvar, "error")){ 29 | xvar <- check_xvar(data, x) 30 | x.name <- NULL 31 | } else { 32 | x.name <- deparse(substitute(x)) 33 | data <- sort_data(data, x.name) 34 | xvar <- check_xvar(data, xvar) 35 | } 36 | } else { 37 | xvar <- NULL 38 | x.name <- NULL 39 | } 40 | 41 | if(!missing(data)){ 42 | data <- map_grps_(data) 43 | assign("data", data, envir = data_env) 44 | } 45 | 46 | # assign for future use 47 | assign("x", xvar, envir = data_env) 48 | assign("x.name", x.name, envir = data_env) 49 | 50 | # forward options using x 51 | x = list( 52 | theme = "default", 53 | options = list( 54 | xAxis = list( 55 | list( 56 | type = "category", 57 | data = xvar 58 | ) 59 | ), 60 | yAxis = list(), 61 | series = list() 62 | ) 63 | ) 64 | 65 | if(!missing(data)){ 66 | x$init <- TRUE 67 | } 68 | 69 | # create widget 70 | htmlwidgets::createWidget( 71 | name = 'echarts', 72 | x, 73 | width = width, 74 | height = height, 75 | sizingPolicy = htmlwidgets::sizingPolicy(knitr.defaultWidth = "100%", 76 | knitr.defaultHeight = 400, 77 | viewer.fill = TRUE, 78 | padding = 0), 79 | package = 'echarts', 80 | elementId = elementId 81 | ) 82 | } 83 | 84 | #' @rdname echart 85 | #' 86 | #' @export 87 | echart_ <- function(data, x, width = NULL, height = NULL, elementId = NULL) { 88 | 89 | # x 90 | if(!missing(x)){ 91 | xvar <- tryCatch(unlist(unname(data[, x])), error = function(e) e) 92 | if(is(xvar, "error")){ 93 | xvar <- check_xvar(data, x) 94 | x.name <- NULL 95 | } else { 96 | xvar <- check_xvar(data, xvar) 97 | x.name <- x 98 | } 99 | } else { 100 | xvar <- NULL 101 | x.name <- NULL 102 | } 103 | 104 | if(!missing(data)){ 105 | 106 | data <- map_grps_(data) 107 | 108 | assign("data", data, envir = data_env) 109 | } 110 | 111 | # assign for future use 112 | assign("x", xvar, envir = data_env) 113 | assign("x.name", x.name, envir = data_env) 114 | 115 | # forward options using x 116 | x = list( 117 | theme = "default", 118 | options = list( 119 | xAxis = list( 120 | list( 121 | type = "category", 122 | data = unique(xvar) 123 | ) 124 | ), 125 | yAxis = list(), 126 | series = list() 127 | ) 128 | ) 129 | 130 | # create widget 131 | htmlwidgets::createWidget( 132 | name = 'echarts', 133 | x, 134 | width = width, 135 | height = height, 136 | sizingPolicy = htmlwidgets::sizingPolicy(defaultWidth = "100%", 137 | knitr.defaultWidth = "100%", 138 | knitr.defaultHeight = 400, 139 | viewer.fill = TRUE, 140 | padding = 0), 141 | package = 'echarts', 142 | elementId = elementId 143 | ) 144 | } 145 | 146 | #' Shiny bindings for echarts 147 | #' 148 | #' Output and render functions for using echarts within Shiny 149 | #' applications and interactive Rmd documents. 150 | #' 151 | #' @param outputId output variable to read from 152 | #' @param width,height Must be a valid CSS unit (like \code{'100\%'}, 153 | #' \code{'400px'}, \code{'auto'}) or a number, which will be coerced to a 154 | #' string and have \code{'px'} appended. 155 | #' @param expr An expression that generates a echarts 156 | #' @param env The environment in which to evaluate \code{expr}. 157 | #' @param quoted Is \code{expr} a quoted expression (with \code{quote()})? This 158 | #' is useful if you want to save an expression in a variable. 159 | #' @param id target chart id. 160 | #' @param session shiny session 161 | #' 162 | #' @name echarts-shiny 163 | #' 164 | #' @export 165 | echartsOutput <- function(outputId, width = '100%', height = '400px'){ 166 | htmlwidgets::shinyWidgetOutput(outputId, 'echarts', width, height, package = 'echarts') 167 | } 168 | 169 | #' @rdname echarts-shiny 170 | #' @export 171 | renderEcharts <- function(expr, env = parent.frame(), quoted = FALSE) { 172 | if (!quoted) { expr <- substitute(expr) } # force quoted 173 | htmlwidgets::shinyRenderWidget(expr, echartsOutput, env, quoted = TRUE) 174 | } 175 | 176 | #' @rdname echarts-shiny 177 | #' @export 178 | echartsProxy <- function(id, session = shiny::getDefaultReactiveDomain()){ 179 | 180 | proxy <- list(id = id, session = session) 181 | class(proxy) <- "echartsProxy" 182 | 183 | return(proxy) 184 | } 185 | -------------------------------------------------------------------------------- /R/helpers.R: -------------------------------------------------------------------------------- 1 | #' emap line effect 2 | #' 3 | #' Effect for emap lines 4 | #' 5 | #' @param show set to \code{TRUE} to show effect. 6 | #' @param loop set to \code{TRUE} to loop animation. 7 | #' @param period period loop. 8 | #' @param scaleSize scale. 9 | #' @param color color. 10 | #' @param shadowBlur blur. 11 | #' @param shadowColor color of shadow. 12 | #' @param ... any other option to pass to effect. 13 | #' 14 | #' @examples 15 | #' coords <- data.frame(city = c("London", "New York", "Beijing", "Sydney"), 16 | #' lon = c(-0.1167218, -73.98002, 116.3883, 151.18518), 17 | #' lat = c(51.49999, 40.74998, 39.92889, -33.92001)) 18 | #' 19 | #' edges <- data.frame(source = c("Beijing", "Beijing", "New York"), 20 | #' target = c("Sydney", "London", "London")) 21 | #' 22 | #' coords %>% 23 | #' echart(city) %>% 24 | #' emap() %>% 25 | #' emap_coords(lon, lat) %>% 26 | #' emap_lines(edges, source, target, effect = emap_line_effect()) 27 | #' 28 | #' @export 29 | emap_line_effect <- function(show = TRUE, loop = TRUE, period = 30, scaleSize = 1, color = "#fff", 30 | shadowBlur = 10, shadowColor = NULL, ...){ 31 | 32 | opts <- list(...) 33 | opts$show <- show 34 | opts$loop <- loop 35 | opts$period <- period 36 | opts$scaleSize <- scaleSize 37 | opts$color <- color 38 | opts$shadowColor <- if(!is.null(shadowColor)) shadowColor 39 | 40 | return(opts) 41 | } 42 | 43 | #' mark points 44 | #' 45 | #' @param p an echart object. 46 | #' @param which serie to mark lines of, takes \code{previous}, \code{all} or name of specific serie. 47 | #' @param data data of mark points, points to mark. 48 | #' @param clickable whether marked points are clickable. 49 | #' @param symbol symbol, see details for valid values. 50 | #' @param symbolSize size of symbol. 51 | #' @param symbolRotate symbol rotation angle, i.e.:\code{30}. 52 | #' @param large set to \code{TRUE} to optimise for large datasets. 53 | #' @param ... any other options to pass to mark points. 54 | #' 55 | #' @details 56 | #' Valid values for \code{symbol}: 57 | #' \itemize{ 58 | #' \item{\code{circle}} 59 | #' \item{\code{rectangle}} 60 | #' \item{\code{triangle}} 61 | #' \item{\code{diamond}} 62 | #' \item{\code{emptyCircle}} 63 | #' \item{\code{emptyRectangle}} 64 | #' \item{\code{emptyTriangle}} 65 | #' \item{\code{emptyDiamond}} 66 | #' \item{\code{heart}} 67 | #' \item{\code{droplet}} 68 | #' \item{\code{pin}} 69 | #' \item{\code{arrow}} 70 | #' \item{\code{star}} 71 | #' } 72 | #' 73 | #' @examples 74 | #' df <- data.frame(x = 1:150, 75 | #' y = round(rnorm(150, mean = 5, sd = 1), 2), 76 | #' z = round(rnorm(150, mean = 7, sd = 1), 2)) 77 | #' 78 | #' df %>% 79 | #' echart(x) %>% 80 | #' escatter(y) %>% 81 | #' escatter(z) %>% 82 | #' emark_point(which = "all", data = list(list(type = "min"), list(type = "max"))) 83 | #' 84 | #' @export 85 | emark_point <- function(p, which = "previous", data = list(), clickable = TRUE, symbol = "pin", symbolSize = 10, 86 | symbolRotate = NULL, large = FALSE, ...){ 87 | 88 | opts <- list(...) 89 | opts$data <- data 90 | opts$clickable <- clickable 91 | opts$symbol = symbol 92 | opts$symbolSize <- symbolSize 93 | opts$symbolRotate <- symbolRotate 94 | opts$large <- large 95 | 96 | p <- mark(p, which, opts, "markPoint") 97 | 98 | p 99 | 100 | } 101 | 102 | #' mark line 103 | #' 104 | #' @param p an echart object. 105 | #' @param which serie to mark lines of, takes \code{previous}, \code{all} or name of specific serie. 106 | #' @param data data of mark points, points to mark. 107 | #' @param clickable whether marked points are clickable. 108 | #' @param symbol symbol, see details for valid values. 109 | #' @param symbolSize size of symbol. 110 | #' @param symbolRotate symbol rotation angle, i.e.:\code{30}. 111 | #' @param large set to \code{TRUE} to optimise for large datasets. 112 | #' @param smooth whether to smooth line. 113 | #' @param precision decimal precision. 114 | #' @param bundling line bundling. 115 | #' @param z,zlevel first and second grade cascading control, the higher z the closer to the top. 116 | #' @param ... any other options to pass to mark points. 117 | #' 118 | #' @details 119 | #' Valid values for \code{symbol}: 120 | #' \itemize{ 121 | #' \item{\code{circle}} 122 | #' \item{\code{rectangle}} 123 | #' \item{\code{triangle}} 124 | #' \item{\code{diamond}} 125 | #' \item{\code{emptyCircle}} 126 | #' \item{\code{emptyRectangle}} 127 | #' \item{\code{emptyTriangle}} 128 | #' \item{\code{emptyDiamond}} 129 | #' \item{\code{heart}} 130 | #' \item{\code{droplet}} 131 | #' \item{\code{pin}} 132 | #' \item{\code{arrow}} 133 | #' \item{\code{star}} 134 | #' } 135 | #' 136 | #' @examples 137 | #' df <- data.frame(x = c("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"), 138 | #' radio = c(320, 332, 301, 334, 390, 330, 320), 139 | #' social = c(120, 132, 101, 134, 90, 230, 210)) 140 | #' 141 | #' df %>% 142 | #' echart(x) %>% 143 | #' ebar(radio, stack = "grp") %>% 144 | #' ebar(social, stack = "grp") %>% 145 | #' emark_line(data = list(list(type = "max")), clickable = FALSE) %>% 146 | #' etooltip(axisPointer = list(type = "shadow")) %>% 147 | #' etoolbox_full() %>% 148 | #' etoolbox_magic(type = list("tiled", "stack", "line", "bar")) 149 | #' 150 | #' @export 151 | emark_line <- function(p, which = "previous", data = list(), clickable = TRUE, symbol = list("circle", "arrow"), 152 | symbolSize = list(2, 4), symbolRotate = NULL, large = FALSE, smooth = FALSE, precision = 2, 153 | bundling = list(enable = FALSE, maxTurningAngle = 45), z = 2, zlevel = 0, ...){ 154 | 155 | opts <- list(...) 156 | opts$data <- data 157 | opts$clickable <- clickable 158 | opts$symbol = symbol 159 | opts$symbolSize <- symbolSize 160 | opts$symbolRotate <- symbolRotate 161 | opts$large <- large 162 | opts$smooth <- smooth 163 | opts$precision <- precision 164 | opts$bundling <- bundling 165 | 166 | p <- mark(p, which, opts, "markLine") 167 | 168 | p 169 | } 170 | -------------------------------------------------------------------------------- /R/force.R: -------------------------------------------------------------------------------- 1 | #' Add edges 2 | #' 3 | #' Add edges for \code{\link{eforce}}. 4 | #' 5 | #' @param p an echart object. 6 | #' @param links edges data.frame. 7 | #' @param source source column. 8 | #' @param target target column. 9 | #' @param weight edge weight. 10 | #' 11 | #' @examples 12 | #' let <- LETTERS[1:20] 13 | #' 14 | #' edges <- data.frame(source = sample(let, 20), target = sample(let, 20), 15 | #' weight = runif(20, 5, 20)) 16 | #' 17 | #' nodes <- data.frame(name = let, value = runif(20, 5, 25), group = rep(LETTERS[1:4], 5)) 18 | #' 19 | #' echart() %>% 20 | #' eforce(itemStyle = list(normal = list(label = list(show = TRUE)))) %>% # show labels 21 | #' enodes(nodes, name, value = value, category = group) %>% 22 | #' elinks(edges, source, target) 23 | #' 24 | #' echart() %>% 25 | #' eforce(itemStyle = list(normal = list(label = list(show = TRUE)))) %>% # show labels 26 | #' enodes(nodes, name, value = value, category = group) %>% 27 | #' elinks(edges, source, target, weight = 1) 28 | #' 29 | #' @name elinks 30 | #' @rdname elinks 31 | #' 32 | #' @seealso \code{\link{enodes}} \code{\link{eforce}} 33 | #' 34 | #' @export 35 | elinks <- function(p, links, source, target, weight = 1){ 36 | 37 | source <- deparse(substitute(source)) 38 | target <- deparse(substitute(target)) 39 | 40 | weight <- if(class(weight)[1] == "integer" || class(weight)[1] == "numeric") weight else deparse(substitute(weight)) 41 | 42 | p %>% 43 | elinks_(links, source, target, weight) 44 | } 45 | 46 | #' Add nodes 47 | #' 48 | #' Add nodes for \code{\link{eforce}}. 49 | #' 50 | #' @param p an echart object. 51 | #' @param nodes nodes data.frame. 52 | #' @param name name column. 53 | #' @param label nodes label column. 54 | #' @param value nodes value (size). 55 | #' @param category nodes group column. 56 | #' @param symbolSize nodes symbol size column. 57 | #' @param depth depth of nodes. 58 | #' @param ignore whether to ignore nodes. 59 | #' @param symbol nodes symbol, see details for valid values. 60 | #' @param fixX,fixY whether to fix x and y axis position. 61 | #' 62 | #' @details 63 | #' Valid values for \code{symbol}: 64 | #' \itemize{ 65 | #' \item{\code{circle}} 66 | #' \item{\code{rectangle}} 67 | #' \item{\code{triangle}} 68 | #' \item{\code{diamond}} 69 | #' \item{\code{emptyCircle}} 70 | #' \item{\code{emptyRectangle}} 71 | #' \item{\code{emptyTriangle}} 72 | #' \item{\code{emptyDiamond}} 73 | #' \item{\code{heart}} 74 | #' \item{\code{droplet}} 75 | #' \item{\code{pin}} 76 | #' \item{\code{arrow}} 77 | #' \item{\code{star}} 78 | #' } 79 | #' 80 | #' @examples 81 | #' let <- LETTERS[1:20] 82 | #' 83 | #' edges <- data.frame(source = sample(let, 20), target = sample(let, 20), 84 | #' weight = runif(20, 5, 20)) 85 | #' 86 | #' nodes <- data.frame(name = let, value = runif(20, 5, 25), group = rep(LETTERS[1:4], 5)) 87 | #' 88 | #' echart() %>% 89 | #' eforce(itemStyle = list(normal = list(label = list(show = TRUE)))) %>% # show labels 90 | #' enodes(nodes, name, value = value, category = group) %>% 91 | #' elinks(edges, source, target) 92 | #' 93 | #' @name nodes 94 | #' @rdname enodes 95 | #' 96 | #' @seealso \code{\link{enodes}} \code{\link{eforce}} 97 | #' 98 | #' @export 99 | enodes <- function(p, nodes, name, label, value, category, symbolSize, depth, ignore = FALSE, symbol = "circle", 100 | fixX = FALSE, fixY = FALSE){ 101 | 102 | name <- deparse(substitute(name)) 103 | label <- if(!missing(label)) deparse(substitute(label)) else NULL 104 | value <- if(!missing(value)) deparse(substitute(value)) else NULL 105 | category <- if(!missing(category)) deparse(substitute(category)) else NULL 106 | symbolSize <- if(!missing(symbolSize)) deparse(substitute(symbolSize)) else NULL 107 | depth <- if(!missing(depth)) deparse(substitute(depth)) else NULL 108 | 109 | p %>% 110 | enodes_(nodes, name, label, value, category, symbolSize, depth, ignore, symbol, fixX, fixY) 111 | 112 | } 113 | 114 | #' Build force network 115 | #' 116 | #' @param p an echart objects. 117 | #' @param name name of network. 118 | #' @param large set to \code{TRUE} to optimise for large graphs. 119 | #' @param center center of network. 120 | #' @param roam set to \code{TRUE} to enable zoom and drag. 121 | #' @param size size of layout. 122 | #' @param minRadius,maxRadius minimum and maximum radius of nodes. 123 | #' @param linkSymbol can be set to \code{arrow}. 124 | #' @param linkSymbolSize size of \code{symbol}. 125 | #' @param scaling scaling factor. 126 | #' @param gravity centripetal force coefficient. 127 | #' @param draggable set to \code{TRUE} to allow dragging nodes. 128 | #' @param useWorker specifies whether to put layout calculation into web worker when the browser supports web worker. 129 | #' @param steps the number of iterations of each frame layout calculation. 130 | #' @param z,zlevel first and second grade cascading control, the higher z the closer to the top. 131 | #' @param ... any other options to pass to serie. 132 | #' 133 | #' @examples 134 | #' let <- LETTERS[1:20] 135 | #' 136 | #' edges <- data.frame(source = sample(let, 20), target = sample(let, 20), 137 | #' weight = runif(20, 5, 20)) 138 | #' 139 | #' nodes <- data.frame(name = let, value = runif(20, 5, 25), group = rep(LETTERS[1:4], 5)) 140 | #' 141 | #' echart() %>% 142 | #' eforce(itemStyle = list(normal = list(label = list(show = TRUE)))) %>% # show labels 143 | #' enodes(nodes, name, value = value, category = group) %>% 144 | #' elinks(edges, source, target) 145 | #' 146 | #' @name eforce 147 | #' @rdname eforce 148 | #' 149 | #' @seealso \code{\link{enodes}} \code{\link{eforce}} 150 | #' 151 | #' @export 152 | eforce <- function(p, name = NULL, large = FALSE, center = list("50%", "50%"), roam = FALSE, size = "100%", 153 | minRadius = 10, maxRadius = 20, linkSymbol = "none", linkSymbolSize = list(10, 15), scaling = 1, 154 | gravity = 1, draggable = TRUE, useWorker = TRUE, steps = 1, z = 2, zlevel = 0, ...){ 155 | 156 | p %>% 157 | eforce_(name, large, center, roam, size, minRadius, maxRadius, linkSymbol, linkSymbolSize, scaling, 158 | gravity, draggable, useWorker, steps, z, zlevel, ...) 159 | 160 | } 161 | -------------------------------------------------------------------------------- /R/axis.R: -------------------------------------------------------------------------------- 1 | #' Customise Y axis 2 | #' 3 | #' @param p an echart object. 4 | #' @param show whether to show the axis. 5 | #' @param z,zlevel first and second grade cascading control, the higher z the closer to the top. 6 | #' @param type type of axis takes, \code{value}, \code{category}, \code{time}, \code{log}. 7 | #' @param append whether to append options to current axis or override. 8 | #' @param boundaryGap whether to plot on axis line or between. 9 | #' @param position position of axis, takes \code{bottom}, \code{top}, \code{left} or \code{right}. 10 | #' @param name name of the axis. 11 | #' @param nameLocation location of \code{name}, takes \code{start} or \code{end}. 12 | #' @param nameTextStyle style \code{name} text. 13 | #' @param min,max min and max values. 14 | #' @param scale If \code{FALSE}, the value axis must start with 0. If \code{TRUE}, you can set the minimum and maximum value 15 | #' of value axis as the starting and ending value of your value axis. 16 | #' @param ... any other parameter to pass to the axis. 17 | #' @param splitNumber number of segments, defaults to auto split along with the min/max. 18 | #' @param logLabelBase base log. 19 | #' @param logPositive if \code{FALSE} negative values are not supported. 20 | #' 21 | #' @examples 22 | #' df <- data.frame(x = c("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"), 23 | #' y = runif(7, 1, 5)) 24 | #' 25 | #' df %>% 26 | #' echart(x) %>% 27 | #' eline(y) %>% 28 | #' exAxis_category(boundaryGap = FALSE) 29 | #' 30 | #' df %>% 31 | #' echart(x) %>% 32 | #' ebar(y) %>% 33 | #' eyAxis_log() 34 | #' 35 | #' @name yAxis 36 | #' @rdname yAxis 37 | NULL 38 | 39 | #' @rdname yAxis 40 | #' @export 41 | eyAxis <- function(p, show = TRUE, type = "value", append = FALSE, ...){ 42 | 43 | opts <- list(...) 44 | opts$type <- type 45 | opts$show <- show 46 | 47 | p <- add_axis(p, opts, append, axis = "yAxis") 48 | 49 | p 50 | } 51 | 52 | #' @rdname yAxis 53 | #' @export 54 | eyAxis_category <- function(p, show = TRUE, zlevel = 0, z = 0, boundaryGap = FALSE, append = FALSE, ...){ 55 | 56 | opts <- axis_category(show, zlevel, z, boundaryGap, ...) 57 | 58 | p <- add_axis(p, opts, append, axis = "yAxis") 59 | 60 | p 61 | } 62 | 63 | #' @rdname yAxis 64 | #' @export 65 | eyAxis_value <- function(p, show = TRUE, zlevel = 0, z = 0, position = "left", name = NULL, 66 | nameLocation = "end", nameTextStyle = list(), boundaryGap = list(0, 0), 67 | min = NULL, max = NULL, scale = FALSE, splitNumber = NULL, append = FALSE, ...){ 68 | 69 | opts <- axis_value(show, zlevel, z, position, name, nameLocation, nameTextStyle, boundaryGap, 70 | min, max, scale, splitNumber, ...) 71 | 72 | p <- add_axis(p, opts, append, axis = "yAxis") 73 | 74 | p 75 | } 76 | 77 | #' @rdname yAxis 78 | #' @export 79 | eyAxis_time <- function(p, show = TRUE, zlevel = 0, z = 0, position = "left", name = NULL, 80 | nameLocation = "end", nameTextStyle = list(), boundaryGap = list(0, 0), 81 | min = NULL, max = NULL, scale = FALSE, splitNumber = NULL, append = FALSE, ...){ 82 | 83 | opts <- axis_time(show, zlevel, z, position, name, nameLocation, nameTextStyle, boundaryGap, 84 | min, max, scale, splitNumber, ...) 85 | 86 | p <- add_axis(p, opts, append, axis = "yAxis") 87 | 88 | p 89 | } 90 | 91 | #' @rdname yAxis 92 | #' @export 93 | eyAxis_log <- function(p, show = TRUE, zlevel = 0, z = 0, position = "left", logLabelBase = NULL, 94 | logPositive = NULL, append = FALSE, ...){ 95 | 96 | opts <- opts <- axis_log(show, zlevel, z, position, logLabelBase, logPositive, ...) 97 | 98 | p <- add_axis(p, opts, append, axis = "yAxis") 99 | 100 | p 101 | } 102 | 103 | #' Customise x axis. 104 | #' 105 | #' @param p an echart object. 106 | #' @param show whether to show the axis. 107 | #' @param z,zlevel first and second grade cascading control, the higher z the closer to the top. 108 | #' @param type type of axis takes, \code{value}, \code{category}, \code{time}, \code{log}. 109 | #' @param append whether to append options to current axis or override. 110 | #' @param boundaryGap whether to plot on axis line or between. 111 | #' @param position position of axis, takes \code{bottom}, \code{top}, \code{left} or \code{right}. 112 | #' @param name name of the axis. 113 | #' @param nameLocation location of \code{name}, takes \code{start} or \code{end}. 114 | #' @param min,max min and max values. 115 | #' @param scale If \code{FALSE}, the value axis must start with 0. If \code{TRUE}, you can set the minimum and maximum value 116 | #' of value axis as the starting and ending value of your value axis. 117 | #' @param ... any other parameter to pass to the axis. 118 | #' @param splitNumber number of segments, defaults to auto split along with the min/max. 119 | #' @param logLabelBase base log. 120 | #' @param logPositive if \code{FALSE} negative values are not supported. 121 | #' 122 | #' @examples 123 | #' mtcars$models <- row.names(mtcars) 124 | #' 125 | #' mtcars[1:10,] %>% 126 | #' echart(models) %>% 127 | #' eline(mpg) %>% 128 | #' exAxis_category() %>% 129 | #' eyAxis_value(min = 10, append = FALSE, scale = TRUE) 130 | #' 131 | #' @name xAxis 132 | #' @rdname xAxis 133 | NULL 134 | 135 | #' Customize X axis 136 | #' 137 | #' @rdname xAxis 138 | #' @export 139 | exAxis <- function(p, show = TRUE, type = "value", append = FALSE, ...){ 140 | 141 | opts <- list(...) 142 | opts$show <- show 143 | opts$data <- axis_data(type) 144 | opts$type <- type 145 | 146 | p <- axis_it(p, append, opts, "xAxis") 147 | 148 | p 149 | } 150 | 151 | #' @rdname xAxis 152 | #' @export 153 | exAxis_category <- function(p, show = TRUE, zlevel = 0, z = 0, boundaryGap = FALSE, append = FALSE, ...){ 154 | 155 | type <- "category" 156 | 157 | opts <- list(...) 158 | opts$data <- axis_data(type) 159 | opts$type <- type 160 | opts$show <- show 161 | opts$zlevel <- zlevel 162 | opts$z <- z 163 | opts$boundaryGap <- boundaryGap 164 | 165 | p <- axis_it(p, append, opts, "xAxis") 166 | 167 | p 168 | } 169 | 170 | 171 | #' @rdname xAxis 172 | #' @export 173 | exAxis_value <- function(p, show = TRUE, min = NULL, max = NULL, zlevel = 0, z = 0, position = "bottom", name = NULL, 174 | nameLocation = "end", boundaryGap = list(0, 0), scale = FALSE, splitNumber = NULL, 175 | append = FALSE, ...){ 176 | 177 | type <- "value" 178 | 179 | opts <- list(...) 180 | opts$data <- axis_data(type) 181 | opts$type <- type 182 | opts$show <- show 183 | opts$zlevel <- zlevel 184 | opts$z <- z 185 | opts$name <- if(!is.null(name)) name 186 | opts$position <- position 187 | opts$boundaryGap <- boundaryGap 188 | opts$min <- if(!is.null(min)) min 189 | opts$max <- if(!is.null(max)) max 190 | opts$nameLocation <- nameLocation 191 | opts$scale <- scale 192 | opts$splitNumber <- if(!is.null(splitNumber)) splitNumber 193 | 194 | p <- axis_it(p, append, opts, "xAxis") 195 | 196 | p 197 | 198 | } 199 | 200 | #' @rdname xAxis 201 | #' @export 202 | exAxis_time <- function(p, show = TRUE, zlevel = 0, z = 0, position = "bottom", name = NULL, 203 | nameLocation = "end", boundaryGap = list(0, 0), min = NULL, max = NULL, scale = FALSE, 204 | splitNumber = NULL, append = FALSE, ...){ 205 | 206 | type <- "time" 207 | 208 | opts <- list(...) 209 | opts$data <- axis_data(type) 210 | opts$type <- type 211 | opts$show <- show 212 | opts$zlevel <- zlevel 213 | opts$z <- z 214 | opts$name <- if(!is.null(name)) name 215 | opts$position <- position 216 | opts$boundaryGap <- boundaryGap 217 | opts$min <- if(!is.null(min)) min 218 | opts$max <- if(!is.null(max)) max 219 | opts$nameLocation <- nameLocation 220 | opts$scale <- scale 221 | opts$splitNumber <- if(!is.null(splitNumber)) splitNumber 222 | 223 | p <- axis_it(p, append, opts, "xAxis") 224 | 225 | p 226 | 227 | } 228 | 229 | #' @rdname xAxis 230 | #' @export 231 | exAxis_log <- function(p, show = TRUE, zlevel = 0, z = 0, position = "bottom", logLabelBase = NULL, 232 | logPositive = NULL, append = FALSE, ...){ 233 | 234 | type <- "log" 235 | 236 | opts <- list(...) 237 | opts$data <- axis_data(type) 238 | opts$type <- type 239 | opts$show <- show 240 | opts$zlevel <- zlevel 241 | opts$z <- z 242 | opts$position <- position 243 | opts$logLabelBase <- if(!is.null(logLabelBase)) logLabelBase 244 | opts$logPositive <- if(!is.null(logPositive)) logPositive 245 | 246 | 247 | p <- axis_it(p, append, opts, "xAxis") 248 | 249 | p 250 | } 251 | -------------------------------------------------------------------------------- /R/toolbox.R: -------------------------------------------------------------------------------- 1 | #' Setup toolbox 2 | #' 3 | #' Setup toolbox 4 | #' 5 | #' @param p an echart object. 6 | #' @param show whether to show the toolbox. 7 | #' @param z,zlevel first and second grade cascading control, the higher z the closer to the top. 8 | #' @param orient toolbox orientation, \code{horizontal} or \code{vertical}. 9 | #' @param x horizontal alignment, \code{left}, \code{right}. 10 | #' @param y vertical alignment, \code{top}, \code{center}, \code{bottom}. 11 | #' @param backgroundColor background color. 12 | #' @param borderColor border color. 13 | #' @param borderWidth border width. 14 | #' @param padding padding. 15 | #' @param itemGap space between toolbox buttons. 16 | #' @param itemSize size of buttons. 17 | #' @param color color of buttons. 18 | #' @param disableColor color of disabled item. 19 | #' @param effectiveColor color of active button. 20 | #' @param showTitle set to \code{TRUE} to show text. 21 | #' @param textStyle style of text. 22 | #' @param ... any other options. 23 | #' 24 | #' @examples 25 | #' mtcars %>% 26 | #' echart(qsec) %>% 27 | #' ebar(mpg) %>% 28 | #' etoolbox() %>% 29 | #' etoolbox_magic(type = list("line", "bar")) 30 | #' 31 | #' @export 32 | etoolbox <- function(p, show = TRUE, zlevel = 0, z = 6, orient = "horizontal", x = "right", y = "top", 33 | backgroundColor = "rgba(0,0,0,0)", borderColor = "#ccc", borderWidth = 0, padding = 5, 34 | itemGap = 10, itemSize = 16, color = NULL, disableColor = "#ddd", effectiveColor = "red", 35 | showTitle = TRUE, textStyle = NULL, ...){ 36 | 37 | if(is.null(textStyle)) textStyle <- list(fontFamily = "Arial, Verdana, sans-serif", fontSize = 12, 38 | fontStyle = "normal", fontWeight = "normal") 39 | 40 | color <- if(is.null(color)) list("#1e90ff", "#22bb22", "#4b0082", "#d2691e") else color 41 | 42 | opts <- list(...) 43 | opts$show <- show 44 | opts$zlevel <- zlevel 45 | opts$z <- z 46 | opts$orient <- orient 47 | opts$x <- x 48 | opts$y <- y 49 | opts$backgroundColor <- backgroundColor 50 | opts$borderColor <- borderColor 51 | opts$borderWidth <- borderWidth 52 | opts$padding <- padding 53 | opts$itemGap <- itemGap 54 | opts$itemSize <- itemSize 55 | opts$color <- color 56 | opts$disableColor <- disableColor 57 | opts$effectiveColor <- effectiveColor 58 | opts$showTitle <- showTitle 59 | opts$textStyle <- textStyle 60 | 61 | p$x$options$toolbox <- opts 62 | 63 | p 64 | 65 | } 66 | 67 | #' Add toolbox feature 68 | #' 69 | #' Add toolbox feature. 70 | #' 71 | #' @param p an echart object. 72 | #' @param mark markLine icons see \code{\link{etoolbox_mark}}. 73 | #' @param dataZoom dataZoom icons \code{\link{etoolbox_zoom}}. 74 | #' @param dataView dataView icons \code{\link{etoolbox_view}}. 75 | #' @param magicType magicType icons \code{\link{etoolbox_magic}}. 76 | #' @param restore restore icon \code{\link{etoolbox_restore}}. 77 | #' @param saveAsImage saveAsImage icon \code{\link{etoolbox_save}}. 78 | #' 79 | #' @examples 80 | #' mtcars %>% 81 | #' echart(qsec) %>% 82 | #' ebar(mpg) %>% 83 | #' etoolbox() %>% 84 | #' etoolbox_magic(type = list("line", "bar")) %>% 85 | #' etoolbox_feature(restore = list(show = TRUE)) 86 | #' 87 | #' @export 88 | etoolbox_feature <- function(p, mark, dataZoom, dataView, magicType, restore, saveAsImage){ 89 | 90 | opts <- list() 91 | opts$mark <- if(!missing(mark)) mark 92 | opts$dataZoom <- if(!missing(dataZoom)) dataZoom 93 | opts$dataView <- if(!missing(magicType)) magicType 94 | opts$restore <- if(!missing(restore)) restore 95 | opts$saveAsImage <- if(!missing(saveAsImage)) saveAsImage 96 | 97 | p$x$options$toolbox$feature <- append(p$x$options$toolbox$feature, opts) 98 | 99 | p 100 | } 101 | 102 | #' Add toolbox feature mark button 103 | #' 104 | #' Enable marking chart. 105 | #' 106 | #' @param p an echart object. 107 | #' @param show whether to show mark. 108 | #' @param title mark button title. 109 | #' @param lineStyle style of marked line. 110 | #' 111 | #' @examples 112 | #' mtcars %>% 113 | #' echart(qsec) %>% 114 | #' ebar(mpg) %>% 115 | #' etoolbox() %>% 116 | #' etoolbox_mark() 117 | #' 118 | #' @export 119 | etoolbox_mark <- function(p, show = TRUE, title = list(mark = "Mark", markUndo = "Undo", markClear = "Clear"), 120 | lineStyle = list(color = "#1e90ff", typed = "dashed", width = 2, shadowColor = "rgba(0,0,0,0)", 121 | shadowBlur = 5, shadowOffsetX = 3, shadowOffsetY = 3)){ 122 | 123 | opts <- list() 124 | opts$show <- show 125 | opts$title <- title 126 | opts$lineStyle <- lineStyle 127 | 128 | p <- add_toolbox_elem(p, opts, "mark") 129 | 130 | p 131 | 132 | } 133 | 134 | #' Add toolbox zoom button 135 | #' 136 | #' Add zoom feature. 137 | #' 138 | #' @param p an echart object. 139 | #' @param show whether to show zoom. 140 | #' @param title button title. 141 | #' 142 | #' @examples 143 | #' mtcars %>% 144 | #' echart(qsec) %>% 145 | #' ebar(mpg) %>% 146 | #' etoolbox() %>% 147 | #' etoolbox_zoom() 148 | #' 149 | #' @export 150 | etoolbox_zoom <- function(p, show = TRUE, title = list(dataZoom = "Area Zoom", dataZoomReset = "Reset")){ 151 | 152 | opts <- list() 153 | opts$show <- show 154 | opts$title <- title 155 | 156 | p <- add_toolbox_elem(p, opts, "dataZoom") 157 | 158 | p 159 | 160 | } 161 | 162 | #' Add toolbox data view 163 | #' 164 | #' Enables viewing data table. 165 | #' 166 | #' @param p an echart object. 167 | #' @param show whether to show data view. 168 | #' @param title button title. 169 | #' @param readOnly set as read-only. 170 | #' @param lang default text. 171 | #' @param ... any other parameters to pass to data view. 172 | #' 173 | #' @examples 174 | #' mtcars %>% 175 | #' echart(qsec) %>% 176 | #' ebar(mpg) %>% 177 | #' etoolbox() %>% 178 | #' etoolbox_view() 179 | #' 180 | #' @export 181 | etoolbox_view <- function(p, show = TRUE, title = "View", readOnly = FALSE, lang = list('Data View', 'close', 'refresh'), ...){ 182 | 183 | opts <- list(...) 184 | opts$show <- show 185 | opts$title <- title 186 | opts$readOnly <- readOnly 187 | opts$lang <- lang 188 | 189 | p <- add_toolbox_elem(p, opts, "dataView") 190 | 191 | p 192 | 193 | } 194 | 195 | #' Add toolbox magic buttons 196 | #' 197 | #' Enable changing chart type. 198 | #' 199 | #' @param p an echart object. 200 | #' @param show wehtehr to show magic buttons. 201 | #' @param type chart types, see details. 202 | #' @param title titles of charts. 203 | #' @param ... any other options to pass to magic feature. 204 | #' 205 | #' @details 206 | #' Pass a \code{list} to \code{type}, valid values are: 207 | #' 208 | #' \itemize{ 209 | #' \item{\code{line}} 210 | #' \item{\code{bar}} 211 | #' \item{\code{stack}} 212 | #' \item{\code{tiled}} 213 | #' \item{\code{force}} 214 | #' \item{\code{chord}} 215 | #' \item{\code{pie}} 216 | #' \item{\code{funnel}} 217 | #' } 218 | #' 219 | #' @examples 220 | #' mtcars %>% 221 | #' echart(disp) %>% 222 | #' ebar(mpg, stack = "grp") %>% # stack 223 | #' ebar(qsec, stack = "grp") %>% # stack 224 | #' ebar(wt) %>% # not stacked 225 | #' etooltip() %>% 226 | #' elegend() %>% 227 | #' etoolbox() %>% 228 | #' etoolbox_magic(type = list("bar", "line", "stack", "tiled")) 229 | #' 230 | #' @export 231 | etoolbox_magic <- function(p, show = TRUE, type = list(), title, ...){ 232 | 233 | title <- if(missing(title)) list(line = "line", 234 | bar = "bar", 235 | stack = "stack", 236 | tiled = "tiled", 237 | force = "force", 238 | chord = "chord", 239 | pie = "pie", 240 | funnel = "funnel") 241 | 242 | opts <- list(...) 243 | opts$show <- show 244 | opts$title <- title 245 | opts$type <- type 246 | 247 | p <- add_toolbox_elem(p, opts, "magicType") 248 | 249 | p 250 | 251 | } 252 | 253 | #' Add toolbox restore button 254 | #' 255 | #' Add toolbox restore button. 256 | #' 257 | #' @param p an echart object. 258 | #' @param show whether to show button. 259 | #' @param title title of button. 260 | #' 261 | #' @examples 262 | #' mtcars %>% 263 | #' echart(disp) %>% 264 | #' ebar(mpg, stack = "grp") %>% # stack 265 | #' ebar(qsec, stack = "grp") %>% # stack 266 | #' ebar(wt) %>% # not stacked 267 | #' etoolbox_restore() 268 | #' 269 | #' @export 270 | etoolbox_restore <- function(p, show = TRUE, title = "Reset"){ 271 | 272 | opts <- list() 273 | opts$show <- show 274 | opts$title <- title 275 | 276 | p <- add_toolbox_elem(p, opts, "restore") 277 | 278 | p 279 | 280 | } 281 | 282 | #' Add toolbox save as image button 283 | #' 284 | #' Add save as image button. 285 | #' 286 | #' @param p an echart object. 287 | #' @param show whether to show the button. 288 | #' @param title title of button. 289 | #' @param type image type 290 | #' @param name of file. 291 | #' @param lang text. 292 | #' 293 | #' @examples 294 | #' mtcars %>% 295 | #' echart(disp) %>% 296 | #' ebar(mpg, stack = "grp") %>% # stack 297 | #' ebar(qsec, stack = "grp") %>% # stack 298 | #' etoolbox() %>% 299 | #' etoolbox_save() 300 | #' 301 | #' 302 | #' @export 303 | etoolbox_save <- function(p, show = TRUE, title = "Save as image", type = "png", name = "echarts", lang = "Save"){ 304 | 305 | opts <- list() 306 | opts$show <- show 307 | opts$title <- title 308 | 309 | p <- add_toolbox_elem(p, opts, "saveAsImage") 310 | 311 | p 312 | 313 | } 314 | 315 | #' Add all elements of toolbox 316 | #' 317 | #' Adds toolbok mark, restor, save, and view. 318 | #' 319 | #' @param p an echart object. 320 | #' @param ... any other option to pass to \code{\link{etoolbox}}. 321 | #' 322 | #' @details Adds mark, restore, save, view and zoom buttons 323 | #' 324 | #' @export 325 | etoolbox_full <- function(p, ...){ 326 | 327 | p <- p %>% 328 | etoolbox(...) %>% 329 | etoolbox_mark() %>% 330 | etoolbox_restore() %>% 331 | etoolbox_save() %>% 332 | etoolbox_zoom() %>% 333 | etoolbox_view() 334 | 335 | p 336 | } 337 | -------------------------------------------------------------------------------- /R/add.R: -------------------------------------------------------------------------------- 1 | #' @rdname ebar 2 | #' @export 3 | ebar <- function(p, serie, name = NULL, stack = NULL, clickable = TRUE, xAxisIndex = 0, yAxisIndex = 0, barGap = "100%", 4 | barCategoryGap = "20%", legendHoverLink = TRUE, z = 2, zlevel = 0, ...){ 5 | 6 | serie <- deparse(substitute(serie)) 7 | 8 | p %>% 9 | ebar_(serie, name, stack, clickable, xAxisIndex, yAxisIndex, barGap, barCategoryGap, legendHoverLink, z, zlevel, ...) 10 | 11 | } 12 | 13 | #' @rdname eline 14 | #' @export 15 | eline <- function(p, serie, name = NULL, stack = NULL, clickable = TRUE, xAxisIndex = 0, yAxisIndex = 0, symbol = NULL, 16 | symbolSize = "2 | 4", symbolRotate = NULL, showAllSymbol = FALSE, smooth = TRUE, legendHoverLink = TRUE, 17 | dataFilter = "nearest", z = 2, zlevel = 0, tooltip, ...){ 18 | 19 | serie <- deparse(substitute(serie)) 20 | tooltip <- if(missing(tooltip)) default_tooltip(trigger = "axis") 21 | 22 | p %>% 23 | eline_(serie, name, stack, clickable, xAxisIndex, yAxisIndex, symbol, symbolSize, symbolRotate, showAllSymbol, smooth, 24 | legendHoverLink, dataFilter, z, zlevel, tooltip, ...) 25 | 26 | } 27 | 28 | #' @rdname earea 29 | #' @export 30 | earea <- function(p, serie, name = NULL, stack = NULL, smooth = TRUE, ...){ 31 | 32 | serie <- deparse(substitute(serie)) 33 | 34 | p %>% 35 | earea_(serie, name, stack, smooth, ...) 36 | } 37 | 38 | #' @rdname escatter 39 | #' @export 40 | escatter <- function(p, serie, size = NULL, name = NULL, clickable = TRUE, symbol = NULL, symbolSize = 4, symbolRotate = NULL, 41 | large = FALSE, largeThreshold = 2000, legendHoverLink = TRUE, z = 2, zlevel = 0, ...){ 42 | 43 | serie <- deparse(substitute(serie)) 44 | size <- if(!missing(size)) deparse(substitute(size)) else NULL 45 | 46 | p %>% 47 | escatter_(serie, size, name, clickable, symbol, symbolSize, symbolRotate, large, largeThreshold, legendHoverLink, z, zlevel, ...) 48 | } 49 | 50 | #' @rdname epie 51 | #' @export 52 | epie <- function(p, serie, name = NULL, clickable = TRUE, legendHoverLink = TRUE, center = list("50%", "50%"), 53 | radius = list(0, "75%"), startAngle = 90, minAngle = 0, clockWise = TRUE, roseType = NULL, selectedOffset = 10, 54 | selectedMode = TRUE, z = 2, zlevel = 0, ...){ 55 | 56 | serie <- deparse(substitute(serie)) 57 | 58 | p %>% 59 | epie_(serie, name, clickable, legendHoverLink, center, radius, startAngle, minAngle, clockWise, roseType, selectedOffset, 60 | selectedMode, z, zlevel, ...) 61 | } 62 | 63 | #' @rdname eradar 64 | #' @export 65 | eradar <- function(p, serie, name = NULL, clickable = TRUE, symbol = NULL, symbolSize = 4, symbolRotate = NULL, 66 | legendHoverLink = TRUE, polarIndex = 0, z = 2, zlevel = 0, ...){ 67 | 68 | serie <- deparse(substitute(serie)) 69 | 70 | p %>% 71 | eradar_(serie, name, clickable, symbol, symbolSize, symbolRotate, legendHoverLink, polarIndex, z, zlevel, ...) 72 | } 73 | 74 | #' @rdname echord 75 | #' @export 76 | echord <- function(p, name = NULL, sort = "none", sortSub = "none", clickable = TRUE, z = 2, zlevel = 0, 77 | symbol = NULL, symbolSize = NULL, clockWise = FALSE, minRadius = 10, maxRadius = 20, 78 | ribbonType = TRUE, showScale = FALSE, showScaleText = FALSE, padding = 2, ...){ 79 | 80 | p %>% 81 | echord_(name, sort, sortSub, clickable, z, zlevel, symbol, symbolSize, clockWise, minRadius, maxRadius, 82 | ribbonType, showScale, showScaleText, padding, ...) 83 | } 84 | 85 | #' @rdname emap_choropleth 86 | #' @export 87 | emap_choropleth <- function(p, serie){ 88 | 89 | serie <- deparse(substitute(serie)) 90 | 91 | p %>% 92 | emap_choropleth_(serie) 93 | } 94 | 95 | #' @rdname emap_coords 96 | #' @export 97 | emap_coords <- function(p, lon, lat){ 98 | 99 | lon <- deparse(substitute(lon)) 100 | lat <- deparse(substitute(lat)) 101 | 102 | p %>% 103 | emap_coords_(lon, lat) 104 | } 105 | 106 | #' 107 | #' @rdname emap_lines 108 | #' 109 | #' @export 110 | emap_lines <- function(p, edges, source, target, name = NULL, clickable = TRUE, symbol = "arrow", 111 | symbolSize = 2, symbolRotate = NULL, large = FALSE, smooth = TRUE, z = 2, zlevel = 0, 112 | smoothness = 0.2, precision = 2, bundling = list(enable = FALSE, maxTurningAngle = 45), ...){ 113 | 114 | source <- deparse(substitute(source)) 115 | target <- deparse(substitute(target)) 116 | 117 | p %>% 118 | emap_lines_(edges, source, target, name, clickable, symbol, symbolSize, symbolRotate, large, smooth, z, zlevel, 119 | smoothness, precision, bundling, ...) 120 | } 121 | 122 | #' @rdname emap_points 123 | #' @export 124 | emap_points <- function(p, serie, clickable = TRUE, symbol = "pin", symbolSize = 10, 125 | symbolRotate = NULL, large = FALSE, itemStyle = NULL, ...){ 126 | 127 | serie <- deparse(substitute(serie)) 128 | itemStyle <- if(is.null(itemStyle)) list(normal = list(label = list(show = FALSE))) else itemStyle 129 | 130 | p %>% 131 | emap_points_(serie, clickable, symbol, symbolSize, symbolRotate, large, itemStyle, ...) 132 | } 133 | 134 | #' @rdname emap_heat 135 | #' @export 136 | emap_heat <- function(p, lon, lat, z, blurSize = 30, minAlpha = 0.05, valueScale = 1, opacity = 1, 137 | gradientColors = NULL, ...){ 138 | 139 | gradientColors <- if(is.null(gradientColors)) default_gradient() else gradientColors 140 | lon <- deparse(substitute(lon)) 141 | lat <- deparse(substitute(lat)) 142 | z <- deparse(substitute(z)) 143 | 144 | p %>% 145 | emap_heat_(lon, lat, z, blurSize, minAlpha, valueScale, opacity, gradientColors, ...) 146 | } 147 | 148 | #' @rdname emap 149 | #' @export 150 | emap <- function(p, name = NULL, mapType = "world", clickable = TRUE, z = 2, zlevel = 0, 151 | selectedMode = NULL, hoverable = FALSE, dataRangeHoverLink = TRUE, 152 | mapLocation = list(x = "center", y = "center"), mapValueCalculation = "sum", 153 | mapValuePrecision = 0, showLegendSymbol = TRUE, roam = FALSE, scaleLimit = NULL, 154 | nameMap = NULL, textFixed = NULL, ...){ 155 | 156 | p %>% 157 | emap_(name, mapType, clickable, z, zlevel, selectedMode, hoverable, dataRangeHoverLink, mapLocation, mapValueCalculation, 158 | mapValuePrecision, showLegendSymbol, roam, scaleLimit, nameMap, textFixed, ...) 159 | 160 | } 161 | 162 | #' @rdname egauge 163 | #' @export 164 | egauge <- function(p, value, indicator = "", name = NULL, clickable = FALSE, legendHoverLink = TRUE, center = list("50%", "50%"), 165 | radius = list("0%", "75%"), startAngle = 225, endAngle = -45, min = 0, max = 100, 166 | splitNumber = 10, z = 2, zlevel = 0, tooltip, ...){ 167 | 168 | tooltip <- if(missing(tooltip)) default_tooltip(trigger = "item") 169 | name <- ifelse(is.null(name), indicator, name) 170 | 171 | p %>% 172 | egauge_(value, indicator, name, clickable, legendHoverLink, center, radius, startAngle, endAngle, min, max, 173 | splitNumber , z, zlevel, tooltip, ...) 174 | } 175 | 176 | #' @rdname efunnel 177 | #' @export 178 | efunnel <- function(p, serie, name = NULL, clickable = TRUE, legendHoverLink = TRUE, sort = "descending", 179 | min = NULL, max = NULL, x = 80, y = 60, x2 = 80, y2 = 60, width = NULL, height = NULL, 180 | funnelAlign = "center", minSize = "0%", maxSize = "100%", gap = 0, tooltip, ...){ 181 | 182 | tooltip <- if(missing(tooltip)) default_tooltip(trigger = "item") 183 | serie <- deparse(substitute(serie)) 184 | 185 | p %>% 186 | efunnel_(serie, name, clickable, legendHoverLink, sort, min, max, x, y, x2, y2, width, height, 187 | funnelAlign, minSize, maxSize, gap, tooltip, ...) 188 | } 189 | 190 | #' @rdname evenn 191 | #' @export 192 | evenn <- function(p, serie, name = NULL, clickable = TRUE, z = 2, zlevel = 0, tooltip = NULL, ...){ 193 | 194 | serie <- deparse(substitute(serie)) 195 | tooltip <- if(is.null(tooltip)) default_tooltip(trigger = "item") else tooltip 196 | 197 | p %>% 198 | evenn_( serie, name, clickable, z, zlevel, tooltip, ...) 199 | } 200 | 201 | #' @rdname ecloud 202 | #' @export 203 | ecloud <- function(p, freq, color, name = NULL, clickable = TRUE, center = list("50%", "50%"), size = list("100%", "100%"), 204 | textRotation = list(0, 90), autoSize = list(enable = TRUE, minSize = 12), z = 2, zlevel = 0, tooltip, ...){ 205 | 206 | tooltip <- if(missing(tooltip)) default_tooltip(trigger = "item") 207 | freq <- deparse(substitute(freq)) 208 | color <- if(!missing(color)) deparse(substitute(color)) else NULL 209 | 210 | p %>% 211 | ecloud_(freq, color, name, clickable, center, size, textRotation, autoSize, z, zlevel, tooltip, ...) 212 | } 213 | 214 | #' @rdname eheatmap 215 | #' @export 216 | eheatmap <- function(p, y, values, name = NULL, clickable = TRUE, blurSize = 30, minAlpha = 0.5, valueScale = 1, 217 | opacity = 1, z = 2, zlevel = 0, gradientColors, tooltip, ...){ 218 | 219 | gradientColors <- if(missing(gradientColors)) default_gradient() else gradientColors 220 | tooltip <- if(missing(tooltip)) default_tooltip(trigger = "item") 221 | y <- deparse(substitute(y)) 222 | values <- deparse(substitute(values)) 223 | 224 | p %>% 225 | eheatmap_(y, values, name, clickable, blurSize, minAlpha, valueScale, opacity, z, zlevel, gradientColors, tooltip, ...) 226 | } 227 | 228 | #' @rdname edata 229 | #' @export 230 | edata <- function(p, data, x){ 231 | 232 | # x 233 | if(!missing(x)){ 234 | xvar <- tryCatch(eval(substitute(x), data), error = function(e) e) 235 | if(is(xvar, "error")){ 236 | xvar <- x 237 | } 238 | } else { 239 | xvar <- list() 240 | } 241 | 242 | if(!missing(data)){ 243 | data <- map_grps_(data) 244 | assign("data", data, envir = data_env) 245 | } 246 | 247 | # assign for future use 248 | assign("x", xvar, envir = data_env) 249 | if(length(xvar)) assign("x.name", deparse(substitute(x)), envir = data_env) 250 | 251 | p 252 | 253 | } 254 | 255 | #' @rdname etreemap 256 | #' @export 257 | etreemap <- function(p, serie, name = NULL, itemStyle = NULL, clickable = FALSE, center = list("50%", "50%"), 258 | size = list("80%", "80%"), z = 2, zlevel = 0, ...){ 259 | 260 | serie <- deparse(substitute(serie)) 261 | 262 | p <- p %>% 263 | etreemap_(serie, name, itemStyle, clickable, center, size, z, zlevel, ...) 264 | 265 | p 266 | 267 | } 268 | 269 | #' @rdname candlestick 270 | #' @export 271 | ecandle <- function(p, opening, closing, low, high, name = NULL, clickable = TRUE, z = 2, zlevel = 0, ...){ 272 | 273 | opening <- deparse(substitute(opening)) 274 | closing <- deparse(substitute(closing)) 275 | low <- deparse(substitute(low)) 276 | high <- deparse(substitute(high)) 277 | 278 | p <- p %>% 279 | ecandle_(opening, closing, low, high, name = NULL, clickable = TRUE, z = 2, zlevel = 0, ...) 280 | 281 | p 282 | 283 | } 284 | -------------------------------------------------------------------------------- /R/utils.R: -------------------------------------------------------------------------------- 1 | # change NA to `-` : ECharts missing data 2 | na2ec <- function(data){ 3 | data[is.na(data)] <- "-" 4 | data 5 | } 6 | 7 | # fetch data 8 | get_dat <- function(serie){ 9 | data <- get("data", envir = data_env) 10 | if(length(data) == 1) names(data) <- serie 11 | data 12 | } 13 | 14 | # simple data vector 15 | vector_data_ <- function(data, serie){ 16 | data[, serie] 17 | } 18 | 19 | # xy_data_ for line and bar 20 | xy_data_ <- function(data, serie, stack){ 21 | x <- get("x.name", envir = data_env) 22 | x <- data[, x] 23 | if(class(x)[1] == "integer" || class(x)[1] == "numeric") { 24 | if(is.null(stack)){ 25 | x <- cbind(x, data[, serie]) 26 | colnames(x) <- NULL 27 | x <- x[order(x[,1]),] 28 | x <- apply(x, 1, as.list) 29 | } else { 30 | x <- data[, serie] 31 | } 32 | } else { 33 | x <- data[, serie] 34 | } 35 | return(x) 36 | } 37 | 38 | # override axis depending on data type 39 | adjust_axis <- function(p, data, stack){ 40 | 41 | data <- do.call("rbind.data.frame", lapply(data, as.data.frame)) 42 | 43 | x.name <- get("x.name", envir = data_env) 44 | x <- data[, x.name] 45 | 46 | if(class(x)[1] == "integer" || class(x)[1] == "numeric") { 47 | p$x$options$yAxis <- list(list(type = "value")) 48 | if(is.null(stack)){ 49 | p$x$options$xAxis <- list(list(type = "value", min = min(x), max = max(x))) 50 | } else { 51 | x <- sort(x) 52 | p$x$options$xAxis <- list(list(type = "category", data = x)) 53 | } 54 | } 55 | p 56 | } 57 | 58 | # prepare scatter data 59 | scatter_data_ <- function(data, serie, size = NULL, symbolSize){ 60 | 61 | # get for eval 62 | x <- get("x", envir = data_env) 63 | 64 | serie <- data[, serie] 65 | 66 | # build matrix 67 | if(!is.null(size)){ 68 | size <- data[, size] 69 | size <- normalise_size(size, symbolSize) 70 | values <- suppressWarnings(cbind(x, serie, size)) 71 | } else { 72 | values <- suppressWarnings(cbind(x, serie)) 73 | } 74 | 75 | colnames(values) <- NULL # remove names 76 | 77 | values <- apply(values, 1, as.list) 78 | 79 | return(values) 80 | } 81 | 82 | # return list of i.e.:{name: 'name', value: 3} 83 | val_name_data_ <- function(data, serie){ 84 | 85 | # get for eval 86 | x <- get("x", envir = data_env) 87 | 88 | serie <- data[, serie] 89 | 90 | data <- cbind.data.frame(x, serie) 91 | names(data) <- c("name", "value") 92 | 93 | data <- apply(data, 1, as.list) 94 | 95 | return(data) 96 | } 97 | 98 | # polar indicator for radar 99 | polar_indicator <- function(){ 100 | x <- get("x", envir = data_env) 101 | x <- unique(x) 102 | x <- data.frame(text = x) 103 | x <- apply(x, 1, as.list) 104 | return(x) 105 | } 106 | 107 | # data for chord diagram 108 | chord_data <- function(){ 109 | x <- get("x", envir = data_env) 110 | x <- data.frame(name = x) 111 | x <- apply(x, 1, as.list) 112 | return(x) 113 | } 114 | 115 | # process chord matrix 116 | chord_matrix <- function(){ 117 | 118 | matrix <- get("data", envir = data_env) 119 | matrix <- matrix[[1]] 120 | 121 | x.len <- length(get("x", envir = data_env)) 122 | 123 | if(ncol(matrix) != nrow(matrix)) stop("uneven columns and rows", call. = FALSE) 124 | if(x.len != ncol(matrix)) stop("length of x != matrix dimensions", call. = FALSE) 125 | 126 | colnames(matrix) <- NULL # remove names 127 | 128 | matrix <- apply(matrix, 2, as.numeric) # to numeric! 129 | matrix <- apply(matrix, 1, as.list) 130 | 131 | return(matrix) 132 | } 133 | 134 | # default colorbar 135 | # no data shows without... 136 | default_dataRange_ <- function(data, serie){ 137 | serie <- data[, serie] 138 | 139 | calc <- class2calc(serie) 140 | 141 | dataRange <- list( 142 | min = min(serie), 143 | max = max(serie), 144 | calculable = calc 145 | ) 146 | 147 | return(dataRange) 148 | 149 | } 150 | 151 | # use class to define `calculable` 152 | class2calc <- function(x){ 153 | 154 | if(class(x)[1] == "integer" || class(x)[1] == "numeric"){ 155 | TRUE 156 | } else { 157 | FALSE 158 | } 159 | } 160 | 161 | # build coordinates 162 | build_coord_ <- function(data, lon, lat){ 163 | 164 | x <- get("x.name", envir = data_env) 165 | x <- data[, x] 166 | 167 | # build serie for EC 168 | serie <- data[, c(lon, lat)] 169 | rownames(serie) <- NULL 170 | colnames(serie) <- NULL 171 | 172 | # to list 173 | serie <- apply(serie, 1, as.list) 174 | 175 | if(!is(x, "error")) names(serie) <- x 176 | 177 | return(serie) 178 | 179 | } 180 | 181 | # lines on map / edges 182 | map_lines_ <- function(data, source, target){ 183 | 184 | # source & target 185 | source <- data[, source] 186 | target <- data[, target] 187 | 188 | # essential for list building, vectors break 189 | source <- as.character(source) # force character 190 | target <- as.character(target) # force character 191 | 192 | # list of lists 193 | edges <- list() 194 | for(i in 1:length(source)){ 195 | edges[[i]] <- list(list(name = source[i]), list(name = target[i])) 196 | } 197 | 198 | return(edges) 199 | } 200 | 201 | # wordcloud data 202 | cloud_data_ <- function(data, freq, color){ 203 | 204 | x <- get("x", envir = data_env) # get words 205 | 206 | # build data 207 | freq <- data[, freq] 208 | 209 | df <- cbind.data.frame(as.character(x), freq) 210 | names(df) <- c("name", "value") 211 | 212 | df <- apply(df, 1, as.list) 213 | 214 | if(!is.null(color)){ 215 | color <- data[, color] 216 | for(i in 1:length(color)){ 217 | df[[i]]$itemStyle <- list(normal = list(color = color[i])) 218 | } 219 | } 220 | 221 | return(df) 222 | } 223 | 224 | # heatmap 225 | heat_data_ <- function(data, y, z){ 226 | 227 | x <- get("x", envir = data_env) # get words 228 | 229 | # source 230 | y <- data[, y] 231 | z <- data[, z] 232 | 233 | df <- cbind(x, y, z) 234 | colnames(df) <- NULL # remove names 235 | 236 | df <- apply(df, 1, as.list) 237 | 238 | return(df) 239 | } 240 | 241 | # data for heatmap 242 | heat_map_data_ <- function(lon, lat, z){ 243 | 244 | # build data 245 | data <- get("data", envir = data_env) 246 | data <- data[[1]] 247 | 248 | # source 249 | df <- data[, c(lon, lat, z)] 250 | colnames(df) <- NULL # remove names 251 | 252 | df <- apply(df, 1, as.list) 253 | 254 | return(df) 255 | } 256 | 257 | # default legend setup 258 | default_legend <- function(p){ 259 | series <- p$x$options$series 260 | 261 | name <- list() 262 | for(i in 1:length(series)){ 263 | name[[i]] <- series[[i]]$name 264 | } 265 | 266 | return(name) 267 | } 268 | 269 | # default tooltip 270 | default_tooltip <- function(show = TRUE, trigger = "axis", zlevel = 1, z = 8, showContent = TRUE, 271 | position = NULL, formatter = NULL, islandFormatter = "{a} < br/>{b} : {c}", 272 | showDelay = 5, hideDelay = 100, transitionDuration = 4, enterable = FALSE, 273 | backgroundColor = "rgba(0,0,0,0.7)", borderColor = "#333", borderRadius = 4, 274 | borderWidth = 0, padding = 5, axisPointer, textStyle, ...){ 275 | 276 | textStyle <- if(missing(textStyle)) list(fontFamily = "Arial, Verdana, sans-serif", fontSize = 12, 277 | fontStyle = "normal", fontWeight = "normal") 278 | 279 | opts <- list(...) 280 | opts$show <- show 281 | opts$trigger <- trigger 282 | opts$zlevel <- zlevel 283 | opts$showContent <- showContent 284 | opts$position <- position 285 | opts$formatter <- formatter 286 | opts$islandFormatter <- islandFormatter 287 | opts$showDelay <- showDelay 288 | opts$hideDelay <- hideDelay 289 | opts$transitionDuration <- transitionDuration 290 | opts$enterable <- enterable 291 | opts$backgroundColor <- backgroundColor 292 | opts$borderColor <- borderColor 293 | opts$borderRadius <- borderRadius 294 | opts$borderWidth <- borderWidth 295 | opts$padding <- padding 296 | opts$axisPointer <- if(!missing(axisPointer)) axisPointer 297 | opts$textStyle <- if(!missing(textStyle)) textStyle 298 | 299 | return(opts) 300 | 301 | } 302 | 303 | default_gradient <- function(){ 304 | list("blue", "cyan", "lime", "yellow", "red") 305 | } 306 | 307 | build_nodes <- function(nodes, name, label = NULL, value = NULL, category = NULL, symbolSize = NULL, 308 | ignore = FALSE, symbol = "circle", fixX = FALSE, fixY = FALSE){ 309 | 310 | name <- eval(substitute(name, parent.frame()), nodes) 311 | ignore <- if(length(ignore) > 1) eval(substitute(ignore, parent.frame()), nodes) 312 | symbol <- if(length(symbol) > 1) eval(substitute(symbol, parent.frame()), nodes) 313 | fixX <- if(length(fixX) > 1) eval(substitute(fixX, parent.frame()), nodes) 314 | fixY <- if(length(fixY) > 1) eval(substitute(fixY, parent.frame()), nodes) 315 | 316 | vertices <- data.frame(row.names = 1:length(name)) 317 | vertices$name <- name 318 | vertices$value <- if(!is.null(value)) eval(substitute(value, parent.frame()), nodes) 319 | vertices$symbolSize <- if(!is.null(symbolSize)) eval(substitute(symbolSize, parent.frame()), nodes) 320 | vertices$label <- if(!is.null(label)) eval(substitute(label, parent.frame()), nodes) 321 | vertices$category <- if(!is.null(category)) eval(substitute(category, parent.frame()), nodes) 322 | vertices$ignore <- ignore 323 | vertices$symbol <- symbol 324 | vertices$fixX <- fixX 325 | vertices$fixY <- fixY 326 | 327 | row.names(vertices) <- NULL 328 | vertices <- apply(vertices, 1, as.list) 329 | 330 | return(vertices) 331 | 332 | } 333 | 334 | build_links_ <- function(edges, source, target, weight = 1){ 335 | 336 | source <- edges[, source] 337 | source <- as.character(unname(unlist(source))) 338 | target <- edges[, target] 339 | target <- as.character(unname(unlist(target))) 340 | if(class(weight)[1] == "character") edges[, weight] 341 | 342 | links <- cbind.data.frame(source, target) 343 | links$weight <- weight 344 | 345 | links <- apply(links, 1, as.list) 346 | 347 | return(links) 348 | 349 | } 350 | 351 | mark <- function(p, which, opts, type = "markPoint"){ 352 | 353 | if(which == "previous"){ 354 | 355 | previous <- length(p$x$options$series) 356 | p$x$options$series[[previous]][[type]] <- opts 357 | 358 | } else if(tolower(which) == "all"){ 359 | 360 | for(i in 1:length(p$x$options$series)){ 361 | p$x$options$series[[i]][[type]] <- opts 362 | } 363 | 364 | } else { 365 | 366 | # get all series names 367 | post <- get_series_name(p, which) 368 | 369 | p$x$options$series[[post]][[type]] <- opts 370 | 371 | } 372 | 373 | p 374 | } 375 | 376 | axis_category <- function(show = TRUE, zlevel = 0, z = 0, boundaryGap = FALSE, ...){ 377 | 378 | opts <- list(...) 379 | opts$type <- "category" 380 | opts$show <- show 381 | opts$zlevel <- zlevel 382 | opts$z <- z 383 | opts$boundaryGap <- boundaryGap 384 | 385 | return(opts) 386 | } 387 | 388 | axis_value <- function(show = TRUE, zlevel = 0, z = 0, position = "left", name = NULL, 389 | nameLocation = "end", nameTextStyle = list(), boundaryGap = list(0, 0), 390 | min = NULL, max = NULL, scale = FALSE, splitNumber = NULL, ...){ 391 | 392 | opts <- list(...) 393 | opts$type <- "value" 394 | opts$show <- show 395 | opts$zlevel <- zlevel 396 | opts$z <- z 397 | opts$position <- position 398 | opts$name <- name 399 | opts$nameLocation <- nameLocation 400 | opts$nameTextStyle <- nameTextStyle 401 | opts$boundaryGap <- boundaryGap 402 | opts$min <- min 403 | opts$max <- max 404 | opts$scale <- scale 405 | opts$splitNumber <- splitNumber 406 | 407 | return(opts) 408 | } 409 | 410 | axis_time <- function(show = TRUE, zlevel = 0, z = 0, position = "bottom", name = NULL, 411 | nameLocation = "end", nameTextStyle = list(), boundaryGap = list(0, 0), 412 | min = NULL, max = NULL, scale = FALSE, splitNumber = NULL, ...){ 413 | 414 | opts <- list(...) 415 | opts$type <- "time" 416 | opts$show <- show 417 | opts$zlevel <- zlevel 418 | opts$z <- z 419 | opts$position <- position 420 | opts$name <- name 421 | opts$nameLocation <- nameLocation 422 | opts$nameTextStyle <- nameTextStyle 423 | opts$boundaryGap <- boundaryGap 424 | opts$min <- min 425 | opts$max <- max 426 | opts$scale <- scale 427 | opts$splitNumber <- splitNumber 428 | 429 | return(opts) 430 | } 431 | 432 | axis_log <- function(show = TRUE, zlevel = 0, z = 0, position = "left", logLabelBase = NULL, 433 | logPositive = NULL, ...){ 434 | 435 | opts <- list(...) 436 | opts$type <- "log" 437 | opts$show <- show 438 | opts$zlevel <- zlevel 439 | opts$z <- z 440 | opts$position <- position 441 | opts$name <- logLabelBase 442 | opts$nameLocation <- logLabelBase 443 | 444 | return(opts) 445 | } 446 | 447 | get_axis_type <- function(x){ 448 | 449 | cl <- class(x)[1] 450 | 451 | if(cl == "character" || cl == "factor" || cl == "date"){ 452 | return("category") 453 | } else { 454 | return("value") 455 | } 456 | 457 | } 458 | 459 | add_axis <- function(p, opts, append = FALSE, axis){ 460 | 461 | # if append = FALSE override 462 | if(append == FALSE){ 463 | p$x$options[[axis]] <- list(opts) 464 | } else { 465 | index <- length(p$x$options[[axis]]) + 1 466 | 467 | data <- tryCatch(p$x$options[[axis]][[index]]$data, error = function(e) e) 468 | p$x$options[[axis]][[index]] <- opts 469 | 470 | if(!is(data, "error")){ 471 | p$x$options[[axis]][[index]]$data <- data 472 | } 473 | 474 | } 475 | 476 | p 477 | } 478 | 479 | add_toolbox_elem <- function(p, opts, elem){ 480 | 481 | tb <- p$x$options$toolbox 482 | 483 | if(!length(tb)){ 484 | p <- p %>% 485 | etoolbox() 486 | } 487 | 488 | p$x$options$toolbox$feature[[elem]] <- opts 489 | 490 | p 491 | 492 | } 493 | 494 | # return name index 495 | get_series_name <- function(p, which){ 496 | 497 | # get all series names 498 | n <- lapply(1:length(p$x$options$series), function(x){ 499 | p$x$options$series[[x]]$name 500 | }) 501 | 502 | position <- grep(paste0("^", which, "$"), n) # get which position 503 | 504 | if(!length(position)) stop(paste("cannot find serie named:", which), call. = FALSE) 505 | 506 | return(position) 507 | } 508 | 509 | get_min_ <- function(serie){ 510 | min(serie) 511 | } 512 | 513 | get_max_ <- function(serie){ 514 | max(serie) 515 | } 516 | 517 | # set calculable according to class 518 | is_calculable_ <- function(x){ 519 | cl <- class(x)[1] 520 | if(cl == "integer" || cl == "numeric"){ 521 | TRUE 522 | } else { 523 | FALSE 524 | } 525 | } 526 | 527 | get_pie_legend <- function(){ 528 | x <- get("x", envir = data_env) 529 | return(as.character(x)) 530 | } 531 | 532 | get_map_index_ <- function(p, series_name){ 533 | all_names <- mapply(function(x){ x[["name"]]}, p$x$options$series) 534 | index <- match(series_name, all_names) 535 | 536 | if(!length(index)) index <- length(p$x$options$series) 537 | return(index) 538 | } 539 | 540 | val_name_data_map_ <- function(data, serie){ 541 | 542 | # get for eval 543 | x <- get("x.name", envir = data_env) 544 | 545 | data <- data[, c(x, serie)] 546 | names(data) <- c("name", "value") 547 | rownames(serie) <- NULL 548 | 549 | data <- apply(data, 1, as.list) 550 | names(data) <- NULL # remove persistent rownames 551 | 552 | return(data) 553 | } 554 | 555 | clean_data_map <- function(data){ 556 | x.name <- get("x.name", envir = data_env) 557 | 558 | if(!is.null(x.name)){ 559 | # clean FUN 560 | clean <- function(x){ 561 | x[x[, x.name] != "",] 562 | } 563 | 564 | data <- Map(clean, data) # clean 565 | } 566 | 567 | # remove now-empty data.frame 568 | data <- data[lapply(data, nrow) > 0] 569 | 570 | return(data) 571 | } 572 | 573 | check_xvar <- function(data, x){ 574 | 575 | if(dplyr::is.grouped_df(data)){ 576 | x <- unique(x) 577 | } 578 | 579 | return(x) 580 | } 581 | 582 | node_cat <- function(categories){ 583 | 584 | categories <- unique(categories) 585 | cat <- data.frame(name = categories) 586 | cat <- apply(cat, 1, as.list) 587 | 588 | return(cat) 589 | } 590 | 591 | cat2num <- function(x){ 592 | x <- as.numeric(as.factor(x)) # to numeric 593 | x <- x - 1 # javascript counts from 0 594 | return(x) 595 | } 596 | 597 | force_legend <- function(categories){ 598 | categories <- unique(categories) 599 | return(categories) 600 | } 601 | 602 | scatter_size <- function(size){ 603 | htmlwidgets::JS("function(value){return value[2];}") 604 | } 605 | 606 | normalise_size <- function(x, symbolSize){ 607 | if(class(x)[1] == "integer" || class(x)[1] == "numeric"){ 608 | x <- (x - min(x)) / (max(x) - min(x)) 609 | x <- x * symbolSize 610 | } 611 | return(x) 612 | } 613 | 614 | compute_max <- function(data, serie){ 615 | 616 | data <- do.call("rbind.data.frame", lapply(data, as.data.frame)) 617 | x <- data[, serie] 618 | 619 | return(max(x)) 620 | 621 | } 622 | 623 | sort_data <- function(data, x){ 624 | xvar <- data[, x] 625 | sort <- sortable(xvar) 626 | if(sort == TRUE){ 627 | data <- data[order(data[, x]),] 628 | } 629 | return(data) 630 | } 631 | 632 | sortable <- function(x){ 633 | if(class(x)[1] == "integer" || class(x)[1] == "numeric" || class(x)[1] == "Date" || class(x)[1] == "POSIXct" || 634 | class(x)[1] == "POSIXlt"){ 635 | TRUE 636 | } else { 637 | FALSE 638 | } 639 | } 640 | 641 | axis_data <- function(type){ 642 | if(type == "category"){ 643 | x <- tryCatch(get("x", envir = data_env), error = function(e) e) 644 | if(!is(x, "error")){ 645 | sort <- sortable(x) 646 | if(sort == TRUE) x <- sort(x) 647 | x <- unique(x) 648 | return(x) 649 | } else { 650 | NULL 651 | } 652 | } else { 653 | return(NULL) 654 | } 655 | } 656 | 657 | axis_it <- function(p, append, opts, axis){ 658 | 659 | if(append == TRUE){ 660 | p$x$options[[axis]] <- append(p$x$options[[axis]], opts) 661 | } else { 662 | p$x$options[[axis]] <- list(opts) 663 | } 664 | 665 | p 666 | } 667 | 668 | treemap_data_ <- function(data, serie){ 669 | 670 | # get for eval 671 | x <- get("x", envir = data_env) 672 | 673 | serie <- data[, serie] 674 | 675 | data <- cbind.data.frame(x, serie) 676 | names(data) <- c("name", "value") 677 | 678 | data <- apply(data, 1, as.list) 679 | 680 | for(i in 1:length(data)){ 681 | data[[i]][[2]] <- as.numeric(paste0(data[[i]][[2]])) 682 | } 683 | 684 | return(data) 685 | } 686 | 687 | candle_data_ <- function(data, opening, closing, minimum, maximum){ 688 | 689 | data <- data[, c(opening, closing, minimum, maximum)] 690 | colnames(data) <- NULL 691 | data <- apply(data, 1, as.list) 692 | 693 | return(data) 694 | } 695 | 696 | valid_effects <- function(){ 697 | c('spin' , 'bar' , 'ring' , 'whirling' , 'dynamicLine' , 'bubble') 698 | } 699 | -------------------------------------------------------------------------------- /R/options.R: -------------------------------------------------------------------------------- 1 | #' Add global options 2 | #' 3 | #' Add global options. 4 | #' 5 | #' @param p an echart object. 6 | #' @param backgroundColor background color. 7 | #' @param color colors to use in chart. 8 | #' @param renderAsImage allows rendering as image. 9 | #' @param calculable specifies whether the drag-recalculate feature will be enabled. 10 | #' @param symbolList list of default symbols. 11 | #' @param ... any other options. 12 | #' 13 | #' @examples 14 | #' mtcars %>% 15 | #' echart(mpg) %>% 16 | #' eline(qsec) %>% 17 | #' eoptions(backgroundColor = "black") 18 | #' 19 | #' @export 20 | eoptions <- function(p, backgroundColor = NULL, renderAsImage = FALSE, calculable = FALSE, color = NULL, symbolList = NULL, ...){ 21 | 22 | opts <- list(...) 23 | opts$backgroundColor <- backgroundColor 24 | opts$color <- if(!is.null(color)) color 25 | opts$renderAsImage <- renderAsImage 26 | opts$calculable <- calculable 27 | opts$symbolList <- if(!is.null(symbolList)) symbolList 28 | 29 | p$x$options <- append(p$x$options, opts) 30 | 31 | p 32 | 33 | } 34 | 35 | #' Add animations 36 | #' 37 | #' Add animations 38 | #' 39 | #' @param p an echart objects. 40 | #' @param animation whether to show the initial animation. 41 | #' @param addDataAnimation specifies whether the dynamic data interface animation will be enabled. 42 | #' @param animationThreshold threshold of animated elements. 43 | #' @param animationDuration duration of animation, in ms. 44 | #' @param animationDurationUpdate duration of the update animation, in ms. 45 | #' @param animationEasing easing effect, see details for valid values. 46 | #' @param ... any other options. 47 | #' 48 | #' @details 49 | #' \itemize{ 50 | #' \item{\code{linear}} 51 | #' \item{\code{QuadraticIn}} 52 | #' \item{\code{QuadraticOut}} 53 | #' \item{\code{QuadraticInOut}} 54 | #' \item{\code{CubicIn}} 55 | #' \item{\code{CubicOut}} 56 | #' \item{\code{CubicInOut}} 57 | #' \item{\code{QuarticIn}} 58 | #' \item{\code{QuarticOut}} 59 | #' \item{\code{QuarticInOut}} 60 | #' \item{\code{SinusoidalIn}} 61 | #' \item{\code{SinusoidalOut}} 62 | #' \item{\code{SinusoidalInOut}} 63 | #' \item{\code{ExponentialIn}} 64 | #' \item{\code{ExponentialOut}} 65 | #' \item{\code{ExponentialInOut}} 66 | #' \item{\code{CircularIn}} 67 | #' \item{\code{CircularOut}} 68 | #' \item{\code{CircularInOut}} 69 | #' \item{\code{ElasticIn}} 70 | #' \item{\code{ElasticOut}} 71 | #' \item{\code{ElasticInOut}} 72 | #' \item{\code{BackIn}} 73 | #' \item{\code{BackOut}} 74 | #' \item{\code{BackInOut}} 75 | #' \item{\code{BounceIn}} 76 | #' \item{\code{BounceOut}} 77 | #' \item{\code{BounceInOut}} 78 | #' } 79 | #' 80 | #' @examples 81 | #' mtcars %>% 82 | #' echart(mpg) %>% 83 | #' ebar(qsec) %>% 84 | #' eanimation(animationEasing = "BounceIn") 85 | #' 86 | #' mtcars %>% 87 | #' echart(mpg) %>% 88 | #' escatter(qsec, drat, symbolSize = 20) %>% 89 | #' eanimation(animationEasing = "CubicInOut") 90 | #' 91 | #' @export 92 | eanimation <- function(p, animation = TRUE, addDataAnimation = TRUE, animationThreshold = 2000, 93 | animationDuration = 2000, animationDurationUpdate = 500, 94 | animationEasing = "ExponentialOut", ...){ 95 | 96 | opts <- list(...) 97 | opts$animation <- animation 98 | opts$addDataAnimation <- addDataAnimation 99 | opts$animationThreshold <- animationThreshold 100 | opts$animationDuration <- animationDuration 101 | opts$animationDurationUpdate <- animationDurationUpdate 102 | opts$animationEasing = animationEasing 103 | 104 | p$x$options <- append(p$x$options, opts) 105 | 106 | p 107 | 108 | } 109 | 110 | #' Add legend 111 | #' 112 | #' @param p an echart object. 113 | #' @param legend legend. 114 | #' @param show wether to show legend. 115 | #' @param z,zlevel first and second grade cascading control, the higher z the closer to the top. 116 | #' @param orient orientation, \code{vertical} or \code{horizontal}. 117 | #' @param x x alignment, \code{center}, \code{left} or \code{right}. 118 | #' @param y y alignment, \code{center}, \code{top} or \code{bottom}. 119 | #' @param backgroundColor background color. 120 | #' @param borderColor border color. 121 | #' @param borderWidth border width. 122 | #' @param selectedMode selection mode. 123 | #' @param selected default selected state. 124 | #' @param textStyle textStyle. 125 | #' @param formatter default formatter. 126 | #' @param itemGap gap between legend items. 127 | #' @param itemWidth,itemHeight width and height of items. 128 | #' @param padding legend padding. 129 | #' @param ... any other option to pass to legend. 130 | #' 131 | #' @examples 132 | #' df <- data.frame(x = LETTERS[1:10], y = runif(10, 0, 10), z = runif(10, 0, 10)) 133 | #' 134 | #' df %>% 135 | #' echart(x) %>% 136 | #' ebar(y, name = "y - serie") %>% 137 | #' ebar(z) %>% 138 | #' elegend() 139 | #' 140 | #' @export 141 | elegend <- function(p, legend, show = TRUE, zlevel = 0, z = 4, orient = "horizontal", x = "center", 142 | y = "top", backgroundColor = "rgba(0,0,0,0)", borderColor = "#ccc", borderWidth = 0, 143 | padding = 5, itemGap = 10, itemWidth = 20, itemHeight = 14, formatter = NULL, 144 | selectedMode = TRUE, selected = NULL, textStyle, ...){ 145 | 146 | textStyle <- if(missing(textStyle)) list(fontFamily = "Arial, Verdana, sans-serif", fontSize = 12, 147 | fontStyle = "normal", fontWeight = "normal") 148 | 149 | if(missing(legend) && !length(p$x$options$legend$data)){ 150 | legend <- if(missing(legend)) default_legend(p) 151 | } else if(missing(legend) && length(p$x$options$legend$data)) { 152 | legend <- p$x$options$legend$data 153 | } else if (!missing(legend)) { 154 | legend <- list(legend) 155 | } 156 | 157 | opts <- list(...) 158 | opts$data <- legend 159 | opts$show <- show 160 | opts$zlevel <- zlevel 161 | opts$z <- z 162 | opts$orient <- orient 163 | opts$x <- x 164 | opts$y <- y 165 | opts$backgroundColor <- backgroundColor 166 | opts$borderColor <- borderColor 167 | opts$borderWidth <- borderWidth 168 | opts$padding <- padding 169 | opts$itemGap <- itemGap 170 | opts$itemWidth <- itemWidth 171 | opts$itemHeight <- itemHeight 172 | opts$formatter <- formatter 173 | opts$selectMode <- selectedMode 174 | opts$selected <- selected 175 | opts$textStyle <- textStyle 176 | 177 | p$x$options$legend <- append(p$x$options$legend, opts) 178 | 179 | p 180 | 181 | } 182 | 183 | #' Add theme 184 | #' 185 | #' Add a theme. 186 | #' 187 | #' @param p an echart object. 188 | #' @param theme, see details for valid values. 189 | #' 190 | #' @details 191 | #' valid themes: 192 | #' \itemize{ 193 | #' \item{\code{default}} 194 | #' \item{\code{mint}} 195 | #' \item{\code{macarons}} 196 | #' \item{\code{macarons2}} 197 | #' \item{\code{green}} 198 | #' \item{\code{blue}} 199 | #' \item{\code{dark}} 200 | #' \item{\code{gray}} 201 | #' \item{\code{helianthus}} 202 | #' \item{\code{red}} 203 | #' \item{\code{wef}} 204 | #' \item{\code{roma}} 205 | #' \item{\code{sakura}} 206 | #' \item{\code{shine}} 207 | #' \item{\code{infographic}} 208 | #' \item{\code{solarlight}} 209 | #' } 210 | #' 211 | #' @examples 212 | #' mtcars %>% 213 | #' echart(disp) %>% 214 | #' ebar(qsec) %>% 215 | #' ebar(mpg) %>% 216 | #' etheme("roma") 217 | #' 218 | #' @export 219 | etheme <- function(p, theme = "default"){ 220 | 221 | if(tolower(theme) == "grey") theme <- "gray" 222 | 223 | themes <- c("default", "mint", "macarons", "macarons2", "green", "blue", "dark", "blue", "dark", "gray", "helianthus", 224 | "red", "roma", "sakura", "shine", "infographic", "solarlight", "wef") 225 | 226 | if(!tolower(theme) %in% themes) stop("invalid theme", call. = FALSE) 227 | 228 | p$x$theme <- tolower(theme) 229 | 230 | p 231 | } 232 | 233 | #' Add tooltip 234 | #' 235 | #' Customise tooltip. 236 | #' 237 | #' @param p an echart object. 238 | #' @param show whether to show the tooltip. 239 | #' @param trigger element that triggers the tooltip, takes \code{item} or \code{axis}. 240 | #' @param z,zlevel first and second grade cascading control, the higher z the closer to the top. 241 | #' @param showContent whether to show the content of tooltip. 242 | #' @param position specifies position, pass a \code{list}, like \code{list(10, 10)}, fixed position; pass a function, 243 | #' like \code{htmlwidgets::JS("function([x, y]) {return [x + 10, y + 10]}")} 244 | #' @param formatter see \href{official documentation}{http://echarts.baidu.com/echarts2/doc/option-en.html#tooltip.formatter} for more details. 245 | #' @param islandFormatter island content formatter. 246 | #' @param showDelay number of milliseconds the tooltip shows. 247 | #' @param hideDelay number of milliseconds to wait until the tooltip is hidden when mouse out from a point or chart. 248 | #' @param transitionDuration duration in seconds of the animated transition. 249 | #' @param enterable whether to let the mouse go into the tip dom. 250 | #' @param backgroundColor background color. 251 | #' @param borderColor border color. 252 | #' @param borderRadius border radius. 253 | #' @param borderWidth border width. 254 | #' @param padding padding. 255 | #' @param axisPointer axis pointer, triggered by axis. 256 | #' @param textStyle tooltip text size. 257 | #' @param ... any other options to pass to tooltip. 258 | #' 259 | #' @examples 260 | #' mtcars %>% 261 | #' echart(disp) %>% 262 | #' eline(mpg) %>% 263 | #' eline(qsec) %>% 264 | #' etooltip(trigger = "axis") 265 | #' 266 | #' @seealso \href{http://echarts.baidu.com/echarts2/doc/option-en.html#title~tooltip}{official tooltip docs} 267 | #' 268 | #' @export 269 | etooltip <- function(p, show = TRUE, trigger = "axis", zlevel = 1, z = 8, showContent = TRUE, 270 | position = NULL, formatter = NULL, islandFormatter = "{a} < br/>{b} : {c}", 271 | showDelay = 20, hideDelay = 100, transitionDuration = 0.4, enterable = FALSE, 272 | backgroundColor = "rgba(0,0,0,0.7)", borderColor = "#333", borderRadius = 4, 273 | borderWidth = 0, padding = 5, axisPointer, textStyle, ...){ 274 | 275 | opts <- default_tooltip(show, trigger, zlevel, z, showContent, position, formatter, islandFormatter, 276 | showDelay, hideDelay, transitionDuration, enterable, backgroundColor, borderColor, 277 | borderRadius, borderWidth, padding, axisPointer, textStyle, ...) 278 | 279 | p$x$options$tooltip <- append(p$x$options$tooltip, opts) 280 | 281 | p 282 | 283 | } 284 | 285 | #' Add data zoom 286 | #' 287 | #' Add data zoom. 288 | #' 289 | #' @param p an echart object. 290 | #' @param show whether to show the data zoom. 291 | #' @param z,zlevel first and second grade cascading control, the higher z the closer to the top. 292 | #' @param orient orientation, takes \code{vertical} or \code{horinzontal}. 293 | #' @param backgroundColor background color. 294 | #' @param dataBackgroundColor background color of data zoom. 295 | #' @param fillerColor fill color of selected area. 296 | #' @param handleColor color of data zoom handle. 297 | #' @param handleSize size of handle. 298 | #' @param start,end percent start and end. 299 | #' @param showDetail whether to show detail when dragging. 300 | #' @param realtime set to \code{TRUE} if using real time data. 301 | #' @param zoomLock when set to true, the selected area cannot be zoomed. 302 | #' @param ... any other options to pass to data zoom. 303 | #' 304 | #' @examples 305 | #' mtcars %>% 306 | #' echart(disp) %>% 307 | #' eline(mpg) %>% 308 | #' ezoom() 309 | #' 310 | #' @seealso \href{http://echarts.baidu.com/echarts2/doc/option-en.html#title~dataZoom}{official dataZoom docs} 311 | #' 312 | #' @export 313 | ezoom <- function(p, show = TRUE, zlevel = 0, z = 4, orient = "horizontal", backgroundColor = "rgba(0,0,0,0)", 314 | dataBackgroundColor = "#eee", fillerColor = "rgba(144,197,237,0.2)", handleColor = "rgba(70,130,180,0.8)", 315 | handleSize = 8, start = 0, end = 100, showDetail = TRUE, realtime = FALSE, zoomLock = FALSE, ...){ 316 | 317 | opts <- list(...) 318 | opts$show <- show 319 | opts$zlevel <- zlevel 320 | opts$z <- z 321 | opts$orient <- orient 322 | opts$backgroundColor <- backgroundColor 323 | opts$dataBackgroundColor <- dataBackgroundColor 324 | opts$fillerColor <- fillerColor 325 | opts$handleColor <- handleColor 326 | opts$handleSize <- handleSize 327 | opts$start <- start 328 | opts$end <- end 329 | opts$showDetail <- showDetail 330 | opts$realtime <- realtime 331 | opts$zoomLock <- zoomLock 332 | 333 | p$x$options$dataZoom <- append(p$x$options$dataZoom, opts) 334 | 335 | p 336 | } 337 | 338 | #' Add title 339 | #' 340 | #' Add chart title and subtitles. 341 | #' 342 | #' @param p an echart object. 343 | #' @param text title. 344 | #' @param subtext subtitle. 345 | #' @param link hyperlink. 346 | #' @param sublink subtext hyperlink. 347 | #' @param target \code{link} opening window: \code{self} or \code{blank}. 348 | #' @param subtarget \code{sublink} opening window: \code{self} or \code{blank}. 349 | #' @param x positon of title, \code{left} or \code{right}. 350 | #' @param y postion of title, \code{top}, \code{bottom} or \code{center}. 351 | #' @param backgroundColor background color. 352 | #' @param borderColor border color. 353 | #' @param borderWidth width of border. 354 | #' @param padding padding. 355 | #' @param itemGap gap between title and subtitle. 356 | #' @param show whether to show the title. 357 | #' @param z,zlevel first and second grade cascading control, the higher z the closer to the top. 358 | #' @param ... any other options to pass to title 359 | #' 360 | #' @examples 361 | #' mtcars %>% 362 | #' echart(disp) %>% 363 | #' eline(mpg) %>% 364 | #' etitle("MPG vs DISP", "Made with EChart", link = "http://echarts.baidu.com", target = "blank") 365 | #' 366 | #' @seealso \href{http://echarts.baidu.com/echarts2/doc/option-en.html#title~title}{official title docs} 367 | #' 368 | #' @export 369 | etitle <- function(p, text, subtext, link, sublink, target = "blank", subtarget = "blank", x = "left", y = "top", 370 | backgroundColor = "rgba(0,0,0,0)", borderColor = "#ccc", borderWidth = 0, padding = 5, 371 | itemGap = 5, zlevel = 0, z = 6, show = TRUE, ...){ 372 | 373 | if(missing(text)) stop("must pass text") 374 | 375 | opts <- list(...) 376 | opts$show <- show 377 | opts$text <- text 378 | opts$subtext <- if(!missing(subtext)) subtext 379 | opts$link <- if(!missing(link)) link 380 | opts$sublink <- if(!missing(sublink)) sublink 381 | opts$target <- target 382 | opts$subtarget <- subtarget 383 | opts$x <- x 384 | opts$y <- y 385 | opts$backgroundColor <- backgroundColor 386 | opts$borderColor <- borderColor 387 | opts$borderWidth <- borderWidth 388 | opts$padding <- padding 389 | opts$itemGap <- itemGap 390 | opts$zlevel <- zlevel 391 | opts$z <- z 392 | 393 | p$x$options$title <- append(p$x$options$title, opts) 394 | 395 | p 396 | } 397 | 398 | #' Customise colorbar 399 | #' 400 | #' Customise the colorbar of your chart. 401 | #' 402 | #' @param p an echart object. 403 | #' @param min,max minimum and maximum. 404 | #' @param which series to serie is to be affected, takes the name of a serie, \code{previous} or \code{all}. 405 | #' @param show whether to show the color bar. 406 | #' @param color colors as list from high to low. i.e.: \code{list("red", "blue")}. 407 | #' @param z,zlevel first and second grade cascading control, the higher z the closer to the top. 408 | #' @param orient orientation of bar, \code{vertical} or \code{horizontal}. 409 | #' @param x x position; \code{left} or \code{right}. 410 | #' @param y y posotion; \code{top} or \code{bottom}. 411 | #' @param backgroundColor background color. 412 | #' @param borderColor border color. 413 | #' @param borderWidth width of border. 414 | #' @param padding padding. 415 | #' @param itemGap gap between items on bar. 416 | #' @param itemWidth width of the bar. 417 | #' @param itemHeight height of the bar. 418 | #' @param precision decimal precision. 419 | #' @param splitNumber number of segments. 420 | #' @param splitList see \href{http://echarts.baidu.com/echarts2/doc/option-en.html#dataRange.splitList}{official docs} for details. 421 | #' @param range used to set initial range i.e.: \code{list(start = 10, end = 50)}. 422 | #' @param selectedMode selection mode. 423 | #' @param calculable whether values are calculable. 424 | #' @param hoverLink hoverlink with map. 425 | #' @param realtime set to \code{TRUE} if using real time stream. 426 | #' @param ... any other argument to pass to color bar. 427 | #' 428 | #' @details 429 | #' \code{ecolorbar} refers to \href{http://echarts.baidu.com/echarts2/doc/option-en.html#dataRange.hoverLink}{datarange} in docs. 430 | #' 431 | #' @examples 432 | #' df <- data.frame(x = 1:20, 433 | #' y = runif(20, 5, 10), 434 | #' size = runif(20, 5, 15)) 435 | #' 436 | #' df %>% 437 | #' echart(x) %>% 438 | #' escatter(y, size, symbolSize = 10, legendHoverLink = TRUE) %>% 439 | #' ecolorbar(color = list("red", "blue"), min = 5, max = 15, calculable = TRUE) 440 | #' 441 | #' @seealso \href{http://echarts.baidu.com/echarts2/doc/option-en.html#dataRange.hoverLink}{official dataRange docs} 442 | #' 443 | #' @export 444 | ecolorbar <- function(p, min = NULL, max = NULL, which = "previous", show = TRUE, color = NULL, zlevel = 4, z = 0, 445 | orient = "vertical", x = "left", y = "bottom", backgroundColor = "rgba(0,0,0,0)", borderColor = "#ccc", 446 | borderWidth = 0, padding = 5, itemGap = 10, itemWidth = 20, itemHeight = 14, precision = 0, splitNumber = 5, 447 | splitList = NULL, range = NULL, selectedMode = TRUE, calculable = FALSE, hoverLink = TRUE, realtime = FALSE, ...){ 448 | 449 | opts <- list(...) 450 | opts$show <- show 451 | opts$color <- if(!is.null(color)) color 452 | opts$zlevel <- zlevel 453 | opts$z <- z 454 | opts$orient <- orient 455 | opts$x <- x 456 | opts$y <- y 457 | opts$backgroundColor <- backgroundColor 458 | opts$borderColor <- borderColor 459 | opts$borderWidth <- borderWidth 460 | opts$padding <- padding 461 | opts$itemGap <- itemGap 462 | opts$itemWidth <- itemWidth 463 | opts$itemHeight <- itemHeight 464 | opts$precision <- precision 465 | opts$splitNumber <- splitNumber 466 | opts$splitList <- splitList 467 | opts$range <- range 468 | opts$selectedMode <- selectedMode 469 | opts$hoverLink <- hoverLink 470 | opts$realtime <- realtime 471 | 472 | p$x$options$dataRange <- append(p$x$options$dataRange, opts) 473 | 474 | p$x$options$dataRange$min <- if(!is.null(min)) min else p$x$options$dataRange$min 475 | p$x$options$dataRange$max <- if(!is.null(max)) max else p$x$options$dataRange$max 476 | p$x$options$dataRange$calculable <- calculable 477 | 478 | p 479 | } 480 | 481 | #' Add Zoom and roam controller 482 | #' 483 | #' Add zoom and roam controller to map. 484 | #' 485 | #' @param p an echart object. 486 | #' @param show set to \code{TRUE} to show the controller 487 | #' @param z,zlevel first and second grade cascading control, the higher z the closer to the top. 488 | #' @param x x position; \code{left} or \code{right}. 489 | #' @param y y posotion; \code{top} or \code{bottom}. 490 | #' @param width,height dimensions of controller. 491 | #' @param backgroundColor background color. 492 | #' @param borderColor border color. 493 | #' @param borderWidth width of border. 494 | #' @param padding padding. 495 | #' @param fillerColor filler color. 496 | #' @param handleColor color of handle. 497 | #' @param step moving step of the 4 direction roam in px. 498 | #' @param mapTypeControl ou can specify every single mapType when multiple map in a chart at the same time, such as: \code{list({ china = FALSE, world = TRUE})}. 499 | #' @param ... any other option to pass to controller. 500 | #' 501 | #' @examples 502 | #' coords <- data.frame(city = c("London", "New York", "Beijing", "Sydney"), 503 | #' lon = c(-0.1167218, -73.98002, 116.3883, 151.18518), 504 | #' lat = c(51.49999, 40.74998, 39.92889, -33.92001), 505 | #' values = runif(4, 10, 20)) 506 | #' 507 | #' coords %>% 508 | #' echart(city) %>% 509 | #' emap() %>% 510 | #' emap_coords(lon, lat) %>% 511 | #' emap_points(values) %>% 512 | #' emap_roam(mapTypeControl = list(world = TRUE)) 513 | #' 514 | #' @seealso \href{http://echarts.baidu.com/echarts2/doc/option-en.html#title~roamController}{official roam controller docs} 515 | #' 516 | #' @export 517 | emap_roam <- function(p, show = TRUE, zlevel = 0, z = 4, x = "left", y = "top", width = 80, height = 120, 518 | backgroundColor = "rgba(0,0,0,0)", borderColor = "#ccc", borderWidth = 0, padding = 5, 519 | fillerColor = "#fff", handleColor = "#6495ed", step = 15, mapTypeControl = NULL, ...){ 520 | 521 | opts <- list(...) 522 | opts$show <- show 523 | opts$zlevel <- zlevel 524 | opts$z <- z 525 | opts$x <- x 526 | opts$y <- y 527 | opts$width <- width 528 | opts$height <- height 529 | opts$backgroundColor <- backgroundColor 530 | opts$borderColor <- borderColor 531 | opts$borderWidth <- borderWidth 532 | opts$padding <- padding 533 | opts$fillerColor <- fillerColor 534 | opts$handleColor <- handleColor 535 | opts$step <- step 536 | opts$mapTypeControl <- if(!is.null(mapTypeControl)) mapTypeControl 537 | 538 | p$x$options$roamController <- opts 539 | 540 | p 541 | 542 | } 543 | 544 | #' Customise grid 545 | #' 546 | #' @param p an echart object. 547 | #' @param backgroundColor background color. 548 | #' @param borderWidth border width. 549 | #' @param borderColor border color. 550 | #' @param width,height dimensions of grid. 551 | #' @param z,zlevel first and second grade cascading control, the higher z the closer to the top. 552 | #' @param x,y ordinate on upper left corner. 553 | #' @param x2,y2 ordinate on upper right corner. 554 | #' 555 | #' @examples 556 | #' df <- data.frame(x = 1:20, y = runif(20, 5, 20)) 557 | #' 558 | #' df %>% 559 | #' echart(x) %>% 560 | #' eline(x) %>% 561 | #' egrid(borderWidth = 5, borderColor = "red", backgroundColor = "yellow") 562 | #' 563 | #' @seealso \href{http://echarts.baidu.com/echarts2/doc/option-en.html#title~grid.width}{official grid docs} 564 | #' 565 | #' @export 566 | egrid <- function(p, backgroundColor = NULL, borderWidth = 1, borderColor = NULL, width = NULL, height = NULL, 567 | z = 0, zlevel = 0, x = 80, y = 60, x2 = 80, y2 = 80){ 568 | 569 | opts <- list( 570 | borderWidth = borderWidth, 571 | z = z, 572 | zlevel = zlevel, 573 | x = x, 574 | y = y, 575 | x2 = x2, 576 | y2 = y2 577 | ) 578 | 579 | opts$backgroundColor <- if(!is.null(backgroundColor)) backgroundColor 580 | opts$borderColor <- if(!is.null(borderColor)) borderColor 581 | opts$width <- if(!is.null(width)) width 582 | opts$height <- if(!is.null(height)) height 583 | 584 | p$x$options$grid <- opts 585 | 586 | p 587 | 588 | } 589 | 590 | #' Data loading options 591 | #' 592 | #' Customise the data loading options. 593 | #' 594 | #' @param p an echart object. 595 | #' @param text the loading text that appears when the chart is set into the loading state, use \code{\\n} for new line. 596 | #' @param effect loading effect, see details for valid values. 597 | #' @param progress specifies the current progress \code{[0~1]}. Applicable to specific effects. 598 | #' @param x,y position, takes \code{left}, \code{right}, \code{center}. 599 | #' @param ... any other parameters, i.e.:\code{textStyle}. 600 | #' 601 | #' @details 602 | #' Valid \code{effect} values: 603 | #' \itemize{ 604 | #' \item{spin} 605 | #' \item{bar} 606 | #' \item{ring} 607 | #' \item{whirling} 608 | #' \item{dynamicLine} 609 | #' \item{bubble} 610 | #' } 611 | #' 612 | #' @examples 613 | #' # no data 614 | #' df <- data.frame(x = NA, y = NA) %>% 615 | #' dplyr::filter(!is.na(x)) 616 | #' 617 | #' df %>% 618 | #' echart(x) %>% 619 | #' eline(y) 620 | #' 621 | #' df %>% 622 | #' echart(x) %>% 623 | #' eline(y) %>% 624 | #' eload(effect = "ring", text = "loading data...") 625 | #' 626 | #' df %>% 627 | #' echart(x) %>% 628 | #' eline(y) %>% 629 | #' eload(effect = "dynamicLine") 630 | #' 631 | #' @export 632 | eload <- function(p, text = "loading", effect = "bubble", x = "center", y = "center", progress = NULL, ...){ 633 | 634 | if(missing(p)) stop("missing echarts object", call. = FALSE) 635 | if(!effect %in% valid_effects()) stop("invalid effect", call. = FALSE) 636 | 637 | opts <- list(...) 638 | opts$text <- text 639 | opts$effect <- effect 640 | opts$x <- x 641 | opts$y <-y 642 | opts$progress <- if(!is.null(progress)) progress 643 | 644 | p$x$options$noDataLoadingOption <- opts 645 | 646 | p 647 | } 648 | --------------------------------------------------------------------------------