Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/the-y-company/litecharts4r
Echarts4r with lit
https://github.com/the-y-company/litecharts4r
Last synced: 3 months ago
JSON representation
Echarts4r with lit
- Host: GitHub
- URL: https://github.com/the-y-company/litecharts4r
- Owner: the-y-company
- License: gpl-3.0
- Created: 2023-09-28T23:08:12.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2023-09-30T18:50:07.000Z (about 1 year ago)
- Last Synced: 2024-01-14T16:40:23.127Z (10 months ago)
- Language: R
- Size: 2.51 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-shiny-extensions - litecharts4r - A lite wrapper around echarts.js and echarts4r. (Visualization / General-Purpose)
- jimsghstars - the-y-company/litecharts4r - Echarts4r with lit (R)
README
# litecharts4r
A lite wrapper around [echarts.js](https://echarts.apache.org/en/index.html) and [echarts4r](https://echarts4r.john-coene.com/).
## Install
```r
# install.packages("remotes")
remotes::install_github("the-y-company/litecharts4r")
```
## ExamplesUse the lite API.
```r
litecharts4r() |>
set_title(title = "Hello world!") |>
set_x_axis(data = letters[1:20]) |>
set_y_axis() |>
add_serie(
name = "serie 1",
type = sample(c("line", "scatter"), 1),
data = runif(20)
) |>
add_serie(
name = "serie 2",
type = sample(c("line", "scatter"), 1),
data = runif(20)
)
```Use an echarts4r object.
```r
data.frame(
x = 1:10,
y1 = runif(10),
y2 = runif(10)
) |>
e_charts(x = x) |>
e_line(y1) |>
e_scatter(y2) |>
as_litecharts4r()
```## echarts4r vs. litecharts4r
The main difference with echarts4r is a more performant renderer that makes
for nicer visualisations transition, particularly using Shiny.
The latter also allows doing away with all the convoluted business of "proxies,"
making the use of the library far simpler.```r
library(shiny)
library(echarts4r)
library(litecharts4r)ui <- fluidPage(
theme = bslib::bs_theme(5L),
actionButton("render", "Render"),
div(
class = "row",
div(
class = "col-md-6",
litecharts4rOutput("lite")
),
div(
class = "col-md-6",
echarts4rOutput("ec")
)
)
)server <- function(input, output, session){
output$lite <- renderLitecharts4r({
input$render
litecharts4r() |>
set_title(title = "Hello world!") |>
set_x_axis(data = letters[1:20]) |>
set_y_axis() |>
add_serie(
name = "serie 1",
type = sample(c("line", "scatter"), 1),
data = runif(20)
) |>
add_serie(
name = "serie 2",
type = sample(c("line", "scatter"), 1),
data = runif(20)
)
})output$ec <- renderEcharts4r({
input$renderdata.frame(
x = 1:10,
y1 = runif(10),
y2 = runif(10)
) |>
e_charts(x = x) |>
e_line(y1) |>
e_scatter(y2)
})
}shinyApp(ui, server, options = list(port = 3000L))
```