JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdn.firebase.com/js/client/2.2.2/firebase.js"></script>
<h1>Referral Tracker Charts & Graphs</h1>
<div>See below for most recent data</div>
<div style="padding:25px 25px">
Filter by: <select id="fltr">
<option value="">All</option>
</select>
</div>
<table id="monthly-by-doc" width="100%" border="1">
<caption>Monthly Breakdown</caption>
<thead>
<tr>
<th colspan="2" id="mymbd" rowspan="2" width="20%">Month, Year</th>
<th colspan="6" id="bdmbd">By Doctor</th>
</tr>
<tr id="mbd-heading-row">
<th>Gary Hoffman</th>
<th>Eiman Firoozmand</th>
<th>Liza Capiendo</th>
<th>Stephen Yoo</th>
<th>Alan Kamrava</th>
<th>TOTAL</th>
</tr>
</thead>
<tbody></tbody>
</table>
<br/>
<br/>
<table id="monthly-by-channel" width="100%" border="1">
<thead>
<tr>
<th colspan="2" id="mymbc" rowspan="2" width="20%">Month, Year</th>
<th colspan="7" id="bdmbc">By Online Channel</th>
</tr>
<tr id="mbc-heading-row">
<th>Google</th>
<th>Bing</th>
<th>Yahoo</th>
<th>Yelp</th>
<th>Cedars</th>
<th>Other</th>
<th>TOTAL</th>
</tr>
</thead>
<tbody></tbody>
</table>
JavaScript
var fbEntries = new Firebase("https://torrid-torch-4323.firebaseio.com/entries");
var year = [2017, 2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009];
var month = [12, 11, 10, 09, 08, 07, 06, 05, 04, 03, 02, 01];
var getYearMonth = [];
var monthWords = ["Dec", "Nov", "Oct", "Sept", "Aug", "July", "June", "May", "Apr", "March", "Feb", "Jan"];
var source = ["Physician", "Friend", "Lapeer", "Insurance", "Internet", "Saban", "Other"];
var channel = ["Google", "Bing", "Yahoo", "Yelp", "Cedars", "Other"];
var doc = ["Gary H. Hoffman, MD", "Eiman Firoozmand, MD", "Liza M. Capiendo, MD", "Stephen Yoo, MD", "Allen Kamrava, MD"];
var docInitials = ["gh", "ef", "lc", "sy", "ak"];
var monthlyByDoc = {};
var monthlyBySource = {};
var monthlyByChannel = {};
var breakdownBySource = {};
var breakdownByChannel = {};
var totals = {};
function reInitVars() {
monthlyByDoc = {
gh: {},
ef: {},
lc: {},
sy: {},
ak: {},
total: {}
};
monthlyBySource = {
Physician: {},
Friend: {},
Lapeer: {},
Insurance: {},
Internet: {},
Saban: {},
Other: {},
total: {}
};
monthlyByChannel = {
Google: {},
Bing: {},
Yahoo: {},
Yelp: {},
Cedars: {},
Other: {},
total: {}
};
breakdownBySource = {
Physician: {},
Friend: {},
Lapeer: {},
Insurance: {},
Internet: {},
Saban: {},
Other: {},
total: {}
};
breakdownByChannel = {
Google: {},
Bing: {},
Yahoo: {},
Yelp: {},
Cedars: {},
Other: {},
total: {}
};
totals = {
byDoc: 0,
bySource: 0,
byChannel: 0
};
}
function parseMyData(fbobj) {
for (var patient in fbobj) {
var getDoc = fbobj[patient]["doctor"]
var getSource = fbobj[patient]["source"]
var getChannel = fbobj[patient]["channel"]
...