我一直在PrimeFaces條形圖模型上工作,現在我的神經緊張起來,我無法弄清楚它的設置圖表系列值。期望的結果應該是One Open對於abc和一個關閉xyz,但它顯示一個開放和一個xyz關閉,ABC被忽略。如果我改變的p:圖表欄的ChartSeries不同步
barModel.addSeries(close); barModel.addSeries(open);
的位置
barModel.addSeries(open); barModel.addSeries(close);
話,就說明一個開放,一個封閉,只准ABC,不XYZ。
這裏是我的getBarModel()第一,
public BarChartModel getBarModel() {
barModel=new BarChartModel();
ChartSeries open = new ChartSeries();
open.setLabel("OPEN");
ChartSeries close = new ChartSeries();
close.setLabel("Close");
open.set("abc", 1);
close.set("xyz", 1);
barModel.addSeries(close);
barModel.addSeries(open);
barModel.setMouseoverHighlight(false);
barModel.setShowPointLabels(false);
barModel.setTitle("Incident_application");
barModel.setLegendPosition("ne");
barModel.setShowDatatip(false);
barModel.setShowPointLabels(true);
barModel.setExtender("chartExtender");
barModel.setSeriesColors("A2CC39,1B75BA");
Axis xAxis = barModel.getAxis(AxisType.X);
xAxis.setLabel("Applications");
barModel.setAnimate(true);
Axis yAxis = barModel.getAxis(AxisType.Y);
yAxis.setLabel("No. of Incident");
yAxis.setMin(0);
yAxis.setMax(20);
yAxis.setTickInterval("10");
return barModel;
}
,這裏是XHTML
<h:outputScript library="primefaces" name="jquery/jquery.js" target="head" />
<h:outputScript library="primefaces" name="jquery/jquery-plugins.js" target="head" />
<style type="text/css">
table.jqplot-table-legend {
border: none;
font-size: x-large;
}
div.jqplot-table-legend-swatch
{
width: 2vw;
height: 2vh;
}
div.jqplot-gridData{
display:none;
}
div.jqplot-xaxis-tick{
font-weight:bold !important;
}
.jqplot-axis.jqplot-xaxis{
font-weight:bold;
}
.jqplot-point-label {
font-size: 300%;
color: black;
font-weight: bold;
}
.jqplot-target{
color:black !important;
}
</style>
<script>
function chartExtender() {
this.cfg.grid = {
background: 'transparent',
gridLineColor: '#303030',
drawBorder: false,
};
}
</script>
<h:form id="barChart">
<p:chart id="bar" type="bar" model="#{incidentBarChartController.barModel}" />
<p:poll interval="10" global="false" update="barChart"/>
</h:form>
</h:body>
快照預期和實際結果的下方添加。
編輯 加入
open.set("abc", 1);
open.set("xyz",0);
close.set("xyz", 1);
close.set("abc", 0);
後,我仍然會有奇怪的結果,即 1開和1關閉XYZ和0打開,0關閉XYZ。
您需要爲每個密鑰的每個集合/系列賦予一個值。所以還要加上'open.set(「xyz」,0); close.set(「abc」,0);'(也許'null'起作用)。或者,也許這需要通過擴展程序在jqplot級別配置 – Kukeltje
由於動態數據,這將過於複雜。 – Learner
爲什麼?鑰匙是以這種或那種方式「訂購」的?或者是訂單相關?按照正確的順序在一組中組合鍵是唯一的「挑戰」。然後添加然後循環雖然該集合,並添加在其他集中的缺失的應該不難。 PF或jqPlot無法爲你解決這個問題。他們無法知道兩組中哪一組包含正確的順序。假設集合1以「a $#」開頭,集合2以「a#$」開頭,哪一個應該先到?根據「字符串」排序但是,如果你「xyz」應該在「abc」之前出現? – Kukeltje