Hacker News new | ask | show | jobs
by nilliams 5162 days ago
Okay, interesting. I perhaps don't understand enough about the syntax to appreciate why those lower-level constructs would be beneficial w.r.t the geo stuff.

On the styling sure, data should often dictate the style in visualisations - the most noddy example people tend to give in JS as the exception to the rule of never 'programatically' (JS) setting styles is the progress bar where the width has to be data-based (as CSS-classes only make sense for discrete increments or 'states'). Of course the same applies for colouring/shading and sizing based on say population data or whatever is being modeled in a visualisation, I get that.

But, in the example on the first page the bars of the histogram are all explicitly coloured gray w/ white text programatically and the bar heights are manually set to '20' (presumably px). What would make more sense is for them to have a default class of say 'hist-bar-default', which is set in CSS to { height: 20px; background: gray; color: white }. If anything it would just make the example simpler as it actually muddles up the code where the widths are being dynamically set. shrug

Edit: btw, you will see that d3.js does this, it applies classes where appropriate rather than setting styles explicitly: http://mbostock.github.com/d3/ex/cartogram.html

1 comments

This is more of a choice of how the creator wanted to display the usefulness of C2. That can just as easily be done with C2.

[:div {:class "hist-bar-default"}] would likely be the way to do it.

Also d3.js examples are riddled with bars.attr("style", "height: " + 30px) just because sometimes it's easier to think about it while developing there. It's not maintainable and very problematic in large designs but I would recommend not judging a library based off of design choices like that with examples of d3 or c2.

I'm glad you're passionate about visualization though, you should definitely start using these libraries, and after a while (d3.js has been said to "melt your brain initially) you'll realize the benefits of working at a lower level with the data.