Learn R Programming

⚠️There's a newer version (0.0.302) of this package.Take me there.

recharts

A R interface to ECharts for data visualization.

recharts 提供了百度开源可视化js框架ECharts的R语言接口,现提供的图形展示接口包括:地图(eMap),柱状图(eBar),折线图(eLine), 雷达图(eRadar),散点图(ePoints),漏斗图(eFunnel)以及万恶的饼图(ePie)。 同时计划对力导向图(eForce), 时间序列散点图(ePoints_timeSeries), 矩阵树图(eTree), 平行坐标图(eParallel) 和桑基图(eSankey)图逐一实现。

recharts的安装(Installation)

recharts包的源代码在Github/taiyun/recharts上提供下载与安装,安装需要使用以下代码:

require(devtools)
devtools::install_github('taiyun/recharts')

图形使用模块

地图(eMap)使用

地图分别提供了世界地图、美国、中国地图以及各省级行政区地图,需要使用'''region'''参数进行地图显示地区的设置。

地图的使用需要由一个data.frame作为输入,包括了一列地名和多列数值,需要使用'''~列名'''的方式进行数值传递。

library(recharts)
mapData <- data.frame(province=c("上海", "江苏", "广东", "黑龙江"), 
	val1=c(100, 200, 300, 500), val2=c(200,300,400,200), val3=c(1,2,3,5), stringsAsFactors=F)

## 全国地图
eMap(mapData, namevar=~province, datavar = ~val1+val2)

provinceMapData <- data.frame(city=c("扬州市", "南京市", "苏州市"), value=c(100, 200, 300),
                        val2=c(200,300,400), val3=c(1,2,3), stringsAsFactors=F)
## 省份地图
eMap(provinceMapData, namevar=~city, datavar = ~value+val2, region="江苏")

柱状图(eBar)使用

柱状图(eBar),允许3种原始数据输入:

  1. data.frame,需要指定'''xvar=~weekDay; yvar= ~saleNum; series=~seller''',其中series参数可选。
df2 = data.frame(
	saleNum=c(10,20,30,40,50,60,70,15,25,35,45,55,65,75,25,35,45,55,65,75,85),
	seller=c(rep("小黄",7), rep("小红",7), rep("小白",7)),
	weekDay = c(rep(c("周一","周二","周三","周四","周五","周六","周日"),3))
)
eBar(dat= df2, xvar=~weekDay, yvar=~saleNum, series=~seller)

  1. 矩阵对象,以'''WorldPhones'''为例,可以显示以行为X轴分度,列名为颜色分度,

矩阵数值为Y轴分度的柱状图。

eBar(WorldPhones)

  1. table对象或因子(factor)数组
library(recharts)
eBar(cut(rnorm(1000), -4:4))

散点(ePoints)图

散点图需要的输入是data.frame,需要指定'''xvar'''和'''yvar''', '''series'''为可选的颜色分度参数,

# 测试下中文
iris$Species <- as.character(iris$Species)
iris$Species[1:20] ="小红帽"
ePoints(iris, ~Sepal.Length, ~Sepal.Width, series = ~Species)

Copy Link

Version

Version

0.0.4

License

MIT + file LICENSE

Maintainer

Taiyun Wei

Last Published

August 26th, 2020

Functions in recharts (0.0.4)

&.echarts

Merge the two ECharts into one output .
eBar

Create an HTML bar charts widget using the ECharts(version:3.2.2) library
ePie

Create an HTML pie charts widget using the ECharts(version:3.2.2) library
eLine

Create an HTML line charts widget using the ECharts(version:3.2.2) library
convertIdx

importFrom DT convertIdx
eForce

Force network graph
ePoints

Create an HTML scatter charts widget using the ECharts(version:3.2.2) library
eArea

Create an HTML area charts widget using the ECharts(version:3.2.2) library
eFunnel

Create an HTML funnel charts widget using the ECharts(version:3.2.2) library
eMap

Create an HTML map charts widget using the ECharts(version:3.2.2) library
option

Set recharts option
optionSet

recharts set fucntion
mapInfoDf

mapInfoDf use for china map name reference.
lazyPlot

Modify the echarts object through shiny server
escapeData

importFrom DT escapeData
mapTestData_chs

mapTestData_chs use for eMap chart generation.
eTitleSet

recharts tilte Set fucntion
eTitle

Set recharts title option
eRadar

Create an HTML radar charts widget using the ECharts(version:3.2.2) library
pause

recharts demo pause function
tilteSet

recharts tilteSet fucntion
eChartOutput

Wrapper functions for Shiny
is.option

Reports whether x is a option object
+.echarts

Modify a recharts by adding on new components.
eAxis.X

Set recharts x Axis option
eDataRange

Set recharts dataRange option
echartsLayout

set multiple echarts layout
eCalculable

Set recharts drag-recaluculation option
eAxis.Y

Set recharts y Axis option
eDataZoom

Set recharts x dataZoom option
eParallel

Create an HTML parallel charts widget using the ECharts(version:3.2.2) library
eLegend

Set recharts legend option
eOption

Set recharts general option
ePolar

Set recharts polar option
eTooltip

Set recharts tooltip option
eToolbox

Set recharts toolbox option
eTheme

Set recharts theme option
eWordcloud

Create an HTML parallel charts widget using the ECharts(version:3.2.2) library
wordFreqDf_chs

wordFreqDf_chs for eWordcloud chart generation.
parallelDf

parallelDf use for eParallel chart generation.
wordFreqDf

wordFreqDf for eWordcloud chart generation.
&.echarts

Merge the two ECharts into one output .