OpenprescribingR Plots UpdatedOpenprescribing R
I’ve been looking back at HTML widgets again this week, having learnt a little more recently about the underline technologies, both D3 and R.
I’d originally just ggiraph as a way to add tooltips, but coming back to it with a new set of experiences allowed me to understand more about how you can use it to apply CSS changes, trigger JS code, and even work server-side as part of a Shiny application.
Unfortunately it doesn’t quite support geom_sf, so my plots aren’t exact copies. But it was helpful as a tool to experiment a little more with voronoi plots. I got a little creative with it, plotting geom_point_interactive with tooltips over the top of lines for example. Or voronoi polygons to create a catchment area around a point, an idea I got from this excellent block.
A few difficulties/limitations I’ve noticed;
- Geom_line_interactive only allows one tooltip per line (perfect for naming it, but I was hoping to note a range of values as you moved along the axis). -Geom objects can’t work together conventionally, i.e polygon with ID 7 can’t trigger CSS changes in point with same ID. Although some creative JS triggers can create the same effect.
CCGs plotted as geom_polygon_interactive with CCG names as tooltips
CCGs with prescribing centres overlaid as points
CCGs with fill colour scaled according to cost per person on ‘BNF Section 7.4.5’ Drugs, May 2017
Prescribing centres plotted as points, used to generate voronoi polygons plotted as geom_polygon_interactive, with prescribing centre names as tooltips
Prescribing centres in NHS West Kent CCG plotted as points, used to generate voronoi polygons within the CCG.
I did also make a voronoi plot using the centre of each CCG, just to see what it would look like. But It’s not an appropriate way to visualise CCG data, bearing in mind the difficulties of using voronoi plots. For example, each of the CCGs around Hull. See the map.
Now that I’m happier working in D3, I’ll consider creating my own widgets at some point.
Next: 'NHS Hackday'
Prev: 'Drug Selections'