Skip to content

Commit 34ab93f

Browse files
author
Larry Helgason
committed
1.6.6
1 parent 781c8dd commit 34ab93f

File tree

15 files changed

+391
-317
lines changed

15 files changed

+391
-317
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 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: 2024-12-29
4-
Version: 1.6.5
3+
Date: 2025-01-15
4+
Version: 1.6.6
55
Authors@R: c(
66
person(given= "Larry", family= "Helgason", role= c("aut", "cre"), email= "larry@helgasoft.com", comment="initial code from John Coene's library echarts4r")
77
)

NEWS.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# history of package _echarty_
22

3-
# echarty 1.6.5 latest in development
3+
# echarty 1.6.6 latest in development
4+
5+
* more tests to increase coverage without disturbing CRAN submission
6+
7+
# echarty 1.6.5 on CRAN
48

59
* upgrade ECharts to v.5.6.0, built with R v.4.4.2.
610
* auto-load 3D plugin when 3D attributes present (xAxis3D, bar3D, etc.).
@@ -12,7 +16,7 @@
1216
* integrate website with library using _pkgdown_.
1317
* moved _examples.R_ into 'demo' folder, _ec.examples_ is no longer a command.
1418

15-
# echarty 1.6.4 on CRAN
19+
# echarty 1.6.4
1620

1721
* upgrade ECharts to v.5.5.0, built with R v.4.4.0.
1822
* add _nasep_ parameter to _ec.data('names')_ to easily set nested lists from a _data.frame_.

