I would like to create color groups for bars. The example below is unprocessed. I would like to add a column with the category type, and based on this category I will color the panel.
Something like:
Column
dataTable.addColumn({ type: 'string', id: 'Category' });
Line
[ 'GROUP #1', 'CategoryA', 'C00001', new Date(2014, 0, 1), new Date(2014, 0, 31) ], [ 'GROUP #1', 'CategoryA', 'C00002', new Date(2014, 1, 1), new Date(2014, 1, 28) ], [ 'GROUP #1', 'CategoryA', 'C00003', new Date(2014, 3, 1), new Date(2014, 3, 15) ], [ 'GROUP #1', 'CategoryB', 'C00003', new Date(2014, 0, 21), new Date(2014, 2, 19) ], [ 'GROUP #1', 'CategoryA', 'C00004', new Date(2014, 0, 1), new Date(2014, 0, 15) ], [ 'GROUP #2', 'CategoryC', 'C00005', new Date(2014, 2, 8), new Date(2014, 2, 15) ], [ 'GROUP #3', 'CategoryC', 'C00006', new Date(2014, 5, 1), new Date(2014, 5, 15) ], [ 'GROUP #4', 'CategoryA', 'C00007', new Date(2014, 1, 15), new Date(2014, 1, 25) ]]);
Based on the category, the panel should have a specific color.
Fiddle
google.load("visualization", "1", {packages: ["timeline"]}); google.setOnLoadCallback(drawChart); function drawChart() { var container = document.getElementById('example4.2'); var chart = new google.visualization.Timeline(container); var dataTable = new google.visualization.DataTable(); dataTable.addColumn({ type: 'string', id: 'Group' }); dataTable.addColumn({ type: 'string', id: 'ID' }); dataTable.addColumn({ type: 'date', id: 'Start' }); dataTable.addColumn({ type: 'date', id: 'End' }); dataTable.addRows([ [ 'GROUP #1', 'C00001', new Date(2014, 0, 1), new Date(2014, 0, 31) ], [ 'GROUP #1', 'C00002', new Date(2014, 1, 1), new Date(2014, 1, 28) ], [ 'GROUP #1', 'C00003', new Date(2014, 3, 1), new Date(2014, 3, 15) ], [ 'GROUP #1', 'C00003', new Date(2014, 0, 21), new Date(2014, 2, 19) ], [ 'GROUP #1', 'C00004', new Date(2014, 0, 1), new Date(2014, 0, 15) ], [ 'GROUP #2', 'C00005', new Date(2014, 2, 8), new Date(2014, 2, 15) ], [ 'GROUP #3', 'C00006', new Date(2014, 5, 1), new Date(2014, 5, 15) ], [ 'GROUP #4', 'C00007', new Date(2014, 1, 15), new Date(2014, 1, 25) ]]); var rowHeight = 41; var chartHeight = (dataTable.getNumberOfRows() + 1) * rowHeight; var options = { timeline: { groupByRowLabel: true, rowLabelStyle: { fontName: 'Roboto Condensed', fontSize: 14, color: '#333333' }, barLabelStyle: { fontName: 'Roboto Condensed', fontSize: 14 } }, avoidOverlappingGridLines: true, height: chartHeight, width: '100%' }; chart.draw(dataTable, options); }