Create

The dimple library supports most of the common chart types.

You can create an interactive plot making use of the dimple library using the dPlot() function. We will go through some basic chart types and adjust the parameters only minimally. dimple is capable of much more with opportunity for customization through chart parameters and d3 manipulation. For a more thorough documentation of the API, see API docs. For more examples, see Dimple gallery.

Argument Type Description
x formula or string formula y ~ x or string x = “” or x=c(“”,””,..) with column names from the data frame
y string or strings y = “” or y = c(“”,””,...) with column names from the data frame
data data frame A data frame containing the data to be plotted
type string The type of chart to plot “line” , “bubble” , “bar” , “area”
z (optional) string z = “” with column names from the data frame
groups (optional) string or strings groups = “” or groups = c(“”,””,...)

Scatter/bubble Chart

#rownames in data.frames are not provided with toJSON
#add names as a column
mtcars.df <- data.frame( car = rownames(mtcars), mtcars )
p1 <- dPlot(mpg ~ wt, groups = c("car","cyl"), data = mtcars.df, type = 'bubble')
#by default dimple rCharts will assign x as a categorical/discrete axis
# and y as a measure/continuous axis
# easily changed as shown in the next step
p1$xAxis( type = "addMeasureAxis" )
p1
Edit

Standalone

Bar Chart

hair_eye = as.data.frame(HairEyeColor)
p2 <- dPlot(Freq ~ Hair, groups = 'Eye',
  data = subset(hair_eye, Sex == "Female"),
  type = 'bar'
)
p2$defaultColors(c('brown', 'blue', '#594c26', 'green'))
p2
Edit

Standalone

Bar Horizontal Chart

Edit

Standalone

Line Chart

data(economics, package = 'ggplot2')
#dimple supports a time axis
#for that we need dimple in a d3 date format
economics$date <- format(economics$date, "%Y-%m-%d")
p6 <- dPlot(uempmed ~ date, data = economics, type = 'line')
#here is how we tell dimple the input and output format of the date
p6$xAxis(
  type = "addTimeAxis",
  inputFormat = "%Y-%m-%d",
  outputFormat = "%b %Y"
)
p6
Edit

Standalone

Area Chart

dat <- data.frame(
  t = rep(0:23, each = 4),
  var = rep(LETTERS[1:4], 4),
  val = round(runif(4*24,0,50))
)
p8 <- dPlot(val ~ t, groups =  'var', data = dat,
 type = 'area'
)
p8
Edit

Standalone

Pie and Donut Charts (not yet supported)

Pie and donut charts are not currently provided in dimple (see issue) .