Interactive Crosstalk elements can be added to Leaflet visualisations too, though not with the Postcode shapes from earlier but with the labels of each Postcode.
In this visualisation, once again achieved with a relatively small amount of code, two sliders are used to select Postcodes based on SEIFA Index of Education and Occupation and also Private Health Cover Percentage.
What interesting correlations can you find?
pc_sf$long <- st_coordinates(st_centroid(pc_sf$geometry))[,"X"]
pc_sf$lat <- st_coordinates(st_centroid(pc_sf$geometry))[,"Y"]
pc_v2_shared <- SharedData$new(pc_sf)
bscols(
widths=c(6,6,12),
filter_slider("ieo_percentile", "SEIFA Index of Education and Occupation", pc_v2_shared, column=~ieo_percentile, step=1, width = "100%"),
filter_slider("PrivateHealth_percentpp", "Private Health Cover Percentage per Postcode", pc_v2_shared, column=~PrivateHealth_percentpp, step=1, width = "100%"),
leaflet(pc_v2_shared) %>%
addPolygons(color="black",weight=0.3, smoothFactor=0.2, fillOpacity=0.5, fillColor="lightgrey", highlightOptions = highlightOptions(color="royalblue",weight=1)) %>%
addProviderTiles(providers$CartoDB.Voyager) %>%
addCircleMarkers(~long,~lat, label=~data_label, radius=1)
)