Mesurer un niveau de fioul dans une cuve

voici le script :slight_smile: :


var volumeCuve = 3000; //volume cuve pleine en litres

//calcul de la consommation à partir de la baisse du niveau
var consommation = ((datasources["IPX"]["response"]["cpt0"]/206)*4.54).toFixed(2); //consommation en litres
//calcul volume Fuel restant
var vf=volumeCuve-consommation;
var pourcent=100 - (100*vf/volumeCuve);
return `
<style>

body { 
  background:$bgColor; 
  font: 14px/1 'Open Sans', helvetica, sans-serif; 
  -webkit-font-smoothing: antialiased; 
  color:#fff; 
} 
.box{ 
  height: 80px;
  width: 80px;
  position: absolute;
  top: 50%;
  left: 10px;
  transform: translate(0, -50%);
  background: #666666;
  border-radius:15%;
  overflow: hidden; 
}
   
 .fuel{ 
    position: absolute;
    left: 0;
    top: 0;
    width: 80px;
    height: 80px;
transform:translate(0,${pourcent}%);
    background:#76B558;
  } 
</style>
<div class="box"> 
  <div id="fuel" class="fuel"></div> 
</div> 
<div style="float:left;margin-left:100px;margin-top:15px;font-size:12px;"> 
	<span >consommation : ${consommation} </span> litres<br>
	<span style="font-weight:bold;">Volume Fioul : ${vf}  litres</span><br>
    <span >Ratio volume : ${(100 - pourcent).toFixed(2)}</span> %<br> 
</div> 

`;

image

cdt

2 « J'aime »