JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.1/Chart.min.js"></script>
<canvas id="graph1" width="300" height="300"></canvas>
<canvas id="graph2" width="250" height="250"></canvas>
<canvas id="graph3" width="250" height="250"></canvas>
<div id="buttons">
<button type ="button" class="btn btn-default btn-lg active" id="day">Day</button>
<button type="button" class="btn btn-default" id="week">Week</button>
<button type="button" class="btn btn-default" id="month">Month</button>
</div>
CSS
#graph1 {padding: 100px 10px 10px 50px;}
#graph2 {padding: 100px 10px 50px 50px;}
#graph3 {padding: 100px 10px 50px 50px;}
#buttons {position: absolute; top: 30px; right: 60px;}
#region-dropdown {position: absolute; top: 30px; left: 60px;}
#visit-text {position: absolute; top: 420px; left: 170px;}
#dwell-text {position: absolute; top: 420px; left: 470px;}
#frequency-text {position: absolute; top: 420px; right: 200px;}
JavaScript
window.onload = function() {init();}
function init() {
// Assign and Create all canvas contexts
var ctx = $("#graph1").get(0).getContext("2d");
var ctx2 = $("#graph2").get(0).getContext("2d");
var ctx3 = $("#graph3").get(0).getContext("2d");
// Retrieve all buttons
var dayButton = document.getElementById("day");
var weekButton = document.getElementById("week");
var monthButton = document.getElementById("month");
/*
Graph1 Data Generator
returns data used for line graph
@param type {String}: Can be either "day", "week", "month"
Eg format created:
{labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
{
label: "My Second dataset",
fillColor: "rgba(151,187,205,0.5)",
strokeColor: "rgba(151,187,205,0.8)",
highlightFill: "rgba(151,187,205,0.75)",
highlightStroke: "rgba(151,187,205,1)",
data: [28, 48, 40, 19, 86, 27, 90]
}]
}
*/
function graph1Generator(type){
if (type == "day"){
var graph1data = Object.create(null)
graph1data.labels = ["8:00AM", "9:00AM", "10:00AM", "11:00AM", "12:00PM", "1:00PM", "2:00PM", "3:00PM", "4:00PM", "5:00PM"];
graph1data.datasets = [];
graph1data.datasets.push(Object.create(null));
graph1data.datasets[0].label = "My second dataset";
graph1data.datasets[0].fillColor = "rgba(151,187,205,0.5)";
graph1data.datasets[0].strokeColor = "rgba(151,187,205,0.8)";
graph1data.datasets[0].highlightFill = "rgba(151,187,205,0.75)";
graph1data.datasets[0].data = [28,48,40, 19, 86, 27, 90, 66, 20, 10];
return graph1data;
} else if (type == "week") {
var graph1data = Object.create(null)
graph1data.labels = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thrusday", "Friday", "Saturday"];
graph1data.datasets = [];
graph1data.datasets.push(Object.create(null));
graph1data.datasets[0].label = "My second dataset";
graph1data.datasets[0].fillColor =...