Using variables in javascript array? -


this short question using chart.js library , code is:

javascript

totalcost = (inputwatts * price + varservicefees + inputservicetrips).tofixed(0); totalfactor = (totalcost / (inputwatts * price)).tofixed(2);  if (selected === 'bservice') {     totalcostservice = totalcost; } else if (selected === 'bmicro') {     totalcostmicro = totalcost; } else {     totalcosttypical = totalcost; }  var data = [     {         value: totalcostservice,         color: '#f7464a'     },     {         value: totalcostmicro,         color: '#46bfbd'     },     {         value: totalcosttypical,         color: '#fdb45c'     }  ], graph = new chart(document.getelementbyid('canvas').getcontext('2d')).doughnut(data); 

my problem when using totalcost variable nothing happens, if replace these numbers such 30 though working fine. know variable working because displaying on web page , shows valid number. have code check isnan === false. wonderful, thanks!

edit

i replaced value: totalcostmicro , value: totalcosttypical both value: 30 while debugging , messed totalcostservice only. above can see totalcostservice totalcost inputwatts * price etc, did value: inputwatts worked, , tried value: price , on, working. general variable totalcost not work , think may because of .tofixed(0) need round number off. alternatives?

sorry wasting everyone's time asking question learned wrong. tofixed(0) caused error, if know why please comment curious, working. again everyone's help, best community!


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -