score:8

Accepted answer

if you want a multilevel drilldown you have to set id of the drilldown to the data point just like in the pure js highcharts.

example: http://jsfiddle.net/6lxvq/2/ and the most important part:

drilldown: {
        series: [{
            id: 'animals',
            name: 'animals',
            data: [{
                name: 'cats',
                y: 4,
                drilldown: 'cats'
            }, ['dogs', 2],
                ['cows', 1],
                ['sheep', 2],
                ['pigs', 1]
            ]
        }, {

            id: 'cats',
            data: [1, 2, 3]
        }]
    }

you can see here that your data points are not only numbers but objects which containts link to the drilldown series.

an example using highcharter - simplified but you should get the idea:

hc <- highchart() %>%
    hc_chart(type="column") %>%
    hc_xaxis(type="category") %>%
    hc_add_series(
        name = "things",
        data = list(
            list(
                name = "animals",
                y = 10,
                drilldown = "animals"
            )
        )
    ) %>%

    hc_drilldown(
        series = list(
            list(
                name = "animals",
                id = "animals",
                data = list(
                    list(
                        name = "cats",
                        y = 2,
                        drilldown = "cats"
                    )
                )
             ),
             list(
                 name = "cats",
                 id = "cats",
                 data = list(list(name = "white cats", y = 2), list(name = "black cats", y = 3), list(name = "red cats",y = 4))
             )
         )
     )
hc

score:1

the important aspect about these drilldowns is the key. the key for the drilldown is [name, value, drilldown] or [name, y, drilldown] (since they're mostly column drilldowns.

df = data_frame(name = dataframe$names,
               y = dataframe$values,
               drilldown = tolower(name))

all data referenced should have the same layout (barring the last one which does not open into a new set of data). and this layout should be of the pattern of the key--names, values, and drilldown id's. drilldown id's are used as reference key's for the next step of drill downs.

there's the initial data which forms the first set of columns and has id's for the next set. the next set is the second layer and has id's for the third set in its data. the third set forms the third layer.

example: in a data set for pets, birds and amphibians: pets next layer is cats, dogs, hamsters, fish. there is also an id attached with every name in pets. cats will pull in tabby, brown, black, tom through that id. dogs will pull in bulldog, pug, lab corgi from its id's and the same with hamsters.

#layer one of drilldown
animalsdf = data_frame(name = animals$names,
               y = animals$values,
               drilldown = tolower(paste(name,'id')))

#example of drilldown id's here: 'pets id', 'birds id', 'amphibians id'

animalsds = list_parse(animalsdf)

names(animalsds) = null

#layer two of drilldown
petsdf = data_frame(name = typeofpets$names,
               y = typeofpets$values,
               drilldown = tolower(paste(name,'id')))

birdsdf = data_frame(name = typeofbirds$names,
               y = typeofbirds$values,
               drilldown = tolower(paste(name,'id')))

amphibiansdf = data_frame(name = typeofamphibians$names,
               y = typeofamphibians$values,
               drilldown = tolower(paste(name,'id')))

petsds <- second_el_to_numeric(list_parse2(petsdf))
birdsds <- second_el_to_numeric(list_parse2(birdsdf))
amphibiansds <- second_el_to_numeric(list_parse2(amphibiansdf))

#layer three of drilldown

#for pets

catsdf = data_frame(name = typeofcats$names,
               y = typeofcats$values,
               drilldown = tolower(paste(name,'id')))

dogsdf= data_frame(name = typeofdogs$names,
               y = typeofdogs$values,
               drilldown = tolower(paste(name,'id')))

hamstersdf = data_frame(name = typeofhamsters$names,
               y = typeofhamsters$values,
               drilldown = tolower(paste(name,'id')))


catsds <- second_el_to_numeric(list_parse2(catsdf))
dogsds <- second_el_to_numeric(list_parse2(dogsdf))
hamstersds <- second_el_to_numeric(list_parse2(hamstersdf))

#for birds
flightlessbirdsdf = data_frame(name = flightlessbirds$names,
               y = flightlessbirds$values,
               drilldown = tolower(paste(name,'id')))

flyingbirdsdf = data_frame(name = flyingbirds$names,
               y = flyingbirds$values,
               drilldown = tolower(paste(name,'id')))

flightlessbirdsds <- second_el_to_numeric(list_parse2(flightlessbirdsdf))
flyingbirdsds <- second_el_to_numeric(list_parse2(flyingbirdsdf))

#for amphibians

largeamphibiansdf = data_frame(name = largeamphibians$names,
               y = flyingbirds$values,
               drilldown = tolower(paste(name,'id')))

smallamphibiansdf = data_frame(name = smallamphibians$names,
               y = smallamphibians$values,
               drilldown = tolower(paste(name,'id')))

largeamphibiansds <- second_el_to_numeric(list_parse2(largeamphibiansdf))
smallamphibiansds <- second_el_to_numeric(list_parse2(smallamphibiansdf))

#highchart starts

hc <- highchart() %>%
hc_chart(type = "column") %>% 
hc_title(text = "drilldown") %>%
hc_subtitle(text = "xyz") %>%
hc_xaxis(type = "category") %>%
hc_legend(enabled = false) %>%
hc_plotoptions(
  series = list(
    boderwidth = 0,
    datalabels = list(enabled = true)
  )
) %>%
hc_add_series(
  name = "category",
  colorbypoint = true,
  data = animalsds
)  %>%
hc_drilldown(
  allowpointdrilldown = true,
  series = list(
    list(
      id = "pets id",
      data = petsds,
      keys = list('name','y','drilldown')
    ),
    list(
      id = "birds id",
      data = birdsds,
      keys = list('name','y','drilldown')
    ),
    list(
      id = "amphibians id",
      data = amphibiansds,
      keys = list('name','y','drilldown')
    ),
    list(
      id = "cats id",
      data = catsds,
    ),
    list(
      id = "dogs id",
      data = dogsds
    ),
    list(
      id = "hamsters id",
      data = hamstersds
    ),
    list(
      id = "flightless birds id",
      data = flightlessbirdsds
    ),
    list(
      id = "flying birds id",
      data = flyingbirdsid
    ),
    list(
      id = "large amphibians id",
      data = largeamphibiansds
    ),
    list(
      id = "small amphibians id",
      data = smallamphibiansds
    )
)) %>% hc_tooltip(valuedecimals = 2)

Related Query

More Query from same tag