humangeo / leaflet-dvf

Leaflet Data Visualization Framework
MIT License
689 stars 152 forks source link

Question: When generating a numeric legend #86

Closed rickj33 closed 8 years ago

rickj33 commented 8 years ago

I am implementing a custom legend to produce this image

I have it working, but when going through the code in L.Datalayer _getLegend I saw this line of code

var weight = layerOptions.weight || 0;
//then later used when breaks are defined 
   segmentWidths.push(width - lastWidth - 2 * weight);

the question is, what is the -2 * weight mean, is it compensating for the size of the border? and if so does weight mean border width?

sfairgrieve commented 8 years ago

That's correct. The code is trying to fit n cells with left and right borders into a particular width. The legend sets the border width based on the weight style property, which is the Leaflet way of setting SVG shape/path stroke width.

rickj33 commented 8 years ago

thanks for the explanation