DocRaptor Home

PDF Code Examples

Code Example: Google Charts Bar Chart

Here's a functioning code example of how to make a PDF that uses a Google Chart Bar Chart:

    <script type="text/javascript" src=""></script>
      var didWait = false;
      docraptorJavaScriptFinished = function() {
        return didWait;

      google.charts.load('current', {packages: ['corechart', 'bar']});

      function drawBasic() {

        var data = google.visualization.arrayToDataTable([
          ['City', '2010 Population',],
          ['New York City, NY', 8175000],
          ['Los Angeles, CA', 3792000],
          ['Chicago, IL', 2695000],
          ['Houston, TX', 2099000],
          ['Philadelphia, PA', 1526000]

        var options = {
          title: 'Population of Largest U.S. Cities',
          chartArea: {width: '50%'},
          hAxis: {
            title: 'Total Population',
            minValue: 0
          vAxis: {
            title: 'City'

        var chart = new google.visualization.BarChart(document.getElementById('chart'));, 'ready', function(){
          didWait = true;

        chart.draw(data, options);
    <div id="chart" style="width: 500px; height: 400px;"></div>

Ready to get started? Try DocRaptor for free with unlimited test documents.