在下面给出的给出的例子中
http://code.google.com/apis/chart/interactive/docs/gallery/geochart.html#Example
当我将鼠标放在工具提示中的区域时,会显示人口和区域 有没有办法只显示这些变量中的任何一个(人口或区域)
function drawMarkersMap() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'City');
data.addColumn('number', 'Population');
data.addColumn('number', 'Area');
data.addRows([
['Rome', 2761477, 1285.31],
['Milan', 1324110, 181.76],
['Naples', 959574, 117.27],
['Turin', 907563, 130.17],
['Palermo', 655875, 158.9],
['Genoa', 607906, 243.60],
['Bologna', 380181, 140.7],
['Florence', 371282, 102.41]
]);
var options = {
region: 'IT',
displayMode: 'markers',
colorAxis: {colors: ['green', 'blue']}
};
var chart = new google.visualization.GeoChart(document.getElementById('chart_div'));
chart.draw(data, options);
};
答案 0 :(得分:0)
试试这个未经测试的
function drawMarkersMap() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'City');
data.addColumn('number', 'Population');
data.addRows([
['Rome', 2761477],
['Milan', 1324110],
['Naples', 959574],
['Turin', 907563],
['Palermo', 655875],
['Genoa', 607906],
['Bologna', 380181],
['Florence', 371282]
]);
var data1 = new google.visualization.DataTable();
data.addColumn('string', 'City');
data.addColumn('number', 'Area');
data.addRows([
['Rome', 1285.31],
['Milan', 181.76],
['Naples', 117.27],
['Turin', 130.17],
['Palermo', 158.9],
['Genoa', 243.60],
['Bologna', 140.7],
['Florence', 102.41]
]);
var options = {
region: 'IT',
displayMode: 'markers',
colorAxis: {colors: ['green', 'blue']}
};
if(condition1){
var chart = new google.visualization.GeoChart(document.getElementById('chart_div'));
chart.draw(data, options);
} else{
var chart = new google.visualization.GeoChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
};
答案 1 :(得分:0)
看看我对另一个类似问题here的回答。这是应用模式格式化器然后为数据创建单独视图的问题。