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

后端 未结 7 1730
说谎
说谎 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:09

    You have to put the role style on the middle of the array. it must be on the middle for it to work. I have tried pushing it on the end of my array and it did not work.

    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: 'Category' });
        dataTable.addColumn({ type: 'string', role: 'style' });      <===========
        dataTable.addColumn({ type: 'date', id: 'Start' });
        dataTable.addColumn({ type: 'date', id: 'End' });
    }
    

提交回复
热议问题