Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Display ints as ints Issue 541 #57

wants to merge 1 commit into from

2 participants


Fixed bug that displayed ints as floats when unnecessary.

Issue #541 on google code:

@yaelelmatad yaelelmatad Dislay ints as ints Issue 541
Fixed bug that displayed ints as floats when unnecessary

I pulled your changes to my local repo for testing, and was surprised to find that I could no longer reproduce the original problem! After a little investigation I realized that pull request #50, which I just merged earlier today, had the unexpected side-effect of fixing this decimal issue.

It looks like the bug actually originates from floating point issues in JavaScript's toFixed, which is used in the default label formatter. Pull request #50 replaces it with a much faster alternative using Math.round, which happens to also avoid the problem entirely.

I did test your fix separately, and it doesn't appear to work, at least using the example provided by lizka in issue #541 on Chrome 20; the decimals still show up. Did you test against that example, or a different one?

In any case, I'm closing this pull request, since the issue is resolved. But I am thankful that you took the time to work on this; otherwise it might have been months before we realized that the problem was already solved, and it would have been very difficult at that point to figure out why.

@dnschnur dnschnur closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 10, 2012
  1. @yaelelmatad

    Dislay ints as ints Issue 541

    yaelelmatad authored
    Fixed bug that displayed ints as floats when unnecessary
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 1 deletion.
  1. +8 −1 jquery.flot.js
9 jquery.flot.js
@@ -1196,10 +1196,17 @@
size = 10;
size *= magn;
if (opts.minTickSize != null && size < opts.minTickSize)
size = opts.minTickSize;
+ //add a checker to determine if we really have a decimeal or integer. if = int, dec =0
+ var integerChecker = - Math.floor(;
+ if (integerChecker < 0.00000001 || integerChecker > 0.999999999)
+ dec = 0;
+ // is within floating point error of an integer
axis.tickDecimals = Math.max(0, maxDec != null ? maxDec : dec);
axis.tickSize = opts.tickSize || size;
Something went wrong with that request. Please try again.