Lodhart
Lodhart

Reputation: 685

jqPlot so many labels for x axis

I start with using jqPlot and I do not understand some option of axis (for example numberTicks). I have a lot of values (about 1000) with this rule ['time', value]. But if I put all these values to the plot I also see all x axis labels (the time labels) and with 1000 values it is a little mess. So can I some how set somethink like: show only labels in step. And numberTicks is not working for me, if I have 1000 values (so 1000 labels) and I set numberTicks: 100. I can see only FIRST 100 labels. I thought that numberTicks means number of ticks in range (first x axis value, last x axis value).

And here is a picture for clearing

Upvotes: 1

Views: 4605

Answers (2)

Lodhart
Lodhart

Reputation: 685

This is what I looking for, thx. But I need this for a time x axis. So after some test I finally found a solution:

  var line1 = [['00:00:06',18.64],['00:01:06',18.73], ..... ];
  var plot1 = $.jqplot('chart1', [line1], {    
  title:'Living room - temperature',    
      axes: {      
        xaxis: {       
          renderer:$.jqplot.DateAxisRenderer,       
          tickOptions: {          
            formatString: '%H:%M:%S'
          },
          min: '00:00:01',
          max: '24:00:00',
          numberTicks: 25  
        }   
      } 
  });

And now I have a more then 1000 values of temperature in plot when the ticks are every one hour.

Upvotes: 0

Pablo Claus
Pablo Claus

Reputation: 5920

Try something like this:

http://jsfiddle.net/pabloker/GsDMW/2/

$(document).ready(function(){
 var points = []; 
 for (var i=0; i<1000; i+=1){ 
 points.push([i, 1 + Math.floor(Math.random() * 60)]); 
 } 
 var plot1 = $.jqplot('chart1', [points], {  
  series:[{showMarker:false}],
  axes:{
    xaxis:{
        max: 1000,
        min: 0,
        numberTicks: 10
    }
  }
 });
});

Upvotes: 2

Related Questions