Exadel Fiji Developer Guide

Exadel Fiji


+1. Introduction
1.1. What is Exadel Fiji?
1.2. What is JSF?
1.3. What is Flex?
+2. Framework
+2.1. Data Transfer
2.1.1. HTTP Service
2.1.2. DataService
+2.2. Key features of Fiji Framework
2.2.1. Fiji components Flex API
2.2.2. Invoking Ajax Request
2.2.3. Passing Parameters
2.2.4. SWF Wrapping
2.3. Event handlers and predefined parameters
+3. Technical Requirements
3.1. Supported Java Versions
3.2. Supported JavaServer Faces Implementations and Frameworks
3.3. Supported servers
3.4. Supported Adobe Flex Versions
+4. Getting Started with Fiji
4.1. Installation
4.2. First Fiji project
+5. The Fiji Components
5.1. < fiji:endpoint >
5.2. < fiji:swf >
5.3. < fiji:barChart >
5.4. < fiji:stackedBarChart >
5.5. < fiji:lineChart >
5.6. < fiji:columnChart >
5.7. < fiji:stackedColumnChart >
+6. Legal Notes
6.1. License

Chapter 1. Introduction

Exadel Fiji is a library of ready-to-use Flex UI components and a framework designed for easy and smooth integration with JSF and other development environments.

The Fiji components use the same server side models, support standard JSF management mechanisms, allow interactions between each other as well as with standard JSF component, and provide look and feel generalization.

1.1. What is Exadel Fiji?

These are the main features of the Fiji framework:

  • Flex modules abstraction mechanism (Re-use of modules also in non JSF environment)

  • Data transfer mechanisms(Flash modules initialization and management)

    • Using DataService

    • Using HttpService

  • Standard interfaces for performing interaction between a JSF page and Flex modules

  • Inclusion existing flex modules using on-the-fly compilation

  • Look and feel interfaces management (Skinnability)

1.2. What is JSF?

JavaServer Faces technology includes:

  • A set of APIs for representing UI components and managing their state, handling events and input validation, defining page navigation, and supporting internationalization and accessibility.

  • A JavaServer Pages (JSP) custom tag library for expressing a JavaServer Faces interface within a JSP page.

Designed to be flexible, JavaServer Faces technology leverages existing, standard UI and web-tier concepts without limiting developers to a particular mark-up language, protocol, or client device. The UI component classes included with JavaServer Faces technology encapsulate the component functionality, not the client-specific presentation, thus enabling JavaServer Faces UI components to be rendered to various client devices. By combining the UI component functionality with custom renderers, which define rendering attributes for a specific UI component, developers can construct custom tags to a particular client device. As a convenience, JavaServer Faces technology provides a custom renderer and a JSP custom tag library for rendering to an HTML client, allowing developers of Java Platform, Enterprise Edition (Java EE) applications to use JavaServer Faces technology in their applications.

Ease-of-use being the primary goal, the JavaServer Faces architecture clearly defines a separation between application logic and presentation while making it easy to connect the presentation layer to the application code. This design enables each member of a web application development team to focus on his or her piece of the development process, and it also provides a simple programming model to link the pieces together. For example, web page developers with no programming expertise can use JavaServer Faces UI component tags to link to application code from within a web page without writing any scripts.

Learn more about JSF here.

1.3. What is Flex?

Flex is a free, open source framework for building highly interactive, expressive web applications that deploy consistently on all major browsers, desktops, and operating systems. It provides a modern, standards-based language and programming model that supports common design patterns. MXML, a declarative XML-based language, is used to describe UI layout and behaviors, and ActionScript™ 3, a powerful object-oriented programming language, is used to create client logic. Flex also includes a rich component library with more than 100 proven, extensible UI components for creating rich Internet applications (RIAs), as well as an interactive Flex application debugger.

RIAs created with Flex can run in the browser using Adobe Flash® Player software or on the desktop on Adobe AIR™, the cross-operating system runtime. This enables Flex applications to run consistently across all major browsers and on the desktop. And using AIR, Flex applications can now access local data and system resources on the desktop.

Learn more about Flex here.

Chapter 2. Framework

As it was mentioned earlier Fiji consists of two major parts:

  • Integration Framework

  • Set of UI Components

The two parts are illustrated on the figure below.

Fiji framework and UI library scheme

Figure 2.1. Fiji framework and UI library scheme


The first part includes a library of components to integrate Flex into the standard JSF environment(FIL), as well as the Universal Wrapper Component(UWC).

Universal Wrapper Component (UWC) is a universal component, that allows to involve any swf module into integration and pass a set of initialization parameters.

The second part is set of UI components.

Each component is essentially a modification and redefinition of Universal Wrapper Component with adjustments and modification to implement a particular component.

Hence all UI components have two integral parts.

  1. A modification of Universal Wrapper Component specific for every component.
  2. Visual Flex module.

Thereby, a Visual Flex module has no dependencies on JSF artifacts: neither on architecture level, nor in Maven dependencies.

The Fiji framework leaves a possibility to use all components not only in JSF environment.

The Visual Flex modules preserve the structure of Maven projects.

2.1. Data Transfer

This section coveres main aspects of data transfer.

2.1.1. HTTP Service

Using this feature any Flex module could get the data from JSF Managed Beans or just call any object method which return this data without having to know about JSF.

In order to implement interoperability between Flex and JSF the <fiji:endPoint> component provides access to the properties or methods of any object via a URL: for Flex module the it is just a URL which it uses to send the request to the server.

An example showing basics of httpService usage can be found on Fiji demo site.

2.1.2. DataService

Fiji DataService feature allows to call remote procedure and get the result using AMF format and standard RemoteObject from JSF back-end.

AMF is a binary format based loosely on the Simple Object Access Protocol (SOAP). It is used primarily to exchange data between an Adobe Flash application and a server.

The "binary" attribute of the <fiji:endPoint> component set to "true" indicates that Fiji will use the AMF protocol. The RemoteObject object uses this protocol to send a request from a Flex module. It the "binary" attribute is set to "false" the request is processed as a flow of sting values, i.e. HTTPSevice is used.

2.2. Key features of Fiji Framework

2.2.1. Fiji components Flex API

Fiji components Flex API - is one of the major features which allows to manage the component from the callback function defined on the component itself either as from any other page elements.

2.2.2. Invoking Ajax Request

Invoking Ajax request could be easily done using Rich Faces Ajax action components together with fiji components. Events of Flex components could be used to send simple ajax request and update parts of the page.

2.2.3. Passing Parameters

Fiji allows to pass parameter to a flash object represented via <fiji:swf> component using standard <f:param> tag.

Value can be simply a constant like <f:param name="someParam" value="paramValue"> or it can be JSF value binding to some bean property.

2.2.4. SWF Wrapping

One of the most important features of the Fiji Framework is the SWF Wrapping.

The SWF Wrapping provides the possibility to easily embed any flash object into a page and also integrate it in the JSF environment.

2.3. Event handlers and predefined parameters

Fiji library provides set of event handlers that are available to use with the component in the library.

The event handlers can be used the same way as any standard HTML event handler, Fiji extends the range of the event handlers and adds a number of extra event handlers.

For example, if it's needed to perform some action when a chart bar is clicked on, the "onitemclick" attribute can be used for this purpose. Read the listing below to see details.

...     
<fiji:columnChart onitemclick="alert('The bar is clicked on.')" value="#{bean.data}" />  	
...

The additional event handlers were designed to ease the work with client side functions, thus any JavaScript function correctly defined in the event handlers will be executed upon a corresponding event.

The following tables list all event handles in the framework. The event handlers are grouped by a prefix which also helps to identify the purpose of a particular event handler.

Table 2.1. Bar event handlers

Event handlerDescription
onitemmouseoverA JavaScript event handler called on when a bar item is hovered
onitemmouseoutA JavaScript event handler called on when the pointer is moved away from a bar item
onitemclickA JavaScript event handler called on when a bar item is clicked on
onitemdblclickA JavaScript event handler called on when a bar item is double clicked on

Items properties should be available inside handlers (x, y, value)

Table 2.2. Legend event handlers

Event handlerDescription
onlegenditemmouseoverA JavaScript event handler called when a legend item is hovered.
onlegenditemmouseoutA JavaScript event handler called when the pointer is moved away from a legend item
onlegenditemclickA JavaScript event handler called when a legend item is clicked on
onlegenditemdblclickA JavaScript event handler called when a legend item is double clicked on

