Change colors on google charts

0

I'm using google charts to generate 4 pizzas.  How do I change the colors that appear?

Follow my code:

<?php
include("conn_user.php");
include("conn_sys.php");
if (!isset($_SESSION)) session_start();
if (!isset($_SESSION['usu_login'])) {
  session_destroy();
  header("Location:logout.php"); exit;
}


ini_set( 'display_errors', true );
error_reporting( E_ALL );

@session_start();
$v_id_usuario = $_SESSION['usu_id'];
$v_login      = $_SESSION['usu_login'];
$v_nome       = $_SESSION['usu_nome'];
$v_loja       = $_SESSION['usu_loja_id'];
$v_nivel      = $_SESSION['usu_area_admin'];

?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="pt-br" xml:lang="pt-br">
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>CONTROLE DE DESPESAS</title>
  <link rel="stylesheet" href="includes/style.css">
  <link rel="stylesheet" href="includes/css/bootstrap.min.css">
  <link rel="stylesheet" href="includes/css/datatables.css">
  <script src="https://code.jquery.com/jquery-3.1.0.min.js"></script><scriptsrc="includes/js/bootstrap.min.js"></script>
  <script src="includes/js/jquery.dataTables.min.js"></script>
  <script src="includes/js/datatables.js"></script>  
  <script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script><linkrel="stylesheet" href="//code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css">
    <style>
  #center {
    margin: auto;
    width: 97%;
    padding: 10px;
}


