0

Hello,
I would like to change the background color for each rows in Timeline chart based on specific value I,ve retrieve from database. For example, if the $status = '1', the backgrouncolor should be #000000, or else #ffffff

var container = document.getElementById('myChart');
var chart = new google.visualization.Timeline(container);
var dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'string', id: 'Position' });
dataTable.addColumn({ type: 'string', id: 'Name' });
dataTable.addColumn({ type: 'date', id: 'Start' });
dataTable.addColumn({ type: 'date', id: 'End' });

dataTable.addRows([
 <?php 
  for($i=0; $i<count($arr_code); $i++)
  {
     echo $data="['TEST', 'BAR NAME', new Date($start_date[$i]), new Date($end_date[$i])],";
  }
  ?>

]);

var options = {
  timeline: { rowLabelStyle: {color: '#ffffff' }},
  backgroundColor: '#92d050'
};

chart.draw(dataTable, options);

How do I change the background color if say that status for row 1 is number 1. ($status[$i] = '1'). If status == 1 , then backgroundColor: '#92d050' or else backgroundColor: '#000000'

Please help me on this.

Thank you

1
Contributor
0
Replies
51
Views
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.