Table 2.3. Diagram area event handlers

Event handlerDescription
onchartmoueoverA JavaScript event handler called when a chart is hovered.
onchartmouseoutA JavaScript event handler called when the pointer is moved away from a chart
onchartclickA JavaScript event handler called when a chart is clicked on
onchartdblclickA JavaScript event handler called when a chart is double clicked on

Some predefined parameters that Fiji provides can be used in the functions that are triggered upon an event defined by an event handler.

Table 2.4. Predefined parameters

ParameterDescription
{x}Stores x value corresponding to currently activated element (activated element concrete bar)
{y} Stores y value corresponding to currently activated element (activated element concrete bar)
{name}Stores name value corresponding to currently activated element (activated element concrete bar)

Chapter 3. Technical Requirements

Below is a list of the supported software versions necessary to start working with Fiji.

3.1. Supported Java Versions

  • JDK 1.5 and higher

3.2. Supported JavaServer Faces Implementations and Frameworks

  • Sun JSF-RI-1.2_09

  • RichFaces-3.2.2.GA

3.3. Supported servers

  • JBoss 4.2.x

  • Apache Tomcat 5.5

    You need to have the following list of libraries to run the Fiji project on Apache Tomcat 5.5.
    • amf-serializer-1.7.0.jar

    • common-annotations.jar

    • commons-beanutils.jar

    • commons-collections.jar

    • commons-digester.jar

    • commons-logging.jar

    • el-api-1.0.jar

    • el-impl-1.0.jar

    • fiji-api-1.0.0.jar

    • fiji-ui-1.0.0.jar

    • flamingo-service-jsf-1.7.0.jar

    • jsf-api-1.2_09.jar

    • jsf-facelets-1.1.14.jar

    • jsf-impl-1.2_09.jar

    • jstl.jar

    • laguna.jar

    • richfaces-api-3.2.2.GA.jar

    • richfaces-impl-3.2.2.GA.jar

    • richfaces-ui-3.2.2.GA.jar

    • standard.jar

  • Apache Tomcat 6.0

    You need to have the following list of libraries to run the Fiji project on Apache Tomcat 6.0

    • amf-serializer-1.7.0.jar

    • common-annotations.jar

    • commons-beanutils.jar

    • commons-collections.jar

    • commons-digester.jar

    • commons-logging.jar

    • fiji-api-1.0.0.jar

    • fiji-ui-1.0.0.jar

    • flamingo-service-jsf-1.7.0.jar

    • jsf-api-1.2_09.jar

    • jsf-facelets-1.1.14.jar

    • jsf-impl-1.2_09.jar

    • jstl.jar

    • laguna.jar

    • richfaces-api-3.2.2.GA.jar

    • richfaces-impl-3.2.2.GA.jar

    • richfaces-ui-3.2.2.GA.jar

    • standard.jar

3.4. Supported Adobe Flex Versions

We assume the list can be incomplete and absence of your environment in the list does not mean incompatibility. We appreciate your feedback on platforms that are not in the list but are compatible with Exadel Flamingo. It helps us to keep the list up-to-date.

Chapter 4. Getting Started with Fiji

The chapter covers basic aspects pertaining to developing rich web applications with Fiji framework and using the Fiji components.

4.1. Installation

  • Copy all required libraries into the "WEB-INF/lib" folder of your application.

  • Add the following line at the top of the view page where you are planning to use the Fiji components.

    ...
    <%@ taglib uri="http://exadel.com/fiji" prefix="fiji"%>
    ...

4.2. First Fiji project

This is a brief tutorial on how to run an application with Exadel Fiji.

You have to make a few step to run and deploy the "helloWorld" project.

  1. Run fijiinstall.bat(or fijiinstall in Linux) script to put all artefacts from lib folder into the maven repository

  2. Find a "helloWorld" in the archive with the "readme.txt" file. It contains a ready skeleton of maven project to make your own Fiji project.

  3. Run "mvn clean package" command on helloWorld project with pom.xml

  4. Note, that if you have Apache Tomcat 6.0 or JBoss/JavaEE5 Server installed. You can use command "mvn clean package -Ptomcat5.5" for Tomcat 5.5 to use "el-api-1.0.jar" and "el-impl-1.0.jar" libraries since they are not installed.

  5. Run "mvn eclipse:eclipse" command on the pom.xml of the "helloWorld" project in case you need to import as a project into the Eclipse IDE.

Now, you can get down to using the Fiji components.

The "helloWorld" project contains a blank "fiji.xhtml" file that will suit you perfectly to use as a template. First, add this code to the view file.

...
  <fiji:barChart id="barChartOne" value="#{oneSeriesBar.data}"
    title="One-series Bar Chart" width="500" height="300">
    <fiji:chartData type="name" value="Series 15" />
  </fiji:barChart>
  ...

As you can see the "value" attribute of <fiji:barChart> has a binding to a Java bean (OneSeriesBar ) which passes the data to the component, therefore you have to find the OneSeriesBar.java file and add the following code into it.

...
    package fiji;
    public class OneSeriesBar {
    public OneSeriesBar() {
    }
    private Integer[] data = new Integer[3];
    public Integer[] getData() {
    data[0] = 5;
    data[1] = 2;
    data[2] = -3;
    System.out.println ( data );
    return data;
    }
    }
    ...

Now you can run your application on the server. The page with the component can be addressed with this URL - http://localhost:8080/helloWorld/fiji.jsf

Anyway, if you fail to create the kick start project using these instructions you can import the helloWorld.war to get a basic idea about the usage of Fiji component helloWorld.war can be found in the "helloWorld" folder.

Chapter 5. The Fiji Components

The library encompasses ready-made Fiji components.

5.1.  < fiji:endpoint >

5.1.1. Description

The <fiji:endPoint> component is used as a child tag of <fiji:swf> that implements bridge mechanism to enable the interaction between client-server architecture used in Flex and JSF.

5.1.2. Key features

  • Getting the whole structure of the bean

  • Getting the structure of the specific bean property

  • Using Encoder

  • Using Decoder

  • Data transfer via HTTPService

  • Data transfer via DataService

Table 5.1. fiji : endpoint attributes

Attribute NameDescription
binaryThe "binary" attribute of indicates that AMF protocol is used for binary data transfer. The attribute enable DataService data transfre mechanism. Default value is "false".
bindingThe attribute takes a value-binding expression for a component property of a backing bean
idEvery component may have a unique id that is automatically created if omitted
nameThe name attribute specifies a name for the component
renderedIf "false", this component is not rendered
serviceMethod for process http service request.
valueThe value attribute is used for binding to a bean property

5.1.3. Creating the Component with a Page Tag

To create the simplest variant on a page use the following syntax:

...
<fiji:endpoint  value="#{bean.data}" />
...

5.1.4. Details of Usage

In order to implement interoperability between Flex and JSF the <fiji:endPoint> provides access to the properties of the object via a URL: for Flex module it is just a URL which it uses to send the request to the server(HTTP service).

This is how the <fiji:endPoint> can be used on a page

...
<fiji:swf>
<fiji:endPoint name="foopath" value="#{bean.data}" />
</fiji:swf>
...

The <fiji:endPoint> has a number of attributes that help it to build the designed functionality.

The "value" and "service" are used to preform binding to a managed bean. The difference between these two attributes is that in "value" you need to bind to a bean property and in case with "service" the attribute is bound to a appropriate method.

In the listing it's shown how the "service" attribute is bound to a method.

...
<fiji:endPoint name="foopath" service="#{report.takeReport}" />
...

In the listing it's shown how the "value" attribute is a bean property.

...
<fiji:endPoint name="foopath" value="#{report.property}" />
...

If you bind some method to the "service" the <fiji:endPoint> will serialize the bean structure with a default encoder into an XML file.

If a bean looks like this

...
user {
String name;
int age;
Order[] orders
}
order {
int id;
int value;
} 
...

the XML file will be the following.

...
<user>
  <name>Smith</name>
  <age>22</age>
    <order>
       <id>12</id>
      ....
    </order>
</user> 
  ...

In this regards if a Flex module requires a certain structure you can use the "encoder" i.e. you need to serialize the bean in a different way.

To perform this you do the following:

...
<fiji:endPoint name="foopath" encoder="com.exadel.demo.MyEncoder" service="#{report.takeReport}" /> 
...

