One question more. Is it possible to use both roles, 'style' and 'annotation'?
I mean, may I add the value of the column as I did for the bars? Ciao Floriano 2014-03-17 23:00 GMT+01:00 Floriano Sabatini <sabatini.florian...@gmail.com> : > I'm so stupid. I duplicated the charts inside and outside the AJAX. > > Now it works. > > Many Many Thanks > Floriano > > > 2014-03-17 22:47 GMT+01:00 asgallant <drew_gall...@abtassoc.com>: > > You're still drawing the charts inside the AJAX call with the DataTables >> instead of the views: >> >> function getData() { >> setInterval(function () { >> $.getJSON("summary.php", function(response){ >> var json = eval(response); >> var prod = parseInt(json['PROD']); >> var net = parseInt(json['NET']); >> var cons = parseInt(json['CONS']); >> var cons_today = parseFloat(json['TOT_CONS']); >> var prod_today = json['TOT_PROD']; >> var prod_today1 = parseFloat(json['TOT_PROD'].split(" >> ")[1].substring(1).replace(',','.')); >> >> console.log("Produzione " + prod + " W"); >> console.log("Consumo " + cons + " W"); >> >> dataProd.setValue(0, 1, prod); >> dataCons.setValue(0, 1, cons); >> dataDisp.setValue(0, 1, net); >> dataTot.setValue(0, 1, prod_today1); >> dataTot.setValue(1, 1, cons_today); >> >> chartProd.draw(dataProd, optionsProd); >> chartCons.draw(dataCons, optionsCons); >> chartDisp.draw(viewDisp, optionsDisp); >> chartTot.draw(viewTot, optionsTot); >> >> document.getElementById('TOT_PROD').innerHTML = prod_today; >> }); >> }, 5000); >> } >> >> >> On Monday, March 17, 2014 4:14:27 PM UTC-4, Floriano Sabatini wrote: >> >>> Hi, >>> I'm sorry but it doesn't work. >>> it runs (while in the past it didin't) but still doens't work: I mean >>> the colour is still blue and doesn't change according to the value, >>> >>> >>> 2014-03-17 16:45 GMT+01:00 asgallant <drew_g...@abtassoc.com>: >>> >>> There's an error in the code I pasted. Try this: >>>> >>>> >>>> var viewTot = new google.visualization.DataView(dataTot); >>>> viewTot.setColumns([0, 1, { >>>> calc: "stringify", >>>> sourceColumn: 1, >>>> type: "string", >>>> role: "annotation" >>>> }, 2]); >>>> >>>> var viewDisp = new google.visualization.DataView(dataDisp); >>>> viewDisp.setColumns([0, 1, { >>>> >>>> type: 'string', >>>> role: 'style', >>>> calc: function (dt, row) { >>>> return (dt.getValue(row, 1) < 0) ? 'red' : 'green'; >>>> } >>>> }]); >>>> >>>> >>>> You need to draw the charts using the views inside the AJAX call that >>>> fetches your data (the initial draw call with the zeroed out data doesn't >>>> matter). >>>> >>>> >>>> On Saturday, March 15, 2014 4:29:18 AM UTC-4, Floriano Sabatini wrote: >>>> >>>>> The fanny think is that if I use viewDisp (for the column chart) >>>>> and viewTot (for the bar chart) I cannot see anything. >>>>> If I rename viewTot in just view it works but still without the right >>>>> color of the column (red/green) >>>>> >>>>> http://solarflor.dyndns.org/123solar/monitor_lite2.html >>>>> >>>>> I'm lost now >>>>> >>>>> >>>>> 2014-03-15 9:07 GMT+01:00 Floriano Sabatini <sabatini....@gmail.com>: >>>>> >>>>>> Done. but there should me some mistakes somewhere. I cannot see >>>>>> anything now. >>>>>> Thanks for your help >>>>>> >>>>>> >>>>>> 2014-03-14 22:54 GMT+01:00 asgallant <drew_g...@abtassoc.com>: >>>>>> >>>>>> There are a few problems with your code. First, you need to draw a >>>>>>> chart using the DataView instead of the DataTable if you want to see the >>>>>>> effects of the calculated column. Second, you create two views based on >>>>>>> different DataTables, but give them the same variable name, so the >>>>>>> second >>>>>>> overwrites the first. Give the two views different names: >>>>>>> >>>>>>> var viewTot = new google.visualization.DataView(dataTot); >>>>>>> view.setColumns([0, 1, { >>>>>>> calc: "stringify", >>>>>>> sourceColumn: 1, >>>>>>> type: "string", >>>>>>> role: "annotation" >>>>>>> }, 2]); >>>>>>> >>>>>>> var viewDisp = new google.visualization.DataView(dataDisp); >>>>>>> view.setColumns([0, 1, { >>>>>>> type: 'string', >>>>>>> role: 'style', >>>>>>> calc: function (dt, row) { >>>>>>> return (dt.getValue(row, 1) < 0) ? 'red' : 'green'; >>>>>>> } >>>>>>> }]); >>>>>>> >>>>>>> Then use the views to draw the charts: >>>>>>> >>>>>>> chartDisp.draw(viewDisp, optionsDisp); >>>>>>> chartTot.draw(viewTot, optionsTot); >>>>>>> >>>>>>> On Friday, March 14, 2014 4:23:18 PM UTC-4, Floriano Sabatini wrote: >>>>>>> >>>>>>>> Ciao Asgallant, >>>>>>>> why it does,t work here. see the column graph >>>>>>>> http://solarflor.dyndns.org/123solar/monitor_lite2.html >>>>>>>> >>>>>>>> what is wrong. >>>>>>>> Thanks >>>>>>>> Floriano >>>>>>>> >>>>>>>> >>>>>>>> 2014-03-14 0:00 GMT+01:00 Floriano Sabatini <sabatini....@gmail.com >>>>>>>> >: >>>>>>>> >>>>>>>>> YES. This is the solution I was looking for. >>>>>>>>> grazie 1000 >>>>>>>>> >>>>>>>>> Floriano >>>>>>>>> >>>>>>>>> >>>>>>>>> Il giorno giovedì 13 marzo 2014 22:49:20 UTC+1, asgallant ha >>>>>>>>> scritto: >>>>>>>>> >>>>>>>>>> Use a "style" role column to set the color of each bar. Here's >>>>>>>>>> an example: http://jsfiddle.net/asgallant/aFs9x/3/ >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On Thursday, March 13, 2014 5:46:00 PM UTC-4, Floriano Sabatini >>>>>>>>>> wrote: >>>>>>>>>>> >>>>>>>>>>> Dear all, >>>>>>>>>>> I would like to use the column chart gouge with just one column >>>>>>>>>>> that will represent the difference between Produced and Consumed >>>>>>>>>>> energy. To >>>>>>>>>>> be effective I need to have the colour of the column that change >>>>>>>>>>> from green >>>>>>>>>>> (if the value is positive) to red if it is negative. >>>>>>>>>>> >>>>>>>>>>> Is this something feasible? >>>>>>>>>>> Many thanks >>>>>>>>>>> Floriano >>>>>>>>>>> >>>>>>>>>> -- >>>>>>>>> You received this message because you are subscribed to a topic in >>>>>>>>> the Google Groups "Google Visualization API" group. >>>>>>>>> To unsubscribe from this topic, visit https://groups.google.com/d/ >>>>>>>>> topic/google-visualization-api/Zd9B1gKrE2w/unsubscribe. >>>>>>>>> To unsubscribe from this group and all its topics, send an email >>>>>>>>> to google-visualization-api+unsubscr...@googlegroups.com. >>>>>>>>> To post to this group, send email to google-visua...@googlegroups. >>>>>>>>> com. >>>>>>>>> >>>>>>>>> Visit this group at http://groups.google.com/group >>>>>>>>> /google-visualization-api. >>>>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>> You received this message because you are subscribed to a topic in >>>>>>> the Google Groups "Google Visualization API" group. >>>>>>> To unsubscribe from this topic, visit https://groups.google.com/d/to >>>>>>> pic/google-visualization-api/Zd9B1gKrE2w/unsubscribe. >>>>>>> To unsubscribe from this group and all its topics, send an email to >>>>>>> google-visualization-api+unsubscr...@googlegroups.com. >>>>>>> To post to this group, send email to google-visua...@googlegroups. >>>>>>> com. >>>>>>> Visit this group at http://groups.google.com/group >>>>>>> /google-visualization-api. >>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>> >>>>>> >>>>>> >>>>> -- >>>> You received this message because you are subscribed to a topic in the >>>> Google Groups "Google Visualization API" group. >>>> To unsubscribe from this topic, visit https://groups.google.com/d/ >>>> topic/google-visualization-api/Zd9B1gKrE2w/unsubscribe. >>>> To unsubscribe from this group and all its topics, send an email to >>>> google-visualization-api+unsubscr...@googlegroups.com. >>>> To post to this group, send email to google-visua...@googlegroups.com. >>>> Visit this group at http://groups.google.com/ >>>> group/google-visualization-api. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "Google Visualization API" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/google-visualization-api/Zd9B1gKrE2w/unsubscribe >> . >> To unsubscribe from this group and all its topics, send an email to >> google-visualization-api+unsubscr...@googlegroups.com. >> To post to this group, send email to >> google-visualization-api@googlegroups.com. >> Visit this group at >> http://groups.google.com/group/google-visualization-api. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsubscr...@googlegroups.com. To post to this group, send email to google-visualization-api@googlegroups.com. Visit this group at http://groups.google.com/group/google-visualization-api. For more options, visit https://groups.google.com/d/optout.