Toggle for fours colours

Joined
Dec 10, 2022
Messages
10
Reaction score
2
Dear all

Could someone please help me to find a way for using the above function for showing 4 bars in distinct colours?

Using simple code no chart.js or any other library

Thank you in advance


JavaScript:
function barIt(tem) {
 tem.length=4;
  var tab = '<table><tr><td colspan="'+tem.length+'" align="center">Table</td></tr>';
  toggle=true;
  for(var k=0;k<tem.length;k++) {
    diff = largest-tem[k][0];
   
    tab += '<tr><td colspan="'+
    tem[k][0]+
    '" bgcolor="'+((toggle)?'lightblue':'yellow')+'">'+
    tem[k][0]+
    '</td><td colspan="'+    
    diff+
    '">'+tem[k][1]+'</td></tr>'
         
    toggle=!toggle;
  }
  tab+='</table>';
  document.getElementById('bar').innerHTML=tab;
}

</script>
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,943
Messages
2,570,128
Members
46,611
Latest member
SusanneWis

Latest Threads

Top