There is a method in MyEncoder that gets an object from takeReport and returns a serialized structure (XML, comma-separated strings, binary structure). Thus the <fiji:endPoint> is addressed with a HTTP request and as a response it returns an XML file.

The "decoder" attribute takes the parameters that Flex sends with an HTTP service and creates an object needed to execute the myEncoder method.

The decoder can be used like this

...
<fiji:endPoint name="foopath" encoder="com.exadel.demo.MyEncoder" decoder="com.exadel.demo.MyDecoder" service="#{report.saveReport}" />
...

You don't need to define a class that implements the myEncoder() and myDecoder() methods.

5.1.5. Relevant Resources Links

Here you can see an example of <fiji:endpoint> usage details and examples with full code listings.

5.2.  < fiji:swf >

5.2.1. Description

The <fiji:swf> is a tag that implements the functionality of Universal Wrapper.

5.2.2. Key features

  • Insertion flex module into JSF page

  • Data definition without string forming

  • Data binding with JSF EL (simple data)

  • Data serialization

Table 5.2. fiji : swf attributes

Attribute NameDescription
applicationThe application attribute defines application name
bgcolorThe bgcolor attribute defines background color for the component
bindingThe attribute takes a value-binding expression for a component property of a backing bean
heightThe height attribute specifies height for the component
idEvery component may have a unique id that is automatically created if omitted
renderedIf "false", this component is not rendered
srcThe src attribute provides a path to the Flash object
valueThe value attribute provides binding to a bean property
widthThe width attribute specifies width for the component

5.2.3. Creating the Component with a Page Tag

To create the simplest variant on a page use the following syntax:

...
<fiji:swf src="my.swf" />
...

5.2.4. Details of Usage

The <fiji:swf> is implementation of Universal Wrapper Component and is designed to embed any swf file that a developer wants to represent on a page. A path to the swf file is specified with "src" attribute.

...     
<fiji:swf src="bar.swf" />
...
  

5.2.4.1. Universal Wrapper Component

5.2.4.1.1. Key features of Universal Wrapper Component

The Universal Wrapper Component has a number of key functional features.

5.2.4.1.1.1. Insertion of a flex module into JSF page

The <fiji:swf> component allows to embed an Flash module to a page without necessity to use such HTML tag as <object> or <embed>.

5.2.4.1.1.2. Data definition without string forming

Passing the initialization data to a Flex module via a standard JSF tag <f:param> which transfers the data to flashvars.

...      
<fiji:swf src="foo/bar.swf">
<f:param name="a" value="3" />
        <f: param name="b" value="4" />
</fiji:swf>
...
        
5.2.4.1.1.3. Data binding with JSF EL expressions

The features works exactly the same way as the previous one, but "value" attribute gets the value from the bean.

...      
<fiji:swf src="bar.swf">
<f: param name="e" value="#{user.name}" />
</fiji:swf>
...
        
5.2.4.1.1.4. Data serialization

If you need to pass some complex type data to the Flex module you should serialize the bean and pass the data right to the Flex module. Data is passed via an XML file. Fiji forms the object of tag that incorporates the xml data transferred to the Flex module and which it has to render to a page. You can access the data passed to the body of the tag read and process it without server calling.

Here is an example of how the Universal Wrapper can be used.

The example shows how an swf file is embedded to that JSF page and how the parameters are passed to the swf file.

...      
<fiji:swf src="/ampie/ampie.swf" bgcolor="#FFFFFF" width="520" height="400">
<f:param name="path" value="/ampie" />
<f:param name="settings_file" value="#{facesContext.externalContext.requestContextPath}/ampie/ampie_settings.xml" />
<f:param name="data_file" value="#{facesContext.externalContext.requestContextPath}/ampie/ampie_data.xml" />
<f:param name="preloader_color" value="#999999" />
</fiji:swf>
 ...
  

The swf file is embedded using the "src" attribute, while the parameters that are passed to the "ampie.swf" file via a standard JSF tag <f:param>. The "name" attribute defines a certain parameter of a Flash object and the "value" contains the valued to be passed.

This is how it looks on a page.

Specifying a set of colors for the bars.

Figure 5.1. Specifying a set of colors for the bars.


5.2.5. Relevant Resources Links

Here you can see an example of <fiji:swf> usage details and examples with full code listings.

5.3.  < fiji:barChart >

5.3.1. Description

The <fiji:barchart> allows to build highly interactive and skinnable bar chart on the page, client side functionality is represented with a Flex module.

<fiji:barchart>

Figure 5.2.  <fiji:barchart>


5.3.2. Key features

  • Interactive chart elements (legend, bars, rulers, etc)

  • Viewing intermediate values between series values

  • Building charts with missing or negative series values

Table 5.3. fiji : barChart attributes

Attribute NameDescription
additionalGridColorThe additionalGridColor attribute specifies additional grid color
applicationThe application attribute specifies the application name
backgroundImageThe backgroundImage attribute allows to define a custom image as a background
barCaptionThe barCaption attribute defines bar caption to be displayed
barCaptionClassThe barCaptionClass attribute defines a CSS style class for bar caption
barColorOpacityThe barColorOpacity attribute defines opacity for all bars displayed on series values. There is no possibility to set opacity for a particular bar / a set of bars belonging to one series
barColorsThe barColors attribute defines a set of colors for the bars. Accepts List of values.
barColorSaturationThe barColorSaturation attribute defines if saturation should be applied to chart representation.
basicGridColorThe basicGridColor attribute defines basic grid color
bgcolorThe bgcolor attribute allows to define background color for the chart
bindingThe attribute takes a value-binding expression for a component property of a backing bean
captionXThe captionX attribute defines caption for x values.
captionYThe captionY attribute defines caption for Y values.
converterId of Converter to be used or reference to a Converter
diagramHeightThe diagramHeight attribute defines chart height with excluded legend and header
diagramWidthThe diagramWidth attribute defines chart width with excluded legend and header
displayLegendThe displayLegend attribute defines whether the legend is displayed or hidden
displayTooltipThe displayTooltip attribute defines if a tooltip should be displayed or not on the hovering of the corresponding column of the chart. Tooltip content needs to be defined using toolTipValue attribute. Tooltip is not displayed if toolTipValue is null.
heightThe height attribute defines height for the component
idEvery component may have a unique id that is automatically created if omitted
legendCaptionThe legendCaption attribute displays a caption in the legend header
legendColorThe legendColor attribute defines color setting for the legend
legendHeaderClassThe legendHeaderClass attribute defines a CSS style class for the legend header
legendItemClassThe legendItemClass attribute defines a CSS style class for a legend item
legendItemInactiveClassThe legendItemInactiveClass attribute defines a CSS style class for an inactive item
legendPositionThe legendPosition attribute defines the position of the legend relatively to the chart. Possible values are right, bottom, top. Default value is right.
onchartclickA JavaScript event handler called when a chart is clicked on
onchartdblclickA JavaScript event handler called when a chart is double clicked on
onchartmouseoutA JavaScript event handler called when the pointer is moved away from a chart
onchartmouseoverA JavaScript event handler called when a chart is hovered
onitemclickA JavaScript event handler called on when a bar item is clicked on
onitemdblclickA JavaScript event handler called on when a bar item is double clicked on
onitemmouseoutA JavaScript event handler called on when the pointer is moved away from a bar item
onitemmouseoverA JavaScript event handler called on when a bar item is hovered
onlegenditemclickA JavaScript event handler called when a legend item is clicked on
onlegenditemdblclickA JavaScript event handler called when a legend item is double clicked on
onlegenditemmouseoutA JavaScript event handler called when a legend item is double clicked on
onlegenditemmouseoverA JavaScript event handler called when a legend item is hovered
orientationThe orientation attribute defines orientation of the component
renderedIf "false", this component is not rendered
rulersColorThe rulersColor attribute sets colors for the rulers
rulersMarkerXClassThe legendItemInactiveClass attribute defines a CSS for X ruler markers
rulersMarkerYClassThe rulersMarkerYClass attribute defines a CSS for Y ruler markers
rulersValuesHighlightThe rulersValuesHighlight attribute defines chart height with excluded Legend and Header
styleClassThe styleClass attribute defines a CSS style class for flash background (area under chart, legend and header)
subtitleThe subtitle attribute defines the subtitle for the chart header
subTitleClassThe subTitleClass attribute defines a CSS class for the subtitle for the chart header
titleThe title attribute defines the title for the chart header
titleClassThe titleClass attribute defines a CSS class for the title for the chart header
toolTipClassThe toolTipClass attribute defines a CSS class for the tooltip
toolTipValueThe toolTipValue attribute defines tooltip text to be displayed. Tooltip is disabled with displayTooltip if the attribute not defined.
valueThe current value of this component
varThe var attribute stores currently selected value
widthThe width attribute defines width for the component

