eurostat / eurostat-map.js

Reusable library to quickly create and customise web maps showing Eurostat data directly retrieved from Eurostat database.
https://github.com/eurostat/eurostat-map.js
Other
60 stars 4 forks source link

Legend - proportionnal symbols #11

Closed jgaffuri closed 3 years ago

jgaffuri commented 3 years ago
joewdavies commented 3 years ago

1) Should we not expose the d3.format function to the user? to allow them to format the legend values? If unspecified then it could default to the current implementation .labelFormat(format("." + out.labelDecNb_ + "f").

2) Would it not be more intuitive to expose the legend configuration as a single method which accepts a single configuration object? See gridviz for example.

jgaffuri commented 3 years ago

Yes, good ideas !

  1. with something like:
    legend = function(map, opts) {
    opt.parameter1 = opt.parameter1 || defaultValue1;
    ...
    }

    ?

joewdavies commented 3 years ago

Yes, in gridviz I first define a default legend configuration and then allow the user to override its properties:

  viewer.legend = function (viewer, config) {
    for (let key in config) {
      viewer.legend_[key] = config[key];
    }
    //update legend if necessary
    if (viewer._gridLegend) {
      updateLegend()
    }
    return viewer;
  };
jgaffuri commented 3 years ago

Excellent !

jgaffuri commented 3 years ago