The dimple
package is a light htmlwidgets wrapper around the dimple javascript chart library (which is itself a wrapper around d3.js).
The dimple
package is currently only available by installing from GitHub.
devtools::install_github("Bart6114/dimple")
There is an example dataset sales
available in the package that is used to generate the below examples.
library(dimple)
head(sales[,1:5])
## Date Month Channel Owner Brand
## 1 01/01/2011 Jan-11 Hypermarkets Aperture Delta
## 2 01/01/2011 Jan-11 Hypermarkets Aperture Eta
## 3 01/01/2011 Jan-11 Hypermarkets Aperture Omicron
## 4 01/01/2011 Jan-11 Hypermarkets Aperture Omicron
## 5 01/01/2011 Jan-11 Hypermarkets Aperture Omicron
## 6 01/01/2011 Jan-11 Hypermarkets Aperture Omicron
dimple(sales,
xCategory="Month",
xOrderRule="Date",
yMeasure="Unit.Sales")
dimple(sales,
xCategory="Month",
xOrderRule="Date",
yMeasure="Unit.Sales",
series="Channel")
dimple(sales,
xCategory="Month",
xOrderRule="Date",
yPct="Unit.Sales",
series="Channel")
dimple(sales,
xCategory=c("Price.Tier", "Channel"),
yMeasure="Unit.Sales")
dimple(sales,
xCategory=c("Price.Tier", "Channel"),
yMeasure="Unit.Sales",
series="Owner",
legend=TRUE)
dimple(sales,
xCategory=c("Price.Tier", "Channel"),
yPct="Unit.Sales",
series="Owner",
legend=TRUE)
dimple(sales,
yCategory="Month",
yOrderRule="Date",
xMeasure="Unit.Sales")
dimple(sales,
yCategory="Month",
yOrderRule="Date",
xMeasure="Unit.Sales",
series="Channel")
dimple(sales,
yCategory="Month",
yOrderRule="Date",
xPct="Unit.Sales",
series="Channel")
dimple(sales,
xCategory=c("Channel", "Price.Tier"),
yCategory="Owner",
series="Price.Tier",
legend=TRUE)
dimple(sales,
xMeasure="Unit.Sales",
yCategory="Month",
yOrderRule="Date",
series="Channel",
stacked = FALSE,
legend=TRUE)
partial_data <-
subset(sales, Month == "Dec-11")
dimple(partial_data,
xMeasure="Price.Monthly.Change",
yMeasure="Distribution.Monthly.Change",
yOrderRule="Date",
series=c("SKU","Channel"),
stacked = FALSE,
legend=TRUE)
dimple(sales,
pMeasure="Unit.Sales",
series="Owner",
legend=TRUE,
chartType="pie")
dimple(sales,
xCategory="Price.Tier",
yCategory="Pack.Size",
pMeasure="Unit.Sales",
series="Owner",
legend=TRUE,
chartType="pie",
piesRadius = 25)
partial_data <-
subset(sales, Date == "01/12/2012")
dimple(partial_data,
xMeasure="Price.Monthly.Change",
yMeasure="Unit.Sales.Monthly.Change",
pMeasure="Operating.Profit",
series=c("Owner","Channel"),
legend=TRUE,
chartType="pie",
piesRadius = 20)
partial_data <-
subset(sales, Date == "01/12/2012")
dimple(partial_data,
xMeasure="Unit.Sales",
yMeasure="Operating.Profit",
series=c("SKU","Channel"),
legend=TRUE,
chartType="bubble")
dimple(sales,
xCategory="Month",
xOrderRule = "Date",
yMeasure="Unit.Sales",
series="Channel",
legend=TRUE,
chartType="bubble")
partial_data <-
subset(sales, Date == "01/12/2012")
dimple(partial_data,
xMeasure="Unit.Sales.Monthly.Change",
yMeasure="Price.Monthly.Change",
zMeasure="Operating.Profit",
series=c("SKU","Channel"),
legend=TRUE,
chartType="bubble")
dimple(sales,
xCategory=c("Channel","Price.Tier"),
yCategory="Owner",
zMeasure="Distribution",
series="Price.Tier",
legend=TRUE,
chartType="bubble",
seriesAggregate = "max",
zOverrideMax = 200)
dimple(sales,
xCategory="Month",
xOrderRule = "Date",
yMeasure="Unit.Sales",
chartType="area")
partial_data <-
subset(sales, Owner %in% c("Aperture","Black Mesa"))
dimple(partial_data,
xCategory="Month",
xOrderRule = "Date",
yMeasure="Unit.Sales",
series="Channel",
chartType="area",
legend=TRUE)
partial_data <-
subset(sales, Owner %in% c("Aperture","Black Mesa"))
dimple(partial_data,
xCategory="Month",
xOrderRule = "Date",
yPct="Unit.Sales",
series="Channel",
chartType="area",
legend=TRUE)
partial_data <-
subset(sales, Owner %in% c("Aperture","Black Mesa"))
dimple(partial_data,
xCategory=c("Owner","Month"),
xOrderRule = "Date",
yMeasure="Unit.Sales",
series="SKU",
chartType="area",
legend=TRUE,
legendX=430,
legendY=20,
legendWidth=100,
legendHeight=300,
legendHorizontalAlign = "left",
boundsX=70,
boundsY=30,
boundsWidth=340,
boundsHeight=330,
seriesLineWeight = 1,
seriesBarGap = 0.05)
partial_data <-
subset(sales, Owner %in% c("Aperture", "Black Mesa"))
dimple(sales,
xCategory="Month",
xOrderRule = "Date",
yMeasure="Unit.Sales",
chartType="line")
partial_data <-
subset(sales, Owner %in% c("Aperture", "Black Mesa"))
dimple(partial_data,
xCategory="Month",
xOrderRule = "Date",
yMeasure="Unit.Sales",
series="Channel",
chartType="line")
partial_data <-
subset(sales, Owner %in% c("Aperture", "Black Mesa"))
dimple(partial_data,
xCategory=c("Owner", "Month"),
xGroupOrderRule = "Date",
yMeasure="Unit.Sales", series="Owner",
chartType="line")
dimple(sales,
pMeasure="Unit.Sales",
series="Owner",
legend=TRUE,
chartType="pie",
ringInnerRadius="50%")
dimple(sales,
xCategory=c("Price.Tier","Channel"),
yMeasure="Unit.Sales",
pMeasure="Unit.Sales",
series="Pack.Size",
legend=TRUE,
chartType="pie",
ringInnerRadius=20,
ringOuterRadius=30)
partial_data <-
subset(sales, Owner %in% c("Aperture", "Black Mesa"))
dimple(partial_data,
xCategory="Month",
yMeasure="Unit.Sales",
xOrderRule="Date",
chartType="step")
partial_data <-
subset(sales, Owner %in% c("Aperture", "Black Mesa"))
dimple(partial_data,
xCategory="Month",
yMeasure="Unit.Sales",
xOrderRule="Date",
chartType="step",
series="Channel",
legend=TRUE)
partial_data <-
subset(sales, Owner %in% c("Aperture", "Black Mesa"))
dimple(partial_data,
xCategory=c("Owner", "Month"),
yMeasure="Unit.Sales",
xOrderRule="Date",
chartType="step",
series="Owner",
legend=TRUE,
seriesBarGap = 0.05)
partial_data <-
subset(sales, Owner %in% c("Aperture", "Black Mesa"))
dimple(partial_data,
xCategory="Month",
yMeasure="Unit.Sales",
xOrderRule="Date",
chartType="steparea")
partial_data <-
subset(sales, Owner %in% c("Aperture", "Black Mesa"))
dimple(partial_data,
xCategory="Month",
yMeasure="Unit.Sales",
xOrderRule="Date",
chartType="steparea",
series="Channel",
seriesLineWeight = 1,
legend=TRUE)
partial_data <-
subset(sales, Owner %in% c("Aperture", "Black Mesa"))
dimple(partial_data,
xPct="Unit.Sales",
yCategory="Month",
yOrderRule="Date",
chartType="steparea",
series="Channel",
seriesLineWeight = 1,
legend=TRUE)
You can also use dimple
charts in shiny
. There is an example included in the package. Simply run dimple_shiny()
. Below you can see the content of the function.
dimple_shiny
## function(){
## server <- function(input, output) {
## output$dimple <- renderdimple({
## dimple(sales,
## xCategory="Month",
## xOrderRule="Date",
## yMeasure=input$yvar)
## })
##
##
## }
##
## ui <- fluidPage(
## sidebarLayout(
## sidebarPanel(
## selectInput("yvar", "measurement variable", choices = c("Cost.of.Sales",
## "Cost.of.Sales.Monthly.Change",
## "Operating.Profit.Monthly.Change",
## "Price.Monthly.Change"))
## ),
## mainPanel(dimpleOutput("dimple"))
## )
## )
##
## shinyApp(ui = ui, server = server)
## }
## <environment: namespace:dimple>