Color in Google's Timeline Chart bars based in the a specific value

后端 未结 7 1728
说谎
说谎 2021-01-02 01:31

I would like to create groups of colors for the bars. The example below is raw. I would like to add a column with a category type, and based on that category I will color th

7条回答
  •  鱼传尺愫
    2021-01-02 02:20

    I have tried something like this and it worked and was able to set different colors to different row labels in the grid.

    var dataTable = new google.visualization.DataTable();
    dataTable.addColumn({ type: 'string', id: 'Name' });
    dataTable.addColumn({ type: 'string', id: 'ShiftDetails' });
    dataTable.addColumn({ type: 'string', role: 'style' });
    dataTable.addColumn({ type: 'date', id: 'Start' });
    dataTable.addColumn({ type: 'date', id: 'End' });
    dataTable.addColumn({ type: 'string', role: 'RowDetails' });
    dataTable.addRows([['APHANEE WORARUCHEE','','',new Date(0,0,0,0,0,0),new 
    Date(0,0,0,18,0,0),'asdf'],
    ['CHEW SEOW LEE','','',new Date(0,0,0,0,0,0),new Date(0,0,0,9,0,0),'qwerty'],['TOTAL 
    MANPOWER PER HOUR','5','color: red',new Date(0,0,0,0,0,0),new 
    Date(0,0,0,1,0,0),'TOTAL'], 
    ['TOTAL MANPOWER PER HOUR','4','color: red',new Date(0,0,0,1,0,0),new 
    Date(0,0,0,2,0,0),'TOTAL']]);
    
    var options = {
    timeline: { singleColor: '#8d8', barLabelStyle: { fontName: 'Arial Black', fontSize: 
    12 } },backgroundColor: '#ffd'};
    

提交回复
热议问题