Mohd_11 0 Newbie Poster

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.