Skip to content

Commit dfd7796

Browse files
committed
v.1.4.4
1 parent ad2949e commit dfd7796

File tree

14 files changed

+166
-55
lines changed

14 files changed

+166
-55
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ README.md
2121
^\.ccache$
2222
^tic\.R$
2323
^codecov\.yml$
24+
^CRAN-SUBMISSION$

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.Rproj.user
22
.Rhistory
33
.RData
4-
.Rbuildignore/**
4+
.Rbuildignore
55
inst/doc
66
*.vs/
77
.V8history

CRAN-SUBMISSION

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Version: 1.4.3
2+
Date: 2021-12-20 05:48:09 UTC
3+
SHA: ad2949e581aec92b3c253a8bd3f3b3127436dd26

DESCRIPTION

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: echarty
22
Title: Minimal R/Shiny Interface to JavaScript Library 'ECharts'
3-
Date: 2021-12-06
4-
Version: 1.4.3
3+
Date: 2022-02-06
4+
Version: 1.4.4
55
Authors@R: c(
66
person("Larry", "Helgason", email = "larry@helgasoft.com", role = c("aut", "cre", "cph")),
77
person("John", "Coene", email = "jcoenep@gmail.com", role = c("aut", "cph"))
@@ -20,12 +20,10 @@ Imports:
2020
shiny (>= 1.7.0),
2121
jsonlite
2222
Suggests:
23-
magrittr,
2423
crosstalk,
2524
rmarkdown,
2625
knitr,
27-
testthat (>= 3.0.0),
28-
covr
26+
testthat (>= 3.0.0)
2927
RoxygenNote: 7.1.2
3028
Roxygen: list(markdown = TRUE)
3129
URL: https://github.com/helgasoft/echarty

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# history of echarty package development
22

3+
## v.1.4.4
4+
5+
- upgrade ECharts to v.5.3.0
6+
- _ec.init_ timeline (_tl.series_) to support 3D
7+
- add _ec.theme_ warnings about _ec.snip_
8+
39
## v.1.4.3
410

511
- upgrade ECharts to v.5.2.2, graph-modularity to v.2.1.0

R/echarty-package.R

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#' @section Package Conventions:
2+
#' echarty is "pipe-friendly", supports both %>% and |> \cr
3+
#' echarty functions have three prefixes to help with auto-completion: \itemize{
4+
#' \item \emph{ec.} for general functions
5+
#' \item \emph{ecr.} for rendering functions
6+
#' \item \emph{ecs.} for Shiny functions
7+
#' }
8+
#'
9+
#' @section Global Options:
10+
#' Options are set with R command \href{https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/options}{options}.\cr
11+
#' echarty uses the following options: \cr \itemize{
12+
#' \item echarty.theme = name of theme file (without extension), from folder /inst/themes
13+
#' \item echarty.font = font family name
14+
#' \item echarty.urltiles = tiles URL template for leaflet maps
15+
#' \item echarty.short = a boolean flag, see [ec.snip]
16+
#' }
17+
#'
18+
#' @examples
19+
#' # basic scatter chart from a data.frame, using presets
20+
#' cars |> ec.init()
21+
#'
22+
#' # set/get global options
23+
#' options('echarty.short'=TRUE) # set
24+
#' getOption('echarty.short') # get
25+
#' options('echarty.short'=NULL) # remove
26+
#'
27+
#' @keywords internal
28+
"_PACKAGE"
29+
30+
## usethis namespace: start
31+
## usethis namespace: end
32+
NULL

R/echarty.R

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,15 @@ ec.init <- function( df=NULL, preset=TRUE, ctype='scatter', load=NULL,
311311
tl.series$coordinateSystem <- 'cartesian2d'
312312
if (tl.series$coordinateSystem=='cartesian2d') {
313313
xtem <- 'x'; ytem <- 'y' }
314+
if (startsWith(tl.series$coordinateSystem, 'cartesian')) {
315+
xtem <- 'x'; ytem <- 'y'; ztem <- 'z' }
314316
else if (tl.series$coordinateSystem=='polar') {
315317
xtem <- 'radius'; ytem <- 'angle' }
316318
else if (tl.series$coordinateSystem %in% c('geo','leaflet')) {
317319
xtem <- 'lng'; ytem <- 'lat'
318320
center <- c(mean(unlist(df[,tl.series$encode$lng])),
319321
mean(unlist(df[,tl.series$encode$lat])))
320-
if (tl.series$coordinateSystem=='geo') wt$x$opts$geo$center <- center
322+
if (tl.series$coordinateSystem=='geo') wt$x$opts$geo$center <- center
321323
if (tl.series$coordinateSystem=='leaflet') wt$x$opts$leaflet$center <- center
322324
}
323325
if (is.null(unlist(tl.series$encode[xtem]))) {
@@ -347,15 +349,15 @@ ec.init <- function( df=NULL, preset=TRUE, ctype='scatter', load=NULL,
347349
# multiple series for each Y, like y=c('col1', 'col3')
348350
series <- lapply(unname(unlist(tl.series$encode[ytem])),
349351
function(sname) {
350-
append(list(datasetIndex=di, name=sname), tl.series)
352+
append(list(datasetIndex= di, name= sname), tl.series)
351353
})
352354
series <- lapply(series, function(s) {
353355
s$encode[ytem] <- s$name # replace multiple col.names with one
354356
s
355357
})
356358

357-
list(title = list(text = as.character(unique(gp[gvar])), left=40),
358-
series = unname(series))
359+
list(title= list(text= as.character(unique(gp[gvar]))),
360+
series= unname(series))
359361
})
360362

361363
wt$x$opts$options <- optl
@@ -595,11 +597,11 @@ ecr.band <- function(df=NULL, lower=NULL, upper=NULL, type='polygon', ...) {
595597
#' @return A widget with error bars added if successful, otherwise the input wt
596598
#'
597599
#' @details
598-
#' Grouped series are supported, but require the group column to be included in df. \cr
599-
#' ecr.ebars are custom series, so \emph{ec.init(load='custom')} is required. \cr
600-
#' ecr.ebars will add a chart legend and its own tooltip if none is provided.\cr
601-
#' ecr.ebars with name attribute will show separate in the legend \cr
602-
#' ecr.ebars should be set at the end, after all other series.
600+
#' \emph{ecr.ebars} are custom series, so \emph{ec.init(load='custom')} is required. \cr
601+
#' Grouped series are supported, but require the group column to be included in \emph{df}. \cr
602+
#' Will add a chart legend and its own tooltip if none is provided.\cr
603+
#' ecr.ebars with name attribute will show separate in the legend. \cr
604+
#' Command should be called last, after all other series.
603605
#'
604606
#' @examples
605607
#' if (interactive()) {
@@ -620,6 +622,8 @@ ecr.ebars <- function(wt, df=NULL, hwidth=6, ...) {
620622
stop('df must be a data.frame', call.=FALSE)
621623
if (!'renderers' %in% unlist(lapply(wt$dependencies, function(d) d$name)))
622624
stop("use ec.init(load='custom') for ecr.ebars", call.=FALSE)
625+
if (!is.null(wt$saved))
626+
stop('Did you place ec.snip at end-of-pipe?', call. = FALSE)
623627

624628
ser <- wt$x$opts$series # all series
625629
if (is.null(ser)) stop('series are missing', call.=FALSE)
@@ -832,7 +836,9 @@ ecs.exec <- function(proxy, cmd='p_merge') {
832836
#' @param width Width of columns, one of xs, md, lg
833837
#' @param title Title for the set
834838
#' @return A container \code{\link[htmltools]{div}} in rmarkdown, otherwise \code{\link[htmltools]{browsable}}
835-
#' @details For 3-4 charts one would use multiple series with a \href{https://echarts.apache.org/en/option.html#grid}{grid}. For greater number of charts _ec.layout_ come in handy.
839+
#' @details
840+
#' For 3-4 charts one would use multiple series with a \href{https://echarts.apache.org/en/option.html#grid}{grid}. \cr
841+
#' For greater number of charts _ec.layout_ come in handy.
836842
#' @examples
837843
#' options(browser = 'firefox')
838844
#' tmp <- lapply(list('dark','macarons','gray','jazz','dark-mushroom'),
@@ -954,21 +960,24 @@ ec.paxis <- function (df=NULL, minmax=TRUE, cols=NULL, ...) {
954960
#' "backgroundColor": "lemonchiffon"}')
955961
#'
956962
#' @export
957-
ec.theme <- function (wt, name, code = NULL)
963+
ec.theme <- function (wt, name, code= NULL)
958964
{
959965
if (missing(name))
960966
stop('must define theme name', call. = FALSE)
961-
967+
if (!is.null(wt$saved))
968+
stop('Did you place ec.snip at end-of-pipe?', call. = FALSE)
969+
970+
#if (length(wt$x[[1]])==0) wt$x[[1]] <- NULL # parasite list
962971
wt$x$theme <- name
963972
if (!is.null(code))
964973
wt$x$themeCode <- code
965974
else {
966975
wt$x$themeCode <- NULL
967-
path <- system.file('themes', package = 'echarty')
976+
path <- system.file('themes', package= 'echarty')
968977
dep <- htmltools::htmlDependency(
969-
name = name,
970-
version = '1.0.0', src = c(file = path),
971-
script = paste0(name, '.js'))
978+
name= name,
979+
version= '1.0.0', src= c(file= path),
980+
script= paste0(name, '.js'))
972981
wt$dependencies <- append(wt$dependencies, list(dep))
973982
}
974983
wt
@@ -985,7 +994,8 @@ ec.theme <- function (wt, name, code = NULL)
985994
#' @return A JSON string if \code{json} is \code{TRUE} and
986995
#' a \code{list} otherwise.
987996
#'
988-
#' @note Must be invoked or chained as last command.
997+
#' @note Must be invoked or chained as last command.\cr
998+
#' ec.inspect is incompatible with [ec.snip]
989999
#'
9901000
#' @examples
9911001
#' # extract JSON
@@ -997,7 +1007,9 @@ ec.theme <- function (wt, name, code = NULL)
9971007
#'
9981008
#' @export
9991009
ec.inspect <- function(wt, target=NULL, json=TRUE, ...) {
1000-
1010+
if (!is.null(wt$saved))
1011+
stop('ec.inspect incompatible with ec.snip', call. = FALSE)
1012+
10011013
opts <- wt$x$opts
10021014

10031015
if (!is.null(target)) {
@@ -1074,10 +1086,11 @@ ec.fromJson <- function(txt, ...) {
10741086
#' Utility to improve readability and typing speed
10751087
#'
10761088
#' @param wt A widget to be converted to option list \cr
1077-
#' OR an option list to plot
1089+
#' OR an option list to a plot
10781090
#' @details
1079-
#' On initialization, pipe _ec.snip_ after [ec.init], \cr
1080-
#' or set for the entire R session with \code{options('echarty.short'=TRUE)}.
1091+
#' On initialization, add _ec.snip_ at the end of the [ec.init] pipe, \cr
1092+
#' or set for the entire R session with \code{options('echarty.short'=TRUE)}.\cr
1093+
#' Note: ec.theme, ecr.ebars, ec.inspect will not work with the session setting.
10811094
#'
10821095
#' @examples
10831096
#' p <- cars |> ec.init() |> ec.snip()
@@ -1099,6 +1112,7 @@ ec.snip <- function(wt) {
10991112
}
11001113
else {
11011114
# return the chart widget to plot
1115+
# wt$x holds theme, registerMap, jcode, locale, renderer, etc.
11021116
p <- wt$saved
11031117
wt$saved <- NULL
11041118
p$x$opts <- wt
@@ -1206,16 +1220,7 @@ if (requireNamespace("shiny", quietly = TRUE)) {
12061220

12071221
# ------------- Global Options -----------------
12081222
#'
1209-
#' echarty uses the following global options: \cr \itemize{
1210-
#' \item echarty.theme = name of theme file (without extension), from folder /inst/themes
1211-
#' \item echarty.font = font family name
1212-
#' \item echarty.urltiles = tiles URL template for leaflet maps
1213-
#' \item echarty.short = a boolean flag, see [ec.snip]
1214-
#' }
1215-
#' @examples
1216-
#' options('echarty.short'=TRUE) # set
1217-
#' getOption('echarty.short') # get
1218-
#' options('echarty.short'=NULL) # remove
1223+
#' For info on options and prefixes, type \emph{?echarty} in the R console.
12191224

12201225

12211226

inst/js/echarts.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/themes/dark-mushroom.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@
5555
}
5656
},
5757
axisLabel: {
58-
textStyle: {
59-
color: contrastColor
60-
}
58+
color: contrastColor
6159
},
6260
splitLine: {
6361
lineStyle: {
@@ -94,7 +92,8 @@
9492
crossStyle: {
9593
color: contrastColor
9694
}
97-
}
95+
},
96+
textStyle: { color: contrastColor }
9897
},
9998
legend: {
10099
textStyle: {
@@ -123,7 +122,7 @@
123122

124123
timeline: {
125124
itemStyle: {
126-
color: colorPalette[1]
125+
color: '#aaa' //colorPalette[1]
127126
},
128127
lineStyle: {
129128
color: contrastColor
@@ -141,7 +140,12 @@
141140
logAxis: axisCommon(),
142141
valueAxis: axisCommon(),
143142
categoryAxis: axisCommon(),
144-
143+
144+
timeAxis3D: axisCommon(),
145+
logAxis3D: axisCommon(),
146+
valueAxis3D: axisCommon(),
147+
categoryAxis3D: axisCommon(),
148+
145149
line: {
146150
symbol: 'circle'
147151
},

man/ec.inspect.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)