I have a Timeline displaying very nicely in a Drupal site, grabbing the
date data from the Drupal database.
I want to get a vertical line showing at 'Today', and have 'Today - 1 week'
as the baseline.
How can I do this?
Here is my code:
/**
* Function to create the Gantt Chart.
*/
function smartsheet_gantt_chart() {
?>
<script type="text/javascript" src=
"https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1','packages':['timeline']}]}"
></script>
<script type="text/javascript">
google.setOnLoadCallback(drawChart);
function drawChart() {
var container = document.getElementById('gantt');
var chart = new google.visualization.Timeline(container);
var dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'string', id: 'Label' });
dataTable.addColumn({ type: 'string', id: 'Task' });
dataTable.addColumn({ type: 'date', id: 'Start' });
dataTable.addColumn({ type: 'date', id: 'End' });
// Get the Schedule Tasks that belong to this Project
<?php
$node = node_load(arg(1));
$project = node_load($node->og_group_ref[$node->language][0][
'target_id']);
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'oa_event')
->fieldCondition('og_group_ref', 'target_id', $project->nid);
$tasks = $query->execute();
foreach ($tasks['node'] as $tasknode) {
$node = node_load($tasknode->nid);
$label = $node->title;
$task = $node->title;
$start = $node->field_oa_date[$node->language][0]['value'];
$end = $node->field_oa_date[$node->language][0]['value2']; ?>
var label = "<?php echo $label;?>";
var name = "<?php echo $task;?>";
var start = "<?php echo date('Y, m, d', $start);?>";
var end = "<?php echo date('Y, m, d', $end);?>";
dataTable.addRows([[ label, name, new Date(start), new Date(end)
]]);
<?php
} ?>
var options = {
timeline: { singleColor: '#8d8' },
timeline: { rowLabelStyle: {fontWeight: 'bold' }},
avoidOverlappingGridLines: false,
};
chart.draw(dataTable);
}
</script>
<?php return '<div id="gantt" style="width: 100%; height: 100%"></div>';
}
Thanks!
--
You received this message because you are subscribed to the Google Groups
"Google Chart API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-chart-api.
For more options, visit https://groups.google.com/d/optout.