We have Javascript that will produce a chart from a table of data within the code.
We are looking to use Cognos to automate the process of pulling the data. Essentially we want to use a list within Report Studio to populate the table section of the below Javascript code.
We tried adding a HTML item before and after a list with the code that is before and after the table, and the page populates as blank.
Any help would be appreciated. Thank you
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load("current", {packages:["timeline"]});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var container = document.getElementById('example5.1');
var chart = new google.visualization.Timeline(container);
var dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'string', id: 'Room' });
dataTable.addColumn({ type: 'string', id: 'Name' });
dataTable.addColumn({ type: 'date', id: 'Start' });
dataTable.addColumn({ type: 'date', id: 'End' });
dataTable.addRows([
['Job1', '', new Date(0,0,0,18,0,0), new Date(0,0,0,18,0,1) ],
['Job2', '', new Date(0,0,0,18,3,0), new Date(0,0,0,18,3,7) ],
['Job3', '', new Date(0,0,0,17,30,0), new Date(0,0,0,18,0,39) ],
['Job4', '', new Date(0,0,0,18,0,0), new Date(0,0,0,18,10,19) ],
['Job5', '', new Date(0,0,0,18,0,0), new Date(0,0,0,18,0,22) ]
]);
var options = {
timeline: { colorByRowLabel: true }
};
chart.draw(dataTable, options);
}
</script>
<div id="example5.1" style="height: 500px;" style="width: 100px;"></div>