5.3.3. Creating the Component with a Page Tag

To create the simplest variant on a page use the following syntax:

...
<fiji:barChart  value="#{bean.data}" />
...

5.3.4. Details of Usage

The simplest bar chart using the <fiji:barChart> component can be created the following way:

...
<fiji:barChart  value="#{bean.monthMap}" width="300" height="300">
<fiji:chartData type="name" value="#{bean.names}" />
</fiji:barChart>
...

The data for the component to render is taken from the model object bound to the component.

...
private  ArrayList<String> names = new ArrayList<String>();
    private	 Map<Integer, Object> monthMap = new LinkedHashMap<Integer,Object>();
    public ArrayList<String> getNames(){
        names.add("Motherboards");
        names.add("Hard drives");
        names.add("Monitors");
        return names;
    }
    private Integer[] data1 = new Integer[]{800, 900, 900};
    private Integer[] data2 = new Integer[]{812, 920, 1300};
    public Map<Integer, Object> getMonthMap() {
    		monthMap.put(1, data1);
    		monthMap.put(2, data2);
    		return monthMap;
    	}
    ...

As you can see from the code listing above the "value" attribute is used for data binding, while the names for the bars are passed to the "value" attribute of the <fiji:dataChart> nested auxiliary component.

As a result you will see this diagram.

The simples bar chart

Figure 5.3. The simples bar chart


There are a number of ways to pass data to the <fiji:barChart> component.

  • Using a map

    • You can pass "x" coordinates as keys and as "y" values.

      <x, y>

      ...
      <fiji:barChartvalue="#{bean.data}">
      <fiji:chartData type="name" value="Series1"/>
      </fiji:barChart> 
       ...
    • You can pass "x" coordinates as keys and a list or an array as "y" values.

      <x, list/array<y>>

      ...
      <fiji:barChartvalue="#{bean.data}"> 
      <fiji:chartData type="name" value="#{bean.names}"/> 
      </fiji:barChart> 
      ...
  • Using arrays

    • Onedimensional array. Index of the array should be "x" coordinates and array[i] should be "y".

      ...
      <fiji:barChartvalue="#{bean.data}" > 
      <fiji:chartData type="name" value="Series1"/> 
      </fiji:barChart> 
      ...
    • A Multidimensional array.

      Row Index of the array should be "x" values(for row orientation, for column – columns index should be "x").

      All array[index][…] - "y" values for index in row orientation.

      ...
      <fiji:barChartvalue="#{bean.data}">
      <fiji:chartData type="name" value="#{bean.names}"/> 
      </fiji:barChart> 
      ...
    • A multidimensional array with "x" specifying.

      Additionally to orientation - x index defines one row/column to be x values. All other row/columns – corresponding y values (normally for the cases where xindex=0(first row/column)) <fiji:dataChart> with name type defines one dimensional array of series names

      ...
      <fiji:barChartvalue="#{bean.data}" orientation="column" > 
      <fiji:chartData type="x" index="1"/> 
      <fiji:chartData type="name" value="#{bean.names}"/> 
      </fiji:barChart> 
      ...
    • Three or more arrays.

      Three arrays defines "x" ,"x" and "name" values.

      The <fiji:dataChart> with "y" type can be used more that once to define a few y values for the x. <fiji:dataChart> with type x could be not defined – indexes used in this case.

      ...
      <fiji:barChart> 
      <fiji:chartData type="x" value="#{bean.data1}"/> 
      <fiji:chartData type="y" value="#{bean.data2}" name=”Series1”/> 
      <fiji:chartData type="y" value="#{bean.data3}" name=”Series2”/> 
      <fiji:chartData type="y" value="#{bean.data4}" name=”Series3”/> 
      <fiji:chartData type="y" value="#{bean.data5}" name=”Series4”/> 
      </fiji:barChart> 
       ...
  • Using a list of objects

    • List of user defined types

      ...     
      <fiji:barChartvalue="#{bean.data}" var="item"> 
      <fiji:chartData type="x" value="#{item.x}"/> 
      <fiji:chartData type="y" value="#{item.y}" name=”Series1”/> 
      </fiji:barChart> 
      ...
    • List of simple types

      ...     
      <fiji:barChartvalue="#{bean.data}"> 
      <fiji:chartData type="name" value="Series1" /> 
      </fiji:barChart> 
      ...

The <fiji:barChart> has a number of helpful and useful attributes. We will cover the some attributes usage aspects here.

The "title" and "subtitle" render a title and a subtitle for the chart respectively.

The <fiji:barChart> with a title and a subtitle

Figure 5.4. The <fiji:barChart> with a title and a subtitle


To provide more information about the figures that a bar represents it is advisable to use "toolTipvalue" and "barCaption" attributes where some predefined substitutions that Fiji framework provides are available. Tooltip and bar caption can be set as follows:

These predefined substitutions available for all chart components:

  • {x} the value of "x" axis

  • {y} the value of "y" axis

  • {name} the series name

...    
<fiji:barChart id="barChartID5" value="#{bean.monthMap}" application="BarChart" bgcolor="#FFFFFF" width="350" height="300"
      title="Demo chart" subtitle="Subtitle with more detailed information" toolTipValue="{y} {name} were sold in {x} " barCaption="{y} {name}">
<fiji:chartData type="name" value="#{bean.names}" />
</fiji:barChart>
...

The <fiji:barChart> with a tooltip and a bar caption

Figure 5.5. The <fiji:barChart> with a tooltip and a bar caption


It looks more vividly if the bars of a different series have various colors. Recoloring can be performed using the "barColors" attribute. You can define colors in the bean file like this:

...    
 public List<String> getColors() {
    	List<String> colors = new ArrayList<String>();
    	colors.add("#5db2c2");
    	colors.add("#b0343c");
    	colors.add("#dd9f2c");
    	return colors;
}
...

And specify binging to the property that stores the colors in "barColors"

...    
<fiji:barChart  value="#{bean.monthMap}" barColors="#{bean.colors}">
<fiji:chartData type="name" value="#{bean.names}" />
</fiji:barChart>
...

This is what you will get as a result

The <fiji:barChart> with colored bars

Figure 5.6. The <fiji:barChart> with colored bars


There are a number of custom event handlers that can be used with the component, more details of their usage you can find here.

5.3.5. JavaScript API

Table 5.4. JavaScript API

FunctionDescription
update()Updates chart. Could be performed with fetching values from server

5.3.6. Relevant Resources Links

Here you can see an example of <fiji:barChart> usage details and examples with full code listings.

5.4.  < fiji:stackedBarChart >

5.4.1. Description

The <fiji:stackedBarChart> allows to build highly interactive and skinnable stacked bar chart on the page, client side functionality is represented with a Flex module.

<fiji:stackedBarChart>

Figure 5.7.  <fiji:stackedBarChart>


5.4.2. Key features

  • Interactive chart elements (legend, bars, rulers, etc)

  • Viewing intermediate values between series values

  • Building charts with missing or negative series values

Table 5.5. fiji : stackedBarChart attributes

