Can't force the number of ticks ticks

JSFiddle presenting the issue.

I've seen many solutions here and on Google, but they don't seem to work. I tried to set tickSize to 1 by setting the checkboxes as an arrayor a number (in this case 15), and yet the lib float does it as pleases.

I've read the API doc so many times, I don't think I missed anything.

If you want to completely override the tick algorithm, you can specify an array for "ticks", ...

Relevant code snippet:

xaxis: {
    show: true,
    ticks: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
}

      

Does anyone have a solution? Feel free to edit the JSFiddle or just comment.

Thanks in advance!

+3


source to share


1 answer


I was lucky to spot xaxis

out series

.

The structure is not entirely clear in the documentation .

var options = {
    series: {
        bars: {
            show: true,
            fill: true,
            align: 'center'
        },
        shadowSize: 0

    },
    xaxis: {
        show: true,
        ticks: [[1,'test label'],2,3,4,5,6,7,8,9,10,11,12,13,14,15]
    }
};

      



$(function() {

  var options = {
    series: {
      bars: {
        show: true,
        fill: true,
        align: 'center'
      },
      shadowSize: 0

    },
    xaxis: {
      show: true,
      ticks: [[1,'test label'], 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
    }
  };

  var d2 = [
    [1, 25],
    [2, 35],
    [3, 15],
    [4, 13],
    [5, 3],
    [6, 8],
    [7, 5],
    [8, 13],
    [9, 3],
    [10, 8],
    [11, 12],
    [12, 15],
    [13, 7],
    [14, 4],
    [15, 1]
  ];

  $.plot($("#placeholder"), [d2], options);
});
      

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
<script src="http://people.iola.dk/olau/flot/jquery.flot.js"></script>
<h1>Flot Examples</h1> 
<div id="placeholder" style="width:600px;height:300px;"></div>
      

Run codeHide result


+1


source







All Articles