sunjavagroups / flot

Automatically exported from code.google.com/p/flot
MIT License
0 stars 0 forks source link

Y-Axis labels sometimes show up as decimals instead of integers #541

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
(Flot Version 0.6, Browser: Firefox 4.0)

When setting the yaxis' max value to certain numbers, the chart displays floats 
as labels in the y axis instead of integers. This happens with only a few 
numbers. For example:

If I set the max value to be 10 (code excerpt: 
"yaxis":{"max":10,"tickSize":1}}), then I get in the y axis the following 
labels: 0.0, 1.0, 2.0... 10.0.
But if I set 8 in the above 'max' param, then I get in the y axis the following 
labels: 0, 1, 2... 7, 8.

Original issue reported on code.google.com by yomora...@gmail.com on 24 May 2011 at 10:06

GoogleCodeExporter commented 8 years ago
Hm, can't reproduce this with the latest version from git. Do you have a 
complete example?

Original comment by olau%iol...@gtempaccount.com on 3 Jun 2011 at 3:52

GoogleCodeExporter commented 8 years ago
I will try upgrading to the latest version from git.

Original comment by yomora...@gmail.com on 3 Jun 2011 at 4:14

GoogleCodeExporter commented 8 years ago
I am experiencing the same problem with flot 0.7.

I have a graph with the following settings:

$xaxis = [[0, "China"], [1, "Japan"], [2, "USA"], [3, "France"]]
$yaxis = [[0, 2], [1, 1], [2, 1], [3, 1]]

$conf = {
     series: {
     lines: { show: 0, fill: true, steps: false },
     points: {show: false},
     bars: { show: true, barWidth: 0.3, align: 'center'},
    },                  
    xaxis: {ticks: $xaxis, tickLength : 0},
    yaxis : {min : 0, tickSize: 1},
    grid: { borderWidth: 1  },
    }
}

$.plot( $cont, [{data: $yaxis},], $conf); 

And instead of seeing "1, 2, 3" in the yaxis, I see "1.0, 2.0, 3.0".

if I set yaxis : {max: 10} - I see "1,2,3,4,5..." on the yaxis.

Original comment by lizk...@gmail.com on 5 Sep 2011 at 8:29

GoogleCodeExporter commented 8 years ago

Original comment by dnsch...@gmail.com on 4 Jun 2012 at 2:32

GoogleCodeExporter commented 8 years ago
Confirmed using master branch.

Original comment by dnsch...@gmail.com on 5 Jun 2012 at 4:26

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I submitted a pull request for this issue here:
https://github.com/flot/flot/pull/57

Original comment by yael.elm...@gmail.com on 10 Jul 2012 at 11:07

GoogleCodeExporter commented 8 years ago
Cool. At last there is a fix. Thanks!

Original comment by yomora...@gmail.com on 10 Jul 2012 at 11:55

GoogleCodeExporter commented 8 years ago
This is fixed in the master branch.  It turned out to be caused by floating 
point issues in JavaScript's toFixed method.  When pull request #50 replaced 
our use of toFixed in the default tickFormatter with a more efficient 
alternative, it also solved this rounding bug.

I wouldn't have realized this if I hadn't been testing Yael's fix, though.

Original comment by dnsch...@gmail.com on 11 Jul 2012 at 3:30

GoogleCodeExporter commented 8 years ago
I am still seeing this intermittent float instead of integer when I use a log 
scale on a line chart.  

Original comment by jnc...@umbc.edu on 29 Aug 2014 at 2:59