Answer the question
In order to leave comments, you need to log in
How to load second page in div that uses api?
Here I am trying to fasten the chart using JS and API from goole. I take an example from here .
But the task is a bit non-trivial, I immediately show what I have.
There is a first file
1.html:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function(){
$('#graf').load('2.html');
});
</script>
<div id='graf'></div>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="./js/jquery.js"></script>
</head>
<script type="text/javascript">
google.load("visualization", "1.1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['Work', 11],
['Eat', 2],
['Commute', 2],
['Watch TV', 2],
['Sleep', 7]
]);
var options = {
title: 'My Daily Activities',
is3D: true,
};
var chart = new google.visualization.PieChart(document.getElementById('statistic'));
chart.draw(data, options);
}
</script>
<body>
<div id='statistic'></div>
</body>
</html>
<html>
<head>
<script src="https://www.google.com/uds/?file=visualization&v=1.1&packages=corechart" type="text/javascript"></script>
<link href="https://www.google.com/uds/api/visualization/1.1/737afc8ce041665a74b6490aec432568/ui+ru.css" type="text/css" rel="stylesheet">
<script src="https://www.google.com/uds/api/visualization/1.1/737afc8ce041665a74b6490aec432568/webfontloader,format+ru,default+ru,ui+ru,corechart+ru.I.js" type="text/javascript">
</script>
</head>
</html>
Uncaught ReferenceError: google is not defined
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question