Hello thank you for your answer, even doing in your way (also previously 
tried) still does not change color and the second bar of "2 percent" is 
always red. 

function drawChart() {
                var data = new google.visualization.DataTable();
                data.addColumn('string', 'Installer'); // Implicit domain 
label col.
                data.addColumn({type:'number',label: 'Percentuale'}, 
'Percentuale Vendita'); 
                data.addColumn({type:'number',role:'annotation'}); 
                data.addColumn({type:'number',label: 'Percentuale 2'}, 
'Percentuale Vendita'); 
                data.addRows({$dato});
                data.sort([{column: 1, desc:true}, {column: 0}]);  
                
                var view = new google.visualization.DataView(data);
                view.setColumns([0, 1, 2, 3, {
                    type: 'string',
                    role: 'style',
                    calc: function (dt, row) {
                        var val = dt.getValue(row, 3); // get the value of 
"Percentuale 2"
                        if (val < 10) {
                            return 'red';
                        }
                        else if (val < 20) {
                            return 'yellow';
                        }
                        else {
                            return 'green';
                        }
                    }
                }]);
                
                var options={
                    title:"Obiettivo Vendite Trimestre",
                    allowHtml: true, 
                    showRowNumber: true,
                    vAxis:{
                        title:"Codice Installer",
                        titleTextStyle:{
                            color:"red"
                        },
                        textStyle:{
                            fontSize:12
                        }
                    },
                    height:data.getNumberOfRows()*35,
                    width:"100%",
                    hAxis:{
                        textStyle:{
                            fontSize:12
                        }
                    },
                    legend:{
                        position:"top",
                        isStacked:true
                    },
                    bar:{
                        groupWidth:"95%"
                    }
                }
                var chart = new 
google.visualization.BarChart(document.getElementById('linechart'));
                chart.draw(data,options);



Where can be the problem?
Il giorno giovedì 24 luglio 2014 18:53:53 UTC+2, Mirko Nulla ha scritto:
>
> Hello,
> I need to make the bars colour change according to particular values 
> related to specific ranges.
> For example every value between null and 10 must give the red colour, 
> between 10 and 20 the yellow one etc.
>
> I tried to use .view() with the calc function without any success. Was it 
> the right way?
> Finally how can I do it?
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to