Last active
August 29, 2015 14:20
-
-
Save hatemalimam/7335cc9c66c107ed181d to your computer and use it in GitHub Desktop.
Chart Data Provider for ChartistJSF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.chartistjsf.model.chart.AspectRatio; | |
import org.chartistjsf.model.chart.ChartSeries; | |
import org.chartistjsf.model.chart.PieChartModel; | |
import org.primefaces.event.ItemSelectEvent; | |
@ManagedBean | |
public class ChartDataBean { | |
private PieChartModel pieChartModel; | |
public ChartDataBean() { | |
createPieChart(); | |
} | |
public void createPieChart() { | |
pieChartModel = new PieChartModel(); | |
pieChartModel.addLabel("Bananas"); | |
pieChartModel.addLabel("Apples"); | |
pieChartModel.addLabel("Grapes"); | |
pieChartModel.set(20); | |
pieChartModel.set(10); | |
pieChartModel.set(30); | |
pieChartModel.setShowTooltip(true); | |
} | |
public void pieItemSelect(ItemSelectEvent event) { | |
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Item selected", "Item Value: " | |
+ pieChartModel.getData().get(event.getItemIndex())); | |
FacesContext.getCurrentInstance().addMessage(event.getComponent().getClientId(), msg); | |
} | |
/** | |
* @return the pieChartModel | |
*/ | |
public PieChartModel getPieChartModel() { | |
return pieChartModel; | |
} | |
/** | |
* @param pieChartModel | |
* the pieChartModel to set | |
*/ | |
public void setPieChartModel(PieChartModel pieChartModel) { | |
this.pieChartModel = pieChartModel; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment