如何将数据动态地集中在Google图表表格中 [英] how to center data in google charts table that is dynamically

查看:72
本文介绍了如何将数据动态地集中在Google图表表格中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google图表中的表格。表格中的所有数据均正确对齐。我需要将文本居中对齐。我正在动态建立表格,因此无法套用set cell方法:

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'});

我想应用类名而不应用25000和$ 25000值。像这样的东西:

data.setCell(1,1,'',``,{'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?

推荐答案

添加自定义CSS

将此代码添加到您的页面

add this code to your page

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

!important对于覆盖Google的数字/文本左/右对齐方式是必需的。

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

这篇关于如何将数据动态地集中在Google图表表格中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