Я хочу отобразить гистограмму с помощью API визуализации Google. Я следил за примером кода в этой теме: https://vaadin.com/forum/#!/thread/2971952/
Вот мой код:
GVis.java
@JavaScript({
"http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js",
"gvis.js",
"gvis-connector.js" })
public class GVis extends AbstractJavaScriptComponent {}
gvis.js
var gvis = gvis || {};
gvis.GVis = function(element) {
this.element = element;
this.element.innerHTML = "<div id='chart_div' style='height:500px; width:500px;'></div>";
var oldDocumentWrite = document.write;
// change document.write temporary
document.write = function(node) {
$("body").append(node);
};
$(function() {
window.initialize = function() {
google.setOnLoadCallback(drawVisualization);
setTimeout(function() {
document.write = oldDocumentWrite;
}, 100);
function drawVisualization() {
// Create and populate the data table.
var data = google.visualization.arrayToDataTable([
[ 'Year', 'Austria', 'Bulgaria', 'Denmark', 'Greece' ],
[ '2003', 1336060, 400361, 1001582, 997974 ],
[ '2004', 1538156, 366849, 1119450, 941795 ],
[ '2005', 1576579, 440514, 993360, 930593 ],
[ '2006', 1600652, 434552, 1004163, 897127 ],
[ '2007', 1968113, 393032, 979198, 1080887 ],
[ '2008', 1901067, 517206, 916965, 1056036 ] ]);
// Create and draw the visualization.
new google.visualization.BarChart(document
.getElementById("chart_div")).draw(data, {
title : "Yearly Coffee Consumption by Country",
width : 100,
height : 100,
vAxis : {
title : "Year"
},
hAxis : {
title : "Cups"
}
});
}
};
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://www.google.com/jsapi?autoload=%7B%22modules%22%3A%5B%7B%22name%22%3A%22visualization%22%2C%22version%22%3A%221%22%2C%22packages%22%3A%5B%22corechart%22%2C%22table%22%5D%7D%5D%7D&'
+ 'callback=initialize';
document.body.appendChild(script);
});
};
gvis-connector.js
window.com_andrebruch_chartframework_chartapis_googlecharts_GVis = function() {
var gVis = new gvis.GVis(this.getElement());
this.onStateChange = function() {};
};
Код загружает эти два файла:
ui + de, table + de.css
<link href="https://www.google.com/uds/api/visualization/1.0/dee027d0b48a2e0a0a0375d00d7dd635/ui+de,table+de.css" type="text/css" rel="stylesheet">
format + de, по умолчанию + de, ui + de, table + de, corechart + de.I.js
<script src="https://www.google.com/uds/api/visualization/1.0/dee027d0b48a2e0a0a0375d00d7dd635/format+de,default+de,ui+de,table+de,corechart+de.I.js" type="text/javascript"></script>
Но диаграмма не отображается и исключений JS нет.
Я использую Vaadin 7.2.5
Заранее спасибо!
com.andrebruch.chartframework.chartapis.googlecharts
, например GVis.java. - person andbruch   schedule 14.08.2014