Basic HTML5 Chart Example - CanvasJS

Basic HTML5 Chart Example

HTML

<script src="http://canvasjs.com/assets/script/canvasjs.min.js"></script>
<script src="http://mrrio.github.io/jsPDF/dist/jspdf.debug.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<div id="report">
    <div id="chartContainer1" class="chartContainer">sss</div>
    <div id="chartContainer2" class="chartContainer">sss</div>
 <img src="http://albonsai.pt/images/artigos/2014/eventos/congressos/noelanders_trophy_2014/miniatura/AVencedora.JPG" alt="Smiley face" height="200" width="400">     
    <div id="customers">
        <table id="tab_customers" class="table table-striped">
            <colgroup>
                <col width="20%">
                    <col width="20%">
                        <col width="20%">
                            <col width="20%">
            </colgroup>
            <thead>
                <tr class='warning'>
                    <th>Country</th>
                    <th>Population</th>
                    <th>Date</th>
                    <th>Age</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Chinna</td>
                    <td>1,363,480,000</td>
                    <td>March 24, 2014</td>
                    <td>19.1</td>
                </tr>
                <tr>
                    <td>India</td>
                    <td>1,241,900,000</td>
                    <td>March 24, 2014</td>
                    <td>17.4</td>
                </tr>
                <tr>
                    <td>United States</td>
                    <td>317,746,000</td>
                    <td>March 24, 2014</td>
                    <td>4.44</td>
                </tr>
                <tr>
                    <td>Indonesia</td>
                    <td>249,866,000</td>
                    <td>July 1, 2013</td>
                    <td>3.49</td>
        ...

CSS

.chartContainer {
    width:50%;
    border: 20px solid #CCCCCC;
    box-sizing: border-box;
    float:down;
    height:300px;
}
#customers{clear:left}

JavaScript

function demoFromHTML() {
    //console.log(9);
    var pdf = new jsPDF('p', 'pt', 'letter');
    // source can be HTML-formatted string, or a reference
    // to an actual DOM element from which the text will be scraped.
    source = $('#report')[0];

    // we support special element handlers. Register them with jQuery-style 
    // ID selector for either ID or node name. ("#iAmID", "div", "span" etc.)
    // There is no support for any other type of selectors 
    // (class, of compound) at this time.
    specialElementHandlers = {
        // element with id of "bypass" - jQuery style selector
        '#bypassme': function (element, renderer) {
            // true = "handled elsewhere, bypass text extraction"
            return true
        }
    };
    margins = {
        top: 80,
        bottom: 60,
        left: 40,
        width: 522
    };
    // all coords and widths are in jsPDF instance's declared units
    // 'inches' in this case
    pdf.fromHTML(
    source, // HTML string or DOM elem ref.
    margins.left, // x coord
    margins.top, { // y coord
        'width': margins.width, // max width of content on PDF
        'elementHandlers': specialElementHandlers
    },

    function (dispose) {
        // dispose: object with X, Y of the last line add to the PDF 
        //          this allow the insertion of new lines after html
        pdf.save('Test.pdf');
    }, margins);
}


var chart = new CanvasJS.Chart("chartContainer1", {

    title: {
        text: "Fruits sold in First Quarter"
    },
    data: [ //array of dataSeries              
    { //dataSeries object

        /*** Change type "column" to "bar", "area", "line" or "pie"***/
        type: "column",
        dataPoints: [{
            label: "banana",
            y: 18
        }, {
            label: "orange",
            y: 29
        }, {
            label: "apple",
            y: 40
        }, {
            label: "mango",
            y: 34
        }, {
            label: "grape",
     ...