miercuri, 4 martie 2015

HighFaces - Ultimate JSF2 / Chart Library based on HighCharts

What are you using for building charts in JSF ? PrimeFaces charts? HighCharts ? Well, is good to know that based on HighCharts, but in JSF style, we can use HighFaces. Here it is a simple example from HighFaces Showcase:

Simple Java bean:
@ManagedBean
@RequestScoped
public class LineChartBean {

    protected List<Integer> simpleList;
     
    public List<Integer> getSimpleList() {
        return simpleList;
    }           
     
    public LineChartBean() {
        reload();
    }

    private void reload() {
        simpleList = new ArrayList<>();
         
        Random r = new Random();
        for (int i = 2000; i < 2010; i++) {
            simpleList.add(r.nextInt(500) + 800);   
        } 
    }

}

JSF page:
<hf:chart type="line" value="# {lineChartBean.simpleList}" var="point"
     point="# {point}" title="List of Integer values" xaxisLabel="Index" yaxisLabel="Amount"/>

Output:

Easy to install:

New versions are submitted to Maven Central, so you can easily add it to your maven based projects:

<dependency>
 <groupId>org.highfaces</groupId>
 <artifactId>highfaces</artifactId>
 <version>${project.version}</version>
</dependency>

HighFaces source code including the showcase can be found at here
Bugs and Feature Requests can be submitted here.

Enjoy!

Niciun comentariu:

Trimiteți un comentariu