current work on d3

This commit is contained in:
Michael Q Larson
2015-02-22 23:47:30 -08:00
parent f4fcb565f4
commit 120cc113b9
3 changed files with 25 additions and 12 deletions

View File

@ -235,10 +235,15 @@ exports.returnUser = function(req, res, next) {
if (user[0]) { if (user[0]) {
var user = user[0]; var user = user[0];
Challenge.find({}, null, {sort: {challengeNumber: 1}}, function (err, c) { Challenge.find({}, null, {sort: {challengeNumber: 1}}, function (err, c) {
data = { data = {};
"1424569155": 1, progressTimestamps = user.progressTimestamps;
"1424519155": 1 // dummy data to experiment with visualizations
}; progressTimestamps = [1417117319, 1384091493, 1367893914, 1411547157, 1366875140, 1382614404, 1374973026, 1363495510, 1372229313, 1389795294, 1393820136, 1395425437, 1383366211, 1402063449, 1368384561, 1413460738, 1390013511, 1408510076, 1395530419, 1391588683, 1410480320, 1360219531, 1367248635, 1408531181, 1374214772, 1424038529, 1387468139, 1381934158, 1409278748, 1390696161, 1415933043, 1389573689, 1395703336, 1401223291, 1375539279, 1371229698, 1371990948, 1422236826, 1363017438, 1359619855, 1364850739, 1401982108, 1381270295, 1420063854, 1406540493, 1409122251, 1360775035, 1367712723, 1395305605, 1382037418, 1378402477, 1377563090, 1398930836, 1417371909, 1377417393, 1423763002, 1357511908, 1377375961, 1388374304, 1406416407, 1399463258, 1422593990, 1383434425, 1420200570, 1379435518, 1414512582, 1416263148, 1398635260, 1381815565, 1369178539, 1378414973, 1394409827, 1398463526, 1379564971, 1385849279, 1392899666, 1367053659, 1417730793, 1400112915, 1379923357, 1417768487, 1415779985, 1416150640, 1399820237, 1370498715, 1374800622, 1363924512, 1402497668, 1400146327, 1362456746, 1394935898, 1414980963, 1413942775, 1367606840, 1387144705, 1407906392, 1417213587, 1422640891, 1414033139, 1365323522, 1424661148];
for (i = 0; i < progressTimestamps.length; i++) {
data[progressTimestamps[i].toString()] = 1;
}
res.render('account/show', { res.render('account/show', {
title: 'Camper: ', title: 'Camper: ',
username: user.profile.username, username: user.profile.username,
@ -250,7 +255,8 @@ exports.returnUser = function(req, res, next) {
twitterHandle: user.profile.twitterHandle, twitterHandle: user.profile.twitterHandle,
bio: user.profile.bio, bio: user.profile.bio,
picture: user.profile.picture, picture: user.profile.picture,
points: user.points, progressTimestamps: req.user.progressTimestamps,
points: user.progressTimestamps,
website1Link: user.portfolio.website1Link, website1Link: user.portfolio.website1Link,
website1Title: user.portfolio.website1Title, website1Title: user.portfolio.website1Title,
website1Image: user.portfolio.website1Image, website1Image: user.portfolio.website1Image,

View File

@ -734,6 +734,11 @@ iframe.iphone {
} }
#cal-heatmap {
margin: 0 auto;
background-color: #fefefe;
}
//uncomment this to see the dimensions of all elements outlined in red //uncomment this to see the dimensions of all elements outlined in red
//* { //* {
// border-color: red; // border-color: red;

View File

@ -105,19 +105,21 @@ block content
<link rel="stylesheet" href="//cdn.jsdelivr.net/cal-heatmap/3.3.10/cal-heatmap.css" /> <link rel="stylesheet" href="//cdn.jsdelivr.net/cal-heatmap/3.3.10/cal-heatmap.css" />
.col-xs-12 .col-xs-12
.embed-responsive.embed-responsive-16by9
#cal-heatmap #cal-heatmap
script. script.
var cal = new CalHeatMap(); var cal = new CalHeatMap();
var calendar = !{JSON.stringify(calender)}; var calendar = !{JSON.stringify(calender)};
console.log(calendar);
cal.init({ cal.init({
itemSelector: "#cal-heatmap", itemSelector: "#cal-heatmap",
domain: "month", domain: "month",
subDomain: "day", subDomain: "day",
data: calendar, data: calendar,
range: 10, cellSize: 15,
start: new Date(2015, 0), cellRadius: 3,
itemName: "", cellPadding: 2,
legend: [5, 10, 15, 20, 25, 30] tooltip: true,
range: 4,
start: new Date().setDate(new Date().getDate() - 90),
legendColors: ["#cccccc", "#215f1e"],
legend: [1, 2, 3]
}); });