﻿
$(document).ready(function () {
    google.setOnLoadCallback(drawCharts);

    function drawCharts() {
        drawChart();
        drawDailyDurationChart();
    }

    function drawDailyDurationChart() {
        var elem = $('#daily_duration_chart');
        var dates = elem.attr('data-dates').split(';');
        var times = elem.attr('data-times').split(';');

        var data = [['Date', 'Duration']];
        dates.forEach(function (date, index, _) {
            var time = parseInt(times[index]);
            data.push([date, time]);
        });

        var dataTable = google.visualization.arrayToDataTable(data);
        var options = {
            title: 'Average Daily Duration',
            curveType: 'function',
            legend: { position: 'bottom' }
        };

        var chart = new google.visualization.LineChart(elem.get(0));
        chart.draw(dataTable, options);
    }

    function drawChart() {
        var data = google.visualization.arrayToDataTable([
            ['Date', 'Duration'],
            ['2010-10-1', 1000],
            ['2010-10-2', 2000],
            ['2010-10-3', 1500],
        ]);

        var options = {
            title: 'Company Performance',
            curveType: 'function',
            legend: { position: 'bottom' }
        };

        var elem = $('#curve_chart').get(0);
        var chart = new google.visualization.LineChart(elem);

        chart.draw(data, options);
    }
});

@@ -60,79 +60,8 @@
 ack(
-drawCharts);%0A%0A    function drawCharts() %7B%0A        drawChart();%0A        
 draw
@@ -82,17 +82,10 @@
 hart
-(
 );
-%0A    %7D
 %0A%0A  
@@ -818,546 +818,8 @@
    %7D
-%0A%0A    function drawChart() %7B%0A        var data = google.visualization.arrayToDataTable(%5B%0A            %5B'Date', 'Duration'%5D,%0A            %5B'2010-10-1', 1000%5D,%0A            %5B'2010-10-2', 2000%5D,%0A            %5B'2010-10-3', 1500%5D,%0A        %5D);%0A%0A        var options = %7B%0A            title: 'Company Performance',%0A            curveType: 'function',%0A            legend: %7B position: 'bottom' %7D%0A        %7D;%0A%0A        var elem = $('#curve_chart').get(0);%0A        var chart = new google.visualization.LineChart(elem);%0A%0A        chart.draw(data, options);%0A    %7D
 %0A%7D);

Remove the demo chart