Graph ils: Date.prototype.addHours = function(h) { this.setHours(this.getHours() + h); return this; }; function getData(trans

Graph ils: Date.prototype.addHours = function(h) { this.setHours(this.getHours() + h); return this; }; function getData(trans,graph,linechart,nvd3.js,Graph,Linechart,Nvd3.js,ils: Date.prototype.addHours = function(h) { this.setHours(this.getHours() + h); return this; }; function getData(transport) { var arr = []; for (var i = 0; i < transport.length; i++) { arr.push({ x : new Date(

ils:
Date.prototype.addHours = function(h) {
    this.setHours(this.getHours() + h);
    return this;
};

function getData(transport) {
    var arr = [];
    for (var i = 0; i < transport.length; i++) {
        arr.push({
            x : new Date(transport[i].timePeriod).addHours(7),
            y : transport[i].number
        });
    }
    return arr;
}

function cumulativeTestData(transport) {

    return [{
        key : "Active Customers",
        values : getData(transport),
        color : "#ff7f0e"
    }];
}

nv.addGraph(function() {
    var chart;
    chart = nv.models.lineChart().x(function(d) {
        return d.x;
    }).y(function(d) {
        return d.y;
    });

    chart.xAxis.tickFormat(function(d) {
        return d3.time.format("%d-%m-%y")(new Date(d));
    });

    chart.yAxis.tickFormat(d3.format(',g'));
    d3.select('#chart1 svg').datum(cumulativeTestData(transport))
    //  .transition().duration(500)
    .call(chart);

    nv.utils.windowResize(chart.update);
    chart.dispatch.on('stateChange', function(e) {
        nv.log('New State:', JSON.stringify(e));
    });

    return chart;
});

$(function() {
    $("#day").click(function() {
        var from = $("#from").val();
        var to = $("#to").val();
        $.ajax({
            url : "http://api.local/api/GraphData?startDate=" + from + "&endDate=" + to,
            type : 'GET',
            contentType : "application/javascript",
            crossDomain : true,
            dataType : "jsonp",
            cache : false,
            async : false,
            success : function(transport) {
                //  nv.addGraph(drawGraph(transport));
                drawGraph(transport);
            },
            error : function() {
                alert("failed in calling status");
            }
        });
    });
});
chart = nv.models.lineChart().x(function(d) {
        return d.x;
    }).y(function(d) {
        return d.y;
    });
chart.xAxis.tickFormat(function(d) {
        return d3.time.format("%d-%m-%y")(new Date(d));
    });
data = [{
    "values" : [{
        "x" : 1025409600000,
        "y" : 0
    }, {
        "x" : 1028088000000,
        "y" : 0.09983341664682815
    }, {
        "x" : 1030766400000,
        "y" : 0.19866933079506122
    }, {
        "x" : 1033358400000,
        "y" : 0.29552020666133955
    }, {
        "x" : 1036040400000,
        "y" : 0.3894183423086505
    }],
    "key" : "Line 1",
    "color" : "#ff7f0e"
}, {
    "values" : [{
        "x" : 1025409600000,
        "y" : 0.5
    }, {
        "x" : 1028088000000,
        "y" : 0.4975020826390129
    }, {
        "x" : 1030766400000,
        "y" : 0.4900332889206208
    }, {
        "x" : 1033358400000,
        "y" : 0.477668244562803
    }, {
        "x" : 1036040400000,
        "y" : 0.46053049700144255
    }],
    "key" : "Line 2",
    "color" : "#2ca02c"
}]