Attribute NameDescription
additionalGridColorThe additionalGridColor attribute specifies additional grid color
applicationThe application attribute specifies the application name
backgroundImageThe backgroundImage attribute allows to define a custom image as a background
barCaptionThe barCaption attribute defines bar caption to be displayed
barCaptionClassThe barCaptionClass attribute defines a CSS style class for bar caption
barColorOpacityThe barColorOpacity attribute defines opacity for all bars displayed on series values. There is no possibility to set opacity for a particular bar / a set of bars belonging to one series
barColorsThe barColors attribute defines a set of colors for the bars. Accepts List of values.
barColorSaturationThe barColorSaturation attribute defines if saturation should be applied to chart representation.
basicGridColorThe basicGridColor attribute defines basic grid color
bgcolorThe bgcolor attribute allows to define background color for the chart
bindingThe attribute takes a value-binding expression for a component property of a backing bean
captionXThe captionX attribute defines caption for x values.
captionYThe captionY attribute defines caption for Y values.
chartTypeThe chartType defines presentation of the chart(The attribute will be implemented in the future releases).
converterId of Converter to be used or reference to a Converter
diagramHeightThe diagramHeight attribute defines chart height with excluded legend and header
diagramWidthThe diagramWidth attribute defines chart width with excluded legend and header
displayLegendThe displayLegend attribute defines whether the legend is displayed or hidden
displayTooltipThe displayTooltip attribute defines if a tooltip should be displayed or not on the hovering of the corresponding column of the chart. Tooltip content needs to be defined using toolTipValue attribute. Tooltip is not displayed if toolTipValue is null.
heightThe height attribute defines height for the component
idEvery component may have a unique id that is automatically created if omitted
legendCaptionThe legendCaption attribute displays a caption in the legend header
legendColorThe legendColor attribute defines color setting for the legend
legendHeaderClassThe legendHeaderClass attribute defines a CSS style class for the legend header
legendItemClassThe legendItemClass attribute defines a CSS style class for a legend item
legendItemInactiveClassThe legendItemInactiveClass attribute defines a CSS style class for an inactive item
legendPositionThe legendPosition attribute defines the position of the legend relatively to the chart. Possible values are right, bottom, top. Default value is right.
onchartclickA JavaScript event handler called when a chart is clicked on
onchartdblclickA JavaScript event handler called when a chart is double clicked on
onchartmouseoutA JavaScript event handler called when the pointer is moved away from a chart
onchartmouseoverA JavaScript event handler called when a chart is hovered
onitemclickA JavaScript event handler called on when a bar item is clicked on
onitemdblclickA JavaScript event handler called on when a bar item is double clicked on
onitemmouseoutA JavaScript event handler called on when the pointer is moved away from a bar item
onitemmouseoverA JavaScript event handler called on when a bar item is hovered
onlegenditemclickA JavaScript event handler called when a legend item is clicked on
onlegenditemdblclickA JavaScript event handler called when a legend item is double clicked on
onlegenditemmouseoutA JavaScript event handler called when a legend item is double clicked on
onlegenditemmouseoverA JavaScript event handler called when a legend item is hovered
orientationThe orientation attribute defines orientation of the component
renderedIf "false", this component is not rendered
rulersColorThe rulersColor attribute sets colors for the rulers
rulersMarkerXClassThe legendItemInactiveClass attribute defines a CSS for X ruler markers
rulersMarkerYClassThe rulersMarkerYClass attribute defines a CSS for Y ruler markers
rulersValuesHighlightThe rulersValuesHighlight attribute defines chart height with excluded Legend and Header
styleClassThe styleClass attribute defines a CSS style class for flash background (area under chart, legend and header)
subtitleThe subtitle attribute defines the subtitle for the chart header
subTitleClassThe subTitleClass attribute defines a CSS class for the subtitle for the chart header
titleThe title attribute defines the title for the chart header
titleClassThe titleClass attribute defines a CSS class for the title for the chart header
toolTipClassThe toolTipClass attribute defines a CSS class for the tooltip
toolTipValueThe toolTipValue attribute defines tooltip text to be displayed. Tooltip is disabled with displayTooltip if the attribute not defined.
valueThe current value of this component
varThe var attribute stores currently selected value
widthThe width attribute defines width for the component

5.4.3. Creating the Component with a Page Tag

Use the following syntax to create the simplest variant of the component on a page :

...
<fiji:stackedBarChart  value="#{bean.data}">
</fiji:stackedBarChart>
...

5.4.4. Details of Usage

The simplest way to add the <fiji:stackedBarChart> component is the following:

...
<fiji:stackedBarChart value="#{bean.monthMap}"  width="300" height="300">
        <fiji:chartData type="name" value="#{bean.beanNames}"></fiji:chartData>
</fiji:stackedBarChart>
...

The data the component renders to a chart is taken from the managed bean. Please read the given below code listing focusing particularly on how the data is passed to the component.

...
private	 Map<String, Object> monthMap = new LinkedHashMap<String,Object>();	
private Integer[] September = new Integer[]{800, 900, 900};
private Integer[] October = new Integer[]{812, 920, 1300};
public Map<String, Object> getMonthMap() {
monthMap.put("September", September);
monthMap.put("October", October);
return monthMap;
}
    ...

Hence, as you can see from the code listing the "value" attribute is used for data binding, while the names for the bars are passed to the "value" attribute of the <fiji:dataChart> nested auxiliary component.

As a result you will see this diagram.

The simples diagram

Figure 5.8. The simples diagram


There are a number of ways to pass data to the <fiji:stackedBarChart> component.

  • Using a map

    • Can pass "x" coordinates as keys and as "y" values.

      <x, y>

      ...
           <fiji:stackedBarChart value="#{bean.data}"> ///EL BINDING TO MAP 
             <fiji:chartData type="name" value="Serie1"/> 
           </fiji:stackedBarChart> 
           ...
    • You can pass "x" coordinates as keys and a list or an array as "y" values.

      <x, list/array<y>>

      ...
           <fiji:stackedBarChart value="#{bean.data}"> 
               <fiji:chartData type="name" value="#{bean.names}"/> 
             </fiji:stackedBarChart> 
             ...
  • Using a arrays

    • Onedimensional array. Index of the array should be "x" coordinates and array[i] should be "y".

      ...
      <fiji:stackedBarChart value="#{bean.data}" > 
      <fiji:chartData type="name" value="Serie1"/> 
      </fiji:stackedBarChart> 
           ...
    • A Multidimensional array. Row Index of the array should be "x" values(for row orientation, for column – columns index should be "x"). All array[index][…] - "y" values for index in row orientation.

      ...
      <fiji:stackedBarChart value="#{bean.data}"> 
      <fiji:chartData type="name" value="#{bean.names}"/> 
      </fiji:stackedBarChart> 
        ...
    • A multidimensional array with "x" specifying. Additionally to orientation - x index defines one row/column to be x values. All other row/columns – corresponding y values (normally for the cases where xindex=0(first row/column)) chartData with name type defines onedimensional array of series names

      ...
         <fiji:stackedBarChart value="#{bean.data}" orientation="column" > 
               <fiji:chartData type="x" index="1"/> 
               <fiji:chartData type="name" value="#{bean.names}"/> 
             </fiji:stackedBarChart> 
             ...
    • Three or more arrays. Three arrays defines x,y and name values. chartData with y type could be used more that once to define a few y values for the x. chartData with type x could be not defined – indexes used in this case.

      ...
             <fiji:stackedBarChart> 
               <fiji:chartData type="x" value="#{bean.data1}"/> 
               <fiji:chartData type="y" value="#{bean.data2}" name=”Series1”/> 
                 <fiji:chartData type="y" value="#{bean.data3}" name=”Series2”/> 
                 <fiji:chartData type="y" value="#{bean.data4}" name=”Series3”/> 
                   <fiji:chartData type="y" value="#{bean.data5}" name=”Series4”/> 
             </fiji:stackedBarChart> 
             ...
  • Using a list of objects

    • List of user defined types

      ...     
      <fiji:stackedBarChart value="#{bean.data}" var="item"> 
      <fiji:chartData type="x" value="#{item.x}"/> 
      <fiji:chartData type="y" value="#{item.y}" name=”Series1”/> 
      </fiji:stackedBarChart> 
      ...
    • List of simple types

      ...     
      <fiji:stackedBarChart value="#{bean.data}"> 
      <fiji:chartData type="name" value="Series1" /> 
      </fiji:stackedBarChart> 
      ...

The <fiji:stackedBarChart> has a number of other helpful and useful attributes. We will cover some attributes usage aspects here .

The "title" and "subtitle" render a title and subtitle for the chart respectively.

...     
  <fiji:stackedBarChart value="#{bean.monthMap}"  title="Demo chart" 
    subtitle="Subtitle with more detailed information">
    <fiji:chartData type="name" value="#{bean.beanNames}"></fiji:chartData>
  </fiji:stackedBarChart>
  ...
The <fiji:stackedBarChart> with a title and a subtitle

Figure 5.9. The <fiji:stackedBarChart> with a title and a subtitle


To provide more information about the figures that a bar represents it is advisable to use "toolTipvalue" attribute where some predefined substitutions are available.

...     
  <fiji:stackedBarChart value="#{bean.monthMap}" 
width="300" height="300" 
    title="Demo chart" subtitle="Subtitle with more detailed information" 
    toolTipValue="In {x} were sold {y} {name}">
    <fiji:chartData type="name" value="#{bean.beanNames}"></fiji:chartData>
  </fiji:stackedBarChart>
  ...
