this.proxy.getTime不是jqplot中的函数异常

时间:2012-02-07 07:29:46

标签: jquery jquery-plugins jqplot

我正在使用jqplot绘制带有x轴日期的折线图。我的图表在chrome浏览器中完美运行但不幸的是我在firefox [Firebug控制台]中得到“this.proxy.getTime不是函数异常”异常。 。

    function rndColor() {
    function c() {
        return ('0' + Math.floor(Math.random() * 256).toString(16)).substr(-2);
    }
    return '#' + c() + c() + c();
}  
  var plot1 = $.jqplot('chart1', [[['2012-01-23 00:23:03', 23], ['2012-02-01 00:14:02', 23]]], {
      title:'Disk Usage',
      axes:{
        xaxis:{
          renderer:$.jqplot.DateAxisRenderer,
          tickOptions:{
        formatString:'%b-%Y'
          },
        min: 'Jan-2012',
        max: 'Dec-2012',
        timeInterval: '1 month',
        },
        yaxis:{
          tickOptions:{
            formatString:'%1.2f TB'
            }
        }
      },
      highlighter: {
        show: true,
        sizeAdjust: 7.5,
      },
            legend: {show: true,placement: "outsideGrid",},
        series:[
        {color: rndColor(),label: '/user/aaaa/'},
        ],
      cursor: {
        show: false
      },
  });

因此没有绘制图表。我的配置中是否有任何错误导致此行为,任何帮助都会非常有用。

1 个答案:

答案 0 :(得分:4)

我无法确定你为什么会收到错误,但我可以告诉你是什么导致它:

min: 'Jan-2012',
max: 'Dec-2012',

将日期指定为文本字符串,然后需要将其解析为数值 。 jqPlot试图智能地将它们转换为javascript日期对象,但是失败了。您应该习惯于传递日期对象或纪元时间(对于javascript,这是自1970年1月1日以来的毫秒数。

将您的代码修改为:

    min: 1326585600000,  // number of milliseconds 1/15/2012
    max: 1355529600000,  // number of milliseconds 12/15/2012