gwatts / jquery.sparkline

A plugin for the jQuery javascript library to generate small sparkline charts directly in the browser
http://omnipotent.net/jquery.sparkline/
1.24k stars 278 forks source link

Bar heights are not proportional to values #125

Closed gnapse closed 10 years ago

gnapse commented 10 years ago

I have noticed that bar heights are not proportional to the values they're supposed to represent. For instance, take a look at this screenshot of a quick bar chart I made on the 'try it out' section of your homepage.

sparklines

The values being represented are 84, 93 and 119. The first value (84) is larger than half the last and largest value (119). So I would expect the first bar to be more than half the height of the last bar.

I have a sense that this is not a bug, but that it works like this by design. If that's the case, I'd like to know what's the logic behind this reasoning. I'd also like to know if there's some configuration option I can pass to achieve the results I'm expecting. I made a quick search on the documentation, and on the issues in this repository, and I've found nothing that could help me on this regard.

gwatts commented 10 years ago

Please see: https://groups.google.com/forum/#!searchin/jquery-sparkline/relative/jquery-sparkline/yIzCCWtkUUY/cEJL4whX3xMJ

On Aug 14, 2014, at 8:40 AM, Ernesto García notifications@github.com wrote:

I have noticed that bar heights are not proportional to the values they're supposed to represent. For instance, take a look at this screenshot of a quick bar chart I made on the 'try it out' section of your homepage.

The values being represented are 84, 93 and 119. The first value (84) is larger than half the last and largest value (119). So I would expect the first bar to be more than half the height of the last bar.

I have a sense that this is not a bug, but that it works like this by design. If that's the case, I'd like to know what's the logic behind this reasoning. I'd also like to know if there's some configuration option I can pass to achieve the results I'm expecting. I made a quick search on the documentation, and on the issues in this repository, and I've found nothing that could help me on this regard.

— Reply to this email directly or view it on GitHub.

gnapse commented 10 years ago

So the solution is to pass the chartRangeMin option with value zero:

$('#selector').sparkline([84, 93, 119], {
  type: 'bar',
  chartRangeMin: 0,
});

Thanks!