gpt4 book ai didi

javascript - 如何自定义 Google Visualization Geochart 工具提示

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:34:16 29 4
gpt4 key购买 nike

我有以下 Google Geochart(也可在 JSFiddle Here 上获得)

我需要做什么来消除工具提示中的额外间距:

enter image description here

<html>
<head>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', {'packages': ['geochart'],'callback': drawVisualization});

function drawVisualization() {

var data = new google.visualization.DataTable();
data.addColumn('number', 'latitude');
data.addColumn('number', 'longitude');
data.addColumn('string', 'Country');
data.addColumn('number', 'Fans');
data.addColumn({type: 'string',role: 'tooltip'});
data.addRow([14.38, -90.33, '', 229, 'Guatemala City!']);
data.addRow([38.8339, -104.8214, '', 500, 'Colorado Springs!']);

var options = {};
var chart = new google.visualization.GeoChart(document.getElementById('my_chart'));
chart.draw(data, options);

};

</script>
</head>
<body>
<div id="my_chart" style="width: 100%; height: 100%; "></div>
</body>
</html>

最佳答案

完成了

工作 fiddle

http://jsfiddle.net/maL943us/6/

 google.load('visualization', '1', {
'packages': ['geochart'],
'callback': drawVisualization
});


function drawVisualization() {

var data = new google.visualization.DataTable();
data.addColumn('number', 'latitude');
data.addColumn('number', 'longitude');
data.addColumn('string', 'Country');

data.addColumn('number', 'Fans');
data.addColumn({
type: 'string',
role: 'tooltip',
'p': {'html': true}//added html version
});
data.addRow([14.38, -90.33, '', 229, 'Guatemala City!']);//added div tag with inline style
data.addRow([38.8339, -104.8214, '', 500, '<div style="background-color:yellow;margin:0; padding:0;">Colorado Springs!</div>']);

var options = {tooltip: {isHtml: true}};//added html version

var chart = new google.visualization.GeoChart(document.getElementById('col_chart_html_tooltip'));
chart.draw(data, options);

};

html

<div id='col_chart_html_tooltip'></div>

CSS(使用 !important 覆盖自定义工具提示样式)

.google-visualization-tooltip {
border:solid 1px #000!important;
border-radius: 2px;
background-color: white;
position: absolute;
font-size: 12px;
padding: 0px;
margin:0!important;
}
.google-visualization-tooltip-item-list {
list-style-type: none;
margin: 0!important;
padding: 0!important;
}

.google-visualization-tooltip-item:first-child {
margin: 0!important;
}
.google-visualization-tooltip-item {
margin: 0!important;
padding: 0!important;
}

关于javascript - 如何自定义 Google Visualization Geochart 工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26153005/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com