Skip to content

Commit

Permalink
v.1.6.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Larry Helgason committed Dec 29, 2024
1 parent 13a059c commit 781c8dd
Show file tree
Hide file tree
Showing 21 changed files with 143 additions and 74 deletions.
3 changes: 0 additions & 3 deletions CRAN-SUBMISSION

This file was deleted.

29 changes: 15 additions & 14 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
Package: echarty
Title: Minimal R/Shiny Interface to JavaScript Library 'ECharts'
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]>
Date: 2024-12-29
Version: 1.6.5
Authors@R: c(
person(given= "Larry", family= "Helgason", role= c("aut", "cre"), email= "[email protected]", comment="initial code from John Coene's library echarts4r")
)
Description: Deliver the full functionality of 'ECharts' with minimal overhead. 'echarty' users build R lists for 'ECharts' API. Lean set of powerful commands.
Depends: R (>= 4.1.0)
Imports:
htmlwidgets,
dplyr (>= 0.7.0),
data.tree (>= 1.0.0),
Suggests:
htmltools (>= 0.5.0),
shiny (>= 1.7.0),
jsonlite,
crosstalk,
testthat (>= 3.0.0),
sf,
leaflet (>= 2.2.0),
knitr,
rmarkdown
htmltools (>= 0.5.0),
shiny (>= 1.7.0),
jsonlite,
crosstalk,
testthat (>= 3.0.0),
sf,
leaflet (>= 2.2.0),
knitr,
rmarkdown
RoxygenNote: 7.3.2
Roxygen: list(markdown = TRUE)
License: Apache License (>= 2.0)
URL: https://helgasoft.github.io/echarty/
BugReports: https://github.com/helgasoft/echarty/issues/
Encoding: UTF-8
Language: en-US
VignetteBuilder: rmarkdown
VignetteBuilder: rmarkdown, knitr
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# history of package _echarty_

# echarty 1.6.4.1 latest in development
# echarty 1.6.5 latest in development

