Issue #47 open

Tick value precision

Andreas Dörler
created an issue


Is there a way to set the precision (decimal places) of the tick values? (depending on the zoom value by e.g. call back function would be really cool ;-) )

Greetings from Austria


Comments (5)

  1. Chris Leonello repo owner

    Hi Andreas,

    Yes, you can set the format string of the tick value labels. Use the options:


    After you've made your plot, it is not as easy to change the format string. You have to loop through all the ticks since the format string is a property of the tick:

    var axis = myplot.axes.xaxis;
    var tick;
    for (var i=0; i<axis._ticks.length; i++) {
        tick = axis._ticks[i];
        tick.formatString = '%.3f';

    I don't have plans to automatically determine a new format string upon zooming based on the displayed data. I can add a "jqplotPreZoom" event that would allow you to do this processing and update the format before the plot is redrawn.

    You may try using a "p" or "g" format string instead of the default "f". The default is "%.1f", try something like "%.2p" or "%.2g".

  2. blanchg

    The problem with just changing the formatter is that it doesn't affect the position of the tick.

    e.g. if the tick values are 1.54, 2.54, 3.54 but I want to only show whole numbers e.g. 1, 2, 3 changing the formatter means the graph values now appear to be out by .54

  3. Lin Shi

    Two ways to solve this issue. Firstly, You can designate a specific range for Y-axis. Display them as string. Secondly, you can just you formatter like '%.1f' to keep numbers before point.

  4. Log in to comment