2014-03-03 4 views
0

Primefaces에는 차트 구성 요소가 함께 제공됩니다. Atmosphere/push 프레임 워크를 사용하여 푸시 동작을 통해 차트를 업데이트하려고합니다.프라임 차트로 업데이트를 푸시하는 방법은 무엇입니까?

XHTML의 :

<h:body> 
    <p:panel id="panel"> 
     <p:lineChart id="category" value="#{beanViz.categoryModel}" legendPosition="e" 
        title="Category Chart" minY="0" maxY="200" style="height:300px;margin-top:20px"/> 

</p:panel> 
<h:form> 
    <p:commandButton value="Update" actionListener="#{beanViz.update()}"></p:commandButton> 
</h:form> 
<p:socket onMessage="handleMessage" channel="/counter" /> 

가 beanViz의 코드는 라인 차트를 만들 : 이제

int increment = 0; 
private CartesianChartModel categoryModel; 
public CartesianChartModel getCategoryModel() { 
    return categoryModel; 
} 

private void createCategoryModel() { 
    categoryModel = new CartesianChartModel(); 
    ChartSeries boys = new ChartSeries(); 
    boys.setLabel("Boys"); 
    boys.set("2004", 120 + increment); 
    boys.set("2005", 100); 
    boys.set("2006", 44); 
    boys.set("2007", 150); 
    boys.set("2008", 25); 
    categoryModel.addSeries(boys); 
} 

는 차트와 같은 페이지에있는 명령이의 업데이트를 트리거 차트에서 1 초 간격으로 하나의 값 :

public void update() { 
    for (int i = 0; i < 50; i = i+5) { 
     increment = increment + i; 
     createCategoryModel(); 
     PushContext pushContext = PushContextFactory.getDefault().getPushContext(); 
     pushContext.push("/counter", ""); 
     try { 
      Thread.sleep(1000); 
     } catch (InterruptedException ex) { 
      Logger.getLogger(BeanViz.class.getName()).log(Level.SEVERE, null, ex); 
     } 
    } 
} 

문제점 : 차트의 값을 업데이트하지 않으므로 진행 방법을 잘 모르겠습니다. 어떤 도움이 필요합니까?

답변

관련 문제