hc_drilldown: Drilldown options for higcharts objects

Description Usage Arguments Examples

Description

Options for drill down, the concept of inspecting increasingly high resolution data through clicking on chart items like columns or pie slices.

Usage

1

Arguments

hc

A highchart htmlwidget object.

...

Arguments defined in http://api.highcharts.com/highcharts#drilldown.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
library("dplyr")
library("purrr")

df <- data_frame(
  name = c("Animals", "Fruits", "Cars"),
  y = c(5, 2, 4),
  drilldown = tolower(name)
)

df

ds <- list_parse(df)
names(ds) <- NULL
str(ds)

hc <- highchart() %>% 
  hc_chart(type = "column") %>% 
  hc_title(text = "Basic drilldown") %>% 
  hc_xAxis(type = "category") %>% 
  hc_legend(enabled = FALSE) %>% 
  hc_plotOptions(
    series = list(
      boderWidth = 0,
      dataLabels = list(enabled = TRUE)
    )
  ) %>% 
  hc_add_series(
    name = "Things",
    colorByPoint = TRUE,
    data = ds
  )

dfan <- data_frame(
  name = c("Cats", "Dogs", "Cows", "Sheep", "Pigs"),
  value = c(4, 3, 1, 2, 1)
)

dffru <- data_frame(
  name = c("Apple", "Organes"),
  value = c(4, 2)
)

dfcar <- data_frame(
  name = c("Toyota", "Opel", "Volkswage"),
  value = c(4, 2, 2) 
)

second_el_to_numeric <- function(ls){
  
  map(ls, function(x){
    x[[2]] <- as.numeric(x[[2]])
    x
  })
  
}

dsan <- second_el_to_numeric(list_parse2(dfan))

dsfru <- second_el_to_numeric(list_parse2(dffru))

dscar <- second_el_to_numeric(list_parse2(dfcar))


hc <- hc %>% 
  hc_drilldown(
    allowPointDrilldown = TRUE,
    series = list(
      list(
        id = "animals",
        data = dsan
      ),
      list(
        id = "fruits",
        data = dsfru
      ),
      list(
        id = "cars",
        data = dscar
      )
    )
  )

hc


Search within the highcharter package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.