JSFiddle - React, Tailwind, and code Playground

by bobbyrne01

HTML

<script src="http://people.iola.dk/olau/flot/jquery.flot.js"></script>
<script src="http://www.2general.com/blog/2012/05/30/flot_stacked_bar_chart/jquery.flot.stack.patched.js"></script>
<div id="content">
    <div class="demo-container">
        <div id="placeholder" class="demo-placeholder"></div>
    </div>
    <div id="chartLegend"></div>
</div>

CSS

#content {
	width: 880px;
	margin: 0 auto;
	padding: 10px;
}

.demo-container {
	box-sizing: border-box;
	width: 850px;
	height: 450px;
	padding: 20px 15px 15px 15px;
	margin: 15px auto 30px auto;
	border: 1px solid #ddd;
	background: #fff;
	background: linear-gradient(#f6f6f6 0, #fff 50px);
	background: -o-linear-gradient(#f6f6f6 0, #fff 50px);
	background: -ms-linear-gradient(#f6f6f6 0, #fff 50px);
	background: -moz-linear-gradient(#f6f6f6 0, #fff 50px);
	background: -webkit-linear-gradient(#f6f6f6 0, #fff 50px);
	box-shadow: 0 3px 10px rgba(0,0,0,0.15);
	-o-box-shadow: 0 3px 10px rgba(0,0,0,0.1);
	-ms-box-shadow: 0 3px 10px rgba(0,0,0,0.1);
	-moz-box-shadow: 0 3px 10px rgba(0,0,0,0.1);
	-webkit-box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

.demo-placeholder {
	width: 100%;
	height: 100%;
	font-size: 14px;
	line-height: 1.2em;

JavaScript

(function ($) {
     text = '[{"name":"team1.txt","points":[[1389340501000,10],[1389370501000,10],[1389873602000,null],[1390046402000,9],[1390078402000,9]]},{"name":"team2.txt","points":[[1389370501000,1],[1389441601000,14],[1389528002000,11]]},{"name":"team6.txt","points":[[1389370501000,7],[1389441601000,9],[1389441601000,12]]}]';
     alert(text);
     var t = JSON.parse(text);
     var n = [];
     for (var r = 0; r < t.length; r++) {
         n.push({
             label: t[r].name.substring(0, t[r].name.length - 4),
             data: t[r].points
         });
     }
     $.plot($("#placeholder"), n, {
         xaxis: {
             mode: "time",
             min: (new Date(2014, 0, 10)).getTime(),
             max: (new Date(2014, 0, 20)).getTime()
         },
         series: {
             stack: true,
             lines: {
                 show: true,
                 fill: true, 
             },
             points: {
                 show: true
             }
         },
         grid: {
             clickable: true
         },
         legend: {
             noColumns: 10,
             container: $("#chartLegend")
         }
     });
 })(jQuery);