http://code.google.com/apis/chart/
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
// Create our data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'date');
data.addColumn('number', 'Views');
data.addColumn('number', 'People');
data.addRows([
<?php echo $analytics; ?>
]);
// …Run Code Online (Sandbox Code Playgroud) 如何将垂直轴设置为显示百分比,例如25%,50%,75%,100%?
我正在使用Google Visualization Geochart API创建国家/地区的地图.我提供ISO 3266-2国家细分代码并获得正确的结果.但是,在图表中将ISO 3266-2代码显示为标签是一种糟糕的用户体验.所以我想提供一个自定义标签.以此为例:
function drawVisualization() {
var data = google.visualization.arrayToDataTable([
['Country', 'Popularity'],
['DE-BY', 200],
['DE-NW', 500]
]);
var geochart = new google.visualization.GeoChart(
document.getElementById('visualization'));
geochart.draw(data, {width: 556, height: 347, region: 'DE', resolution: 'provinces'});
}
Run Code Online (Sandbox Code Playgroud)
[在Code Playground上试试]
我想提供'DE-BY'但是有'Bavaria'作为标签.虽然谷歌写了一个,但我必须使用ISO 3266-2代码
等值的英文文本(例如,"US-NJ"或"New Jersey")
是允许的,它是非常不可靠的,并不适用于'巴伐利亚'的例子.