-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CustomColorFunction, color classes & legend #25
Comments
Sylvain, Good question. You can pass an interpolate option in the var fillColorSeq = new L.CustomColorFunction(range[0], range[1],
L.ColorBrewer.Sequential.PuBuGn['9'], {
interpolate: false
}); This will ensure that only the 9 or 4 or desired number of color classes As far as the legend goes, it looks like that's a bug or at least an Thanks, Scott Sent from my iPhone On Mar 21, 2014, at 6:52 PM, sylvaincaillot notifications@github.com Good morning, I am developing a map with a chloropeth layer similar to you countystats var fillColorSeq = new L.CustomColorFunction(range[0], range[1], I works OK but when i reduce the number of color classes Am i doing something wrong? At least, is it possible to define automatically the number of segments of Thanks in advance for your reply. Sylvain Reply to this email directly or view it on |
…rRegularPolygonMarker class and L.MarkerGroup class. Fixed bugs with WeightedPolyline
Just pushed an update which should make this work. In the DataLayer legendOptions section, just include an option called gradient with a value of false in addition to setting interpolate to false in the L.CustomColorFunction. I updated the county stats example to illustrate this. |
It works beautifully. Thanks for your prompt answer. Sylvain |
Good morning,
First of all congratulations for this amazing plugin.
I am developing a map with a chloropeth layer similar to you countystats example.
I would like to give the user the posiibility to choose its color palette(sequential/diverging) and the number of data classes as in the Colorbrewer website.
Using this webpage and this site (http://www.cse.unsw.edu.au/~mike/myrlibrary.old/RColorBrewer/html/ColorBrewer.html), i have been writing the following code for sequential and diverging colors:
var fillColorSeq = new L.CustomColorFunction(range[0], range[1], L.ColorBrewer.Sequential.PuBuGn['9']);
var fillColorDiv= new L.CustomColorFunction(range[0], range[1], L.ColorBrewer.Diverging.PRGn['11']);
I works OK but when i reduce the number of color classes (eg.:L.ColorBrewer.Diverging.PRGn['4']);), i would expect to have 4 colors only in my map and legend but, i still continue to have more colors than data classes with perhaps a clearer tint.
Am i doing something wrong?
Should i use the slice attribute? I didn't find much information on it.
At least, is it possible to define automatically the number of segments of the legend based on the number of data classes chosen for the customeColorFunction without using the numSegments option of the legend and the gradient effect?
I would like to get something similar to the Colorbrewer site.
Thanks in advance for your reply.
Sylvain
The text was updated successfully, but these errors were encountered: