callback functions

I’m in the stage where I’m starting to be able to do more, but nothing is easy yet :).  Fortunately, I’m heading out to Western CT for a very hilly & rocky 7 mile trail race early tomorrow morning, so by tomorrow afternoon my body will be as tired as my brain is now.

This week was effectively a 3-day week as I spent Monday prepping & giving an unrelated presentation & yesterday was an offsite with the office.  Before I head out for the weekend, just wanted to celebrate two things: reading in real data & creating a day-of-week profile.

London makes data from their cycle program easily available here.  This is just # of rented per day since summer 2010.  Reading in data isn’t so hard now.  But, I had to wrap my head around the nature of callbacks & asynchronous loading.  More on that later.

Creating the day of week profile required a lot more array manipulation than I’d done before, in particular leveraging native array methods like “forEach” and “filter.”  This gave me more practice with call backs as well.  And, as a bonus, I got to spend time with date handling… which was an adventure.  Next week I might try translating dates into numbers, instead of treating as dates, with a function for going to & from the date strings/numbers.

In the chart below, blue is weekends & red is Monday.  The bottom chart shows the typical day compared to average, with Sunday on the left.  Obviously I need to add in some labels to make this more meaningful.  I think that Monday is being dragged down to average a bit by holidays, which I haven’t handled for.

Screenshot from 2013-08-02 17:53:57


Will put on fiddle on Monday.

Next steps next week: scales & mouseovers & (maybe) reading in data using native javascript!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s