Commit 8c201004 authored by Dumoulin Nicolas's avatar Dumoulin Nicolas
Browse files

fix in buttons colors

parent 4db0026b
......@@ -33,29 +33,8 @@
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="choixculture navbar-nav mr-auto">
<li class="nav-item active">
<button class="btn btn-primary btn-sm" data-toggle="button" aria-pressed="false" val='0' col="#008080" style="background-color:#926c03;color:white">Cult. Ind.</button>
</li>
<li class="nav-item">
<button class="btn btn-primary btn-sm" val='1' col="#ffff00" style="background-color:#d5a243;color:white">Céréales</button>
</li>
<li class="nav-item">
<button class="btn btn-primary btn-sm" val='3' col="#ff0084" style="background-color:#cf294d;color:white">Fruits/légumes</button>
</li>
<li class="nav-item">
<button class="btn btn-primary btn-sm" val='4' col="#ff4000" style="background-color:#7570b3;color:white">Oléagineux</button>
</li>
<li class="nav-item">
<button class="btn btn-primary btn-sm" val='6' col="#f0b400" style="background-color:#e7298a;color:white">Protéagineux</button>
</li>
<li class="nav-item">
<button class="btn btn-primary btn-sm" val='5' col="#9dff00" style="background-color:#66a61e;color:white">Prairies</button>
</li>
<li class="nav-item">
<button class="btn btn-primary btn-sm" val='2' col="#7ec700" style="background-color:#1b9e77;color:white">Fourrages</button>
</li>
</ul>
<ul id="choixculture" class="navbar-nav mr-auto">
</ul> <!-- filled by following script -->
<form class="form-inline">
<div class="nav-item custom-control custom-switch mr-sm-2" >
<input type="checkbox" class="form-control custom-control-input" id="transparency" checked>
......@@ -98,6 +77,21 @@
<form></form> <!-- filled by following script -->
</div>
<script type="text/javascript">
<!-- generating culture choice buttons -->
$([['Cult. Ind.','#008080',0],['Céréales','#ffff00',1],
['Fruits/légumes','#ff0084',3],['Oléagineux','#ff4000',4],
['Protéagineux','#f0b400',6],['Prairies','#9dff00',5],
['Fourrages','#7ec700',2]]).each(function(i,e){
// determine if the font color should be white or black depending on the bg
color = d3.color(e[1]);
// https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color/3943023#3943023
fontColor = ((color.r*0.299 + color.g*0.587 + color.b*0.114) > 186) ? "#000000" : "#ffffff";
$('#choixculture').append('<li class="nav-item">'
+'<button class="btn btn-primary btn-sm" val="' + e[2]+ '" col="' + e[1] + '" style="background-color:' + e[1] + ';color:' + fontColor + '">'
+ e[0] + '</button>'
+'</li>')
});
<!-- generating indicators selectors -->
$([['Proximité','Optimise la répartition de la production en Fruits/Légumes sur le territoire en fonction de la densité de population.'],
['Résilience','Favorise la diversité de cultures dans une maille de 2,5kha.'],
['Productivité','Favorise la transition vers des Fruits/Légumes sur des parcelles à haute valeur cadastrale.'],
......@@ -125,13 +119,13 @@
var dataset_column='0_11111';
var cult_code=0;
// https://www.d3indepth.com/scales/
var linearScale = d3.scaleLinear().domain([0, 1.0]).range(['#fff', "#926c03"]);
var linearScale = d3.scaleLinear().domain([0, 1.0]).range(['#fff', "#008080"]);
var loaded = false;
function linearScale4(value) {
return linearScale(value).replace('rgb(','rgba(').replace(')',',' + hexagonAlpha + ')');
}
$('.choixculture button').on('click', function(e) {
$('#choixculture button').on('click', function(e) {
cult_code = $(e.currentTarget).attr('val');
cult_color = $(e.currentTarget).attr('col');
$('#cult_reallouee').text($(e.currentTarget).text())
......@@ -289,7 +283,6 @@
});
map = new ol.Map({
target: 'map',
//controls: ol.control.defaults(),
controls: ol.control.defaults({
attributionOptions: {
collapsible: true
......
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