The <fiji:stackedBarChart> with a tooltip customized

Figure 5.10. The <fiji:stackedBarChart> with a tooltip customized


Likewise you can use the "barCaption" attribute to specify the caption on each bar.

...     
<fiji:stackedBarChart  value="#{bean.monthMap}" width="300" height="300" 
title="Demo chart" subtitle="Subtitle with more detailed information" 
toolTipValue=" {y} {name} were sold in  {x}     "
barCaption="{y} {name} ">
      <fiji:chartData type="name" value="#{bean.beanNames}"></fiji:chartData>
</fiji:stackedBarChart>
  ...

The given below figure shows the <fiji:stackedBarChart> with a tooltip and a caption displayed dynamically with the information for each bar, furthermore as it was mentioned the data is passed by means of substitutions.

The <fiji:stackedBarChart> with a tooltip and a caption on a bar

Figure 5.11. The <fiji:stackedBarChart> with a tooltip and a caption on a bar


These predefined substitutions available for all chart components:

  • {x} the value of "x" axis

  • {y} the value of "y" axis

  • {name} the series name

It looks more vividly if the bars of a different series have various colors. Recoloring can be performed using "barColors" attribute. You can define colors in the bean file and specify binging to the property that stores the colors.

Specifying a set of colors for the bars.

Figure 5.12. Specifying a set of colors for the bars.


In this example the "barColors" attribute is bound to the following collection of colors in the bean file.

...     
 public List<String> getColors() {
List<String> colors = new ArrayList<String>();
colors.add("#5db2c2");
colors.add("#b0343c");
colors.add("#dd9f2c");
return colors;
    }
...

There are a number of custom event handlers that can be used with the component, more details of their usage you can find here.

5.4.5. JavaScript API

Table 5.6. JavaScript API

FunctionDescription
update()Updates chart. Could be performed with fetching values from server

5.4.6. Relevant Resources Links

Here you can see an example of <fiji:stackedBarChart> usage details and examples with full code listings.

5.5.  < fiji:lineChart >

5.5.1. Description

The <fiji:lineChart> allows to build highly interactive and skinnable line chart on the page, client side functionality is represented with a Flex module.

<fiji:lineChart>

Figure 5.13.  <fiji:lineChart>


5.5.2. Key features

  • Interactive chart elements (legend, bars, rulers, etc)

  • Viewing series values of particular line

  • Viewing intermediate values between series values

  • Building charts with missing or negative series values

Table 5.7. fiji : lineChart attributes

Attribute NameDescription
additionalGridColorThe additionalGridColor attribute specifies additional grid color
applicationThe application attribute specifies the application name
backgroundImageThe backgroundImage attribute allows to define a custom image as a background
barCaptionThe barCaption attribute defines bar caption to be displayed
barCaptionClassThe barCaptionClass attribute defines a CSS style class for bar caption
barColorOpacityThe barColorOpacity attribute defines opacity for all bars displayed on series values. There is no possibility to set opacity for a particular bar / a set of bars belonging to one series
barColorsThe barColors attribute defines a set of colors for the bars. Accepts List of values.
barColorSaturationThe barColorSaturation attribute defines if saturation should be applied to chart representation.
basicGridColorThe basicGridColor attribute defines basic grid color
bgcolorThe bgcolor attribute allows to define background color for the chart
bindingThe attribute takes a value-binding expression for a component property of a backing bean
captionXThe captionX attribute defines caption for x values.
captionYThe captionY attribute defines caption for Y values.
converterId of Converter to be used or reference to a Converter
diagramHeightThe diagramHeight attribute defines chart height with excluded legend and header
diagramWidthThe diagramWidth attribute defines chart width with excluded legend and header
displayLegendThe displayLegend attribute defines whether the legend is displayed or hidden
displayTooltipThe displayTooltip attribute defines if a tooltip should be displayed or not on the hovering of the corresponding column of the chart. Tooltip content needs to be defined using toolTipValue attribute. Tooltip is not displayed if toolTipValue is null.
heightThe height attribute defines height for the component
idEvery component may have a unique id that is automatically created if omitted
legendCaptionThe legendCaption attribute displays a caption in the legend header
legendColorThe legendColor attribute defines color setting for the legend
legendHeaderClassThe legendHeaderClass attribute defines a CSS style class for the legend header
legendItemClassThe legendItemClass attribute defines a CSS style class for a legend item
legendItemInactiveClassThe legendItemInactiveClass attribute defines a CSS style class for an inactive item
legendPositionThe legendPosition attribute defines the position of the legend relatively to the chart. Possible values are right, bottom, top. Default value is right.
lineColorsThe lineColors attribute specifies custom colors for the chart lines
lineWidthThe lineWidth attribute specifies width parameters for the lines
markerCaptionThe markerCaption attribute defines caption for the chart markers
markerCaptionClassThe markerCaptionClass attribute defines a CSS style class for marker caption
onchartclickA JavaScript event handler called when a chart is clicked on
onchartdblclickA JavaScript event handler called when a chart is double clicked on
onchartmouseoutA JavaScript event handler called when the pointer is moved away from a chart
onchartmouseoverA JavaScript event handler called when a chart is hovered
onitemclickA JavaScript event handler called on when a bar item is clicked on
onitemdblclickA JavaScript event handler called on when a bar item is double clicked on
onitemmouseoutA JavaScript event handler called on when the pointer is moved away from a bar item
onitemmouseoverA JavaScript event handler called on when a bar item is hovered
onlegenditemclickA JavaScript event handler called when a legend item is clicked on
onlegenditemdblclickA JavaScript event handler called when a legend item is double clicked on
onlegenditemmouseoutA JavaScript event handler called when a legend item is double clicked on
onlegenditemmouseoverA JavaScript event handler called when a legend item is hovered
orientationThe orientation attribute defines orientation of the component
renderedIf "false", this component is not rendered
rulersColorThe rulersColor attribute sets colors for the rulers
rulersMarkerXClassThe legendItemInactiveClass attribute defines a CSS for X ruler markers
rulersMarkerYClassThe rulersMarkerYClass attribute defines a CSS for Y ruler markers
rulersValuesHighlightThe rulersValuesHighlight attribute defines chart height with excluded Legend and Header
showMarkersThe showMarkers attribute defines whether markers are displayed or not
styleClassThe styleClass attribute defines a CSS style class for flash background (area under chart, legend and header)
subtitleThe subtitle attribute defines the subtitle for the chart header
subTitleClassThe subTitleClass attribute defines a CSS class for the subtitle for the chart header
titleThe title attribute defines the title for the chart header
titleClassThe titleClass attribute defines a CSS class for the title for the chart header
toolTipClassThe toolTipClass attribute defines a CSS class for the tooltip
toolTipValueThe toolTipValue attribute defines tooltip text to be displayed. Tooltip is disabled with displayTooltip if the attribute not defined.
valueThe current value of this component
varThe var attribute stores currently selected value
widthThe width attribute defines width for the component

5.5.3. Creating the Component with a Page Tag

Use the following syntax to create the simplest variant of the component on a page :

...
<fiji:lineChart  value="#{bean.data}" />
...

5.5.4. Details of Usage

The simplest way to add the <fiji:lineChart> component is the following:

...
<fiji:lineChart   value="#{bean.monthMap}"  >
      		<fiji:chartData type="name" value="#{bean.names}" ></fiji:chartData>
</fiji:lineChart >
...

The data the component renders to a chart is taken from the managed bean. Please read the given below code listing focusing particularly on how the data is passed to the component.

...
private	 Map<String, Object> monthMap = new LinkedHashMap<String,Object>();
    public ArrayList<String> getNames(){
        names.add("Series one");
        names.add("Series two");
        names.add("Series three");
        return names;
    }
     private Integer[] data1 = new Integer[]{800, 900, 900};
    private Integer[] data2 = new Integer[]{812, 920, 1300 };
    private Integer[] data3 = new Integer[]{700, 600, 750 };
    public Map<String, Object> getMonthMap() {
    		monthMap.put("September", data1);
    		monthMap.put("October", data2);
    		monthMap.put("November", data3);
    		return monthMap;
    	}
    ...

Hence, as you can see from the code listing the "value" attribute is used for data binding, while the names for the bars are passed to the value attribute of the <fiji:dataChart> nested auxiliary component.

As a result you will see this diagram.

The simples diagram

Figure 5.14. The simples diagram


There are a number of ways to pass data to the <fiji:lineChart> component.

  • Using a map

    • Can pass "x" coordinates as keys and as "y" values.

      <x, y>

      ...
           <fiji:lineChart value="#{bean.data}"> ///EL BINDING TO MAP 
             <fiji:chartData type="name" value="Serie1"/> 
           </fiji:lineChart> 
           ...
    • You can pass "x" coordinates as keys and a list or an array as "y" values.

      <x, list/array<y>>

      ...
           <fiji:lineChart value="#{bean.data}"> 
               <fiji:chartData type="name" value="#{bean.names}"/> 
             </fiji:lineChart> 
             ...
  • Using a arrays

    • Onedimensional array. Index of the array should be "x" coordinates and array[i] should be "y".

      ...
      <fiji:lineChart value="#{bean.data}" > 
      <fiji:chartData type="name" value="Serie1"/> 
      </fiji:lineChart> 
           ...
    • A Multidimensional array. Row Index of the array should be "x" values(for row orientation, for column – columns index should be "x"). All array[index][…] - "y" values for index in row orientation.

      ...
      <fiji:lineChart value="#{bean.data}"> 
      <fiji:chartData type="name" value="#{bean.names}"/> 
      </fiji:lineChart> 
        ...
    • A multidimensional array with "x" specifying. Additionally to orientation - x index defines one row/column to be x values. All other row/columns – corresponding y values (normally for the cases where xindex=0(first row/column)) chartData with name type defines onedimensional array of series names

      ...
         <fiji:lineChart value="#{bean.data}" orientation="column" > 
               <fiji:chartData type="x" index="1"/> 
               <fiji:chartData type="name" value="#{bean.names}"/> 
             </fiji:lineChart> 
             ...
    • Three or more arrays. Three arrays defines x,y and name values. chartData with y type could be used more that once to define a few y values for the x. chartData with type x could be not defined – indexes used in this case.

      ...
             <fiji:lineChart> 
               <fiji:chartData type="x" value="#{bean.data1}"/> 
               <fiji:chartData type="y" value="#{bean.data2}" name=”Series1”/> 
                 <fiji:chartData type="y" value="#{bean.data3}" name=”Series2”/> 
                 <fiji:chartData type="y" value="#{bean.data4}" name=”Series3”/> 
                   <fiji:chartData type="y" value="#{bean.data5}" name=”Series4”/> 
             </fiji:lineChart> 
             ...
  • Using a list of objects

    • List of user defined types

      ...     
      <fiji:lineChart value="#{bean.data}" var="item"> 
      <fiji:chartData type="x" value="#{item.x}"/> 
      <fiji:chartData type="y" value="#{item.y}" name=”Series1”/> 
      </fiji:lineChart> 
      ...
    • List of simple types

      ...     
      <fiji:lineChart value="#{bean.data}"> 
      <fiji:chartData type="name" value="Series1" /> 
      </fiji:lineChart> 
      ...

The <fiji:lineChart> has a number of other helpful and useful attributes. We will cover some attributes usage aspects here .

The "title" and "subtitle" render a title and subtitle for the chart respectively.

...     
  <fiji:lineChart value="#{bean.monthMap}"  title="Demo chart" 
    subtitle="Subtitle with more detailed information">
    <fiji:chartData type="name" value="#{bean.beanNames}"></fiji:chartData>
  </fiji:lineChart>
  ...
The <fiji:lineChart> with a title and a subtitle

Figure 5.15. The <fiji:lineChart> with a title and a subtitle


It looks more vividly if the bars of a different series have various colors. Recoloring can be performed using "barColors" attribute. You can define colors in the bean file and specify binging to the property that stores the colors.

Specifying a set of colors for the bars.

Figure 5.16. Specifying a set of colors for the bars.


In this example the "barColors" attribute is bound to the following collection of colors in the bean file.

...     
private  ArrayList<String> names = new ArrayList<String>();
public List<String> getColors() {
List<String> colors = new ArrayList<String>();
colors.add("#5db2c2");
colors.add("#b0343c");
colors.add("#dd9f2c");
return colors;
    }
...

There are a number of custom event handlers that can be used with the component, more details of their usage you can find here.

5.5.5. JavaScript API

Table 5.8. JavaScript API

FunctionDescription
update()Updates chart. Could be performed with fetching values from server

5.5.6. Relevant Resources Links

Here you can see an example of <fiji:lineChart> usage details and examples with full code listings.

5.6.  < fiji:columnChart >

5.6.1. Description

The <fiji:columnChart> allows to build highly interactive and skinnable column chart on the page.

<fiji:columnChart>

Figure 5.17.  <fiji:columnChart>


5.6.2. Key features

  • Interactive chart elements (legend, bars, rulers, etc)

  • Viewing intermediate values between series values

  • Building charts with missing or negative series values

Table 5.9. fiji : columnChart attributes

Attribute NameDescription
additionalGridColorThe additionalGridColor attribute specifies additional grid color
applicationThe application attribute specifies the application name
backgroundImageThe backgroundImage attribute allows to define a custom image as a background
barCaptionThe barCaption attribute defines bar caption to be displayed
barCaptionClassThe barCaptionClass attribute defines a CSS style class for bar caption
barColorOpacityThe barColorOpacity attribute defines opacity for all bars displayed on series values. There is no possibility to set opacity for a particular bar / a set of bars belonging to one series
barColorsThe barColors attribute defines a set of colors for the bars. Accepts List of values.
barColorSaturationThe barColorSaturation attribute defines if saturation should be applied to chart representation.
basicGridColorThe basicGridColor attribute defines basic grid color
bgcolorThe bgcolor attribute allows to define background color for the chart
bindingThe attribute takes a value-binding expression for a component property of a backing bean
captionXThe captionX attribute defines caption for x values.
captionYThe captionY attribute defines caption for Y values.
converterId of Converter to be used or reference to a Converter
diagramHeightThe diagramHeight attribute defines chart height with excluded legend and header
diagramWidthThe diagramWidth attribute defines chart width with excluded legend and header
displayLegendThe displayLegend attribute defines whether the legend is displayed or hidden
displayTooltipThe displayTooltip attribute defines if a tooltip should be displayed or not on the hovering of the corresponding column of the chart. Tooltip content needs to be defined using toolTipValue attribute. Tooltip is not displayed if toolTipValue is null.
heightThe height attribute defines height for the component
idEvery component may have a unique id that is automatically created if omitted
legendCaptionThe legendCaption attribute displays a caption in the legend header
legendColorThe legendColor attribute defines color setting for the legend
legendHeaderClassThe legendHeaderClass attribute defines a CSS style class for the legend header
legendItemClassThe legendItemClass attribute defines a CSS style class for a legend item
legendItemInactiveClassThe legendItemInactiveClass attribute defines a CSS style class for an inactive item
legendPositionThe legendPosition attribute defines the position of the legend relatively to the chart. Possible values are right, bottom, top. Default value is right.
onchartclickA JavaScript event handler called when a chart is clicked on
onchartdblclickA JavaScript event handler called when a chart is double clicked on
onchartmouseoutA JavaScript event handler called when the pointer is moved away from a chart
onchartmouseoverA JavaScript event handler called when a chart is hovered
onitemclickA JavaScript event handler called on when a bar item is clicked on
onitemdblclickA JavaScript event handler called on when a bar item is double clicked on
onitemmouseoutA JavaScript event handler called on when the pointer is moved away from a bar item
onitemmouseoverA JavaScript event handler called on when a bar item is hovered
onlegenditemclickA JavaScript event handler called when a legend item is clicked on
onlegenditemdblclickA JavaScript event handler called when a legend item is double clicked on
onlegenditemmouseoutA JavaScript event handler called when a legend item is double clicked on
onlegenditemmouseoverA JavaScript event handler called when a legend item is hovered
orientationThe orientation attribute defines orientation of the component
renderedIf "false", this component is not rendered
rulersColorThe rulersColor attribute sets colors for the rulers
rulersMarkerXClassThe legendItemInactiveClass attribute defines a CSS for X ruler markers
rulersMarkerYClassThe rulersMarkerYClass attribute defines a CSS for Y ruler markers
rulersValuesHighlightThe rulersValuesHighlight attribute defines chart height with excluded Legend and Header
styleClassThe styleClass attribute defines a CSS style class for flash background (area under chart, legend and header)
subtitleThe subtitle attribute defines the subtitle for the chart header
subTitleClassThe subTitleClass attribute defines a CSS class for the subtitle for the chart header
titleThe title attribute defines the title for the chart header
titleClassThe titleClass attribute defines a CSS class for the title for the chart header
toolTipClassThe toolTipClass attribute defines a CSS class for the tooltip
toolTipValueThe toolTipValue attribute defines tooltip text to be displayed. Tooltip is disabled with displayTooltip if the attribute not defined.
valueThe current value of this component
varThe var attribute stores currently selected value
widthThe width attribute defines width for the component

