Felix
Felix

Reputation: 41

jQuery Sparklines: Automatic zero-centering for bar charts

I am using jQuery sparklines to display a bar chart, e.g.:

<p><span class="inlinebar">11,13,14,15,13,12,15,11,10,13</span></p>

The problem is that jQuery is using the lowest value, i.e. 10, as a reference and is only displaying a very small bar for it (as if it was 0), while the other bars differ significantly in size (although the values are almost equal).

What I am looking for is an option that tells jQuery to use 0 as a reference, i.e., automatically zero-center the bars. The option

zeroAxis: true

is not doing the trick.

A workaround would be to add a 0 manually to each bar chart, i.e.:

<p><span class="inlinebar">0,11,13,14,15,13,12,15,11,10,13</span></p>

But maybe there is a more elegant way. Any help is appreciated! Thank you very much!

Felix

Upvotes: 4

Views: 2754

Answers (1)

jbbarth
jbbarth

Reputation: 712

In case you haven't found an answer yet: you can use "chartRangeMin: 0" to do what you want, see http://www.omnipotent.net/jquery.sparkline/#common

Upvotes: 7

Related Questions