Skip to content

Commit

Permalink
pkgdown
Browse files Browse the repository at this point in the history
integrate website
  • Loading branch information
helgasoft committed Dec 9, 2024
1 parent 394b0cf commit 6483e49
Show file tree
Hide file tree
Showing 23 changed files with 160 additions and 86 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ README.md
cleanup.bat
^doc$
^Meta$
^pkgdown$
49 changes: 49 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
release:
types: [published]
workflow_dispatch:

name: pkgdown.yaml

permissions: read-all

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ docs/
cleanup.bat
/doc/
/Meta/
docs
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-11-24
Date: 2024-12-09
Version: 1.6.4.1
Author: Larry Helgason, with initial code from John Coene's library echarts4r
Maintainer: Larry Helgason <[email protected]>
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
- change in dataset: store column names in _dimensions_ instead of _source_
- fixed bug in ecr.ebars for single series
- add optional placeholder '%@' in title$text for timeline
- add _event_ parameter in _ec.util_ for cmd='morph'
- integrate website with library using _pkgdown_

## v. 1.6.4 on CRAN

Expand Down
63 changes: 34 additions & 29 deletions R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#'
#' @param cmd utility command, see Details
#' @param js optional JavaScript function, default is NULL.
#' @param event optional event name for cmd='morph'.
#' @param ... Optional parameters for the command \cr
#' for \emph{sf.series} - see \href{https://echarts.apache.org/en/option.html#series-scatter.type}{points}, \href{https://echarts.apache.org/en/option.html#series-lines.type}{polylines}, polygons(itemStyle).\cr
#' for \emph{tabset} parameters should be in format \emph{name1=chart1, name2=chart2}, see example\cr
Expand Down Expand Up @@ -56,8 +57,8 @@
#' \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
#' **cmd = 'morph'** \cr
#' \verb{ }... - a list of charts or chart options\cr
#' \verb{ }js - optional JS function for switching charts. Default function is on \emph{mouseover}. Disable with FALSE.\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
#' **cmd = 'fullscreen'** \cr
#' \verb{ }A toolbox feature to toggle fullscreen on/off. Works in a browser, not in RStudio.\cr
Expand Down Expand Up @@ -88,28 +89,36 @@
#' }) |>
#' ec.util(cmd= 'tabset')
#' )
#' }
#'
#' cars |> ec.init(
#' graphic = list(
#' ec.util(cmd='button', text='see type', right='center', top=20,
#' js="function(a) {op=ec_option(echwid); alert(op.series[0].type);}")
#' )
#' )
#'
#' p1 <- cars |> ec.init(grid= list(top= 20)) # move chart up
#' p2 <- mtcars |> ec.init()
#' ec.util(cmd= 'tabset', cars= p1, mtcars= p2, width= 333, height= 333)
#' 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'),
#' \(x) cars |> ec.init() |> ec.theme(x) ) |>
#' 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')
#'
#' setd <- \(type) {
#' mtcars |> group_by(cyl) |>
#' ec.init(ctype= type,
#' title= list(subtext= 'mouseover points to morph'),
#' 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)
#' }
#' oscatter <- setd('scatter')
#' obar <- setd('bar')
#' ec.util(cmd='morph', oscatter, obar)
#'
#' @importFrom utils unzip
#' @export
ec.util <- function( ..., cmd='sf.series', js=NULL) {
ec.util <- function( ..., cmd='sf.series', js=NULL, event='click') {

opts <- list(...)

Expand Down Expand Up @@ -290,8 +299,7 @@ ec.util <- function( ..., cmd='sf.series', js=NULL) {

'tabset'= {
tabStyle <- NULL # CRAN check fix
do.opties(c('tabStyle'),
list("<style>
do.opties(c('tabStyle'), list("<style>
/* CSS for the main interaction */
.tabset > input[type='radio'] {
position: absolute;
Expand Down Expand Up @@ -436,8 +444,7 @@ body { padding: 10px; }
else oo
})
# series types should be different for morph options
clickHandler <- htmlwidgets::JS("
function(event) {
morfHandler <- htmlwidgets::JS("function(event) {
opt= this.getOption();
keep= opt.morph;
for(i=0; i<keep.length; i++) {
Expand All @@ -446,18 +453,16 @@ body { padding: 10px; }
optcurr= Object.assign({}, keep[next]);
break;
}
};
if (!optcurr) return;
optcurr.morph= keep;
this.setOption(optcurr, true);
}")
};
if (!optcurr) return;
optcurr.morph= keep;
this.setOption(optcurr, true);
}")
out <- ec.init(preset=FALSE, js=js)
out$x$opts <- opts[[1]]
out$x$opts$morph <- opts
if (is.null(js))
out$x$on <- list(list(
event= 'click', handler= clickHandler
))
#if (is.null(event)) event <- 'click'
out$x$on <- list(list(event= event, handler= morfHandler))
out
},

Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# <img src='man/figs/logo.png' width='70px' alt='' /> echarty
# <img src='man/figures/logo.png' width='70px' alt='' /> echarty

<!-- badges: start -->

Expand All @@ -15,7 +15,7 @@ downloads](https://cranlogs.r-pkg.org/badges/last-day/echarty)](https://cranlogs

<!-- badges: end -->

<a href='https://helgasoft.github.io/echarty'><img src="man/figs/echarty.gallery.png" alt="echarty.gallery" /></a>
<a href='https://helgasoft.github.io/echarty'><img src="man/figures/echarty.gallery.png" alt="echarty.gallery" /></a>

This package is a thin R wrapper around Javascript library
[ECharts](https://echarts.apache.org/en/index.html).
Expand All @@ -31,15 +31,15 @@ R package | echarts4r | echarty
--- | --- | ---
initial commit | Mar 12, 2018 | Feb 5, 2021
library size | ![878 KB](https://img.shields.io/github/languages/code-size/JohnCoene/echarts4r.svg) | ![224KB](https://img.shields.io/github/languages/code-size/helgasoft/echarty)
test coverage | ![32%](https://coveralls.io/repos/github/JohnCoene/echarts4r/badge.svg) [![link](man/figs/external-link-16.png)](https://coveralls.io/github/JohnCoene/echarts4r) | ![93%](https://coveralls.io/repos/github/helgasoft/echarty/badge.svg) [![link](man/figs/external-link-16.png)](https://coveralls.io/github/helgasoft/echarty)
lines of code | 1,202,623 [![link](man/figs/external-link-16.png)](https://api.codetabs.com/v1/loc/?github=JohnCoene/echarts4r) | 5,517 [![link](man/figs/external-link-16.png)](https://api.codetabs.com/v1/loc?github=helgasoft/echarty)
test coverage | ![32%](https://coveralls.io/repos/github/JohnCoene/echarts4r/badge.svg) [![link](man/figures/external-link-16.png)](https://coveralls.io/github/JohnCoene/echarts4r) | ![93%](https://coveralls.io/repos/github/helgasoft/echarty/badge.svg) [![link](man/figures/external-link-16.png)](https://coveralls.io/github/helgasoft/echarty)
lines of code | 1,202,623 [![link](man/figures/external-link-16.png)](https://api.codetabs.com/v1/loc/?github=JohnCoene/echarts4r) | 5,517 [![link](man/figures/external-link-16.png)](https://api.codetabs.com/v1/loc?github=helgasoft/echarty)
API design <sup>(1)</sup> | own commands with parameters | mostly [ECharts option](https://echarts.apache.org/en/option.html) lists
number of commands | over [200](https://echarts4r.john-coene.com/reference/) | **one** command + optional utility commands
data storage support | series data | **[datasets](https://echarts.apache.org/en/option.html#dataset)**, series data
dependencies ([packrat](https://rdrr.io/cran/packrat/src/R/recursive-package-dependencies.R#sym-recursivePackageDependencies)) | 65 | 40
dependencies ([WebR](https://repo.r-wasm.org)) | 188 | 46
[dataset](https://echarts.apache.org/en/option.html#dataset) support | no | **yes**
[WebR](https://docs.r-wasm.org/webr/latest/) support | no | **yes**
[crosstalk](https://rstudio.github.io/crosstalk/) support | no | **yes**
dependencies ([packrat](https://rdrr.io/cran/packrat/src/R/recursive-package-dependencies.R#sym-recursivePackageDependencies)) | 65 | 40
dependencies ([WebR](https://repo.r-wasm.org)) | 188 | 46
utilities | bezier, correlations, histogram, density, loess, flip, nesting, more | extended boxplots, tabsets, layouts, shapefiles, lotties, more

<sup>(1)</sup> We encourage users to follow the original ECharts API to construct charts with echarty.
Expand Down Expand Up @@ -115,14 +115,14 @@ ECharts**](https://echarts.apache.org/examples/en/index.html) (and
<br>
<p align="center">
<a href='https://helgasoft.github.io/echarty/gallery.html' target='_blank'>
<img src="man/figs/ssPolarStack.png" alt="Polar Stack" width="180"/>
<img src="man/figs/ssBars.gif"/>
<img src="man/figs/ssThemeRiver.png" width="180"/>
<img src="man/figs/ssBunny.gif"/> <br>
<!-- img src="man/figs/ssMorph.gif" width="180"/ -->
<img src="man/figs/ssRose.png" width="180"/>
<img src="man/figs/ssSpeed.png" width="180"/>
<img src="man/figs/ssStackBar.png" width="180"/>
<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"/>
<img src="man/figures/ssBunny.gif"/> <br>
<!-- img src="man/figures/ssMorph.gif" width="180"/ -->
<img src="man/figures/ssRose.png" width="180"/>
<img src="man/figures/ssSpeed.png" width="180"/>
<img src="man/figures/ssStackBar.png" width="180"/>
</a>
<br>Made with echarty. Powered by ECharts.
</p>
4 changes: 4 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
url: https://helgasoft.github.io/echarty/
template:
bootstrap: 5

42 changes: 26 additions & 16 deletions man/ec.util.Rd

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

File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading

0 comments on commit 6483e49

Please sign in to comment.