Skip to content

Commit

Permalink
website integration
Browse files Browse the repository at this point in the history
helgasoft committed Dec 19, 2024
1 parent 6483e49 commit f03c0d6
Showing 27 changed files with 537 additions and 1,015 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ inst/doc
CRAN-RELEASE
CRAN-SUBMISSION
cran-comments.md
docs/
cleanup.bat
/doc/
/Meta/
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: echarty
Title: Minimal R/Shiny Interface to JavaScript Library 'ECharts'
Date: 2024-12-09
Date: 2024-12-18
Version: 1.6.4.1
Author: Larry Helgason, with initial code from John Coene's library echarts4r
Maintainer: Larry Helgason <[email protected]>
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@

export(ec.clmn)
export(ec.data)
export(ec.examples)
export(ec.fromJson)
export(ec.init)
export(ec.inspect)
441 changes: 219 additions & 222 deletions NEWS.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions R/echarty.R
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ noCoord <- c('polar','radar','singleAxis','parallelAxis','calendar')
#' * ask - prompt user before downloading plugins when _load_ is present, FALSE by default
#' * js - single string or a vector with JavaScript expressions to evaluate.\cr
#' single: exposed _chart_ object (most common)\cr
#' vector: \verb{ }see demo code in [ec.examples]\cr
#' vector: \verb{ }see code in \href{https://github.com/helgasoft/echarty/blob/main/demo/examples.R}{examples}\cr
#' \verb{ }First expression evaluated before initialization, exposed object _window_ \cr
#' \verb{ }Second is evaluated with exposed object _opts_. \cr
#' \verb{ }Third is evaluated with exposed _chart_ object after _opts_ set.
@@ -1142,7 +1142,7 @@ ecs.proxy <- function(id) {
#' @return A proxy object to update the chart.
#'
#' @seealso [ecs.proxy], [ecs.render], [ecs.output] \cr
#' Read about event handling in [-- Introduction --], code in [ec.examples].
#' Read about event handling in [-- Introduction --], or from \href{https://github.com/helgasoft/echarty/blob/main/demo/examples.R}{examples}.
#'
#' @examples
#' if (interactive()) {
168 changes: 94 additions & 74 deletions R/util.R
Original file line number Diff line number Diff line change
@@ -12,64 +12,66 @@
#' for \emph{tabset} parameters should be in format \emph{name1=chart1, name2=chart2}, see example\cr
#' @details
#' **cmd = 'sf.series'**\cr
#' \verb{ }Build _leaflet_ or \href{https://echarts.apache.org/en/option.html#geo.map}{geo} map series from shapefiles.\cr
#' \verb{ }Supported types: POINT, MULTIPOINT, LINESTRING, MULTILINESTRING, POLYGON, MULTIPOLYGON \cr
#' \verb{ }Coordinate system is _leaflet_(default), _geo_ or _cartesian3D_ (for POINT(xyz))\cr
#' \verb{ }Limitations:\cr
#' \verb{ }polygons can have only their name in tooltip, \cr
#' \verb{ }assumes Geodetic CRS is WGS 84, for conversion use \link[sf]{st_transform} with _crs=4326_.\cr
#' \verb{ }Parameters:\cr
#' \verb{ }df - value from \link[sf]{st_read}\cr
#' \verb{ }nid - optional column name for name-id used in tooltips\cr
#' \verb{ }cs - optional _coordinateSystem_ value, default 'leaflet'\cr
#' \verb{ }verbose - optional, print shapefile item names in console\cr
#' \verb{ }Returns a list of chart series\cr
#' &emsp;Build _leaflet_ or \href{https://echarts.apache.org/en/option.html#geo.map}{geo} map series from shapefiles.\cr
#' &emsp;Supported types: POINT, MULTIPOINT, LINESTRING, MULTILINESTRING, POLYGON, MULTIPOLYGON \cr
#' &emsp;Coordinate system is _leaflet_(default), _geo_ or _cartesian3D_ (for POINT(xyz))\cr
#' &emsp;Limitations:\cr
#' &emsp; &emsp; polygons can have only their name in tooltip, \cr
#' &emsp; &emsp; assumes Geodetic CRS is WGS 84, for conversion use \link[sf]{st_transform} with _crs=4326_.\cr
#' &emsp;Parameters:\cr
#' &emsp; &emsp; df - value from \link[sf]{st_read}\cr
#' &emsp; &emsp; nid - optional column name for name-id used in tooltips\cr
#' &emsp; &emsp; cs - optional _coordinateSystem_ value, default 'leaflet'\cr
#' &emsp; &emsp; verbose - optional, print shapefile item names in console\cr
#' &emsp;Returns a list of chart series\cr
#' **cmd = 'sf.bbox'**\cr
#' \verb{ }Returns JavaScript code to position a map inside a bounding box from \link[sf]{st_bbox}, for leaflet only.\cr
#' &emsp;Returns JavaScript code to position a map inside a bounding box from \link[sf]{st_bbox}, for leaflet only.\cr
#' **cmd = 'sf.unzip'**\cr
#' \verb{ }Unzips a remote file and returns local file name of the unzipped .shp file\cr
#' \verb{ }url - URL of remote zipped shapefile\cr
#' \verb{ }shp - optional name of .shp file inside ZIP file if multiple exist. Do not add file extension. \cr
#' &emsp;Unzips a remote file and returns local file name of the unzipped .shp file\cr
#' &emsp; &emsp; url - URL of remote zipped shapefile\cr
#' &emsp; &emsp; shp - optional name of .shp file inside ZIP file if multiple exist. Do not add file extension. \cr
#' **cmd = 'geojson'** \cr
#' \verb{ }Custom series list from geoJson objects\cr
#' \verb{ }geojson - object from \link[jsonlite]{fromJSON}\cr
#' \verb{ }cs - optional _coordinateSystem_ value, default 'leaflet'\cr
#' \verb{ }ppfill - optional fill color like '#F00', OR NULL for no-fill, for all Points and Polygons\cr
#' \verb{ }nid - optional feature property for item name used in tooltips\cr
#' \verb{ }... - optional custom series attributes like _itemStyle_\cr
#' \verb{ }Can display also geoJson _feature properties_: color; lwidth, ldash (lines); ppfill, radius (points)\cr
#' &emsp;Custom series list from geoJson objects\cr
#' &emsp; &emsp; geojson - object from \link[jsonlite]{fromJSON}\cr
#' &emsp; &emsp; cs - optional _coordinateSystem_ value, default 'leaflet'\cr
#' &emsp; &emsp; ppfill - optional fill color like '#F00', OR NULL for no-fill, for all Points and Polygons\cr
#' &emsp; &emsp; nid - optional feature property for item name used in tooltips\cr
#' &emsp; &emsp; ... - optional custom series attributes like _itemStyle_\cr
#' &emsp;Can display also geoJson _feature properties_: color; lwidth, ldash (lines); ppfill, radius (points)\cr
#' **cmd = 'layout'** \cr
#' \verb{ }Multiple charts in table-like rows/columns format\cr
#' \verb{ }... - List of charts\cr
#' \verb{ }title - optional title for the set, rows= Number of rows, cols= Number of columns\cr
#' \verb{ }Returns a container \link[htmltools]{div} in rmarkdown, otherwise \link[htmltools]{browsable}.\cr
#' \verb{ }For 3-4 charts one would use multiple series within a \href{https://echarts.apache.org/en/option.html#grid}{grid}. \cr
#' \verb{ }For greater number of charts _ec.util(cmd='layout')_ comes in handy\cr
#' &emsp;Multiple charts in table-like rows/columns format\cr
#' &emsp; &emsp; ... - List of charts\cr
#' &emsp; &emsp; title - optional title for the entire set\cr
#' &emsp; &emsp; rows - optional number of rows\cr
#' &emsp; &emsp; cols - optional number of columns\cr
#' &emsp;Returns a container \link[htmltools]{div} in rmarkdown, otherwise \link[htmltools]{browsable}.\cr
#' &emsp;For 3-4 charts one would use multiple series within a \href{https://echarts.apache.org/en/option.html#grid}{grid}. \cr
#' &emsp;For greater number of charts _ec.util(cmd='layout')_ comes in handy\cr
#' **cmd = 'tabset'** \cr
#' \verb{ }... - a list name/chart pairs like \emph{n1=chart1, n2=chart2}, each tab may contain a chart.\cr
#' \verb{ }tabStyle - tab style string, see default \emph{tabStyle} variable in the code\cr
#' \verb{ }Returns A) \link[htmltools]{tagList} of tabs when in a pipe without '...' params, see example\cr
#' \verb{ }Returns B) \link[htmltools]{browsable} when '...' params are provided by user\cr
#' &emsp; &emsp; ... - a list name/chart pairs like \emph{n1=chart1, n2=chart2}, each tab may contain a chart.\cr
#' &emsp; &emsp; tabStyle - tab style string, see default \emph{tabStyle} variable in the code\cr
#' &emsp;Returns A) \link[htmltools]{tagList} of tabs when in a pipe without '...' params, see example\cr
#' &emsp;Returns B) \link[htmltools]{browsable} when '...' params are provided by user\cr
#' **cmd = 'button'** \cr
#' \verb{ }UI button to execute a JS function,\cr
#' \verb{ }text - the button label\cr
#' \verb{ }js - the JS function string\cr
#' \verb{ }... - optional parameters for the \href{https://echarts.apache.org/en/option.html#graphic.elements-rect.type}{rect} element\cr
#' \verb{ }Returns a graphic.elements-\href{https://echarts.apache.org/en/option.html#graphic.elements-rect.type}{rect} element.\cr
#' &emsp;UI button to execute a JS function,\cr
#' &emsp; &emsp; text - the button label\cr
#' &emsp; &emsp; js - the JS function string\cr
#' &emsp; &emsp; ... - optional parameters for the \href{https://echarts.apache.org/en/option.html#graphic.elements-rect.type}{rect} element\cr
#' &emsp;Returns a graphic.elements-\href{https://echarts.apache.org/en/option.html#graphic.elements-rect.type}{rect} element.\cr
#' **cmd = 'morph'** \cr
#' \verb{ }... - a list of charts or chart option lists\cr
#' \verb{ }event - name of event for switching charts. Default is \emph{click}.\cr
#' \verb{ }Returns a chart with ability to morph into other charts\cr
#' &emsp; &emsp; ... - a list of charts or chart option lists\cr
#' &emsp; &emsp; event - name of event for switching charts. Default is \emph{click}.\cr
#' &emsp;Returns a chart with ability to morph into other charts\cr
#' **cmd = 'fullscreen'** \cr
#' \verb{ }A toolbox feature to toggle fullscreen on/off. Works in a browser, not in RStudio.\cr
#' &emsp;A toolbox feature to toggle fullscreen on/off. Works in a browser, not in RStudio.\cr
#' **cmd = 'rescale'** \cr
#' \verb{ }v - input vector of numeric values to rescale\cr
#' \verb{ }t - target range c(min,max), numeric vector of two\cr
#' &emsp; &emsp; v - input vector of numeric values to rescale\cr
#' &emsp; &emsp; t - target range c(min,max), numeric vector of two\cr
#' **cmd = 'level'** \cr
#' \verb{ }Calculate vertical levels for timeline \emph{line} charts, returns a numeric vector\cr
#' \verb{ }df - data.frame with _from_ and _to_ columns\cr
#' \verb{ }from - name of 'from' column\cr
#' \verb{ }to - name of 'to' column\cr
#' &emsp;Calculate vertical levels for timeline \emph{line} charts, returns a numeric vector\cr
#' &emsp; &emsp; df - data.frame with _from_ and _to_ columns\cr
#' &emsp; &emsp; from - name of 'from' column\cr
#' &emsp; &emsp; to - name of 'to' column\cr
#'
#' @examples
#' if (interactive()) { # comm.out: Fedora errors about some 'browser'
@@ -89,6 +91,10 @@
#' }) |>
#' ec.util(cmd= 'tabset')
#' )
#'
#' p1 <- cars |> ec.init(grid= list(top=26), height=333) # move chart up
#' p2 <- mtcars |> dplyr::arrange(mpg) |> ec.init(height=333, ctype='line')
#' ec.util(cmd= 'tabset', cars= p1, mtcars= p2)
#' }
#'
#' cars |> ec.init(
@@ -98,23 +104,35 @@
#' )
#' )
#'
#' p1 <- cars |> ec.init(grid= list(top=20), height=333) # move chart up
#' p2 <- mtcars |> ec.init(height=333)
#' ec.util(cmd= 'tabset', cars= p1, mtcars= p2)
#'
#' lapply(list('dark','macarons','gray','jazz','dark-mushroom'),
#' function(x) cars |> ec.init() |> ec.theme(x) ) |>
#' ec.util(cmd='layout', cols= 2, title= 'my layout')
#' function(x) cars |> ec.init(grid= list(bottom=0)) |> ec.theme(x) ) |>
#' ec.util(cmd='layout', cols= 2, title= 'my layout')
#'
#' setd <- function(type) {
#' mtcars |> dplyr::group_by(cyl) |>
#' ec.init(ctype= type,
#' title= list(subtext= 'click points to morph'),
#' xAxis= list(scale= TRUE))
#' }
#' oscatter <- setd('scatter')
#' obar <- setd('bar')
#' ec.util(cmd='morph', oscatter, obar)
#' colors <- c("blue","red","green")
#' cyls <- as.character(sort(unique(mtcars$cyl)))
#' sers <- lapply(mtcars |> group_by(cyl) |> group_split(), \(x) {
#' cyl <- as.character(unique(x$cyl))
#' list(type='scatter', id=cyl, dataGroupId=cyl,
#' data= ec.data(x|>select(mpg,hp)),
#' universalTransition= TRUE)
#' })
#' oscatter <- list(
#' title= list(subtext='click points to morph'),
#' color= colors, tooltip= list(show=TRUE),
#' xAxis= list(scale=TRUE, name='mpg'), yAxis= list(scale=TRUE, name='hp'),
#' series= sers
#' )
#' opie <- list(
#' title= list(text= 'Average hp'),
#' color= colors, tooltip= list(show=TRUE),
#' series= list(list(
#' type= 'pie', label= list(show=TRUE), colorBy= 'data',
#' data= ec.data(mtcars |> group_by(cyl) |> summarize(value= mean(hp)) |>
#' mutate(groupId= as.character(cyl), name= as.character(cyl)),'names'),
#' universalTransition= list(enabled=T, seriesKey= cyls)
#' ))
#' )
#' ec.util(cmd='morph', oscatter, opie)
#'
#' @importFrom utils unzip
#' @export
@@ -348,7 +366,7 @@ body {
margin-bottom: -1px;
}
.tab-panel {
padding: 10px 0;
padding: 10px 0; width: 100%;
border-top: 1px solid #ccc;
}
body { padding: 10px; }
@@ -405,6 +423,7 @@ body { padding: 10px; }

title <- NULL # CRAN check fix
do.opties(c('rows','cols','title'))
stopifnot("ec.util: list of charts is missing"= length(opts)>0)
lplots <- length(opts[[1]])
if (is.null(rows) & !is.null(cols)) rows <- ceiling(lplots/cols)
if (!is.null(rows) & is.null(cols)) cols <- ceiling(lplots/rows)
@@ -573,8 +592,8 @@ body { padding: 10px; }
#'
#' @details
#' `format='boxplot'` requires the first two _df_ columns as: \cr
#' \verb{ }column for the non-computational categorical axis\cr
#' \verb{ }column with (numeric) data to compute the five boxplot values\cr
#' &emsp; &emsp; column for the non-computational categorical axis\cr
#' &emsp; &emsp; column with (numeric) data to compute the five boxplot values\cr
#' Additional grouping is supported on a column after the second. Groups will show in the legend, if enabled.\cr
#' Returns a `list(dataset, series, xAxis, yAxis)` to set params in [ec.init].
#' Make sure there is enough data for computation, 4+ values per boxplot.\cr
@@ -596,7 +615,7 @@ body { padding: 10px; }
#' series= list(list(
#' type= 'tree', orient= 'TB', roam= TRUE, initialTreeDepth= -1,
#' data= ec.data(hc, format='dendrogram'),
#' # layout= 'radial', symbolSize= ec.clmn(scale= 0.33),
#' layout= 'radial', # symbolSize= ec.clmn(scale= 0.33),
#' ## exclude added labels like 'pXX', leaving only the originals
#' label= list(formatter= htmlwidgets::JS(
#' "function(n) { out= /p\\d+/.test(n.name) ? '' : n.name; return out;}"))
@@ -1191,9 +1210,9 @@ ec.theme <- function (wt, name='custom', code= NULL)
#'
#' @param wt An \code{echarty} widget as returned by [ec.init]
#' @param target type of resulting value: \cr
#' \verb{ }'opts' - the htmlwidget _options_ as JSON (default)\cr
#' \verb{ }'full' - the _entire_ htmlwidget as JSON\cr
#' \verb{ }'data' - info about chart's embedded data (char vector)
#' &emsp; &emsp; 'opts' - the htmlwidget _options_ as JSON (default)\cr
#' &emsp; &emsp; 'full' - the _entire_ htmlwidget as JSON\cr
#' &emsp; &emsp; 'data' - info about chart's embedded data (char vector)
#' @param ... Additional attributes to pass to \link[jsonlite]{toJSON}\cr
#' 'file' - optional file name to save to when target='full'\cr
#' @return A JSON string, except when \code{target} is 'data' - then
@@ -1270,10 +1289,10 @@ ec.inspect <- function(wt, target='opts', ...) {
#' Convert JSON string or file to chart
#'
#' @param txt Could be one of the following:\cr
#' \verb{ }class _url_, like \code{url('https://serv.us/cars.txt')}\cr
#' \verb{ }class _file_, like \code{file('c:/temp/cars.txt','rb')}\cr
#' \verb{ }class _json_, like \code{ec.inspect(p)}, for options or full\cr
#' \verb{ }class _character_, JSON string with options only, see example below\cr
#' &emsp; &emsp; class _url_, like \code{url('https://serv.us/cars.txt')}\cr
#' &emsp; &emsp; class _file_, like \code{file('c:/temp/cars.txt','rb')}\cr
#' &emsp; &emsp; class _json_, like \code{ec.inspect(p)}, for options or full\cr
#' &emsp; &emsp; class _character_, JSON string with options only, see example below\cr
#' @param ... Any attributes to pass to internal [ec.init] when _txt_ is options only
#' @return An _echarty_ widget.
#'
@@ -1290,6 +1309,7 @@ ec.inspect <- function(wt, target='opts', ...) {
#' # cars |> ec.init() |> ec.inspect(target='full', file=outFile)
#' # ec.fromJson(file(outFile, 'rb'))
#' # ec.fromJson(url('http://localhost/echarty/cars.json'))
#'
#' ec.fromJson('https://helgasoft.github.io/echarty/test/pfull.json')
#' @export
ec.fromJson <- function(txt, ...) {
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -103,18 +103,13 @@ echarty::ec.fromJson('https://helgasoft.github.io/echarty/test/pfull.json')

The **Coder** is a good introduction, type ```library(echarty); demo(coder)```.
The [**WEBSITE**](https://helgasoft.github.io/echarty) has a vast gallery with code and tutorials.
The package itself has also [**code examples**](https://github.com/helgasoft/echarty/blob/main/R/examples.R)
included. Type
**?ec.examples**, then copy/paste any code to
see the chart.

Now you can start building [**beautiful
ECharts**](https://echarts.apache.org/examples/en/index.html) (and
[**more**](https://www.makeapie.cn/echarts)) with R and Shiny!
The package itself has [code examples](https://github.com/helgasoft/echarty/blob/main/demo/examples.R)
included.
Now you can start building [**beautiful ECharts**](https://echarts.apache.org/examples/en/index.html) with R and Shiny!

<br>
<p align="center">
<a href='https://helgasoft.github.io/echarty/gallery.html' target='_blank'>
<a href='https://helgasoft.github.io/echarty/articles/gallery.html' target='_blank'>
<img src="man/figures/ssPolarStack.png" alt="Polar Stack" width="180"/>
<img src="man/figures/ssBars.gif"/>
<img src="man/figures/ssThemeRiver.png" width="180"/>
31 changes: 31 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,35 @@
url: https://helgasoft.github.io/echarty/
template:
bootstrap: 5
bootswatch: darkly
home:
sidebar:
structure:
- links
- license
- community
- dev
navbar:
structure:
left:
- intro
- reference
- articles
- tutorials
- news
right:
- search
- twitter
- github
components:
twitter:
icon: fa-twitter
href: http://twitter.com/echarty_R
aria-label: Twitter
footer:
structure:
left: legal
right: built_with
components:
legal: \(c\) Helgasoft

109 changes: 46 additions & 63 deletions R/examples.R → demo/examples.R
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
# ----------- Examples --------------

#' Code Examples
#'
#' Learn by example - copy/paste code from Examples below.\cr
#' Learn by example - copy/paste code from examples below.
#' This code collection is to demonstrate various concepts of
#' data preparation, conversion, grouping,
#' parameter setting, visual fine-tuning,
#' custom rendering, plugins attachment,
#' Shiny plots & interactions through Shiny proxy.\cr
#'
#' @return No return value, used only for help
#'
#' @seealso \href{https://helgasoft.github.io/echarty/}{website} has many more examples
#'
#' @examples
#' \donttest{
#' see also gallery https://helgasoft.github.io/echarty/articles/gallery.html for more examples

#' \donttest { # for CRAN
#' library(dplyr); library(echarty)
#'
#' #------ Basic scatter chart, instant display
@@ -50,7 +45,7 @@
#' z = round(rnorm(cnt, 11, 2)),
#' colr = rainbow(cnt)
#' ) |>
#' ec.init( preset= FALSE,
#' ec.init(
#' polar= list(radius= '90%'),
#' radiusAxis= list(max= 'dataMax'),
#' angleAxis= list(type= "category"),
@@ -76,7 +71,7 @@
#' ec.init(load= 'leaflet',
#' tooltip= list(formatter= ec.clmn('magnitude %@', 'mag')),
#' legend= list(show=TRUE),
#' series.param= list(name= 'quakes', symbolSize= ec.clmn(6, scale=2)) # 6th column is size
#' series.param= list(name= 'quakes', symbolSize= ec.clmn('size', scale=2))
#' )
#'
#' #------ Plugin 'world' with visualMap
@@ -119,35 +114,35 @@
#'
#' #------ registerMap JSON
#' # registerMap supports also maps in SVG format, see website gallery
#' if (interactive()) {
#' json <- jsonlite::read_json("https://echarts.apache.org/examples/data/asset/geo/USA.json")
#' dusa <- USArrests
#' dusa$states <- row.names(dusa)
#' p <- ec.init(preset= FALSE,
#' #if (interactive()) {
#' json <- jsonlite::read_json("https://echarts.apache.org/examples/data/asset/geo/USA.json")
#' dusa <- USArrests
#' dusa$states <- row.names(dusa)
#' p <- ec.init(preset= FALSE,
#' series= list(list(type= 'map', map= 'USA', roam= TRUE, zoom= 3, left= -100, top= -30,
#' data= lapply(ec.data(dusa, 'names'),
#' function(x) list(name=x$states, value=x$UrbanPop))
#' )),
#' visualMap= list(type='continuous', calculable=TRUE,
#' inRange= list(color = rainbow(8)),
#' min= min(dusa$UrbanPop), max= max(dusa$UrbanPop))
#' )
#' p$x$registerMap <- list(list(mapName= 'USA', geoJSON= json))
#' p
#' }
#' )
#' p$x$registerMap <- list(list(mapName= 'USA', geoJSON= json))
#' p
#' #}
#'
#' #------ locale
#' mo <- seq.Date(Sys.Date() - 444, Sys.Date(), by= "month")
#' df <- data.frame(date= mo, val= runif(length(mo), 1, 10))
#' p <- df |> ec.init(title= list(text= 'locale test'))
#' p <- df |> ec.init(title= list(text= 'ZH locale test'),
#' toolbox= list(feature= list(saveAsImage= list(type='svg'))) )
#' p$x$locale <- 'ZH'
#' p$x$renderer <- 'svg'
#' p
#'
#'
#' #------ Pie
#' isl <- data.frame(name=names(islands), value=islands) |> filter(value>100) |> arrange(value)
#'
#' ec.init( preset= FALSE,
#' title= list(text = "Landmasses over 60,000 mi\u00B2", left = 'center'),
#' tooltip= list(trigger='item'), #, formatter= ec.clmn()),
@@ -302,27 +297,23 @@
#' color= c("blue","purple","red","gold","blue","purple","red","gold")
#' )
#' df |> group_by(group) |> ec.init(
#' preset= FALSE, legend= list(selectedMode= "single"),
#' timeline= list(show=TRUE),
#' series.param= list(type= 'pie', roseType= 'radius',
#' itemStyle= list(color=ec.clmn(5)),
#' label= list(formatter=ec.clmn(4)),
#' encode=list(value='value', itemName='type'))
#' legend= list(show=TRUE),
#' timeline= list(show=TRUE),
#' series.param= list(type= 'pie', roseType= 'radius',
#' itemStyle= list(color=ec.clmn(5)),
#' label= list(formatter=ec.clmn(4)),
#' encode=list(value='value', itemName='type'))
#' )
#'
#'
#' #------ Boxplot without grouping
#' ds <- mtcars |> select(cyl, drat) |>
#' ec.data(format='boxplot', jitter=0.1, #layout= 'h',
#' symbolSize=5, itemStyle=list(opacity=0.9),
#' emphasis= list(itemStyle= list(
#' color= 'chartreuse', borderWidth=4, opacity=1))
#' )
#' ec.data(format='boxplot', jitter=0.1, symbolSize=6 ) #,layout='c')
#' ds$series[[1]]$color= 'LightGrey'
#' ds$series[[1]]$itemStyle= list(color='DimGray')
#' ec.init(
#' #colors= heat.colors(length(mcyl)),
#' legend= list(show= TRUE), tooltip= list(show=TRUE),
#' dataset= ds$dataset, series= ds$series, xAxis= ds$xAxis, yAxis= ds$yAxis,
#' series.param= list(color= 'LightGrey', itemStyle= list(color='DimGray'))
#' ) |> ec.theme('dark-mushroom')
#'
#'
@@ -359,9 +350,9 @@
#' list('Jasmin Krause', 52, 'Musician', 287, '2011-02-14'),
#' list('Li Lei', 37, 'Teacher', 219, '2011-02-18'),
#' list('Karle Neumann', 25, 'Engineer', 253, '2011-04-02'),
#' list('Adrian Groß', 19, 'Teacher', NULL, '2011-01-16'),
#' list('Adrian Groß', 19, 'Teacher', NULL, '2011-01-16'),
#' list('Mia Neumann', 71, 'Engineer', 165, '2011-03-19'),
#' list('Böhm Fuchs', 36, 'Musician', 318, '2011-02-24'),
#' list('Böhm Fuchs', 36, 'Musician', 318, '2011-02-24'),
#' list('Han Meimei', 67, 'Engineer', 366, '2011-03-12'))),
#' list(transform = list(type= 'sort', config=list(
#' list(dimension='profession', order='desc'),
@@ -453,21 +444,20 @@
#'
#'
#' # graph plot with same data ---------------
#' ec.init(preset= FALSE,
#' title= list(text= 'Graph'),
#' tooltip= list(show= TRUE),
#' series= list(list(
#' type= 'graph',
#' layout= 'force', # try 'circular' too
#' data= lapply(data,
#' function(x) list(name= x$node, tooltip= list(show=FALSE))),
#' edges= lapply(data,
#' function(x) { x$lineStyle <- list(width=x$value); x }),
#' emphasis= list(focus= 'adjacency',
#' label= list(position= 'right', show=TRUE)),
#' label= list(show=TRUE), roam= TRUE, zoom= 4,
#' tooltip= list(textStyle= list(color= 'blue')),
#' lineStyle= list(curveness= 0.3) ))
#' ec.init(
#' title= list(text= 'Graph'),
#' tooltip= list(show= TRUE),
#' series= list(list(
#' type= 'graph',
#' layout= 'force', # try 'circular' too
#' data= data,
#' edges= lapply(data,
#' function(x) { x$lineStyle <- list(width=x$value); x }),
#' emphasis= list(focus= 'adjacency',
#' label= list(position= 'right', show=TRUE)),
#' label= list(show=TRUE), roam= TRUE, zoom= 4,
#' tooltip= list(textStyle= list(color= 'blue')),
#' lineStyle= list(curveness= 0.3) ))
#' )
#'
#'
@@ -481,9 +471,7 @@
#' legend <- list(show=TRUE) # show first legend to share
#' })
#' q2 <- main |> ec.upd({ series[[1]]$encode <- list(y='wt'); yAxis$name <- 'wt' })
#' #if (interactive()) { # browsable
#' ec.util(cmd='layout', list(q1,q2), cols=2, title='group connect')
#' #}
#' ec.util(cmd='layout', list(q1,q2), cols=2, title='group connect')
#'
#'
#' #------ Javascript execution: ec.init 'js' parameter demo
@@ -510,9 +498,10 @@
#' dbut <- ec.util(cmd='button', text='toggle', js=jtgl)
#' data <- list(list(name='root', children=list(list(name='A',value=1),list(name='B',value=3))))
#' ec.init( # elementId='myTree',
#' series.param= list(type='tree', data=data), graphic= list(dbut)
#' series.param= list(type='tree', data=data, symbolSize=33), graphic= list(dbut)
#' )
#'
#'
#' #------ Events in Shiny ----------
#' if (interactive()) {
#' library(shiny); library(dplyr); library(echarty)
@@ -546,10 +535,4 @@
#' #------------- Shiny interactive charts demo ---------------
#' # run command: demo(eshiny)
#'
#' } # donttest
#' @export
ec.examples <- function(){
cat("copy/paste code from ?ec.examples Help\n
Or run all examples at once with example('ec.examples') to see in Viewer.")
}

#' } # donttest
16 changes: 8 additions & 8 deletions man/Introduction.Rd
6 changes: 3 additions & 3 deletions man/ec.data.Rd
557 changes: 0 additions & 557 deletions man/ec.examples.Rd

This file was deleted.

9 changes: 5 additions & 4 deletions man/ec.fromJson.Rd
2 changes: 1 addition & 1 deletion man/ec.init.Rd
6 changes: 3 additions & 3 deletions man/ec.inspect.Rd
144 changes: 81 additions & 63 deletions man/ec.util.Rd
2 changes: 1 addition & 1 deletion man/ecs.exec.Rd
Binary file added pkgdown/favicon/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/favicon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/favicon.ico
Binary file not shown.
3 changes: 3 additions & 0 deletions pkgdown/favicon/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions pkgdown/favicon/site.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "",
"short_name": "",
"icons": [
{
"src": "/web-app-manifest-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "/web-app-manifest-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
Binary file added pkgdown/favicon/web-app-manifest-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/web-app-manifest-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 13 additions & 2 deletions tests/testthat/test-ec.util.R
Original file line number Diff line number Diff line change
@@ -98,6 +98,8 @@ test_that("layout", {
expect_equal(p$children[[2]]$children[[2]]$children[[2]]$children[[1]]$x$theme, 'macarons')
# test for 2nd row
expect_equal(p$children[[2]]$children[[4]]$children[[1]]$children[[1]]$x$theme, 'dark-mushroom')
list(cars |> ec.init()) |> ec.util(cmd='layout', rows=2, title= 'coveralls')
list(cars |> ec.init()) |> ec.util(cmd='layout', title= 'coveralls')
})

test_that("tabset with pairs", {
@@ -294,6 +296,12 @@ test_that("ec.data dendrogram", {

test_that("ec.data boxlpot", {

# simple boxplot
ds <- mtcars |> select(cyl, drat) |>
ec.data(format='boxplot', outliers=TRUE, layout= 'v')
#ec.init(dataset= ds$dataset, series= ds$series, xAxis= ds$xAxis, yAxis= ds$yAxis)
expect_equal(ds$series[[1]]$type, 'boxplot')

# without grouping -------------------
p <- mtcars |> relocate(cyl,mpg) |> ec.data(format='boxplot', outliers=TRUE)
expect_equal(p$series[[1]]$type, 'boxplot')
@@ -310,7 +318,6 @@ test_that("ec.data boxlpot", {
emphasis= list(itemStyle= list(color= 'chartreuse', borderWidth=4, opacity=1))
)
p <- ec.init(
#colors= heat.colors(length(mcyl)),
legend= list(show= TRUE), tooltip= list(show=TRUE),
dataset= ds$dataset, series= ds$series, xAxis= ds$xAxis, yAxis= ds$yAxis
) |>
@@ -384,7 +391,7 @@ test_that("ec.data treeTK", {
expect_equal(p$x$opts$series[[1]]$data[[1]]$value, 2201)
})

test_that("ec.data 'names' + nasep", {
test_that("ec.data 'names' + nasep, header", {
df <- data.frame(name= c('A','B','C'), value= c(1,2,3),
itemStyle_color= c('chartreuse','lightblue','pink'),
itemStyle_decal_symbol= c('rect','diamond','none'),
@@ -395,6 +402,10 @@ test_that("ec.data 'names' + nasep", {
expect_equal(p$x$opts$series[[1]]$data[[1]]$emphasis$itemStyle$color, 'green')
expect_equal(p$x$opts$series[[1]]$data[[2]]$itemStyle$decal$symbol, 'diamond')
expect_equal(p$x$opts$series[[1]]$data[[3]]$itemStyle$color, 'pink')
p <- cars |> ec.data(header=TRUE)
expect_equal(p[[1]][1], 'speed')
p <- mtcars |> ec.data(format='values')
expect_equal(p[[1]]$value[1], 21)
})

test_that("ec.inspect and ec.fromJson", {
1 change: 1 addition & 0 deletions tests/testthat/test-other.R
Original file line number Diff line number Diff line change
@@ -276,6 +276,7 @@ test_that('stops are working in echarty.R', {
# expect_silent(ec.init(data.frame(name='n',value=1) |> group_by(name),
# tl.series= list(type='map'))) # 2 cols exception for map
expect_error(ec.init(mtcars |> group_by(gear), tl.series= list(encode= list(x=1, y=2),groupBy='zzz'))) # groupBy
expect_error(ec.util(cmd='layout'))
expect_error(ecr.band(cars))
tmp <- cars; tmp <- tmp |> rename(lower=speed, upper=dist)
expect_error(ecr.band(tmp, lower='lower', upper='upper')) # no first col
Binary file added vignettes/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f03c0d6

Please sign in to comment.