javascript - Google Charts: How to create tables with grouped columns names? -
i'm trying create table google charts data in column names placed in higher-level column name readability.
in example, move "group 1" , "group 2" 'higher' level; left table end right table.
i've read through documentation , haven't found reference this. possible? if yes, approach? thanks.
what (uses jquery), can modify own custom needs:
https://jsfiddle.net/7tq6sdwc/
google.setonloadcallback(drawtable); function drawtable() { var data = new google.visualization.datatable(); data.addcolumn('string', 'name'); data.addcolumn('number', 'salary'); data.addcolumn('boolean', 'full time employee'); data.addrows([ ['mike', {v: 10000, f: '$10,000'}, true], ['jim', {v:8000, f: '$8,000'}, false], ['alice', {v: 12500, f: '$12,500'}, true], ['bob', {v: 7000, f: '$7,000'}, true] ]); var table = new google.visualization.table(document.getelementbyid('table_div')); table.draw(data, {showrownumber: true, width: '100%', height: '100%'}); var tablehead ='<tr class="google-visualization-table-tr-head"><th class="google-visualization-table-th gradient unsorted" colspan="4">my header</th></tr'; var stuff = jquery('#table_div').find('thead').prepend(tablehead); }
result:
Comments
Post a Comment