2015-05-10 47 views
0

我使用jqplot通過Primefaces,並已輸入到條形圖是這樣的:條形圖兩個系列不同的日期/值的範圍

Series 1: 
label: "Company 1" 
data: {"01-05-2015": 10, "06-05-2015": 3} 
Series 2: 
label: "Company 2" 
data: {"03-05-2015": 10, "06-05-2015": 3} 

當我通過這個數據爲BarChartModel,我數據錯誤地繪製在圖表上。

數據在第一個系列之後,因爲Series 2Series 1日期之後繪製。我已經將數據轉換爲在順序遵循得到圖表精細得出:

Series 1: 
label: "Company 1" 
data: {"01-05-2015": 10, *"03-05-2015": 0*, "06-05-2015": 3} 
Series 2: 
label: "Company 2" 
data: { *"01-05-2015": 0* , "03-05-2015": 10, "06-05-2015": 3} 

通知*之間的數據項*。

此處有任何建議嗎? (如果使用DateAxis有幫助?)

回答

0

當我沒有使用DateAxis時,我遇到了與LinearChartModel相同的問題。 作爲一種解決方法,我用所有可能的數據填充了我的系列,然後重新排列列表。 URG!

也應該使用BarChartModel。

使用DateAxis你只需要使用時間戳添加日期軸,像這樣:

serie.set(new Date().getTime(), new Double(123)); 

或本

serie.set("2015-09-08", new Double(123)); 

把DateAxis在LineChartModel這樣的:

DateAxis axis = new DateAxis("Data da inspeção"); 
linearModel.setZoom(true); 
linearModel.getAxes().put(AxisType.X, axis); 
linearModel.setExtender("linhaSetor"); 

並在extender.js中格式化您的日期:

function linhaSetor() { 
    this.cfg.axes.xaxis.tickOptions = { 
     show : true, 
     angle : 45, 
     formatString : '%d/%m/%y %Hh' 
    }; 
} 

您甚至不需要按順序放置數據。

相關問題