They way that is set up, you should see "Percentuale 2" colored red, 
yellow, and green (based on the values of "Percentuale", though).  Is that 
working?  To get both data sets working, you need to make a few tweaks:

view.setColumns([0, 1, {
    type: 'string',
    role: 'style',
    calc: function (dt, row) {
        var val = dt.getValue(row, 1); // get the value of "Percentuale"
        if (val < 10) {
            return 'red';
        }
        else if (val < 20) {
            return 'yellow';
        }
        else {
            return 'green';
        }
    }
}, 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';
        }
    }
}]);

On Thursday, July 24, 2014 6:21:26 PM UTC-4, Mirko Nulla wrote:
>
>
> 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 2'); 
>                   
>                 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, 1);
>                         if (val < 10) {
>                             return 'red';
>                         }
>                         else if (val < 20) {
>                             return 'yellow';
>                         }
>                         else {
>                             return 'green';
>                         }
>                     }
>                 }]);
>
>
> I tried as you say it is wrong. where am I wrong?
> 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 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.

Reply via email to