Sam
Sam

Reputation: 1063

jqplot : tickOptions: {formatString: '%d'} shows duplicate intervals on x-axis

I am plotting graphs using "jQplot" (jquery.jqplot.js and jquery.jqplot.css)

For this I have written following code:

$tfsGraphNodes= "[1,4],[2,2],[3,21],[4,61],[5,71],[6,10]";
$.jqplot('chartdiv', [[{/literal}{$tfsGraphNodes}{literal}]],
                        {title: 'Applicant Behaviour'
                                    , series: [{color: 'green'},
                                , {label: 'Applicant Trend'}]
                                    , legend: {show: true}
                            , highlighter: {showTooltip: true}
                            , axes: {
                                xaxis: {
                                    tickOptions: {formatString: '%d'}
                                },
                            }
                        });

To get integer value on x-axis I have used tickOptions: {formatString: '%d'} and I am getting the value as (0,1,1,2,2,3,3,4,4,.....)

But I want the interval not to be duplicated.

For better understanding I am attaching the image:

enter image description here

Upvotes: 0

Views: 9366

Answers (3)

cby016
cby016

Reputation: 1278

I had to add min and max options to make the duplicates go away:

xaxis: {
    tickOptions: {formatString: '%d'},
    tickInterval: 1,
    min: 0,
    max: 10,
}

Upvotes: 0

RohannG
RohannG

Reputation: 669

Using %d as a format string I got the same problem. When I replace '%d' by '%#d' problem got solved.

axes: {
 xaxis: {
  tickOptions: {formatString: '%#d'},
  tickInterval: 1
 } 
} 

Upvotes: 2

AnthonyLeGovic
AnthonyLeGovic

Reputation: 2335

Try to specify tickInterval: 1 in xaxis options :

axes: {
 xaxis: {
  tickOptions: {formatString: '%d'},
  //Comment or un-comment to see what happens on xaxis's ticks
  tickInterval: 1
 } 
} 

Please see working Fiddle here, you can comment/un-comment tickInterval line to see how it changes xaxis's ticks.

Upvotes: 0

Related Questions