2014-11-03 75 views
1

我正在努力創建一個jqPlot線條圖,並希望有人可以提供幫助。出於某種原因,我的線條和蜱沒有出現,我不明白爲什麼。我在下面複製了麻煩的代碼。jqPlot:線條圖:線條和方格不顯示

誰能告訴我我做錯了什麼?

如果還有其他事情可以幫助說明或解決問題,請告訴我。

$(document).ready(function(){ 

    var line1 = [['07-01-2014',0],['08-01-2014',87],['09-01-2014',0],['10-01-2014',0],['11-01-2014',0],['12-01-2014',0],['01-01-2015',0],['02-01-2015',71],['03-01-2015',0],['04-01-2015',83],['05-01-2015',0],['06-01-2015',82]] 
    var line2 = [['07-01-2014',0],['08-01-2014',85],['09-01-2014',0],['10-01-2014',0],['11-01-2014',1],['12-01-2014',0],['01-01-2015',0],['02-01-2015',71],['03-01-2015',0],['04-01-2015',83],['05-01-2015',0],['06-01-2015',82]] 
    var jqpData = [line1, line2]; 

    var xLabels = ['07-01-2014','08-01-2014','09-01-2014','10-01-2014','11-01-2014','12-01-2014','01-01-2015','02-01-2015','03-01-2015','04-01-2015','05-01-2015','06-01-2015'], 
     lLables = ['Series 1','Series 2']; 

    $(function() { 
     var plot1 = $.jqplot('chart1', jqpData, { 
      title: 'July through June', 
      seriesDefaults:{ 

       rendererOptions: {smooth: true}, 
       label:' ', 
       lineWidth: 2 
      }, 
      axesDefaults: { 
       labelRenderer: $.jqplot.CanvasAxisLabelRenderer, 
       tickRenderer: $.jqplot.CanvasAxisTickRenderer 
      }, 
      legend:{ 
       show: true, 
       location: 'sw', 
       placement: 'outsideGrid', 
       labels: lLables 
      }, 
      axes: { 
       xaxis: { 
        renderer:$.jqplot.DateAxisRenderer, 
        tickOptions:{ 
         angle:-30, 
         fontFamily:'Trebuchet MS,Arial,Helvetica,sans-serif', 
         fontSize: '1em', 
         min:'07-01-2014', 
         tickInterval:'1 month' 
        } 
       }, 
       yaxis:{ 
        label:'', 
        min:0, 
        max:96.9849 
       } 
      } 
     }); 
    }); 
}); 
+0

你是否包含了所有必需的插件作爲'DateAxisRenderer'?控制檯中是否有任何錯誤? – skobaljic 2014-11-03 01:29:14

+0

嘗試沒有選項,只有行,而不是逐個添加。 – skobaljic 2014-11-03 01:30:53

+0

如果您需要顯示標記,那麼您需要將它們轉義出來,以告訴JavaScript它們是* literal *。逃離這樣的charaacters:「'你好,我的名字\'\\Godisgood!'」 – 2014-11-03 01:34:33

回答

1

嘗試添加這是其中的一個選項:

axes: { 
    xaxis:{ 
     renderer: $.jqplot.CategoryAxisRenderer, //etc 

此處瞭解詳情: 看看這個鏈接,如果您尚未:

http://www.jqplot.com/docs/files/jqplot-axisTickRenderer-js.html 

,然後適用如下所示:

http://www.jqplot.com/tests/rotated-tick-labels.php 
+0

正是我所需要的!天才。 – campbelt 2014-11-03 01:51:44

+1

太棒了!我很高興能夠提供幫助 – 2014-11-03 01:54:04