</style>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script><scripttype="text/javascript">

      // Load Charts and the corechart package.
      google.charts.load('current', {'packages':['corechart']});

      // Draw the pie chart for Sarah's pizza when Charts is loaded.
      google.charts.setOnLoadCallback(drawSolicitacoes);

      // Draw the pie chart for the Anthony's pizza when Charts is loaded.
      google.charts.setOnLoadCallback(drawSetores);

      // Draw the pie chart for the Anthony's pizza when Charts is loaded.
      google.charts.setOnLoadCallback(drawValores);

      // Draw the pie chart for the Anthony's pizza when Charts is loaded.
      google.charts.setOnLoadCallback(drawFornecedores);

      // Callback that draws the pie chart for Sarah's pizza.
      function drawSolicitacoes() {

        // Create the data table for Sarah's pizza.
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Topping');
        data.addColumn('number', 'Slices');
        data.addRows([
        <?php
        $solicitacoes = mysql_query("SELECT  
        distinct sol_id AS SOL,
         st.status_desc AS STATUS,
         CONCAT(count(st.status_id)) AS QUANT
        FROM
         solicitacao AS s 
         INNER JOIN  status AS st ON s.sol_status = st.status_id
         GROUP BY sol_status");
         while ($r = mysql_fetch_array($solicitacoes)) {
            echo "['$r[1]', $r[2]],\n";
        }
        ?>
        ]);

        // Set options for Sarah's pie chart.
        var options = {title:'SOLICITAÇÕES',
                       width:550,
                       height:300};

        // Instantiate and draw the chart for Sarah's pizza.
        var chart = new google.visualization.PieChart(document.getElementById('Solicitacoes'));
        chart.draw(data, options);
      }

      // Callback that draws the pie chart for Anthony's pizza.

      function drawSetores() {

        // Create the data table for Sarah's pizza.
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Topping');
        data.addColumn('number', 'Slices');
        data.addRows([
        <?php
        $setores = mysql_query("SELECT  
        distinct sol_setor AS ID,
        st.setor_nome AS SETOR,
        CONCAT(count(s.sol_setor)) AS QUANT
        FROM
         solicitacao AS s 
         INNER JOIN  setor  AS st ON s.sol_setor = st.setor_id
         GROUP BY sol_setor");
         while ($r = mysql_fetch_array($setores)) {
            echo "['$r[1]', $r[2]],\n";
        }
        ?>
        ]);

        // Set options for Sarah's pie chart.
        var options = {title:'SETORES',
                       width:550,
                       height:300};

        // Instantiate and draw the chart for Sarah's pizza.
        var chart = new google.visualization.PieChart(document.getElementById('Setores'));
        chart.draw(data, options);
      }

      // Callback that draws the pie chart for Anthony's pizza.

      function drawValores() {

        // Create the data table for Anthony's pizza.
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Topping');
        data.addColumn('number', 'Slices');
        data.addRows([
        <?php
        $valores = mysql_query("         SELECT 
          s.sol_id AS ID,
          st.setor_nome AS SETOR,
          SUM(o.orc_valor_total) AS TOTAL
          FROM solicitacao AS s
          INNER JOIN  setor    AS st ON s.sol_setor =  st.setor_id
          INNER JOIN orcamento AS o  ON s.sol_id    =  o.orc_solicitacao
          GROUP BY sol_setor");
         while ($r = mysql_fetch_array($valores)) {
            echo "['$r[1]', $r[2]],\n";
        }
        ?>
        ]);


        // Set options for Anthony's pie chart.
        var options = {title:'VALORES',
                       width:500,
                       height:300};

        // Instantiate and draw the chart for Anthony's pizza.
        var chart = new google.visualization.PieChart(document.getElementById('Valores'));
        chart.draw(data, options);
      }
      // Callback that draws the pie chart for Sarah's pizza.
      function drawFornecedores() {

        // Create the data table for Sarah's pizza.
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Topping');
        data.addColumn('number', 'Slices');
        data.addRows([
        <?php
        $fornecedores = mysql_query("         SELECT 
          s.sol_id AS ID,
          f.fornec_nome AS SETOR,
          SUM(o.orc_valor_total) AS TOTAL
          FROM solicitacao AS s
          INNER JOIN  setor    AS st ON s.sol_setor  =  st.setor_id
          INNER JOIN orcamento AS o  ON s.sol_id     =  o.orc_solicitacao
          INNER JOIN fornecedor AS f ON s.sol_fornec =  f.fornec_id
          GROUP BY sol_fornec");
         while ($r = mysql_fetch_array($fornecedores)) {
            echo "['$r[1]', $r[2]],\n";
        }
        ?>
        ]);

        // Set options for Sarah's pie chart.
        var options = {title:'FORNECEDORES',
                       width:550,
                       height:300};

        // Instantiate and draw the chart for Sarah's pizza.
        var chart = new google.visualization.PieChart(document.getElementById('Fornecedores'));
        chart.draw(data, options);
      }
    </script>
</head>
<body>
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#"><span class="glyphicon glyphicon-globe" aria-hidden="true"></span>S</a>
    </div>

    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li ><a href="principal.php"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span>&nbsp;&nbsp;Solicitacao</a></li>
        <li ><a href="solicitacoes.php"><span class="glyphicon glyphicon-th-list" aria-hidden="true"></span>&nbsp;&nbsp;Minhas Solicitações</a></li>
        <li ><a href="admin.php"><span class="glyphicon glyphicon-tasks" aria-hidden="true"></span>&nbsp;&nbsp;Administração</a></li>
        <li ><a href="dashboard_loja.php"><span class="glyphicon glyphicon-stats" aria-hidden="true"></span>&nbsp;&nbsp;Dashboard Loja</a></li>
        <li ><a href="dashboard_admin.php"><span class="glyphicon glyphicon-stats" aria-hidden="true"></span>&nbsp;&nbsp;Dashboard Admin</a></li>      
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li ><a href="logout.php"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span>&nbsp;&nbsp;Sair</a></li>
      </ul>
    </div>
  </div>
</nav>

<div class="container">
  <div class="row">
   <div class="col-sm-6">
    <div id="Solicitacoes"></div>
   </div>
   <div class="col-sm-6">
     <div id="Setores"></div>
   </div>
  </div>

  <div class="row">
    <div class="col-sm-6">
      <div id="Valores"></div>
    </div>
    <div class="col-sm-6">
      <div id="Fornecedores"></div>
    </div>
  </div>
</div>        



</body>
</html>
    
asked by anonymous 05.08.2016 / 15:29

1 answer

4

I believe in the documentation you can have a pass which parameters should be updated:

var options = {
  width: 400,
  height: 240,
  title: 'Toppings I Like On My Pizza',
  colors: ['#e0440e', '#e6693e', '#ec8f6e', '#f3b49f', '#f6c7b6']
};

chart.draw(data, options);

link

    
05.08.2016 / 18:21