Commit aa7505b9 authored by Sarath's avatar Sarath

Fixed issue #2 with legend control

parent 0b39df83
Pipeline #3220798 passed with stage
in 7 seconds
......@@ -35,20 +35,35 @@ html, body {
width: 18px;
height: 18px;
float: left;
margin-right: 8px;
opacity: 0.7;
}
.legend .labels {
display: inline;
.legend .info {
width: 33%;
}
.legend .range {
width: 80%;
height: 18px;
/*background: linear-gradient(90deg, yellow, red); // generated from code */
padding: 1px 4px;
font-weight: bold;
margin: 0px 15px;
flex-grow: 10px;
}
.legend .min {
float: left;
margin-left: -15px;
}
.legend .max {
float: right;
margin-right: -15px;
}
.legend .instructions {
float: right;
display: inline;
margin-left: 10px;
width: 50px;
float: left;
display: block;
font-size: smaller;
font-style: italic;
}
......
......@@ -157,7 +157,7 @@ $.getJSON("data/india_states.geojson", function (data) {
map.attributionControl.addAttribution('<span class="data-license"><strong>Data compiled by SFLC.in</strong></span>');
/* Legend (disabled) */
/* Legend */
var legend = L.control({position: 'bottomright'});
......@@ -165,18 +165,13 @@ legend.onAdd = function (map) {
var container = L.DomUtil.create('div', 'legend info');
var instructions = L.DomUtil.create('div', 'instructions', container);
instructions.innerHTML = "Code available on <a href='https://gitlab.com/sflc.in/internetshutdowns'>GitLab</a>";
var labels = L.DomUtil.create('div', 'labels', container);
var labelItems = [];
container.innerHTML = "<div class='range' style='background: linear-gradient(90deg, " + startColor + "," + endColor + ");'>" +
"<span class='min'>0</span><span class='max'>" +
shutdowns.maxCount +
"</span> </div>";
for (var i = 0; i <= shutdowns.maxCount; i++) {
labelItems.push(
'<i style="background:' + shutdowns.colors[i] + '"></i> ' + i);
}
labels.innerHTML = labelItems.join('<br>');
var instructions = L.DomUtil.create('div', 'instructions', container);
instructions.innerHTML = "Report issues | Contribute code | <a href='https://gitlab.com/sflc.in/internetshutdowns'>GitLab</a>";
return container;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment