continue work trying to get d3 to work

This commit is contained in:
Michael Q Larson
2015-02-20 23:55:19 -08:00
parent 80485a9ad6
commit 74f6fc6763
2 changed files with 40 additions and 4 deletions

View File

@ -152,6 +152,15 @@ exports.postEmailSignup = function(req, res, next) {
});
};
/**
* For Calendar display
*/
exports.getStreak = function(req, res) {
var completedStreak = req.user.challengesHash;
}
/**
* GET /account
* Profile page.
@ -226,6 +235,20 @@ exports.returnUser = function(req, res, next) {
if (user[0]) {
var user = user[0];
Challenge.find({}, null, {sort: {challengeNumber: 1}}, function (err, c) {
var calendarData = Object.keys(user.challengesHash).map(function(key){return user.challengesHash[key]});
calendarData.sort(function(a , b) {
return a - b;
});
calendarData = calendarData.filter(function(elem) {
return elem !== 0;
});
var data = {};
calendarData.pop();
for (i = 0; i < calendarData.length; i++) {
var timestamp = 'timestamp' + i;
data[timestamp] = calendarData[i];
};
data = {timestamp0: new Date(2015, 3, 15)}
res.render('account/show', {
title: 'Camper: ',
username: user.profile.username,
@ -248,7 +271,7 @@ exports.returnUser = function(req, res, next) {
website3Title: user.portfolio.website3Title,
website3Image: user.portfolio.website3Image,
challenges: c,
ch: user.challengesHash,
calender: data,
moment: moment
});
});

View File

@ -97,18 +97,31 @@ block content
i.fa.icon-beaker
| Try it out
- if (ch[0] > 0)
html.
<script type="text/javascript" src="//d3js.org/d3.v3.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/cal-heatmap/3.3.10/cal-heatmap.min.js"></script>
<link rel="stylesheet" href="//cdn.jsdelivr.net/cal-heatmap/3.3.10/cal-heatmap.css" />
.col-xs-12
p= ch
.embed-responsive.embed-responsive-16by9
#cal-heatmap
script.
var cal = new CalHeatMap();
var calendar = !{JSON.stringify(calender)};
console.log(calendar);
cal.init({
"domain": "day"
itemSelector: "#cal-heatmap",
domain: "month",
subDomain: "day",
data: calendar,
dataType: "json",
range: 10,
start: new Date(2015, 0),
itemName: "",
legend: [5, 10, 15, 20, 25, 30],
legendColors: {
empty: "#ededed",
min: "#40ffd8",
max: "#f20013"
}
});