JavaScript Animated CoVID Vaccination Coverage Chart - Editor

Example which showcases laying LightningChart JS ChartXY data visualization features over a LightningChart JS MapChart.

This is likely to be the single easiest method available of implementing a geographical data visualization component:

  • No tile server or large tile storage required
  • Can be used offline
  • Extremely simple to develop (minimal setup less than 50 lines of code)

The two charts are laid perfectly over each other by placing them on their own HTML div elements with same position and size. To complete the setting, MapChart provides a method onViewChange which can be used to conveniently synchronize the map latitude and longitude view with the overlaid XY axes.

// Minimal working code for overlaid and synchronized MapChart and ChartXY.
const divMap = document.createElement("div");
document.body.append(divMap);

const divOverlay = document.createElement("div");
document.body.append(divOverlay);

const mapChart = lightningChart()
  .Map({
    type: MapTypes.World,
    container: divMap,
  })
  .setTitle("");

const chart = lightningChart()
  .ChartXY({
    container: divOverlay,
  })
  .setMouseInteractions(false)
  .setBackgroundFillStyle(transparentFill)
  .setSeriesBackgroundFillStyle(transparentFill);
chart.engine.setBackgroundFillStyle(transparentFill);
chart
  .getDefaultAxes()
  .forEach((axis) =>
    axis.setTickStrategy(AxisTickStrategies.Empty).setStrokeStyle(emptyLine)
  );

mapChart.onViewChange((view) => {
  const { latitudeRange, longitudeRange, margin } = view;
  chart
    .getDefaultAxisX()
    .setInterval(longitudeRange.start, longitudeRange.end, false, true);
  chart
    .getDefaultAxisY()
    .setInterval(latitudeRange.start, latitudeRange.end, false, true);
  chart.setPadding(margin);
});

divMap.style.width = "100vw";
divMap.style.height = "100vh";
divMap.style.position = "absolute";
divMap.style.left = "0px";
divMap.style.top = "0px";
mapChart.engine.layout();

divOverlay.style.width = "100vw";
divOverlay.style.height = "100vh";
divOverlay.style.position = "absolute";
divOverlay.style.left = "0px";
divOverlay.style.top = "0px";
chart.engine.layout();

The example animates the progression of first round of Covid-19 vaccines coverage across all countries.

The used data set is from ourworldindata.org

Hannah Ritchie, Edouard Mathieu, Lucas Rodés-Guirao, Cameron Appel, Charlie Giattino, Esteban Ortiz-Ospina, Joe Hasell, Bobbie Macdonald, Diana Beltekian and Max Roser (2020) - "Coronavirus Pandemic (COVID-19)". Published online at OurWorldInData.org. Retrieved from: 'https://ourworldindata.org/coronavirus' [Online Resource]

More map examples: