title: Google pie chart color depending on value
body: <p>I have a chart where I only count the number of values for only two categories.</p>
  
  <p>What I want is to color in green for that category having the max value and in blue for the one having the min value.</p>
  
  <p>From the two quantity values, I want to determine inside the loop, the value that has the higher value. So the green color will be displayed for that value inside the pie chart, in this case, to be able to choose either 0 or 1 inside the options part, at the <code>slices</code>.</p>
  
  <p>So far this is my code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      google.charts.load('current', {'packages':['corechart']});
      google.charts.setOnLoadCallback(interinstituctionals_quantity);
      function interinstituctionals_quantity(){/*Quantity de proyectos interinstitucionales del total de los proyectos vigentes*/
              var data = new google.visualization.DataTable();
              var interinstituctionals_quantity = {{interinstituctionals_quantity|json_encode|raw}};
              var projectstotal = 0;
  
              /****This is the array I get from the database:
                ['¿Interinstitutional?', 'Quantity'],
                ['yes', 70],
                ['no', 166],
              ****/
  
              data.addColumn('string', '¿Interinstitucional?');
              data.addColumn('number', 'Quantity');
  
  
              $.each(interinstituctionals_quantity, function(index, value){
                  projectstotal += value.Quantity;/*Adding total of the quantity gotten from query*/
                  /*HOW can I determine inside this loop which of the two values has the highest value? And what if they're the same?*/
                  data.addRow([value.Interinstitucional,value.Quantity]);
              });
  
              var optionMax=1;
              var optionMin=0;
  
  
              var options = {
                  title: 'Number of interinstitutional projects (total: '+projectstotal+')',
                  backgroundColor: { fill:'transparent'},
                  height: 500,
                  is3D: true,
                  slices: {
                      0: { color: 'blue',offset: 0.5 },/*THIS TURNED OUT TO BE MAX AND SHOULD HAVE THESE OPTIONS*/
                      1: { color: 'green' }/*THIS TURNED OUT TO BE MIN AND SHOULD HAVE THESE OPTIONS*/
                  }
                  //width: 900,
              };
  
              var chart = new google.visualization.PieChart(document.getElementById('interinstituctionals_quantity_div'));
  
              chart.draw(data, options);
              function resizeHandler () {
                  chart.draw(data, options);
              }
              if (window.addEventListener) {
                  window.addEventListener('resize', resizeHandler, false);
              }
              else if (window.attachEvent) {
                  window.attachEvent('onresize', resizeHandler);
              }
          }
  &lt;/script&gt;
  </code></pre>
  
  <p>HOW can I determine inside this loop which of the two values has the highest value? And what if they're the same?
  How do I achieve that?</p>