jqPlot DateAxisRenderer挂起浏览器

时间:2013-01-14 20:08:08

标签: javascript jquery jqplot

我在XAxis上使用带有DateAxisRender的jqPlot线图,我看到我的浏览器挂起了。没有崩溃,只是挂在那里。

我的图表代码是:

var lineChart = $.jqplot('viewsAppsTime', [data.VIEWS], {
  seriesColors:["#3bafe4","#00a44d"],
  grid:{
    shadow:false,
    drawBorder:false,
    drawGridlines:false,
    background:"#fff"
  },
  gridPadding:{bottom:20},
  seriesDefaults:{
    markerOptions:{
      style:"circle",
      lineWidth:5,
      size:12
    }
  },
  axesDefaults:{
    min:0,
    showTickMarks:false,
    tickOptions:{
      showLabel:true,
      showMark:false,
      showGridline:false
    }
  },
  highlighter:{
    show:true,
    tooltipAxes:"y"
  },
  title:"Visits and Applications",
  height:"340px",
  axes:{
    xaxis:{
      label:"Days Active",
      renderer: $.jqplot.DateAxisRenderer,
      tickInterval:7,
      tickOptions:{}
    }
  },
  series:[
    {
      label:"Visits",
      neighborThreshold:-1
    },{
      label:"Applications",
      neighborTheshold:-1
    }
  ],
  legend:{
    show:true,
    location:"ne",
    yOffset:0
  }
});

data.VIEWS变量将如下所示(实际值的副本):

[["2012-12-13",25],["2012-12-14",31],["2012-12-15",38],["2012-12-16",23],["2012-12-17",40],["2012-12-18",23],["2012-12-19",11],["2012-12-20",7],["2012-12-21",7],["2012-12-23",4],["2012-12-24",3],["2012-12-25",9],["2012-12-26",12],["2012-12-27",8],["2012-12-28",7],["2012-12-29",1],["2012-12-30",4],["2012-12-31",4],["2013-01-01",6],["2013-01-02",24],["2013-01-03",11],["2013-01-04",10],["2013-01-05",6],["2013-01-06",10],["2013-01-07",6],["2013-01-08",16],["2013-01-09",14],["2013-01-10",5],["2013-01-11",7],["2013-01-12",6],["2013-01-13",2]]

我已阅读this post并复制了答案中链接的文件,但我仍然看到我的浏览器已挂起。

1 个答案:

答案 0 :(得分:0)

我发现我的问题的原因是我使用了错误的tickInterval语法,我必须指定最小值和最大值。我修改了我的代码如下:

  axes:{
    xaxis:{
      label:"Days Active",
      renderer: $.jqplot.DateAxisRenderer,
      tickInterval:"7 days",
      min: data.VIEWS[0][0],
      max: data.VIEWS[data.VIEWS.length-1][0]
      tickOptions:{}
    }
  },