2013-09-26 38 views
1

我想在我的xaxis上旋轉日期。看來rotate參數沒有考慮到,而fontFamily,fontSizeformatString工作。jqPlot:旋轉xaxis日期標籤

我使用jqPlot 1.0.8使用jQuery 1.10.2和Firefox 23.0.1

http://jsfiddle.net/JVY6a/

HTML:

<div id="chart-blood-pressure" class="jqplot-target" data-json="{&quot;diastolic_blood_pressure&quot;:[[&quot;2013\/09\/25 00:00:00&quot;,100],[&quot;2013\/09\/24 00:00:00&quot;,70]],&quot;systolic_blood_pressure&quot;:[[&quot;2013\/09\/25 00:00:00&quot;,130],[&quot;2013\/09\/24 00:00:00&quot;,120]],&quot;heart_rate&quot;:[[&quot;2013\/09\/25 00:00:00&quot;,76],[&quot;2013\/09\/24 00:00:00&quot;,85]]}"></div> 

JS:

$(document).ready(function(){ 
    var data = $('#chart-blood-pressure').data('json'); 
    var plot = $.jqplot('chart-blood-pressure', [data.diastolic_blood_pressure, data.systolic_blood_pressure, data.heart_rate], { 
     axes:{ 
      xaxis:{ 
       renderer:$.jqplot.DateAxisRenderer, 
       rendererOptions:{ 
        tickRenderer:$.jqplot.CanvasAxisTickRenderer 
       }, 
       tickInterval:'1 day', 
       tickOptions:{ 
        fontSize:'10pt', 
        fontFamily:'Tahoma', 
        angle:-40, 
        formatString:'%b %#d, %Y', 
       } 
      }, 
     }, 
    }); 
}); 

回答

2

你必須包含canvasAxisTickRenderer插件:external link here或來自jqPlot源代碼(「 /src/plugins/jqplot.canvasAxisTickRenderer.min.js「)

<script type="text/javascript" src="http://cdn.jsdelivr.net/jqplot/1.0.8/plugins/jqplot.canvasAxisTickRenderer.min.js"></script> 
//or 
<script type="text/javascript" src="../src/plugins/jqplot.canvasAxisTickRenderer.min.js"></script> 

見工作示例here

+0

謝謝!!這是一個混亂的所有論文插件需要 –

+0

是的,它是!有關jqPlot文檔的示例可以讓您很好地瞭解針對特定問題需要哪些插件。 – AnthonyLeGovic

+0

事實上,一些示例頁面不完整,並且不會給出所需的每個插件...例如http://www.jqplot.com/deploy/dist/examples/rotatedTickLabelsZoom.html :) –