R/echarty.R

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@ ec.init <- function( df= NULL, preset= TRUE, ctype= 'scatter', ...,
274274
is.null(vm$min) && is.null(vm$max) && is.null(vm$categories) &&
275275
(is.null(vm$type) || (vm$type == 'continuous')) ) {
276276

277-
xx <- length(colnames(df)) # last numeric column by default
278-
for(xx in xx:1) if (is.numeric(df[,xx])) break
277+
xx <- length(colnames(df)) # last numeric column (by default)
278+
for(xx in xx:1) if (is.numeric(unlist(df[,xx]))) break # unlist for group_by
279279
if (any(names(df) == 'value') && (
280280
(!is.null(tl.series) && tl.series$type=='map') ||
281281
(!is.null(series.param) && series.param$type=='map'))
@@ -659,7 +659,7 @@ ec.init <- function( df= NULL, preset= TRUE, ctype= 'scatter', ...,
659659
tmp <- xyNamesCS(tl.series)
660660
xtem <- tmp$x; ytem <- tmp$y
661661
if (!is.null(tmp$c)) tl.series$coordinateSystem <- tmp$c
662-
#if (dbg) cat('\ntl=',tmp$x,' ',tmp$y,' ',tmp$c)
662+
if (dbg) cat('\ntimeline: x=',xtem,' y=',ytem,' cs=',tmp$c)
663663

664664
if (any(c('geo','leaflet') %in% tl.series$coordinateSystem)) {
665665
klo <- 'lng'; kla <- 'lat'
@@ -693,15 +693,9 @@ ec.init <- function( df= NULL, preset= TRUE, ctype= 'scatter', ...,
693693
})
694694
}
695695
else {
696-
if (is.null(unlist(tl.series$encode[xtem]))) {
697-
# append col XcolX 1:max for each group
698-
df <- df |> group_modify(~ { .x |> mutate(XcolX = 1:nrow(.)) })
699-
tl.series$encode[xtem] <- 'XcolX' # instead of relocate(XcolX)
700-
# replace only source, transforms stay
701-
wt$x$opts$dataset[[1]] <- list(source= ec.data(df, header=TRUE))
702-
}
703-
stopifnot("timeline: bad second parameter name for encode"= !is.null(unlist(tl.series$encode[ytem])))
704-
696+
if (is.null(tl.series$encode[[xtem]]) || is.null(tl.series$encode[[ytem]]))
697+
stop(paste0('for ',tl.series$type,' use encode=list(',xtem,'=..., ',ytem,'=...)'), call.=FALSE)
698+
705699
# dataset is already in, now loop group column(s)
706700
#gvar <- df |> group_vars() |> first() |> as.character() # convert if factor
707701
di <- 0
@@ -1114,12 +1108,12 @@ ecs.render <- function(wt, env=parent.frame(), quoted= FALSE) {
11141108
#' @export
11151109
ecs.proxy <- function(id) {
11161110
sessi <- globalenv()
1117-
if (interactive()) {
1111+
#if (interactive()) {
11181112
if (requireNamespace("shiny", quietly = TRUE)) {
11191113
sessi <- shiny::getDefaultReactiveDomain()
11201114
} else
11211115
return(invisible(NULL))
1122-
}
1116+
#}
11231117
proxy <- list(id= id, session= sessi)
11241118
class(proxy) <- 'ecsProxy'
11251119
return(proxy)
@@ -1164,13 +1158,13 @@ ecs.exec <- function(proxy, cmd= 'p_merge') {
11641158

11651159
# create web dependencies for JS, if present
11661160
if (!is.null(proxy$dependencies)) {
1167-
if (interactive()) {
1161+
#if (interactive()) {
11681162
if (requireNamespace("shiny", quietly = TRUE)) {
11691163
plist$deps <- list(shiny::createWebDependency(
11701164
htmltools::resolveDependencies( proxy$dependencies )[[1]]
11711165
))
11721166
}
1173-
}
1167+
#}
11741168
}
11751169
if (!is.null(proxy$session))
11761170
proxy$session$sendCustomMessage('kahuna', plist)
@@ -1256,9 +1250,7 @@ ec.plugjs <- function(wt=NULL, source=NULL, ask=FALSE) {
12561250
}
12571251

12581252
# called by widget init
1259-
# .preRender <- function(wt) {
1260-
# wt
1261-
# }
1253+
# .preRender <- function(wt) { wt }
12621254

12631255
# convert from R to JS numbering
12641256
.renumber <- function(opa) {

R/util.R

Lines changed: 101 additions & 94 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
<!-- badges: start -->
55

66
[![R-CMD-check](https://github.com/helgasoft/echarty/workflows/R-CMD-check/badge.svg)](https://github.com/helgasoft/echarty/actions)
7-
[![coverage](https://coveralls.io/repos/github/helgasoft/echarty/badge.svg)](https://coveralls.io/r/helgasoft/echarty?branch=main)
7+
[![coverage](https://coveralls.io/repos/github/helgasoft/echarty/badge.svg)](https://coveralls.io/github/helgasoft/echarty)
88
[![size](https://img.shields.io/github/languages/code-size/helgasoft/echarty)](https://github.com/helgasoft/echarty/releases/)
99
[![website](https://img.shields.io/badge/Website-Visit-blue)](https://helgasoft.github.io/echarty)
10-
[![twitter](https://img.shields.io/twitter/follow/echarty.svg?style=social&label=Follow)](https://twitter.com/echarty_R)
10+
[![twitter](https://img.shields.io/twitter/follow/echarty.svg?style=social&label=Follow)](https://x.com/echarty_R)
1111

1212
<!--
1313
[![CRAN
@@ -54,7 +54,7 @@ Please consider granting a Github star ⭐ to show your support.
5454
## Installation
5555

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

5959
``` r
6060
if (!requireNamespace('remotes')) install.packages('remotes')

demo/examples.R

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -98,38 +98,36 @@
9898
#' color = c("#387e78","#eeb422","#d9534f",'magenta'))
9999
#' tmp <- head(flights,10) |> inner_join(tmp) # add color by airport
100100
#' ec.init(load= 'world',
101-
#' geo= list(center= c(mean(flights$start_lon), mean(flights$start_lat)),
102-
#' zoom= 7, map='world' ),
103-
#' series= list(list(
104-
#' type= 'lines', coordinateSystem= 'geo',
101+
#' geo= list(center= c(mean(flights$start_lon), mean(flights$start_lat)), zoom=7, map='world'),
102+
#' series.param= list( type= 'lines',
105103
#' data= lapply(ec.data(tmp, 'names'), function(x)
106-
#' list(coords = list(c(x$start_lon,x$start_lat),
107-
#' c(x$end_lon,x$end_lat)),
104+
#' list(coords = list(c(x$start_lon, x$start_lat),
105+
#' c(x$end_lon, x$end_lat)),
108106
#' colr = x$color)
109107
#' ),
110108
#' lineStyle= list(curveness=0.3, width=3, color=ec.clmn('colr'))
111-
#' ))
109+
#' )
112110
#' )
113111
#' } }
114112
#'
115113
#' #------ registerMap JSON
116114
#' # registerMap supports also maps in SVG format, see website gallery
117-
#' #if (interactive()) {
118-
#' json <- jsonlite::read_json("https://echarts.apache.org/examples/data/asset/geo/USA.json")
119-
#' dusa <- USArrests
120-
#' dusa$states <- row.names(dusa)
121-
#' p <- ec.init(preset= FALSE,
122-
#' series= list(list(type= 'map', map= 'USA', roam= TRUE, zoom= 3, left= -100, top= -30,
123-
#' data= lapply(ec.data(dusa, 'names'),
124-
#' function(x) list(name=x$states, value=x$UrbanPop))
125-
#' )),
126-
#' visualMap= list(type='continuous', calculable=TRUE,
127-
#' inRange= list(color = rainbow(8)),
128-
#' min= min(dusa$UrbanPop), max= max(dusa$UrbanPop))
129-
#' )
130-
#' p$x$registerMap <- list(list(mapName= 'USA', geoJSON= json))
131-
#' p
132-
#' #}
115+
#' if (interactive()) {
116+
#' json <- jsonlite::read_json("https://echarts.apache.org/examples/data/asset/geo/USA.json")
117+
#' dusa <- USArrests
118+
#' dusa$states <- row.names(dusa)
119+
#' p <- ec.init(
120+
#' series.param= list(type= 'map', map= 'USA', roam= TRUE, zoom= 3, left= -100, top= -30,
121+
#' data= lapply(ec.data(dusa, 'names'),
122+
#' function(x) list(name=x$states, value=x$UrbanPop))
123+
#' ),
124+
#' visualMap= list(type='continuous', calculable=TRUE,
125+
#' inRange= list(color = rainbow(8)),
126+
#' min= min(dusa$UrbanPop), max= max(dusa$UrbanPop))
127+
#' )
128+
#' p$x$registerMap <- list(list(mapName= 'USA', geoJSON= json))
129+
#' p
130+
#' }
133131
#'
134132
#' #------ locale
135133
#' mo <- seq.Date(Sys.Date() - 444, Sys.Date(), by= "month")
@@ -199,12 +197,12 @@
199197
#' if (interactive()) {
200198
#' iris |> group_by(Species) |>
201199
#' mutate(size= log(Petal.Width*10)) |> # add size as 6th column
202-
#' ec.init(load= '3D',
203-
#' xAxis3D= list(name= 'Petal.Length'),
204-
#' yAxis3D= list(name= 'Sepal.Width'),
205-
#' zAxis3D= list(name= 'Sepal.Length'),
206-
#' legend= list(show= TRUE),
207-
#' series.param= list(symbolSize= ec.clmn(6, scale=10))
200+
#' ec.init(
201+
#' xAxis3D= list(name= 'Petal.Length'),
202+
#' yAxis3D= list(name= 'Sepal.Width'),
203+
#' zAxis3D= list(name= 'Sepal.Length'),
204+
#' legend= list(show= TRUE),
205+
#' series.param= list(type='scatter3D', symbolSize= ec.clmn(6, scale=10))
208206
#' )
209207
#' }
210208
#'

man/ec.data.Rd

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

man/ec.fromJson.Rd

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

man/ec.inspect.Rd

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

0 commit comments

Comments
 (0)