Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created February 2, 2016 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/4dbe405dc614fd08ad77 to your computer and use it in GitHub Desktop.
Save zeffii/4dbe405dc614fd08ad77 to your computer and use it in GitHub Desktop.
Glucose over time + food hints
var svg = d3.select("svg")
d3.csv("sugars.csv", function(error, data) {
if (error) throw error;
console.log(data);
draw_graph(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 d.time*12;})
circleEnter.attr("cy", function(d, i){return d.bsl*4;})
circleEnter.attr("r", function(d, i) {return 2})
circleEnter.style({fill: "#002200"})
}
<!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>
time bsl hint food
1 12.3 n -
3 14.3 nn -
4 17.3 n -
6 22.3 n -
11 - - some kind of food
12 22.3 n -
13 12.3 nn -
17 22.3 n -
18 - - some kind of food
20 16.3 n -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment