Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created February 2, 2016 14:28
Show Gist options
  • Save zeffii/bb56b979c5a6117b334b to your computer and use it in GitHub Desktop.
Save zeffii/bb56b979c5a6117b334b to your computer and use it in GitHub Desktop.
Glucose over time + food hints
var svg = d3.select("svg")
/*
sample row
num,date,time,bsl,id,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12
"165","02/02/2016","08:26:20","15.76","JBHPR012","2","10","-1","0","1","","601","3","","","1","0"
*/
d3.csv("sugars.csv", function(error, data) {
if (error) throw error;
data = csv_preprocessor(data)
draw_graph(data);
});
function csv_preprocessor(data){
return data
}
function draw_graph(data){
var g1 = svg.append("g")
var circle = g1.selectAll('circle').data(data);
var circleEnter = circle.enter().append('circle');
circleEnter.attr("cx", function(d, i){return i*12;})
circleEnter.attr("cy", function(d, i){return d.bsl*4;})
circleEnter.attr("r", function(d, i) {return 3})
circleEnter.style({fill: "#002200"})
data.forEach(function(d){
console.log(d.time);
});
}
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
svg { width:100%; height: 100% }
</style>
</head>
<body>
<svg></svg>
<script src="dillitant.js"></script>
</body>
num date time bsl id u1 u2 u3 u4 u5 u6 u7 u8 u9 u10 u11 u12
165 02/02/2016 08:26:20 15.76 JBHPR012 2 10 -1 0 1 601 3 1 0
164 02/01/2016 04:32:57 13.38 JBHPR012 2 10 -1 0 7 601 3 2 -1
163 01/30/2016 08:38:46 13.71 JBHPR012 2 10 -1 0 1 601 3 3 0
162 01/29/2016 08:36:30 19.26 JBHPR012 2 10 -1 0 1 601 3 4 0
161 01/25/2016 08:33:55 16.43 JBHPR012 2 10 -1 0 1 601 3 5 0
160 01/25/2016 08:29:55 15.99 JBHPR012 2 10 -1 0 1 601 3 6 0
159 01/24/2016 08:29:57 17.32 JBHPR012 2 10 -1 0 1 601 3 7 0
158 01/24/2016 08:29:16 17.04 JBHPR012 2 10 -1 0 1 601 3 8 0
157 01/23/2016 08:59:12 10.55 JBHPR012 2 10 -1 0 1 601 3 9 0
156 01/22/2016 08:48:21 9.71 JBHPR012 2 10 -1 0 1 601 3 10 0
155 01/21/2016 08:40:38 12.6 JBHPR012 2 10 -1 0 1 601 3 11 0
154 01/20/2016 09:25:26 16.43 JBHPR012 2 10 -1 0 2 601 3 12 0
153 01/18/2016 11:29:08 15.65 JBHPR012 2 10 -1 0 3 601 3 13 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment