Google可视化表:显示完整列标签

时间:2013-11-15 18:40:28

标签: charts google-visualization

我创建了一个包含谷歌图表的表格,即使用google.visualization.Table,同样的列标题是HR,BR等等。

例如
{COLS:[{ID: 'A',标签: '',类型: '字符串'},         {ID: 'B',标签: 'IMP',类型: '编号'}]}

因为我的实际代码中有很多列,所以我缩写了它们,但是当我将鼠标悬停在它上面时,我需要显示完整的列名。有什么想法可以解决它吗?

2 个答案:

答案 0 :(得分:1)

您可以在标签字段中使用html - 例如:

<span title='Full label'>b</span>

“完整标签”将在鼠标悬停时显示为工具提示。

答案 1 :(得分:0)

Visualization API表格可视化不允许您将任何元数据与列标题相关联,因此您必须找到标题单元格并使用其内容查找全名。你可以使用这样的东西来帮助你入门:

google.visualization.events.addListener(myTable, 'ready', function () {
    var headerCells = document.querySelectorAll('#my_table_div .google-visualization-table-th');
    // loop over headerCells and use contents of cells to find the full name
    // note that the headerCells will contain a <span> element for the sort arrows, if sorting is enabled
});

在创建Table对象之后但在绘制之前插入事件侦听器。