Embedding Interactive Charts Generated with ECharts Library into Shiny Applications

Embed interactive charts to their Shiny applications. These charts will be generated by ECharts library developed by Baidu (< http://echarts.baidu.com/>). Current version supports line chart, bar chart, pie chart, scatter plot, gauge, word cloud, radar chart, tree map, and heat map.


CRAN Status Badge

Drawing

Drawing

As an R package, ECharts2Shiny can help embed the interactive charts plotted by ECharts library into our Shiny application. Currently, we can support

  • Pie charts
  • Line charts
  • Bar charts
  • Scatter plots
  • Radar chart
  • Gauge
  • Word Cloud
  • Tree Map
  • Heat Map

Contents

How to Install

From CRAN,

install.packages("ECharts2Shiny")

For the latest development version, please install from GitHub

library(devtools)
install_github("XD-DENG/ECharts2Shiny")

Examples

library(shiny)
library(ECharts2Shiny)
 
# Prepare sample data for plotting --------------------------
dat <- data.frame(c(1, 2, 3),
                  c(2, 4, 6))
names(dat) <- c("Type-A", "Type-B")
row.names(dat) <- c("Time-1", "Time-2", "Time-3")
 
# Server function -------------------------------------------
server <- function(input, output) {
  # Call functions from ECharts2Shiny to render charts
  renderBarChart(div_id = "test", grid_left = '1%', direction = "vertical",
                 data = dat)
}
 
# UI layout -------------------------------------------------
ui <- fluidPage(
  # We MUST load the ECharts javascript library in advance
  loadEChartsLibrary(),
  
  tags$div(id="test", style="width:50%;height:400px;"),
  deliverChart(div_id = "test")
)
 
# Run the application --------------------------------------
shinyApp(ui = ui, server = server)

Drawing

(For more examples, please refer to the /examples folder)

List of Examples

License

ECharts2Shiny package itself is under GPL-2.

The ECharts JS library is under BSD license (ECharts).

ECharts2Shiny包

CRAN Status Badge

Drawing

Drawing

ECharts2Shiny作为一个R包,可以帮助在Shiny应用程序中插入由ECharts库绘出的交互图形。当前支持的图形包括

  • 饼图 (pie chart)
  • 折线图 (line chart)
  • 柱形图 (bar chart)
  • 散点图 (scatter chart)
  • 雷达图 (radar chart)
  • 仪表盘 (gauge)
  • 词云 (word cloud)
  • 矩形树图 (Tree Map)
  • 热力图 (heat map)

目录

安装

CRAN版本

install.packages("ECharts2Shiny")

由GitHub安装最新开发版本

library(devtools)
install_github("XD-DENG/ECharts2Shiny")

例子

library(shiny)
library(ECharts2Shiny)
 
# Prepare sample data for plotting --------------------------
dat <- data.frame(c(1, 2, 3),
                  c(2, 4, 6))
names(dat) <- c("Type-A", "Type-B")
row.names(dat) <- c("Time-1", "Time-2", "Time-3")
 
# Server function -------------------------------------------
server <- function(input, output) {
  # Call functions from ECharts2Shiny to render charts
  renderBarChart(div_id = "test", grid_left = '1%', direction = "vertical",
                 data = dat)
}
 
# UI layout -------------------------------------------------
ui <- fluidPage(
  # We MUST load the ECharts javascript library in advance
  loadEChartsLibrary(),
  
  tags$div(id="test", style="width:50%;height:400px;"),
  deliverChart(div_id = "test")
)
 
# Run the application --------------------------------------
shinyApp(ui = ui, server = server)

Drawing

(请参考/examples 文件夹以获得更多实例信息)

实例列表

许可证

ECharts2Shiny 包使用GLP-2许可证。

The ECharts JS库使用BSD许可证(ECharts)。

News


Version 0.2.13

  • Word cloud doesn't work if the vector/dataframe contains \n. Replace \n with space.

Version 0.2.12

  • Add "grid to container distance adjustment" feature for Line Chart, Heat Map, and Scatter. In previous version, only Bar Chart supports this feature.

Version 0.2.10

  • Upgrade ECharts Javascript file. This also helped fix the bug of word cloud raised in GitHub issue #46
  • Added the themes contributed by Janet Wagner
  • Removed some unnecessary tedious codes
  • Fix the issues arose due to the JS file upgrade (data input must be with row names and column names)

Version 0.2.8

  • New feature added: for bar chart, pie chart and word cloud, users can add hyperlinks to each part of the chart. For example, if there are 3 elements in the word cloud, users can specify a hyperlink(URL like http://***.com) for each element.

Version 0.2.5

  • Users can sepcify axis names for line chart, bar chart, and scatter plot now.

Version 0.2.4

  • Added Tree Map charts

Version 0.2.3

  • Refined the built-in HELP documents

  • Charts are able to adjust according to the browser window resize, automatically

  • Users can specify the maximum bar width in Bar charts.


Version 0.2.0

  • Added STACK line plot;

  • Added STACK bar plot.

  • For bar chart, added one more option about "stack" or "tiled", so that end-users can choose and change between "stack" and "tiled" in the final interactive charts;

  • Added options to determine if we show legends or not, and if we show tool bar or not.

  • Added Scatter plots (including the auto.scale argument for it).

  • We use includeScript() function to help include JS files into the apps, so that we no longer need to explicitly build a "www" folder and copy the JS scripts into the users' Shiny apps. This is a quite big progress for this pacakge.

  • Figured out the reactive data issue. Previously, if we use reactive() function to introduce some data and use it to plot with this package, we will encounter scope error. But now we can use reactive data seamlessly (by making use of isolate() function in our functions). This is a big progress too.

  • Additiaonlly, regarding the reactive data, we solved the issue in which the chart can't respond to the change in the reactive data. That is, we can use input$ to change the reactive data, but the chart will not be updated accordingly automatically. Fortunately, we found that this issue can be perfectly solved by using the chart rendering function together with the observeEvent() function.

  • Added Radar charts feature.

  • Added wordcloud feature using the extension publised by ECharts team recently.

  • Added point.size, point.type, line.width and line.type arguments for line charts;

  • Added point.size and point.type argument for scatter plots;

  • Added Step Line Chart. Users can use it by specifying step in line chart functioon.

  • Figured out the conflict between word cloud and other charts. Now we can use all kinds of charts in one application (previously, the word cloud can't be used together other charts)

  • Compressed ECharts library file. Also merged the main JS library with the word cloud extension file, so that users don't need to load extension JS file separately for word cloud.

  • Line Charts, Bar Charts and Scatter Plots can deal with NA values now.

  • Added font.size.legend argument for all charts with legend bar applicable, to help users better customize the legend bar.

  • Added arguments font.size.axis.x, font.size.axis.y, rotate.axis.x, and rotate.axis.y for line charts, bar charts, and scatter plots. These arguments can help users better customize the charts.

  • Added Heat Map function.

  • Added show.label argument for pie charts.

  • With animation argument, users can decide if they want to display the charts with animation (not available for word cloud or heat map)

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("ECharts2Shiny")

0.2.13 by Xiaodong Deng, 2 months ago


https://github.com/XD-DENG/ECharts2Shiny


Report a bug at https://github.com/XD-DENG/ECharts2Shiny/issues


Browse source code at https://github.com/cran/ECharts2Shiny


Authors: Xiaodong Deng [aut, cre], Hao Zhu [ctr], Yiheng Li [ctr], Janet Wagner [ctr], ChinYong Lim [ctr]


Documentation:   PDF Manual  


GPL-2 license


Imports shiny, jsonlite

Suggests knitr, rmarkdown


See at CRAN