Highcharts : R User Day

Sam Hunter - NRS

This presentation on Highcharts

A bit of background information to raise awareness and share our learning from using Highcharts in publications.

  • What is it?

  • Why use it?

  • Where has it been used?

  • What have we learned?

  • What are we working on?

Reproducibility

Source code for producing these slides is available on github.

Contact me: sam.hunter@nrscotland.gov.uk

Highcharts

Highcharts

What is it?

  • Highcharts is a software library for data visualisation, written in pure JavaScript.

  • It is free for personal/non-commercial uses and paid for commercial applications.

  • The Scottish Government and NRS have licenses for publications.

Highcharts

Why use it to make charts with?

  • Meant for HTML. To be viewed in a browser.

  • Lightweight. Charts are rendered in the page by the browser as vector graphics.

  • Interactive/ reactive. Charts change based on user interaction.

  • Accessibility. Works with screen readers, charts can be sonified for visually impaired.

  • Customisation. Fine control over features; Colours, Fonts, Patterns, Download images/ data.

R to HTML and JavaScript

But this is the R User Day… Why are you telling me about JS?

  • Works great embedded in HTML from R markdown and R Shiny.

  • The R package highcharter enables building charts entirely in R.

  • We don’t need to know any JS to go from data to visualisation and still get all the benefits.

Publications

Well if it’s so good, where have highcharts been used in publications?

What have we learned about producing highcharts?

Straightforward to build and edit

  • Similar syntax to ggplot.

  • Good documentation, resources and demos.

  • A little JavaScript goes a long way.

  • Great with RAPs for reports and publications.

What Highcharts features have we used?

Line charts with tooltips

Bar charts with annotation

Choropleth Maps

Requires some geography files in geojson format

Two Chart Types with Flipped Axis

Horizontal axis is positive in both directions.

What’s next?

What other Highcharts features are we learning to use?

Sonification

Sonification doesn’t work inside this slideshow but does in standalone HTML knitted from R markdown.

SONIFICATION DEMO

Pros and Cons

Pros

  • Powerful for web based content.

  • Interactive by default.

  • Easy to get started.

  • Accessibility features.

  • Charts resize well.

  • Looks professional.

Cons

  • Paid license for publishing.

  • JavaScript.

  • Endless options.

  • Adding sonification isn’t straightforward.

  • Hard to master.

Alternatives

ggplot + wrappers

ggplotly / ggigraph

Pros

builds off ggplot, easy to add on to existing code. FREE!

Cons

Not so flexible, ggigraph isn’t popular, small feature set for interactivity.

How do I get started?

Resources

Start with the…

Good documentation, resources and demos.

Further reading in the R Users’ sharepoint docs

Join the Community

  • Join the RAP Yammer group

  • Request to join the Teams “Highcharter Users Group - Org - NRS” here.

Reproducibility

Code for producing these slides is available on github.

Contact me: sam.hunter@nrscotland.gov.uk

Any Questions?