简体   繁体   English

如何自定义Google Geo Chart中的工具提示文本

[英]How customize tooltip text in Google Geo Chart

I need remove first empty string in tooltip. 我需要删除工具提示中的第一个空字符串。 I'm used formater, for change first string to '', but I'm can't remove it. 我使用了格式化程序,将第一个字符串更改为”,但是我无法将其删除。 If I change '' to null then in first string shows first column data. 如果我将''更改为null,则在第一个字符串中显示第一列数据。

在此处输入图片说明

Code: 码:

var data = new google.visualization.DataTable();
data.addColumn('string', 'State');
data.addColumn('number', 'TempNumber');
data.addColumn({
    type: 'string',
    role: 'tooltip'
});
data.addRows([
    ['Ohio', 0, 'Ohio'],
    ...
]);
var options = {
    width:      580,
    region:     'US',
    resolution: 'provinces',
    colorAxis:  {colors: ['#abb7df']},
    legend:     'none'
};
var chart = new google.visualization.GeoChart(document.getElementById('chart_div'));
var formatter = new google.visualization.PatternFormat('');
    formatter.format(data, [0,1,2]);

chart.draw(data, options);

Unfortunately there is no easy way to currently do this (without drawing your own tooltip function to draw the boxes). 不幸的是,目前尚没有简便的方法(无需绘制自己的工具提示功能来绘制框)。 In the future, hopefully they will implement isHtml: true to geocharts, but right now it isn't supported. 希望将来他们会实现isHtml:真正适用geocharts ,但目前不支持。

Tooltip cannot do what you want it to do in its current implementation. 工具提示无法在其当前实现中执行您想要的操作。 You can reduce text size, but that will also reduce the size of the text you want shown. 您可以减小文本大小,但是这也将减小要显示的文本大小。 You can change color, but again it affects the entire tooltip. 您可以更改颜色,但同样会影响整个工具提示。 There isn't really much you can do to fix the issue rather than implement your own form of tooltipping (creating a function that will take the column 0 value of whatever your mouse is over, and display it either in a separate in the page, or have it calculate where your mouse is and show it there). 除了解决您自己的形式的工具提示(创建一个将获取鼠标悬停在上方的第0列值并将其显示在页面中的单独值,或让它计算鼠标的位置并在那里显示它)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM