
Appendix C - The Highcharter Cookbook
Creating nice looking NBA charts using the HighCharteR library
The below is a recreation and an update of the orginal HighCharter Cookbook by Tom Bishop available here: https://github.com/TMBish/MelbURN-highcharter .
Here is also another great reference, from the creator of the highcharteR library : https://jkunst.com/blog/
Overview of Highcharter
What is it?
highcharter is an R implementation of the highcharts javascript graphing API through R’s htmlwidgets. Most of the highcharts functionality is implemented through highcharter however the documentation is a little light. This guide will provide examples on how to create and customise various graphs whilst providing some tips on how to think about the package that will help you build and debug your more ambitious charts. I’ll try to show and explain (to the best of my knowledge) the most common graphs and customisation options I use in my day-to-day work. I assume you’re familiar with tidy data, dplyr, and R lists, as well as as simple understanding of the grammar of graphics (ggplot / aes()).
Highcharts is a commercial product so you can’t add these charts to a commercial product (selling to customers) without purchasing a licence but non commercial use (internal organisation / research) comes under their free license.
Your most important resources should be the highcharter official website, and the highcharts API documentation which you should bookmark in your browser:
Additionally get into styling your charts so a few extra resources you might want bookmarked:
As you become more a more proficient highcharter user and your charting requirements become more complicated you will need to understand more about the complexities of the highcharts API and you might need to learn, read and write a little javascript. This learning curve is actually the best thing about highcharter: most basic charts are as easy to create as ggplot, whilst complex and beautiful charts are still achievable with enough thought and tinkering.
Why and Why use it?
highcharter is a perfect compliment for ggplot2. Depending on your needs you it might not completely replace your use of that library, but it may. ggplot has a number of functional advantages over highcharter as it has simple implementations of reasonably complex chart types. I’d say I use highcharter for 90% of my day to day plots.
If you need to do any of the following or you’re a gun at making ggplots look presentable it’s I’d suggest using ggplot: * Semi-complicated facetting * Standard statistical layers / geoms like smooths and confidence intervals / error bars etc.
Getting the NBA data
I’ll be illustrating highcharter functionality with an NBA dataset I’ll get from the nbastatR package.
We’ll use the gamelogs (boxscores) from the most recent complete NBA season 2023-24:
Basic Charts
Tidy Data
Most (~90%) of your day-to-day charts can be probably written with 2-3 lines of code using the hchart and hcaes functions. These functions allow you to use the extremely powerful grammar of graphics to turn R data into interactive charts - functionality that isn’t implemented natively in R plotly for example. Like ggplot2 your data needs to be in tidy / long format so you’ll often need to use tidyr for some simple data pivotting before passing it to your highchart functions.
A simple ggplot of the top 10 scorers in the NBA this year might look like the following:
This chart, let’s be honest here, looks awful. Ggplot needs to do a better job of creating pleasing default charts and themes to entice beginners. Ggplot has also chosen to alphabetize the players on the x-axis even though I specifically ordered the dataframe in descending points per game order, a reasonbaly challenging workaround is needed for an R beginner. Highcharter, on the other hand, creates readable, nice looking default charts that can be presented naturally in a widely used publishing format (a html page).
Here’s the highcharter version of this plot which you’ll notice feels extremely similar to above:
This chart doesn’t look that nice, but there’s some notable format based advantages to the ggplot version:
- You can interact with it - hover over it to see a (relatively ugly) tooltip
- It’s dynamic - reduce the width of your browser window to see the chart react and replot as it tries to estimate the best way to present the data without it looking busy and cluttered
Chart Types
There are many chart types available in higcharts which you can see here however, I’ll go through simple calls for the most common chart types.
Column
Bar
Scatter
Bubble
Line
Spline
Splines have smoothed edges
Area
There is an areaspline (smoothed edges) too.
Treemap
Layering Elements
As you can see from the code for some of these charts highcharter is much like ggplot where charts are built with layers. The good thing about highchart layers is that they are layered with the pipe %>% or ‘|>’ operator rather than ggplots plus operator +. Layering is an excellent pattern for charting as chart objects can be passed further down scripts and altered / ammended by simply taking the current chart object and piping more layers onto it.
Layering Series (geoms)
Layering series onto the same chart works much like ggplot. It’s a little bet less natural as the data object must be supplied each time which prevents big long data into highcharter chains. The additional layers, added with hc_add_series() can be added with exactly the same pattern as your initial hchart() call. It’s good practice to name your series and you can specifically add them to the legend with the showInLegend option.
Series don’t have to be the same type either obviously
Understanding The API
The most important thing to learn about this package is how the relatively undocumented R functions map onto the actual highcharts javascript library. The way these htmlwidgets packages work is consuming R dataframes and R instructions and turning them into the javascript code, that when embedded into your output html page, will display the particular chart you wanted to create.
Once you understand this concept you’ll no longer be limited by the package documnetation, or Josh Kunst’s highcharter showcase website. You’ll be able to build many, many different charts with near unlimited customisation.
To illustrate how to write R highcharter code from just the javascript API documentation we’ll isolate a relatively simple component: a chart’s y axis.
A Simple Example
To customise a highcharter y axis you need to use the hc_yAxis() function. Let’s have a look at the documentation in R for that function.
There is some example customisation supplied in the examples which can be very helpful, but is still limited to a few examples.
However, it might not click with you immediately what’s required or valid as an input for the hc_yAxis() function.
- How do I know what arguments I can use for this function?
The answer is always the API documentation. Let’s check the actual highcharts API documentation for a highcharts y Axis. You can find it yourself here but a screen shot of the page looks like this:
The arguments in the green rectangle (there are more than shown) is an exhaustive list of the customisation options for a highcharts y Axis. There are nearly 50 different arguments for a y axis that will change the way your charts looks or works. You can use any of them (provided highcharter stays up to date) in your R function calls.
- These don’t look like R arguments, how do I write then into my R function?
The highcharts javascript API is expecting a JSON packet to define all y axis options. In other words: some options are single strings, some are booleans, some are numbers, but some are arrays of numbers or strings, and some are more JSON packets. Highcharter will make conversion provided you supply the options as an appropriately structured and named R list. It’s easiest to see this in an example.
Simple Arguments
Starting simply using a couple of the simple boolean chart options we can adjust the gridLineWidth to 10 which will make the major grid lines extremely thick and change the dash style to “shortdash”. We know we can enter the string “shortdash” as a possible option for the grid line dash style because when we click on that option in the API documentation it links us to another page which shows us the valid options:
Without going to this page on the documentation we’d be completely in the dark about the valid values for gridLineDashStyle were. That’s why understanding this API documentation / highcharter link is the only way to use this package.
Nested Arguments
Your most common form of axis customisation will be probably be the title and labels on the axis. Here’s the documentation for a Y axis title
Notice the dropdown icons and nested arguments. They tell us that the axis title should be defined by it’s own JSON packet within the broader y axis configuration. Further any styling you want to add to the title should be another JSON packet (we’ll get to this part next). To correctly create this JSON packet in R we use named lists.
When using the documentation all you should think is when I see a nested JSON packet with a dropdown marker / open curly braces I need to start a new R list.
It’s as simple as that. Any argument listed in the highcharts API documentation, whether it’s a simple string or number or another nested JSON packet, can be inserted into the appropriate R function call using the right syntax. Failure to name the arguments properly or nest the options appropriately won’t cause a fatal error for your chart (in most instances) the options just won’t be successfully added to the chart (this can be frustrating debugging at times tbh).
Style (CSS)
The style argument is a special case available on many highcharts components. In the documentation for y axis above, only color is listed as an option in the style section but it’s not nearly the only option.
If you’ve done a little bit more web coding you’ll know that what it’s referring to is CSS style. Any CSS property can be added to a highcharter component that has this style argument. In this case we’ll be defining the CSS properties to adjust on the chart title. A list of CSS properties can be found here.
What to watch for here is that CSS properties are often hyphenated words (like font-weight) which won’t play perfectly nicely in R lists so you should define properties in your R lists with camel case version of these property names (eg. fontWeight). As an example we’ll make the chart title bold, slightly larger and the color of the columns like so:
Chart Data
Not only are the various chart features understandable and configurable from referencing the javascript API documentation but the data itself (the mapping between R dataframe rows and columns to highcharts data structures you normally just let hchart() do on your behalf) is understandable in the same way.
Building your own nested lists to bypass the normal hchart() approach is a very useful tool to have at your disposal but is overkill for 99% of charts that can be built with a simpler approach. It is, however, helpful to understand and if you want to make highly bespoke charts you’ll probably need to understand how this works.
Columns
Let’s check the API documentation for a column graph. We’ll find the specification for each chart type under the series > sub header.
What we’re interested in is the series > column > data entry which tells us the viable formats to enter the data for a column chart:
The documentation says we can enter the data in 3 different ways:
- A simple array of numerical values
- A array of arrays with x, y value pairs
- An array of objects (JSON packets) with each object defining a single data point
Let’s try to implement the assists chart in each of these 3 ways but without the help of hchart().
Option 1: Simple Array
The first option says data can be presented as a simple array of values. When we see JSON “array” we should generally think of R lists but sometimes an R vector works too.
[1] 10.898551 10.796296 9.800000 8.962025 8.527778 8.295775 8.207317
[8] 8.111111 8.068493 8.000000
To build a highcharter chart without hchart() we need to do it in 2 steps: instantiate a highcharter plot with highchart() and then add data and chart type with hc_add_series().
So it worked, but given we only passed the chart the assist per game data series it doesn’t know what players the values correspond to. Referencing the option 1 specification above, we can add the player names to the chart in a second step by specifying axis “categories” manually:
Option 2: Array of Arrays
So this option suggests you can provide the data as an array of x, y pairs. This isn’t a perfectly natural data structure for R but we can construct a list of x, y pairs from a dataframe with the help of the list_parse2() function exported with highcharter. The reason this function has been created alongside these charting functions is exactly for this purpose. You often need to construct these specific list types if you’re building charts this way.
Hardcode List
It’s helpful to see the R code for each of these lists before we let a blackbox function build them on our behalf so we’ll repeat this pattern for the rest of these chart types. First let’s hardcode an example data series to see what the data looks like in R:
Notice that the x values (assuming these are x,y pairs) haven’t been placed on the x axis as we’d like but rather appear as the “name” of the column when you hover over it - this is called the series name.
Generate List
Instead of manually hardcoding the list in the right structure we can construct the same structure for the top 10 players using list_parse2(). This function will create a list of length equal to the rows in your dataframe with pairs of values that come from the columns:
[[1]]
[[1]][[1]]
[1] "Tyrese Haliburton"
[[1]][[2]]
[1] 10.89855
[[2]]
[[2]][[1]]
[1] "Trae Young"
[[2]][[2]]
[1] 10.7963
That’s exactly what we were looking for, let’s pass it as the value to the data argument and add the names on as categories to finish it off
Array of Objects
This is the most general and most frequently viable data specification option for a highcharts series. An array of JSON packets describing all the appropriate properties required (or possible) for the chart. In R this will be a list (array) of named lists.
Hardcode List
Again let’s harcode the named list manually to see what it looks like. We can even pass distinct column colors to illustrate that the named list configures each column independently:
To achieve this list structure we use the other list parsing function list_parse() which will do the same thing as list_parse2() but preserve the names on the list. However, we do need the appropriate names inside each point specification so the column names to match up to the graph dimensions. We must first rename the columns. Best way to understand is to inspect a couple of elements:
[[1]]
[[1]]$name
[1] "Tyrese Haliburton"
[[1]]$y
[1] 10.89855
[[2]]
[[2]]$name
[1] "Trae Young"
[[2]]$y
[1] 10.7963
Now passing as data for the series
hc_add_series_list()
So we understand the various ways we can construct the data vectors / lists that can be passed to as the data argument in hc_add_series(). The natural extension to this process is that not just the data is defined by a correctly structured named list but the entire series specification is input as a named list. That’s what hc_series_add_list() expects - a single named list defining the entire series config.
- Remember, the data, is just one component of the configuration of a series
Hardcode List
Again let’s start with the manual harcoded list first
Everything about the series (name, type, data) is defined in a named list. This gives us the most flexibility for advanced charts, but the challenge is obviously constructing this deeply nested named list in exactly the right way. Like we’ve seen the package provides as with a number of helpers to make this more feasible however it’s normally overkill for most tasks.
Generate List
Let’s try to do the same chart again.
# A tibble: 1 × 3
data name type
<list> <chr> <chr>
1 <list [10]> Assists Per Game column
So for us to use list_parse() appropriately here we need a single row which defines our series. On that row at the top level we need the series name, the series type and then a list column which contains the correctly structured list which we saw could be accomplished using the list_parse() function on the renamed dataframe. That’s what we have so now we can use list_parse() again on this dataframe to correctly structure the list and plot that series config list.
Now, you might be thinking that’s alot of work and complexity to plot this simple chart. Let’s show the power of this approach by extending this aprroach to multiple series. Notice the reasonably involved R required to build the right named list, but after that’s achieved there’s no highcharter configuration required. Hopefully this simple example will help you when you’re building your own deeply nested named lists for advanced attempts
Conclusion
Hopefully what you should understand after these examples is that highcharts on the javascript side are just giant JSON configuration objects. Even the data is nested within the series > data slot in the appropriately structured format. On the R side a set of functions and helpers enable you to create this JSON often with only 1 or 2 lines of code. Most of the time you simply pass hchart() a tidy dataframe and let it convert your data into the JSON that will be placed inside the series config. Every now and then, though, and when you need to venture into more complicated chart types (animated charts is an example) the data specification won’t be simple and easy to construct with hchart() and you’ll need to build the raw data specification list yourself. To do so you need to know how to wrangle lists, likely with purrr, but most importantly: you need to understand the structure the javascript API needs expects. Knowing that you just fiddle around with purrr functions till your output list looks exactly right.
Pre-Baked hchart() for different R classes
One of the awesome features Josh Kunst has built into highcharter is that, with some black box magic, hchart() supports charting of various standard R objects / classes out of the box.
The github page currently says this function current supports:
numeric,
histogram,
character,
density,
factors,
ts,
mts,
xts,
stl,
ohlc,
acf,
forecast,
mforecast,
ets,
igraph,
dist,
dendrogram,
survfit classes.
To see how this works lets have a look at a few examples of the functionality that i use regularly. This gamelog dataset doesn’t lend itself to some of these classes so I won’t show them all.
Histograms
I want to view histograms or density plots of numeric vectors very regularly. This is a simple one liner in highcharter
hchart() has been passed a simple numeric vector here (the points scored by players in all 19-20 NBA games), and decided that the appropriate plot is a histogram. Like other highcharts it is a highcharts object that supports the normal layering and customisation so we can add a few lines to makes the chart more readable:
Densities
Similarly if we were interested in this plot but in a density form (smoothed & proportion of total cases) we can simply pass hchart() a density object created by the base density() function
Character / Factor Counts
Like the numeric vector example supplying hchart() with a character vector or factor vector will create a plot of the value counts within the vector.
Forecast
To show a more elaborate implementation a forecast created with the forecast package is plotted automatically as follows
Correlation Matrix
Plotting a correlation matrix from a base R correlation analysis is also simple and easy. Notice the huge presentation and clutter advantage of interactivity for a chart type like this.
Components + Style
Adding the right components and style to charts is my #1 rule for data visualisation. It’s your job as the visualiser to make a chart that is clear, easy to understand, and purposeful. Too many charts are presented without labels, descriptions, units or fail to convey a clear message or conclusion and it’s a crime (not a real crime I suppose, but a chart crime). Making your chart clean and aesthetically appealing is also a hugely underated job and has huge impact on how much effort your viewer will spend trying to absorb your chart’s insight.
This is where highcharter really shines over some of it’s htmlwidget & static competitors. Highcharter is brimming with options to customise and highcharter allows natural component and option layering through the pipe operator making highcharter charts flexible and extensible.
Grids + Facetting
This is an area highcharter is genuinely much inferior to ggplot. In ggplot, facetting is natural, logical and easy. Supplmentary ggplot packages like cowplot and Thomas Pedersen’s new patchwork package enhance this process even further. Assembling a grid of highcharts split by some variable or combination of variables requires a fair bit more code. Like most things in highcharter, though, it is largely possible.
Splitting charts vertically is easy with the concept of multiple axes. Axes can be assembled with different heights / sizes to make vertical grids within charts plotting different series. You use the hc_yAxis_multiples() function instead of the single hc_yAxis() function to do this.
You can either specify the options for each yAxis with named R lists like the following. When creating the initial series or adding additional series you also need to define which axis you want to chart the data against. You do this with a y axis index, obsersving that javascript is a language where indicies start at 0.
2 Axes:
With 3 axes we need to specify the top of the axis (the % of the way down the plot area) and how tall we want the axis to be. If we want 3 equal rows then each axis should be 33% (roughly) of the plot area and their starting points should be 0% (top) 33% the way down and 66% of the way down.
However, you’ll notice some weird spacing issues on the 3rd axis, that’s due to some little fidgety stuff about the heights and sizes of each axis. The helper function create_yaxis can create these axis specifications for you with a more simple function call. You could create the same chart like:
Multiple y axes is not our only option for grids thankfully. We can simply chain together individual highcharts objects to acheive a similar goal using the hw_grid() function.
Let’s produce a similar version of this chart using that approach to see how it would work. (Note this R is a little big trickier than what we’ve seen previously. The output of this group_map is a list of highcharter charts. Check the group_map documentation if you’re confused about how this worked.)
Axes
Axes can be customised in numerous ways. Most frequently I’ll simply be changing the axis title, adding unit formatting to the axis labels, changing the plot grid lines, and sometimes removing the axis all together.
Axes Transforms
Not yet completed…
Unit Formatting
You should never leave units like this. You should always display units in the most human readable way for the data series: including adding comma seperators to large numbers, rounding, percentages etc.
To do this in highcharter you need to write a little javascript. Lickily javascript is very syntactically similar to R so it should make sense. There are two options to format labels: format and formatter. I’ll just explore formatter as it’s more flexible and what i use predominantly. Formatter is simply a javascript function that will be applied to your label object, the return of which will show up on your chart. So we simply want to multiply the 0-1 decimal by 100, round and add the percentage character on the end.
Just a few notes to make this understandable if you haven’t used javascript before:
JS()tells processes downstream that the string is literal javascript and should be interpretted as such- Brackets, function definition and return all the same as R which is handy
- You need to invoke the Math library to get the
round()function (it’s not available by default in javascript) - You get elements from within other objects (or libraries) using the dot
Math.XXX - Strings can be concatenated with the
+operator like python - The
this.XXXnotation is very pervasive javascript concept which is the current object decided by the current execution context, so in this example it would be the axis object which contains, among other things a.value
Titles
highcharts have a title and a subtitle element which you can set like following. We can style the titles like we’ve seen before:
Chart Padding and Spacing
The axis title and the chart title now look a little cramped. You can fully customise the padding and margins of highcharts chart components. Here’s a visual on how that works.

