First, you should load recharts:

library(recharts)

1 Introduction

Radar charts are based on Polar Coordinate System, which calls for center and radius. When you generate an Echarts object of radar chart using echartr, you can then modify the axes by setPolar.

2 Function Call

All the function names have two forms: small camel and lowercase_underscore (endorsed by Hadley Wickham).

setPolar(chart, polarIndex = NULL, center = c("50%", "50%"),
  radius = "90%", startAngle = 90, splitNumber = 5, boundaryGap = c(0,
  0), scale = FALSE, axisLine = NULL, axisLabel = NULL,
  splitLine = NULL, splitArea = NULL, type = c("polygon", "circle"),
  indicator = NULL, axisName = NULL, ...)
  
set_polar(chart, polarIndex = NULL, center = c("50%", "50%"),
  radius = "90%", startAngle = 90, splitNumber = 5, boundaryGap = c(0,
  0), scale = FALSE, axisLine = NULL, axisLabel = NULL,
  splitLine = NULL, splitArea = NULL, type = c("polygon", "circle"),
  indicator = NULL, axisName = NULL, ...)
Arg Requirement

chart

Echarts object generated by echartR or echart.

PolarIndex

Integer vector. The index of the polar systems you want to set. Default NULL.

center

Vector of the x, y position of the polar center. Could be numeric or character (percent form) vectors of length 2. Default c(‘50%’, ‘50%’).

radius

The radius of the polar system, could be numeric or character (percent form). Default ‘75%’.

startAngle

Numeric (-180 ~ 180). The start angle. Default 90.

splitNumber

Numeric. The number of sections to divide. Default 5.

boundaryGap

Numeric vector of length 2. The gapping policy of the axis. Default c(0, 0).

scale

Logical. Whether to ignore zero and zoom toward the range of _min and _max.

axisLine

List. Axis line styles. You can set its show, onZero, lineStyle features. Default list(show=TRUE).

axisLabel

List. Axis label styles. You can set its show, rotate, margin, clickable, formatter, textStyle features. Default list(show=FALSE).

splitLine

List. Split line styles. You can set its show, lineStyle features. Default list(show=TRUE).

splitArea

List. Split area styles. You can set its show, onGap, areaStyle features. Default list(show=TRUE).

type

Character, ‘polygon’ or ‘circle’. The type of the polar shape. Default ‘polygon’..

indicator

List. The radar indicator and labels. The basic structure is list(list(text='...', min=..., max=..., axisLabel=list(...)), list(text='...', min=..., max=...), list(...), ...). Default is empty.

axisName

List. The name of the axis. You can set its show, formatter, textStyle features. Default list(show=TRUE, formatter=NULL, textStyle= list(color='#333')).

Elipsis.

3 Showcase

3.1 Data Preparation

Let’s use mtcars to generate an Echarts objects g:

require(data.table)
## Loading required package: data.table
cars = mtcars[c('Merc 450SE','Merc 450SL','Merc 450SLC'),
              c('mpg','disp','hp','qsec','wt','drat')]
cars$model <- rownames(cars)
cars <- data.table::melt(cars, id.vars='model')
names(cars) <- c('model', 'indicator', 'Parameter')
g <- echartr(cars, indicator, Parameter, facet=model, type='radar') %>%
        setTitle('Merc 450SE  vs  450SL  vs  450SLC')

3.2 Modification

You can change the three radars one by one using setPolar.

g %>% setPolar(1, center=c('20%', '50%'), radius='30%', splitNumber=10) %>%
      setPolar(2, center=c('50%', '50%'), radius='35%', type='circle') %>%
      setPolar(3, center=c('80%', '50%'), radius='30%', 
            splitArea=list(show=FALSE), axisLabel=list(show=TRUE))

Or change all of the radars at one time.

g %>% setPolar(splitNumber=10, type='circle', splitArea=list(
              areaStyle=areaStyle(color=c('white', 'lightblue'))))