|
|
|
|
|
by milroc
5162 days ago
|
|
Just a little info on this, this is not a charting library, it's probably closer to a graphics or visualization library. It pulls a lot of it's ideas from d3.js, allowing CSS to dictate a lot of your style choices, but also allowing the data to change the style (a typical example is a chart where you have different categories of data, coloring those categories depending on the data). This is low level for a reason, most charting libraries take a specific stance on how to visualize something. d3 and c2 let that be dictated entirely by the developer. It may take more effort to get a bar chart working in either of these libraries but generally the control you have allows you to fit it into your design rather than your design molding around the charting library you use. |
|
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