Leo
Leo

Reputation: 239

Flot chart unwanted decimals on changing width

I am using google flot chart which displays graph on the base of the values selected by the user. Graph displays years on x-axis and prices on y-axis.

The problem is that if graph width is small it displays values properly. for example if I set width as

<div id="placeholder" style="width:500px;height:300px"></div>

But if the graph width is increased just like

<div id="placeholder" style="width:650px;height:300px"></div>

Graph show unwanted zeroes on x-axis e.g

Insted of  2010  it shows  2010.0
Insted of  2011  it shows  2011.0
Insted of  2012  it shows  2012.0

I just want to get rid of these unwanted zeroes. Google didn't help me at all and I've totally no idea for this stupid behavior of flot.

Upvotes: 4

Views: 4009

Answers (3)

Reece
Reece

Reputation: 91

I had this problem too. I could easily fix it like this:

xaxis:
{                
    tickDecimals: 0
}

Upvotes: 9

DNS
DNS

Reputation: 38189

Are you using 0.7 or the master branch from Github? This sounds like a bug that was recently fixed on the master branch.

Upvotes: 0

Dan F
Dan F

Reputation: 12052

Looking through the doco, you might want to try setting tickDecimals or setup a tickFormatter for the xaxis option.

Upvotes: 2

Related Questions