* upgrade ECharts to v.5.5.1, built with R v.4.4.2.
* upgrade ECharts to v.5.6.0, built with R v.4.4.2.
* auto-load 3D plugin when 3D attributes present (xAxis3D, bar3D, etc.).
* auto-set 3D axes from data (name, type).
* change in _dataset_: store column names in _dimensions_ instead of _source_.
Expand Down
51 changes: 33 additions & 18 deletions R/echarty.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ noCoord <- c('polar','radar','singleAxis','parallelAxis','calendar')
#' @details Command _ec.init_ creates a widget with \link[htmlwidgets]{createWidget}, then adds some ECharts features to it.\cr
#' Numerical indexes for series,visualMap,etc. are R-counted (1,2...)\cr
#'
#' **Presets**: \cr
#' **Presets** \cr
#' When data.frame **df** is present, a \href{https://echarts.apache.org/en/option.html#dataset}{dataset} is preset. \cr
#' When **df** is grouped and _ctype_ is not NULL, more datasets with legend and series are also preset. \cr
#' Plugin '3D' (load='3D') is required for GL series like _scatterGL, linesGL_, etc. \cr
#' Plugins 'leaflet' and 'world' preset _center_ to the mean of all coordinates from **df**. \cr
#' Users can delete or overwrite any presets as needed. \cr
#'
#' **Widget attributes**: \cr
#' **Widget attributes** \cr
#' Optional echarty widget attributes include: \cr
#' * elementId - Id of the widget, default is NULL(auto-generated)
#' * load - name(s) of plugin(s) to load. A character vector or comma-delimited string. default NULL.
Expand All @@ -60,7 +60,7 @@ noCoord <- c('polar','radar','singleAxis','parallelAxis','calendar')
#' * locale - 'EN'(default) or 'ZH'. Use predefined or custom \href{https://gist.github.com/helgasoft/0618c6537c45bfd9e86d3f9e1da497b8}{like so}.
#' * useDirtyRect - enable dirty rectangle rendering or not, FALSE by default, see \href{https://echarts.apache.org/en/api.html#echarts.init}{here}\cr
#'
#' **Built-in plugins**: \cr
#' **Built-in plugins** \cr
#' * leaflet - Leaflet maps with customizable tiles, see \href{https://github.com/gnijuohz/echarts-leaflet#readme}{source}\cr
#' * world - world map with country boundaries, see \href{https://github.com/apache/echarts/tree/master/test/data/map/js}{source} \cr
#' * lottie - support for \href{https://lottiefiles.com}{lotties} \cr
Expand All @@ -74,12 +74,12 @@ noCoord <- c('polar','radar','singleAxis','parallelAxis','calendar')
#' * wordcloud - cloud of words, see \href{https://github.com/ecomfe/echarts-wordcloud}{source} \cr
#' or install your own third-party plugins.\cr
#'
#' **Crosstalk**:\cr
#' Parameter _df_ should be of type \link[crosstalk]{SharedData}, see \href{https://helgasoft.github.io/echarty/gallery.html#crosstalk-2d}{more info}.\cr
#' **Crosstalk** \cr
#' Parameter _df_ should be of type \link[crosstalk]{SharedData}, see \href{https://helgasoft.github.io/echarty/articles/gallery.html#crosstalk-2d}{more info}.\cr
#' Optional parameter _xtKey_: unique ID column name of data frame _df_. Must be same as _key_ parameter used in _SharedData$new()_. If missing, a new column _XkeyX_ will be appended to df.\cr
#' Enabling _crosstalk_ will also generate an additional dataset called _Xtalk_ and bind the **first series** to it.\cr
#'
#' **Timeline**:\cr
#' **Timeline** \cr
#' Defined by _series.param_ for the \href{https://echarts.apache.org/en/option.html#series}{options series} and a _timeline_ list for the \href{https://echarts.apache.org/en/option.html#timeline}{actual control}.
#' A grouped _df_ is required, each group providing data for one option serie.
#' Timeline \href{https://echarts.apache.org/en/option.html#timeline.data}{data} and \href{https://echarts.apache.org/en/option.html#options}{options} will be preset for the chart.\cr
Expand All @@ -88,13 +88,13 @@ noCoord <- c('polar','radar','singleAxis','parallelAxis','calendar')
#' Optional attribute _groupBy_, a _df_ column name, can create series groups inside each timeline option.\cr
#' Options/timeline for hierarchical charts like graph,tree,treemap,sankey have to be built directly, see \href{https://helgasoft.github.io/echarty/uc4.html}{example}.
#'
#' **\href{https://echarts.apache.org/en/option.html#series-line.encode}{Encode}** \cr
#' A series attribute to define which columns to use for the axes, depending on chart type and coordinate system: \cr
#' Optional series attribute \href{https://echarts.apache.org/en/option.html#series-line.encode}{encode} defines which columns to use for the axes, depending on chart type and coordinate system: \cr
#' * set _x_ and _y_ for coordinateSystem _cartesian2d_
#' * set _lng_ and _lat_ for coordinateSystem _geo_ and _scatter_ series
#' * set _value_ and _name_ for coordinateSystem _geo_ and _map_ series
#' * set _radius_ and _angle_ for coordinateSystem _polar_
#' * set _value_ and _itemName_ for _pie_ chart
#' * set _value_ and _itemName_ for _pie_ chart.
#'
#' Example: \code{encode(x='col3', y='col1')} binds xAxis to _df_ column 'col3'.
#'
#' @return A widget to plot, or to save and expand with more features.
Expand Down Expand Up @@ -524,7 +524,8 @@ ec.init <- function( df= NULL, preset= TRUE, ctype= 'scatter', ...,
if ('leaflet' %in% load) {
# coveralls pops error, win/linux ok :
#stopifnot("ec.init: library 'leaflet' not installed"= file.exists(file.path(.libPaths(), 'leaflet')[[1]]))
if (!file.exists(file.path(.libPaths(), 'leaflet')[[1]])) warning("ec.init: library 'leaflet' not installed")
fldr <- sub('_build/','',file.path(.libPaths(), 'leaflet')[[1]])
if (!file.exists(fldr)) warning(paste("ec.init: library 'leaflet' problem in",fldr))
if (preset) {
# customizations for leaflet
wt$x$opts$xAxis <- wt$x$opts$yAxis <- NULL
Expand Down Expand Up @@ -1190,20 +1191,22 @@ ecs.exec <- function(proxy, cmd= 'p_merge') {
#'
#' @details When \emph{source} is URL, the plugin file is installed with an optional popup prompt.\cr
#' When \emph{source} is a file name (file://xxx.js), it is assumed installed and only a dependency is added.\cr
#' When \emph{source} is invalid, an error message will be written in the chart's title.\cr
#' Called internally by [ec.init]. It is recommended to use \emph{ec.init(load=...)} instead of \emph{ec.plugjs}.
#'
#' @examples
#' # import map plugin and display two (lon,lat) locations
#' if (interactive()) {
#' ec.init(preset= FALSE,
#' geo = list(map= 'china-contour', roam= TRUE),
#' series = list(list(
#' type= 'scatter', coordinateSystem= 'geo',
#' symbolSize= 9, itemStyle= list(color= 'red'),
#' data= list(list(value= c(113, 40)), list(value= c(118, 39))) ))
#' durl <- paste0('https://raw.githubusercontent.com/apache/echarts/',
#' 'master/test/data/map/js/china-contour.js')
#' ec.init( # load= durl,
#' geo = list(map= 'china-contour', roam= TRUE),
#' series.param = list(
#' type= 'scatter', coordinateSystem= 'geo',
#' symbolSize= 9, itemStyle= list(color= 'red'),
#' data= list(list(value= c(113, 40)), list(value= c(118, 39))) )
#' ) |>
#' ec.plugjs( paste0('https://raw.githubusercontent.com/apache/echarts/',
#' 'master/test/data/map/js/china-contour.js') )
#' ec.plugjs(durl)
#' }
#' @importFrom utils askYesNo download.file
#'
Expand All @@ -1213,6 +1216,10 @@ ec.plugjs <- function(wt=NULL, source=NULL, ask=FALSE) {
if (is.null(source)) return(wt)
stopifnot('ec.plugjs: expecting source as URL or file://'=
startsWith(source, 'http') || startsWith(source, 'file://'))
if (!.valid.url(source)) { # CRAN does not like stopifnot errors
wt$x$opts$title <- list(text='ERROR ec.plugjs: source is invalid!')
return(wt)
}
fname <- basename(source)
fname <- unlist(strsplit(fname, '?', fixed=TRUE))[1] # when 'X.js?key=Y'
# if (!endsWith(fname, '.js')) stop('ec.plugjs expecting .js suffix', call. = FALSE)
Expand Down Expand Up @@ -1315,6 +1322,14 @@ ec.plugjs <- function(wt=NULL, source=NULL, ask=FALSE) {
c(l1, l2)[!duplicated(c(names(l1), names(l2)), fromLast= TRUE)]
}

# validate URL (https:// or file://)
.valid.url <- function(durl, tsec=2){
con <- url(durl)
check <- suppressWarnings(try(open.connection(con,open="rt",timeout=tsec),silent=TRUE)[1])
suppressWarnings(try(close.connection(con),silent=TRUE))
ifelse(is.null(check),TRUE,FALSE)
}

# manage colnames for ec.clmn (not used)
.getColnm <- function() { the$.ecv.colnames }
.setColnm <- function(vv=NULL) {
Expand Down
2 changes: 2 additions & 0 deletions R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#' &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
#' &emsp;Please note that sometimes those tabsets do not merge well inside advanced web pages.\cr
#' **cmd = 'button'** \cr
#' &emsp;UI button to execute a JS function,\cr
#' &emsp; &emsp; text - the button label\cr
Expand Down Expand Up @@ -279,6 +280,7 @@ ec.util <- function( ..., cmd='sf.series', js=NULL, event='click') {
},
'sf.unzip'= {
stopifnot('ec.util: expecting url of zipped shapefile'= !is.null(opts$url))
stopifnot('ec.util: invalid zip url'= .valid.url(opts$url))
destfile <- tempfile('shapefile')
download.file(opts$url, destfile, mode='wb') #, method='curl')
# get name only, use as folder name to unzip to
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Please consider granting a Github star ⭐ to show your support.
## Installation

<!-- [![Github version](https://img.shields.io/github/v/release/helgasoft/echarty?label=github)](https://github.com/helgasoft/echarty/releases) <sup>.02</sup> -->
Latest development build **1.6.4.1**
Latest development build **1.6.5**

``` r
if (!requireNamespace('remotes')) install.packages('remotes')
Expand Down
4 changes: 2 additions & 2 deletions inst/js/echarts.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion man/Introduction.Rd

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

20 changes: 10 additions & 10 deletions man/ec.init.Rd

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

18 changes: 10 additions & 8 deletions man/ec.plugjs.Rd

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

1 change: 1 addition & 0 deletions man/ec.util.Rd

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

14 changes: 13 additions & 1 deletion _pkgdown.yml → pkgdown/_pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ url: https://helgasoft.github.io/echarty/
template:
bootstrap: 5
bootswatch: darkly
theme: arrow-dark
home:
sidebar:
structure:
Expand All @@ -15,7 +16,6 @@ navbar:
- intro
- reference
- articles
- tutorials
- news
right:
- search
Expand All @@ -26,6 +26,18 @@ navbar:
icon: fa-twitter
href: http://twitter.com/echarty_R
aria-label: Twitter

articles:
text: Gallery+
menu:
- text: Gallery
href: articles/gallery.html
- text: Extras
href: articles/extras.html
- text: -------
- text: Tutor - mapping
href: articles/mapping.html

footer:
structure:
left: legal
Expand Down
16 changes: 16 additions & 0 deletions pkgdown/assets/extras.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Page Redirection</title>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0;url=articles/extras.html" />
<meta name="robots" content="noindex">
<link rel="canonical" href="articles/extras.html" />
<script type="text/javascript">window.location.href = "articles/extras.html";</script>
</head>
<body>
<h1>
The page been moved to <a href="articles/extras.html">articles/extras.html</a>
</h1>
</body>
</html>
Binary file added pkgdown/assets/favicon-16x16.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/assets/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 781c8dd

Please sign in to comment.