Reputation: 537
I have created table with Google Chart API and I would like to align text in one of the columns to the right. I have been looking for solution to include bootstrap "text-right" class to this s but didnt find a lot of sources how to do that.
So after sorting it, I thought to share how to do that :)
Upvotes: 2
Views: 2830
Reputation: 61222
you can also add within the column definition...
data.addColumn({type: 'string', label: 'Address', p: {className: 'text-right'}});
Upvotes: 0
Reputation: 537
This is very simple. You need to use setColumnProperty() method of google.visualization.DataTable() object.
var data = new google.visualization.DataTable();
data.addColumn('string', 'First name');
data.addColumn('string', 'Last name');
data.addColumn('string', 'Address');
// add rows here like: data.addRow(['a', 'b', 'c']);
data.setColumnProperty(2, 'className', 'text-right');
First number is referring to which column is that. In my example First name is 0, Last name is 1, and Address is 2. So I'm adding class named 'text-right' to all s in the third column (Address).
Upvotes: 4