Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trail Difficulty by Date from Summary #12

Open
abkfenris opened this issue Dec 11, 2016 · 0 comments
Open

Trail Difficulty by Date from Summary #12

abkfenris opened this issue Dec 11, 2016 · 0 comments

Comments

@abkfenris
Copy link
Owner

It would be nice to have a stacked bar that showed the amounts of trails open by difficulty by date

var summary,
    dates = {};

d3.json('/api/summary', function(data) {
	summary = data;

	summary.conditions.forEach(function(c) {
		if (undefined === dates[c.datetime]) {
			dates[c.datetime] = {}
		}
		if (undefined === dates[c.datetime][c.difficulty]) {
			dates[c.datetime][c.difficulty] = {}
		}
		if (undefined == dates[c.datetime][c.difficulty][c.open]) {
			dates[c.datetime][c.difficulty][c.open] = 0
		}
		dates[c.datetime][c.difficulty][c.open] += c.trail_count
	});
});

Builds a dictionary of datetimes with with difficulty and the amount of runs open and closed

{"Fri, 02 Dec 2016 08:25:00 GMT": {
    "beginner": {"true": 2, "false": 31}, 
    "black": {"true": 2, "false": 34},
    "double-black": {"false": 37},
    "intermediate": {"true": 4, "false": 43},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant