how to center data in google charts table that is

2019-08-07 07:58发布

I am using the table in google charts. All of the data in the table is aligned right. I need to align the text in the center. I am building the table dynamically so I cannot apply the set cell method:

 data.setCell(1, 1, 25000, '$25,000', {'className': 'bold-font center-text'});

I would like to apply the class name without applying the 25000 and $25000 values. Something like:
data.setCell(1, 1, '', '', {'className': 'bold-font center-text'});

I also don't want to apply this just to the first cell but entire table.

In conclusion, how do I center all of the text in a table?

1条回答
甜甜的少女心
2楼-- · 2019-08-07 09:03

add custom css

add this code to your page

<style>
.google-visualization-table-td {
text-align: center !important;
}
</style>

"!important" is necessary to override google's left/right align for number/text.

查看更多
登录 后发表回答