Tuesday, 19 August 2014

Refactoring troubles...

A bit of a challenging day.
Too much time spent coding.


Some errors still present:
The graph on the advice page has an error because of the number format.
Not sure how to change this but I will have to learn.

I spend some time this morning trying to refactor my code so that I only had one map drawing function.
However, I couldn't really make it work.

I tried to put the code into two different functions but I just ended up with the map at the top and the circles below it.

Then I tried to understand why the graph on the advice page wasn't working.
I played around a lot with numbers and the like.

In the end I realised that it was do to with a little function called type

"
   function type(d) {
      d.low_numbers = +d.low_numbers;
            return d;

    }
"

This was copy and pasted from:
the bar chart making code for example:

The comment says that the role of this function is to "coerce to number"

However, it only coerces the data from low_number not from all the lists. 
This is why the low_numbers data works but the other doesn't. 

I don't know how to coerce the data generally because I still don't understand enough of how Ian uses the Methods in the graphresponsive.js script. 

It's a bit annoying but hey it's all learning. 


On a positive note, I did some refactoring and organising on the CSS side. This will help. 

Also, I made 15 commits to GitHub using a combination of the Terminal and Aptana. 

All in all that builds confidence in my coding abilities. 

Step by step!


No comments:

Post a Comment