Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 334
Leo Avatar asked Dec 20 '22 18:12

Leo


2 Answers

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

xaxis:
{                
    tickDecimals: 0
}
like image 130
Reece Avatar answered Dec 27 '22 05:12

Reece


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

like image 31
Dan F Avatar answered Dec 27 '22 06:12

Dan F