score:8
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)
Source: stackoverflow.com
Related Query
- How to make 3 levels drilldown plot in R highcharter (possible other packages)
- How to change the palette colors of a highcharter column plot which depends on a variable?
- Highcharts - How to make a scatter plot with multiple series from HTML table
- In Highcharts, how to make box plot outliers transition from light to dark colors?
- How to create a highcharts dot plot graph? - R Highcharter
- Highcharts how to make legends as data labels on scatter plot
- Highcharts how to make a set number of colors for pie chart data and drilldown data
- How to make a HighCharts drilldown column/bar chart that does not hide the non-drilldown categories
- How to make scrollable plot area fill all chart's background area in highcharts?
- How to plot Highcharter arearange from matrix
- highcharter: how do I make a grouped plot using the hcaes function
- How to make this code more simple or shorten?
- How to make an irregularly scaled x-Axis and plot to both sides of it using Highcharts/Highstock
- HighCharts how to make drilldown label show on mobile view?
- How do I make highcharter use colorIndex number from tidy dataframe
- How to plot Highcharter side by side in RStudio Viewer?
- How to drilldown multi-series spline charts multiple levels in HighCharts
- How to make highcharts default to 0 for missing data
- Drilldown multiple levels Highchart
- How to make highcharts scrollable horizontally when having big range in x-axis
- Drilldown in highmaps - how to remove a series
- bootstrap data-toggle="tab" - how to make a tab active with a JS call
- r - How to set xlim and ylim range in a highcharter plot?
- How to make stacked column graph to show total data value on top
- How to show plot lines in the legend in Highcharts?
- Optimize JavaScript DrillDown code
- How to convert datetime string to UTC to plot points on Highcharts
- How to convert datetime string to UTC to plot points on Highcharts
- Highcharts : Chart with drilldown how to obtain click event of drill up button
- how to make highcharts pie datalabels always in center of each slice?
More Query from same tag
- Highstocks - Display year when hovering over a point
- Area Chart with overlapping series in highcharts, overlap point behaving strangely
- Highcharts bubble graph, custom marker
- Strange behavior Highcharts pie chart in document mode IE8
- How to create overlapping bar charts in angular js?
- Highcharts Tick Positions are not aligned on multiple Y-axises
- Highmaps min and max zoom level
- Highcharts show loading icon when fetching data in javascript
- How can I render full chart using PhantomJS?
- Highcharts Density Dot Map Support?
- can you have more than one ajax?
- How to remove a series in Highcharts by name
- tool that shows javascript errors in code
- How do I setup Individual Column color for each Column (HighStock/HighChart)
- Highcharts allowDecimals condition
- Highcharts polar spider with multiple y-axis scale
- R Highcharter: dynamic drilldown in Shiny on the fly
- highcharts, Set minimum height for stacked column chart?
- Highcharts - Issue with the chart reflow function
- How to place dataLabels on series point in Highcharts
- HighChart Data label issue in bar chart
- Create a Highcharts Pie Chart Legend Inside a Table
- Highcharts Map bubble on Pacific Centered World map
- Issues using highcharts node export server from ClojureScript - "0x03 error when performing chart generation"
- Wrong alignment in highcharts datetime points with xaxis
- highchart Dynamically updated data
- Highcharts - drill down to multiple series in R
- Chart using highcharts and Json asp.net MVC
- How to make highcharts scrollable horizontally when having big range in x-axis
- Highcharts - Stockchart Zoom position without Navigator