2016-09-29 98 views
0

我創建了以下jqlotjqPlot最小刻度間隔

$.jqplot('chartdiv', JSON.parse(response.occnum), { 
     title: 'Occurrences',   
     legend: { 
      show: true, 
      renderer: $.jqplot.EnhancedLegendRenderer, 
      placement: "outsideGrid", 
      labels: response.labels, 
      location: "ne", 
      rowSpacing: "0px", 
      rendererOptions: { 
       // set to true to replot when toggling series on/off 
       // set to an options object to pass in replot options. 
       seriesToggle: 'normal', 
       seriesToggleReplot: {resetAxes: true} 
      } 
     }, 
     seriesDefaults: {renderer:$.jqplot.BarRenderer}, 
     axes: { 
      xaxis:{ 
      label: 'Months', 
      tickOptions : { 
       tickInterval: 1} 
      },    
      yaxis: { 
            labelRenderer: $.jqplot.CanvasAxisLabelRenderer, 
            labelOptions:{ 
                fontFamily:'Helvetica' 
                //fontSize: '14pt' 
            },     
      label: 'Occurrences number' 
      } 
     }   
    }); 

用以下數據

[[[7,4]],[[4,2],[5,1],[6,1],[7,1],[8,1]],[[5,2],[6,10],[7,6],[8,1]]] 

並得到結果

enter image description here

我想餵養的情節在x軸處僅獲得整數值0,1,2,3而不是0.0,0.5,0.1等t我現在得到的帽子。

回答

0

使用formatString選項將xaxis滴答格式設置爲整數。

tickOptions : { 
      formatString:'%d', 
      tickInterval: 1} 
     }, 

如果你會得到蜱的重複(1,1,2,2 ...),你還可以添加numberTicks選項,設置這將顯示刻度線的確切數量。 Read about it here