Skip to content

Commit 18b245b

Browse files
committed
clsf. mode: logarithmic; legend footer; rounding fix
1 parent 82bf82c commit 18b245b

File tree

5 files changed

+101
-30
lines changed

5 files changed

+101
-30
lines changed

README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ Aims to simplify data visualization and creation of elegant thematic web maps wi
1616
- quantile (equal count)
1717
- equal interval
1818
- standard deviation
19+
- logarithmic scale
1920
- manual
20-
- Supports ColorBrewer2 color ramps and custom color ramps (thanks to [chroma.js](https://github.com/gka/chroma.js))
21+
- Supports ColorBrewer2 color ramps and c ustom color ramps (thanks to [chroma.js](https://github.com/gka/chroma.js))
2122
- Various SVG shapes/symbols for Point features
2223
- For size/width based symbology, min and max values can be adjusted to create a telling visualization with distinguishable classes
2324
- Normalization by another attribute field
2425
- Rounding of class boundary values to *n* decimals or up/down to the nearest 10, 100, 1000 etc. numbers
2526
- Handling of null/nodata feature attributes
2627
- Legend generation with options for:
2728
- class order (ascending/descending)
28-
- legend header (title)
29+
- legend header (title), footer
2930
- custom HTML templating of legend rows, including the display of feature counts in classes
3031
- modifying class boundary values in legend by dividing/multiplying by a number (to easily change unit of measurement from m to km for example)
3132
- positioning (L.control options)
@@ -84,6 +85,7 @@ const layer = L.dataClassification(data, {
8485
classRounding: 2,
8586
normalizeByField: 'areakm2',
8687
legendTitle: 'Density (pop/km²)',
88+
legendFooter: '(additional info in footer)',
8789
legendPosition: 'bottomleft',
8890
legendRowGap: 5,
8991
legendAscending: false,
@@ -105,7 +107,7 @@ const layer = L.dataClassification(data, {
105107
```
106108
107109
### Required options
108-
- `mode <string>`: ['jenks'|'quantile'|'equalinterval'|'stddeviation'|'manual'] classification method: natural break (Jenks), equal count (quantile), equal interval, standard deviation, manual. When using standard deviation, option `classes` is ignored. When using manual (which partially defeats the purpose of this plugin), option `classes` must be an array of class boundary values!
110+
- `mode <string>`: ['jenks'|'quantile'|'equalinterval'|'logarithmic'|'stddeviation'|'manual'] classification method: natural break (Jenks), equal count (quantile), equal interval, logarithmic scale, standard deviation, manual. When using standard deviation, option `classes` is ignored. When using manual (which partially defeats the purpose of this plugin), option `classes` must be an array of class boundary values!
109111
- `classes <integer|array>`: desired number of classes (min: 3; max: 10 or featurecount, whichever is lower. If higher, reverts back to the max of 10.). If `mode` is manual, this must be an array of numbers (for example [0, 150, 200] would yield the following three classes: below 150, 150-200, above 200).
110112
- `field <string>`: target attribute field name to base classification on. Case-sensitive!
111113
@@ -152,6 +154,7 @@ const layer = L.dataClassification(data, {
152154
- `classRounding <integer>`: class boundary value rounding. When positive numbers are used for this option, class boundary values are rounded to x decimals, zero will round to whole numbers, while negative numbers will round values to the nearest 10, 100, 1000, etc. Example: with a setting of "1", a value of 254777.253 will get rounded up to 254777.3, with "0" it will be 254777, with "-2" it will become 254800. (default: null - no rounding happens, values are used as-is)
153155
- `normalizeByField <string>`: attribute field name to normalize values of `field` by. Useful for choropleth maps showing population density. Case-sensitive!
154156
- `legendTitle <string>`: legend header (usually a description of visualized data, with a unit of measurement). HTML-markdown and styling allowed. To hide header, set this as ''. (by default it inherits target attribute field name, on which the classification is based on)
157+
- `legendFooter <string>`: legend footer, centered, using a smaller italic font by default (customizble in CSS - .legendFooter class). HTML-markdown and CSS styling allowed. Hidden by default. (default: null)
155158
- `legendPosition <string>`: ['topleft'|'topright'|'bottomleft'|'bottomright'] legend position, L.control option. (default: 'bottomleft')
156159
- `legendRowGap <number>`: legend symbology row gap in pixels. You can also alter this in the attached CSS file. (default: 3)
157160
- `legendAscending <boolean>`: if true, value classes in legend will be ascending (low first, high last) (default: false)

examples/points_c.html

+4-2
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,13 @@
8888
pointMode: 'color',
8989
colorRamp: 'YlOrRd',
9090
classRounding: 2,
91-
legendTitle: 'Diesel prices (€/l)<br>as of 7-Jul-2023 ',
91+
legendTitle: 'Diesel prices (€/l)',
92+
legendFooter: '(as of 7 July 2023)',
9293
legendPosition: 'bottomright',
9394
legendTemplate: {highest: '{low} and above', lowest: 'under {high}'},
9495
attribution: "Diesel prices (7-Jul-2023): <a href='https://www.prix-carburants.gouv.fr/rubrique/opendata/'>Ministère de l'Economie, de l'Industrie et du Numérique</a>",
95-
onEachFeature: tooltip
96+
onEachFeature: tooltip,
97+
legendRowGap: 2
9698
}).addTo(map);
9799
map.fitBounds(testdata.getBounds());
98100
});

examples/points_s.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
field: 'population',
8787
pointMode: 'size',
8888
pointSize: {min: 3.25, max: 10},
89-
classRounding: -2,
89+
classRounding: -3,
9090
legendTitle: 'Population',
9191
pointShape: 'diamond',
9292
style: {fillColor: '#B136E3'},

leaflet-dataclassification.css

+7
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,11 @@
4545
}
4646
.legendAscNodata {
4747
order: -1
48+
}
49+
.legendfooter {
50+
display: flex;
51+
font-size: 12px;
52+
font-style: italic;
53+
justify-content: center;
54+
margin-top: 5px;
4855
}

0 commit comments

Comments
 (0)