Skip to content

laem/async-cartogram

Repository files navigation

What ?

A js cartogram library that does not block the browser, using web workers, forked from the original d3 cartogram. It can also be run with node, which is nice for preprocessing geometries offline.

  • Designed to handle a series of cartograms (called tasks) : compute all the maps at once then display them smoothly.

  • Using only a geo subset of d3 (you'll probably use d3 again to display the map in the browser, add colors, transitions, hovers...).

  • Also attempts to add the effective range tip from Algorithms for Cartogram Animation, by Ouyang et al., hopefully making it slightly faster.

Usage :

The library is compiled in dist/ as UMD, and has been tested using require("dist/async-cartogram.js")

var promiseOfGeometries = AsyncCartogram(
  {
    topology: topojsonData,
    // geometries to reshape:
    geometries: topojsonData.objects.OBJECTNAME.geometries,
    projection: {
      name: 'mercator',
      translation: [X,Y],
      scaling: scalingFactor, //e.g. 2000
      center: [long, lat]
    }
  },
  values, // { taskId => { geoJsonFeatureValue => newArea} }
  featureProperty // geoJsonFeatureIdKey to link geojson features to values
);

See the example app (cartogram of Paris) for detailed usage.

L'escargot

Check the project for which this lib was created, a 90-years cartogram of europe.

About

Javascript non-blocking cartograms (web workers / node)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published