jqPlot有很多x轴的标签。

时间:2022-09-15 08:47:59

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).

我从使用jqPlot开始,我不理解axis的某些选项(例如numberTicks)。我有很多值(大约1000)有这个规则['time', value]。但是如果我把所有这些值都放到绘图上,我还会看到所有的x轴标签(时间标签)和1000个值,这有点乱。所以我能告诉你如何设置一些想法:在步骤中只显示标签。如果我有1000个值(1000个标签),那么numberTicks就不适合我了,我设置了numberTicks: 100。我只能看到前100个标签。我认为numberTicks意味着range(第一个x轴值,最后一个x轴值)的刻度数。

jqPlot有很多x轴的标签。

2 个解决方案

#1


2  

Try something like this:

试试这样:

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

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
    }
  }
 });
});

#2


0  

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:

这就是我要找的,thx。但我需要这个x轴。经过一些测试,我终于找到了一个解决方案:

  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.

现在我有一个更大的温度在每一个小时的时候。

#1


2  

Try something like this:

试试这样:

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

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
    }
  }
 });
});

#2


0  

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:

这就是我要找的,thx。但我需要这个x轴。经过一些测试,我终于找到了一个解决方案:

  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.

现在我有一个更大的温度在每一个小时的时候。