rte-antares-rpackage / leaflet.minichart

Leaflet.minichart is a leaflet plugin for adding to a leaflet map small animated charts
https://rte-antares-rpackage.github.io/leaflet.minichart/
Other
31 stars 10 forks source link

Bubble Chart and Legend #8

Open hairpin86 opened 6 years ago

hairpin86 commented 6 years ago

Hi,

First of all, thanks for this great plugin. I have 2 questions regarding your implementation:

1. How did you get to show Bubble Charts like here : https://github.com/rte-antares-rpackage/leaflet.minichart/blob/master/img/bubblecharts.png ?

Did you just pass one value into the data array? But how come you can add a String to the data and still have a dyamic Bubble size?

  1. How did you add the legend like here: https://github.com/rte-antares-rpackage/leaflet.minichart/blob/master/img/barcharts.png ?

FrancoisGuillem commented 4 years ago

Hi,

My answer is a little late, but better late than never :D

Concerning question 1, you can pass a single number or an array of length 1 as data and set option "type" to "pie", "polar-radius" or "polar-area" and set "labels" to "auto". For instance:

L.minichart([0, 0], {data: 1234, type:"pie", labels:"auto"}).addTo(map)

gives: image

Concerning the legend, it is not generated with this package. I have used the R package "leaflet" that generates interactive maps. It has a simple function "addLegend()" that generates the required javascript to display such legend.

szkatalin commented 3 years ago

There is a good tutorial for the legend here: https://leafletjs.com/examples/choropleth/