So we want to add a little more margin to the top of the chart.
Fonts
Standard Fonts
Different fonts can be added to individual sections or a new default font family can be added to all elements on the chart. Here I’ll update the font family on the chart to a google font by simply referring to it’s name:
Font choice is HUGELY underrated by most technical people. Using a nice or appropriate font can increase the aesthetic appeal of a chart by an order of magnitude with almost zero effort.
Custom / Private Fonts
Not yet complete…
Tooltip
Another slight ding for highcharter is the default tooltip is pretty awful. So I’m almost always changing the default tooltip for every chart I make. Given tooltips are one of the key advantages of web based charts I think it’s worth the effort to customise your tooltip almost every time.
This is another area where the use of the formatter is preferred so you have to write a little javascript function to define your output. We’ll discuss further down how you can be a little smarter about this and push most of the logic into your R code to minimise the amount of javascript you have to write:
So you might notice that even though we didn’t define the team name (nameTeam) as a dimension of the plot it was still accessible through the this.point.[input dataframe column] accessor in the tooltip. This is extremely handy and we’ll be able to use this to make the above tooltip easier to construct later in this document.
Plot Area
The plot area of a chart can be customised with colors, color gradients, images or even gifs.
Color can be customised in hc_chart() options:
Looks awful in this instance but that’s how we could do it. Let’s try a color gradient
Still ugly. Let’s make a slightly different lakers theme with a few more color specifications on the axis labels and titles, and a font which is closer to the lakers font:
Similarly we could add a picture as the entire background to the plot area to give the viewer an even faster recognition of what player this chart is visualising:
Lookin good.. Using the same approach would could simply look up a relevant gif and insert it’s url as the background image like follows:
Annotations
Instead of setting the entire background image to be a lebron gif or image I could utilise the annotation functionality within highcharts. You can add annotations with the specifications at this link. You can add a single annotation with hc_add_annotation or multiple with distinct lists with hc_add_annotations. Annotation can be shapes, text or image links.
or the gif we used above:
These annotations can be easily added and placed programatically (smartly in the plot area etc) rather than manually as we’ve done, and are a great tool for customising your charts.
Plot Lines and Bands
Plot lines or bands can be a great way to highlight things on the chart you want to call the users attention to. In the above Lebron James points column chart we know the big gap in the middle is explained by Lebron experiencing his first significant injury of his career in this season. We should spefically call that out to the viewer as it’s an obvious anomoly with the data shown. It makes sense to do that with a plot area in this example. We could also add his season average points to the line as a reference point for the columns
Datalabels
Data labels can easily be added to charts of all types. Highcharts data labels also have some built in smarts that prevent display when labels are too crowded. Options can be set for individual series or for all series types inside the hc_plotOptions() function. Given we’ve already added the series layer to this chart let’s just specify that all column charts should have data labels like following:
Advanced Labels
Even though highcharts has been smart enough to remove some labels where they have distinct overlap with other labels it still looks a bit busy. Maybe I just want to highlight Lebron’s highest and lowest scoring games. There’s two good ways I can do this.
JS Callbacks + Highcharts Properties
If you’re comfortable writing more involved javascript callback functions you can leverage some of the many properties of highcharts series to accomplish goals like this. I don’t do a lot of this but only because my javascript is poor. For example there is a .dataMax and a .dataMin property of a highcharts series which I could access to check whether or not this point is equal to this value and plot a label if required:
There are many other properties of series and points that you could access for more advanced tooltips or datalabels however the R side processing is a big advantage for the R highcharts user given R is so natural for this kind of structured data processing.
Glue + HTML
One great highcharter tip is using your R dplyr / glue skills to build HTML that will be parsed to highcharts to render. This will save you a lot of time and prevent you from having to write longer more involved javascript callback functions. Suppose I want to create a nice label for Lebron’s high and low scoring games including the date of the game and the opponent, I can do that using dplyr. I’ll have to go back to the starting point because I’m augmenting the chart data:
hc_dataLabel n
1 67
2 High Score 40 <i> (2023-12-23 vs OKC) </i> 1
3 High Score 40 <i> (2024-03-16 vs GSW) </i> 1
4 High Score 40 <i> (2024-03-31 vs BKN) </i> 1
5 Low Score 10 <i> (2024-01-11 vs PHX) </i> 1
Let’s rebuild the whole chart and add a reference to these strings as the labels. Now all I need to write in the callback is that I want to return the exact value of the label (hc_dataLabel) that I’ve prebaked in my dplyr chain. Notice also the slight html markup that will display the opponent team and date of game in italics.
Advanced Tooltips
The exact same approach can be used to define a more advanced tooltip specification. Let’s say I wanted to the tooltip to give more information about Lebron’s game for each of these bars.
Continuing…
Nested Charts
Not yet complete…
Dates + Datetimes
Dates and datetimes work well but require a little bit more understanding. Let’s look at the series of # of NBA games for the dates of the 23-24 season
highcharter has correctly plotted this as a date axis (the tooltip will show a day of the week for example). Highcharts finds the appropriate format for the span of the dates. Those patterns are:
second: '%H:%M:%S',
minute: '%H:%M',
hour: '%H:%M',
day: '%e. %b',
week: '%e. %b',
month: '%b \'%y',
year: '%Y'
So it looks like given our chart is about 6 months of data it has chosen the week units. We can change the default for this type by customising the unit formats in the .dateTimeLabelFormats property of the x axis
With date axes it’s also natural to add a date filter on the x axis. There are many options including the awesome navigator which I can add like this:
Notice how the axis labels are dynamic and update the format to the appropriate units if you zoom in all the way to an individual week for example.
I can also add another filter element called a rangeSelector which gives me some more dynamic filtering functionality
The last thing you might find difficult with this chart type is adding annotations or plot lines. On a date or datetime axis the value / location of a plotline needs to be converted to a unix timestamp with highcharters datetime_to_timestamp() function. Let’s add a line for christmas day games using the second method.
Packaged Themes
highcharter comes with a number of nice out of the box themes. Let’s take a look at them all:
Some gooduns in there, how bout making your own theme
Custom Themes
You can create custom themes from scratch or use one of these themes as a base and merge in some changes. I like the elementary theme and I also like circular line markers with white borders. I could create a New Orleans Pelicans theme by combining these two components, adding a new default font, and adding the Pelicans color palette. Note: creating a theme from scratch you just need the second component of the merge below.
Harder Charts / Showcase
I’ve spent a few hours attempting some more ambitious charts to show you a fraction of what’s possible with this package. The R list wrangling on a few of these charts is a little bit of a mind fuck sometimes so I wouldn’t dwell too much on that to begin with. Just have a look at the final list / dataframe structure and how it’s getting ingested by the highcharter functions. A lot of the time I’ll just repurpose the list wrangling I’ve used for other charts or from stack-overflow or from Kunsts examples / blog itself as a starting point.
Let’s start by making a custom theme that we’ll style this chart set with
Packed Bubble
# A tibble: 2 × 6
namePlayer nameTeam fg3m games fg3m_pg madeFG3M_byGame
<chr> <chr> <int> <int> <dbl> <list>
1 AJ Green Milwaukee Bucks 69 56 1.23 <list [56]>
2 Al Horford Boston Celtics 108 65 1.66 <list [65]>
Donut Tooltip
Full diclosure this isn’t my idea, I just think it’s an awesome graph. Josh Kunst’s version of this chart is located on his blog here: http://jkunst.com/blog/posts/2019-02-04-using-tooltips-in-unexpected-ways/
So for my version I’d like to plot scoring efficiency for each team as measured by True Shooting %. I’ll use a donut arrangement not to present any data dimension but to just layout the teams in a ring. The visual will be presented on hover over in the form of a tooltip located in the center of the donut. Let’s roll
To be added….
…
References/Sources/Citations:
Bishop, Tom. (2020). A cookbook for we based data visualisations with R + Highcharter on June 30, 2020. Available at: https://github.com/TMBish/MelbURN-highcharter (Accessed: 9 February 2025).
Kunst, Joshua (2020). Data, Code and Visualization Blog, 2020. Available at: https://github.com/jbkunst/blog (Accessed: 9 February 2025)