我要根据持续时间更改时间线中特定栏的颜色,如果持续时间超过20分钟,则该栏将变为红色
<?php
$connect=mysqli_connect("localhost","root","","agmsdb");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$query = "SELECT * FROM ProcessTime";
$qresult = mysqli_query($connect,$query);
$rows = array();
$table = array();
$table['cols'] = array (
array('id' = 'Screen', 'type' = 'string'),
array('id' = 'Movie', 'type' = 'string'),
array('id' = 'Start time', 'type' = 'date'),
array('id' = 'End time', 'type' = 'date')
);
while($res = mysqli_fetch_assoc($qresult)) {
$result[] = $res;
}
foreach ($result as $r) {
$temp = array();
$temp[] = array('v' = $r['planeID']);
$temp[] = array('v' = $r['ProcessName']);
$temp[] = array('v' = 'Date(0,0,0,'.date('H',strtotime($r['StartTime'])).','.date('i',strtotime($r['StartTime'])).','.date('s',strtotime($r['StartTime'])).')');
$temp[] = array('v' = 'Date(0,0,0,'.date('H',strtotime($r['EndTime'])).','.date('i',strtotime($r['EndTime'])).','.date('s',strtotime($r['EndTime'])).')');
$rows[] = array('c' = $temp);
}
$table['rows'] = $rows;
$jsonTable = json_encode($table);
?>
<script src="https://www.gstatic.com/charts/loader.js" </script>
<script>
google.charts.load('current', {
callback: drawChart,
packages: ['timeline']
});
function drawChart() {
var dataTable = new google.visualization.DataTable(<?php echo $jsonTable; ?>);
var container = document.getElementById('example');
var chart = new google.visualization.Timeline(container);
chart.draw(dataTable);
}
</script>
<div id="example"></div>