Ok, nel frattempo ho fatto passi avanti...l'onload l'ho messo qui e funziona:
codice:
<script type="text/javascript">
window.onload=function(){
...
Adesso devo utilizzare più istanze e non funzionano, cioé si visualizzano ma modificando le opzioni (setOptions) non ottrngo nessuna modificam non vengono applicate.
Il problema è (document.getElementById('clickme').addEventListen er('click', function ()) devo capire come modificarlo.
codice:
<script type="text/javascript">
window.onload=function(){
console.log("GAUGE ONE");
var gaugeOneTarget = document.getElementById('gaugeOne');
var gaugeOne = new Donut(gaugeOneTarget);
gaugeOne.maxValue = 100;
gaugeOne.set(25);
console.log("GAUGE TWO");
var gaugeTwoTarget = document.getElementById('gaugeTwo');
var gaugeTwo = new Donut(gaugeTwoTarget);
gaugeTwo.maxValue = 50;
gaugeTwo.set(75);
document.getElementById('clickme').addEventListener('click', function () {
gaugeOne.setOptions({
lines: 12,
angle: 0.50,
lineWidth: 0.05,
colorStart: '#000',
strokeColor: '#9a9a9a'
});
gaugeTwo.setOptions({
lines: 12,
angle: 0.50,
lineWidth: 0.05,
colorStart: '#0afc19',
strokeColor: '#9a9a9a'
});
});
}
</script>
codice:
<canvas id="gaugeOne" height="61" width="103"></canvas>
<canvas id="gaugeTwo" height="61" width="103"></canvas>