Documentation
- Getting Started
- Installation
- Key Concepts
- Integrations
- Account & Billing
- Security & Privacy
- PDF Generation
- Reference
- Tutorials
- Troubleshooting
- Excel Generation
- Reference
- Troubleshooting
Code Example: Google Charts Pie Chart
Here's a functioning code example of how to make a PDF that uses a Google Chart Pie Chart:
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.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'
};
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, options);
}
</script>
<script type="text/javascript">
var didWait = false;
// DocRaptor polls docraptorJavaScriptFinished until it is true
docraptorJavaScriptFinished = function() {
if (! didWait) {
setTimeout(function(){
didWait = true;
}, 10000);
return false;
}
document.body.appendChild(document.createTextNode("JavaScript inserted this text."));
return true;
}
</script>
</head>
<body>
This is an example Google Charts Pie Chart.
<div id="piechart" style="width: 900px; height: 500px;"></div>
</body>
</html>