chengvt / MovingBubbles

Animated d3 bubble chart

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MovingBubbles : Animated d3 bubble chart

The package provides a method to add the second information dimension, which can be either qualitative or quantitative, to the bubble chart by means of animation. The plotting and transitions between frames are handled by d3 library. The package uses htmlwidgets framework to bridge Javascript and R.

Usage & Demo

The function takes in a data.frame with key, value, and frame columns. Optional data.frame with key and color (hex) can be given to specify the bubble color. The frame column will be factorized if not already and the order of factor levels will be used to run the animation sequentially. Thus, the sequence can be defined by manually setting the levels of the frame column.

library(MovingBubbles)
dat <- data.frame(alphabets = rep(letters[1:6],5),
                  time = rep(paste0(1:5, "pm"), each = 6),
                  size = round(runif(30)*100))
dat$time <- factor(dat$time, levels = rep(paste0(1:5, "pm")))
MovingBubbles(dat, key = "alphabets", frame = "time", value = "size")

demo

Installation

devtools::install_github("chengvt/MovingBubbles", dependencies = TRUE)

About

Animated d3 bubble chart


Languages

Language:HTML 98.0%Language:JavaScript 1.4%Language:R 0.5%Language:CSS 0.1%