2014-01-24 57 views
0

渲染我渲染一些腳本來創建使用jqplot的圖形,並在頁面上的腳本最終是這樣的:JQPlot不帶標籤

<script> 
    $.jqplot('chartdiv', [[['13/11/2013', 38.25],['14/11/2013', -11.70],['15/11/2013', 5930.15],['16/11/2013', 4139.13],['17/11/2013', 207.92],['18/11/2013', -103.53],['19/11/2013', 635.81],['20/11/2013', 559.16],['21/11/2013', 253.53],['22/11/2013', 183.53],['23/11/2013', 183.53],['24/11/2013', 183.53],['25/11/2013', 54.62],['26/11/2013', 67.62],['27/11/2013', 67.62],['28/11/2013', 47.62],['29/11/2013', -32.38],['30/11/2013', -32.38],['1/12/2013', -32.38],['2/12/2013', -82.33],['3/12/2013', 364.07],['4/12/2013', 254.45],['5/12/2013', 186.95],['6/12/2013', 114.05],['7/12/2013', 57.05],['8/12/2013', 53.36],['9/12/2013', 50.51],['10/12/2013', 30.51],['11/12/2013', 30.51],['12/12/2013', -86.43],['13/12/2013', 5922.89],['14/12/2013', 5720.82],['15/12/2013', 5468.87],['16/12/2013', 4742.57],['17/12/2013', 896.11],['18/12/2013', 680.69],['19/12/2013', 425.07],['20/12/2013', 323.07],['21/12/2013', 228.42],['22/12/2013', 113.42],['23/12/2013', -20.82],['24/12/2013', -20.82],['25/12/2013', -20.82],['26/12/2013', -47.82],['27/12/2013', -47.82],['28/12/2013', -47.82],['29/12/2013', -47.82],['30/12/2013', -59.30],['31/12/2013', 1004.02],['1/01/2014', 767.00],['2/01/2014', 663.15],['3/01/2014', 302.16],['4/01/2014', 231.66],['5/01/2014', 223.16],['6/01/2014', 12.60],['7/01/2014', -27.40],['8/01/2014', -27.40],['9/01/2014', -27.40],['10/01/2014', -27.40],['11/01/2014', -27.40],['12/01/2014', -27.40],['13/01/2014', -39.60],['14/01/2014', 803.29],['15/01/2014', 6709.11],['16/01/2014', 4968.20],['17/01/2014', 1381.55],['18/01/2014', 296.86],['19/01/2014', 285.61],['20/01/2014', 161.77],['21/01/2014', 47.80],['22/01/2014', 70.90],['23/01/2014', 56.30]]], { 
    title: 'Your financial control', 
    axes: { yaxis: { renderer: $.jqplot.LogAxisRenderer } }, 
    series: [{ 
     lineWidth: 1, 
     color: '#5FAB78', 
     showMarker: false 
    }] });</script> 

這使得一個空白圖表 - 沒有行。但是,Y軸顯示總數,但x軸是空白的。

但是,如果我只用價值使其 - 它的工作原理:

$.jqplot('chartdiv', [[38.25,-11.70,5930.15,4139.13,207.92,-103.53,635.81,559.16,253.53,183.53,183.53,183.53,54.62,67.62,67.62,47.62,-32.38,-32.38,-32.38,-82.33,364.07,254.45,186.95,114.05,57.05,53.36,50.51,30.51,30.51,-86.43,5922.89,5720.82,5468.87,4742.57,896.11,680.69,425.07,323.07,228.42,113.42,-20.82,-20.82,-20.82,-47.82,-47.82,-47.82,-47.82,-59.30,1004.02,767.00,663.15,302.16,231.66,223.16,12.60,-27.40,-27.40,-27.40,-27.40,-27.40,-27.40,-39.60,803.29,6709.11,4968.20,1381.55,296.86,285.61,161.77,47.80,70.90,56.30]], 
{ 
    title: 'Your financial control', 
    axes: { yaxis: { renderer: $.jqplot.LogAxisRenderer } }, 
    series: [{ 
     lineWidth: 1, 
     color: '#5FAB78', 
     showMarker: false 
    }] 
}); 

我試圖按照他們提供的頁面上的例子 - 但只要我的標籤添加到似乎數據 - 它不起作用。你能探討一個問題嗎?

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

回答

1

你需要指定x軸迄今爲止渲染

xaxis: { 
      renderer: $.jqplot.DateAxisRenderer 
     } 

您的日期格式也需要改變,如果你使用的默認渲染器。 如圖例中,日期格式爲mm/dd/yyyy和所述一個代碼中的其dd/mm/yyyy -

改變輸入日期格式,它應該拿出精細 - ['11 /二千零十三分之一十三' ,38.25],[」 11/14/2013',-11.70],...

jqplot本身可能有一些util接受其他日期格式。

編輯 - 這裏是選擇接受其他日期格式 - http://www.jqplot.com/docs/files/plugins/jqplot-dateAxisRenderer-js.html

,你將需要設置tickOptions.formatString = ‘%Y-%m-%d’