1 {% extends "base.html" %}
6 <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
8 function drawGraph(data, graph_id, graph_title){
9 var container = document.getElementById(graph_id);
10 var plot_data = { x: data[0],
19 Plotly.newPlot(container, [plot_data], layout);
22 var req = new XMLHttpRequest();
23 var url = "/booking/stats/json";
24 var day_input = document.getElementById("number_days");
25 var days = day_input.value;
26 //var days = document.getElementById("number_days").value;
28 url = url + "?days=" + days;
30 req.onreadystatechange = function(){
31 if( req.readyState == XMLHttpRequest.DONE) {
32 var data = JSON.parse(req.responseText);
33 drawGraph(data["booking"], "booking_graph_container", "Active Bookings");
34 drawGraph(data["user"], "user_graph_container", "Active Users");
37 req.open("GET", url, true);
44 <p>Number of days to plot: </p>
45 <input id="number_days" type="number" min="1" step="1"/>
46 <button onclick="getData();">Submit</button>
47 <div id="all_graph_container">
48 <div id="booking_graph_wrapper">
49 <div id="booking_graph_container"/>
51 <div id="user_graph_wrapper" >
52 <div id="user_graph_container"/>
56 var data = {{data|safe}};
57 drawGraph(data["booking"], "booking_graph_container", "Active Bookings");
58 drawGraph(data["user"], "user_graph_container", "Active Users");
60 {% endblock content %}