我的数据表:
Country Types of sales Total sales($) Name State
United states of America chemicals 12662871 Obama GA
United states of America electronics 20145684 Romney ON
United states of America textiles 22458756 Gliton MB
United states of America automobiles 34235684 Andrew Jackson BC
United states of America chemicals 19438333 James Madison AB
而不是给状态列,如果我给名称列,该名称也绘制在地理图表中,就像在附件文件中一样。
仅当 displayMode 为 Marker 时才会发生这种情况。
Javascript代码:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Google Visualization API Sample</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
function drawMarkersMap() {
var data = google.visualization.arrayToDataTable([
['Name', 'Total Sales'],
['Romney', 20145684],
['Obama', 12662871],
['Gliton', 22458756],
['Andrew Jackson', 34235684],
['James Madison', 19438333]
]);
var options = {
region: 'US',
resolution: 'provinces',
displayMode:'markers',
width: 400,
height: 400,
colorAxis: {
//values: [-1, 0, 1],
colors: ['#FF0000']
}
};
var geochart = new google.visualization.GeoChart(document.getElementById('visualization'));
geochart.draw(data, options);
google.visualization.events.addListener(geochart, 'select', function (eventOption) {
var item = geochart.getSelection();
var value = data.getValue(item[0].row, 1);
alert(value);
});
}
google.load('visualization', '1', { packages: ['geochart'] });
google.setOnLoadCallback(drawMarkersMap);
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="visualization"></div>
</body>
</html>
请提供解决方案来解决它。
提前致谢。