5.6.3. Creating the Component with a Page Tag

Use the following syntax to create the simplest variant of the component on a page :

...
<fiji:columnChart  value="#{bean.data}" />
...

5.6.4. Details of Usage

The simplest way to add the <fiji:columnChart> component is the following:

...
<fiji:columnChart id="columnChartID1" value="#{bean.data}">
<fiji:chartData type="name" value="Series one" />
</fiji:columnChart>
...

The data that the component renders to the chart is taken from the managed bean.

...
    public Object[] getData() {
Random rnd = new Random(new Date().getTime());
List<Integer> data = new ArrayList<Integer>();
int dataSize = 3;
for (int i = 0; i < dataSize; i++) {
    data.add(rnd.nextInt(50));
}
return data.toArray();
    }
    ...

Hence, as you can see from the code listing the "value" attribute is used for data binding.

As a result you will see this diagram.

The simples diagram

Figure 5.18. The simples diagram


There are a number of ways to pass data to the <fiji:columnChart> component.

  • Using a map

    • Can pass "x" coordinates as keys and as "y" values.

      <x, y>

      ...
           <fiji:columnChart value="#{bean.data}"> ///EL BINDING TO MAP 
             <fiji:chartData type="name" value="Serie1"/> 
           </fiji:columnChart> 
           ...
    • You can pass "x" coordinates as keys and a list or an array as "y" values.

      <x, list/array<y>>

      ...
           <fiji:columnChart value="#{bean.data}"> 
               <fiji:chartData type="name" value="#{bean.names}"/> 
             </fiji:columnChart> 
             ...
  • Using a arrays

    • Onedimensional array. Index of the array should be "x" coordinates and array[i] should be "y".

      ...
      <fiji:columnChart value="#{bean.data}" > 
      <fiji:chartData type="name" value="Serie1"/> 
      </fiji:columnChart> 
           ...
    • A Multidimensional array. Row Index of the array should be "x" values(for row orientation, for column – columns index should be "x"). All array[index][…] - "y" values for index in row orientation.

      ...
      <fiji:columnChart value="#{bean.data}"> 
      <fiji:chartData type="name" value="#{bean.names}"/> 
      </fiji:columnChart> 
        ...
    • A multidimensional array with "x" specifying. Additionally to orientation - x index defines one row/column to be x values. All other row/columns – corresponding y values (normally for the cases where xindex=0(first row/column)) chartData with name type defines onedimensional array of series names

      ...
         <fiji:columnChart value="#{bean.data}" orientation="column" > 
               <fiji:chartData type="x" index="1"/> 
               <fiji:chartData type="name" value="#{bean.names}"/> 
             </fiji:columnChart> 
             ...
    • Three or more arrays. Three arrays defines x,y and name values. chartData with y type could be used more that once to define a few y values for the x. chartData with type x could be not defined – indexes used in this case.

      ...
             <fiji:columnChart> 
               <fiji:chartData type="x" value="#{bean.data1}"/> 
               <fiji:chartData type="y" value="#{bean.data2}" name=”Series1”/> 
                 <fiji:chartData type="y" value="#{bean.data3}" name=”Series2”/> 
                 <fiji:chartData type="y" value="#{bean.data4}" name=”Series3”/> 
                   <fiji:chartData type="y" value="#{bean.data5}" name=”Series4”/> 
             </fiji:columnChart> 
             ...
  • Using a list of objects

    • List of user defined types

      ...     
      <fiji:columnChart value="#{bean.data}" var="item"> 
      <fiji:chartData type="x" value="#{item.x}"/> 
      <fiji:chartData type="y" value="#{item.y}" name=”Series1”/> 
      </fiji:columnChart> 
      ...
    • List of simple types

      ...     
      <fiji:columnChart value="#{bean.data}"> 
      <fiji:chartData type="name" value="Series1" /> 
      </fiji:columnChart> 
      ...

The <fiji:columnChart> has a number of helpful and useful attributes. We will cover some attributes usage aspects here .

The "title" and "subtitle" render a title and subtitle for the chart respectively.

The <fiji:columnChart> with a title and a subtitle

Figure 5.19. The <fiji:columnChart> with a title and a subtitle


It looks more vividly if the bars of a different series have various colors. Recoloring can be performed using "barColors" attribute. You can define colors in the bean file and specify binging to the property that stores the colors.

Specifying a set of colors for the bars.

Figure 5.20. Specifying a set of colors for the bars.


In this example the "barColors" attribute is bound to the following collection of colors in the bean file.

...     
    public List<String> getBarColorsStr() {
    	List<String> data = new ArrayList<String>();
    	data.add("#ea9008");
    	data.add("#c44851");
    	return data;
    }  
...

It is certainly also possible to customize basically all visual elements of the component like rulers captions, line marker captions, legend items, etc.

The most common elements of a chart to be customized are line markers.

In order to add some specific names that are displayed as line markers you can pass the data to the "value" attribute of <fiji:chartData> as a map. Where the first key is the name of the line marker.

The provided below code listings show how you can add your specific names for the line markers.

This is the view page part.

...     
    <fiji:columnChart id="columnChartMulti" value="#{columnChartBean.monthMap}" title="Multi-dimensional Column Chart" 
                        barColors="#{columnChartBean.colors}"
                        subtitle="Hardware sales per month" legendWidth="200" width="300" height="300">
        <fiji:chartData type="name" value="#{columnChartBean.names}"></fiji:chartData>
    </fiji:columnChart>
...

The bean file.

...
private	 Map<String, Object> monthMap = new HashMap<String,Object>();
...
public Map<String, Object> getMonthMap() {
monthMap.put("February", getData());
monthMap.put("March", getData());
monthMap.put("January", getData());
return monthMap;
}
...

The background of the chart can be also set via the attribute "backgroundImage" of the component.

The caption for "X" and "Y"rulers can be specified using "captionX" "captionY" respectively.

There are a number of custom event handlers that can be used with the component, more details of their usage you can find here.

5.6.5. JavaScript API

Table 5.10. JavaScript API

FunctionDescription
update()Updates chart. Could be performed with fetching values from server

5.6.6. Relevant Resources Links

Here you can see an example of <fiji:columnChart> usage details and examples with full code listings.

5.7.  < fiji:stackedColumnChart >

5.7.1. Description

The <fiji:stackedColumnChart> allows to build a highly interactive and skinnable stacked column chart on the page, client side functionality is represented with a Flex module.

<fiji:stackedColumnChart>

Figure 5.21.  <fiji:stackedColumnChart>


5.7.2. Key features

  • Interactive chart elements (legend, bars, rulers, etc)

  • Viewing series values of particular line

  • Viewing intermediate values between series values

  • Building charts with missing or negative series values

Table 5.11. fiji : stackedColumnChart attributes

Attribute NameDescription
additionalGridColorThe additionalGridColor attribute specifies additional grid color
applicationThe application attribute specifies the application name
backgroundImageThe backgroundImage attribute allows to define a custom image as a background
barCaptionThe barCaption attribute defines bar caption to be displayed
barCaptionClassThe barCaptionClass attribute defines a CSS style class for bar caption
barColorOpacityThe barColorOpacity attribute defines opacity for all bars displayed on series values. There is no possibility to set opacity for a particular bar / a set of bars belonging to one series
barColorsThe barColors attribute defines a set of colors for the bars. Accepts List of values.
barColorSaturationThe barColorSaturation attribute defines if saturation should be applied to chart representation.
basicGridColorThe basicGridColor attribute defines basic grid color
bgcolorThe bgcolor attribute allows to define background color for the chart
bindingThe attribute takes a value-binding expression for a component property of a backing bean
captionXThe captionX attribute defines caption for x values.
captionYThe captionY attribute defines caption for Y values.
chartTypeThe chartType defines presentation of the chart(The attribute will be implemented in the future releases).
converterId of Converter to be used or reference to a Converter
diagramHeightThe diagramHeight attribute defines chart height with excluded legend and header