2015-01-11 77 views
1

我正在開發一個使用PrimeFaces條形圖的JSF中的Web應用程序。我想改變傳說的位置。我驗證了它們使用後Primefaces: Charts and Legend position如何更改條形圖PrimeFaces中的圖例位置?

<p:barChart id="stackedKWH" 
      value="#{kwhSalesBeanManager.kwhSalesChart}" 
      legendPosition="e" style="height:300px;width:800px" 
      title="kWh Sales by Type" 
      stacked="true" 
      barMargin="10" 
      min="0" 
      max="125000000"/> 

但primeface 5.1沒有<p:barchart/>

<p:chart type="bar" model="#{chartView.barModel}" style="height:300px"/> 

我的輸出是什麼樣子,

enter image description here

預期輸出:

enter image description here

我該如何做到這一點?有人建議我使用正確的方法嗎?

回答

4

你可以做到這一點的綠豆:

BarChartModel model = new BarChartModel(); 
model.setLegendPosition("e"); 
model.setLegendPlacement(LegendPlacement.OUTSIDEGRID); 
+0

@jaquen H'ghar感謝ü這麼多,它的工作。 –

+0

謝謝,不客氣 –

1

您仍然可以使用model.setLegendPosition(「w」);在你的豆。 如果你想要更具體的控制,你可以修改圖例表的css。這個類被稱爲table.jqplot-table-legend。

事情是這樣的:

XHTML:

<p:chart styleClass="barChartStyleClass" type="bar" widgetVar="barChart" model="#{playgroundController.barModel}" style="width:400px;height:300px"> 

    </p:chart> 

CSS:

.barChartStyleClass table.jqplot-table-legend { 
    top:50px !important; 
    right:50px !important; 
    //more css here 
} 

也許你可以把它沒有重要的工作,但我沒有運氣!但我還是希望它有助於:)