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.
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)
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.
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.
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.
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.
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.
This section coveres main aspects of data transfer.
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.
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.
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.
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.
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.
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 handler | Description |
|---|---|
| onitemmouseover | A JavaScript event handler called on when a bar item is hovered |
| onitemmouseout | A JavaScript event handler called on when the pointer is moved away from a bar item |
| onitemclick | A JavaScript event handler called on when a bar item is clicked on |
| onitemdblclick | A 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 handler | Description |
|---|---|
| onlegenditemmouseover | A JavaScript event handler called when a legend item is hovered. |
| onlegenditemmouseout | A JavaScript event handler called when the pointer is moved away from a legend item |
| onlegenditemclick | A JavaScript event handler called when a legend item is clicked on |
| onlegenditemdblclick | A JavaScript event handler called when a legend item is double clicked on |
Table 2.3. Diagram area event handlers
| Event handler | Description |
|---|---|
| onchartmoueover | A JavaScript event handler called when a chart is hovered. |
| onchartmouseout | A JavaScript event handler called when the pointer is moved away from a chart |
| onchartclick | A JavaScript event handler called when a chart is clicked on |
| onchartdblclick | A 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
| Parameter | Description |
|---|---|
| {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) |
Below is a list of the supported software versions necessary to start working with Fiji.
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
Adobe® Flex™ 2.0.1 Hotfix 2 and higher - (http://www.adobe.com/go/kb402000)
Adobe® Flex™ 3.0
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.
The chapter covers basic aspects pertaining to developing rich web applications with Fiji framework and using the Fiji components.
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"%> ...
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.
Run fijiinstall.bat(or fijiinstall in Linux) script to put all artefacts from lib folder into the maven repository
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.
Run "mvn clean package" command on helloWorld project with pom.xml
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.
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.
The library encompasses ready-made Fiji components.
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.
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 Name | Description |
|---|---|
| binary | The "binary" attribute of indicates that AMF protocol is used for binary data transfer. The attribute enable DataService data transfre mechanism. Default value is "false". |
| binding | The attribute takes a value-binding expression for a component property of a backing bean |
| id | Every component may have a unique id that is automatically created if omitted |
| name | The name attribute specifies a name for the component |
| rendered | If "false", this component is not rendered |
| service | Method for process http service request. |
| value | The value attribute is used for binding to a bean property |
To create the simplest variant on a page use the following syntax:
...
<fiji:endpoint value="#{bean.data}" />
...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.
Here you can see an example of <fiji:endpoint> usage details and examples with full code listings.
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 Name | Description |
|---|---|
| application | The application attribute defines application name |
| bgcolor | The bgcolor attribute defines background color for the component |
| binding | The attribute takes a value-binding expression for a component property of a backing bean |
| height | The height attribute specifies height for the component |
| id | Every component may have a unique id that is automatically created if omitted |
| rendered | If "false", this component is not rendered |
| src | The src attribute provides a path to the Flash object |
| value | The value attribute provides binding to a bean property |
| width | The width attribute specifies width for the component |
To create the simplest variant on a page use the following syntax:
... <fiji:swf src="my.swf" /> ...
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" /> ...
The Universal Wrapper Component has a number of key functional features.
The <fiji:swf> component allows to embed an Flash module to a page without necessity to use such HTML tag as <object> or <embed>.
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>
...
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>
...
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.
Here you can see an example of <fiji:swf> usage details and examples with full code listings.
The <fiji:barchart> allows to build highly interactive and skinnable bar chart on the page, client side functionality is represented with a Flex module.
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 Name | Description |
|---|---|
| additionalGridColor | The additionalGridColor attribute specifies additional grid color |
| application | The application attribute specifies the application name |
| backgroundImage | The backgroundImage attribute allows to define a custom image as a background |
| barCaption | The barCaption attribute defines bar caption to be displayed |
| barCaptionClass | The barCaptionClass attribute defines a CSS style class for bar caption |
| barColorOpacity | The 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 |
| barColors | The barColors attribute defines a set of colors for the bars. Accepts List of values. |
| barColorSaturation | The barColorSaturation attribute defines if saturation should be applied to chart representation. |
| basicGridColor | The basicGridColor attribute defines basic grid color |
| bgcolor | The bgcolor attribute allows to define background color for the chart |
| binding | The attribute takes a value-binding expression for a component property of a backing bean |
| captionX | The captionX attribute defines caption for x values. |
| captionY | The captionY attribute defines caption for Y values. |
| converter | Id of Converter to be used or reference to a Converter |
| diagramHeight | The diagramHeight attribute defines chart height with excluded legend and header |
| diagramWidth | The diagramWidth attribute defines chart width with excluded legend and header |
| displayLegend | The displayLegend attribute defines whether the legend is displayed or hidden |
| displayTooltip | The 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. |
| height | The height attribute defines height for the component |
| id | Every component may have a unique id that is automatically created if omitted |
| legendCaption | The legendCaption attribute displays a caption in the legend header |
| legendColor | The legendColor attribute defines color setting for the legend |
| legendHeaderClass | The legendHeaderClass attribute defines a CSS style class for the legend header |
| legendItemClass | The legendItemClass attribute defines a CSS style class for a legend item |
| legendItemInactiveClass | The legendItemInactiveClass attribute defines a CSS style class for an inactive item |
| legendPosition | The legendPosition attribute defines the position of the legend relatively to the chart. Possible values are right, bottom, top. Default value is right. |
| onchartclick | A JavaScript event handler called when a chart is clicked on |
| onchartdblclick | A JavaScript event handler called when a chart is double clicked on |
| onchartmouseout | A JavaScript event handler called when the pointer is moved away from a chart |
| onchartmouseover | A JavaScript event handler called when a chart is hovered |
| onitemclick | A JavaScript event handler called on when a bar item is clicked on |
| onitemdblclick | A JavaScript event handler called on when a bar item is double clicked on |
| onitemmouseout | A JavaScript event handler called on when the pointer is moved away from a bar item |
| onitemmouseover | A JavaScript event handler called on when a bar item is hovered |
| onlegenditemclick | A JavaScript event handler called when a legend item is clicked on |
| onlegenditemdblclick | A JavaScript event handler called when a legend item is double clicked on |
| onlegenditemmouseout | A JavaScript event handler called when a legend item is double clicked on |
| onlegenditemmouseover | A JavaScript event handler called when a legend item is hovered |
| orientation | The orientation attribute defines orientation of the component |
| rendered | If "false", this component is not rendered |
| rulersColor | The rulersColor attribute sets colors for the rulers |
| rulersMarkerXClass | The legendItemInactiveClass attribute defines a CSS for X ruler markers |
| rulersMarkerYClass | The rulersMarkerYClass attribute defines a CSS for Y ruler markers |
| rulersValuesHighlight | The rulersValuesHighlight attribute defines chart height with excluded Legend and Header |
| styleClass | The styleClass attribute defines a CSS style class for flash background (area under chart, legend and header) |
| subtitle | The subtitle attribute defines the subtitle for the chart header |
| subTitleClass | The subTitleClass attribute defines a CSS class for the subtitle for the chart header |
| title | The title attribute defines the title for the chart header |
| titleClass | The titleClass attribute defines a CSS class for the title for the chart header |
| toolTipClass | The toolTipClass attribute defines a CSS class for the tooltip |
| toolTipValue | The toolTipValue attribute defines tooltip text to be displayed. Tooltip is disabled with displayTooltip if the attribute not defined. |
| value | The current value of this component |
| var | The var attribute stores currently selected value |
| width | The width attribute defines width for the component |
To create the simplest variant on a page use the following syntax:
...
<fiji:barChart value="#{bean.data}" />
...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.
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.
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>
...
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
There are a number of custom event handlers that can be used with the component, more details of their usage you can find here.
Table 5.4. JavaScript API
| Function | Description |
|---|---|
| update() | Updates chart. Could be performed with fetching values from server |
Here you can see an example of <fiji:barChart> usage details and examples with full code listings.
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.
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 Name | Description |
|---|---|
| additionalGridColor | The additionalGridColor attribute specifies additional grid color |
| application | The application attribute specifies the application name |
| backgroundImage | The backgroundImage attribute allows to define a custom image as a background |
| barCaption | The barCaption attribute defines bar caption to be displayed |
| barCaptionClass | The barCaptionClass attribute defines a CSS style class for bar caption |
| barColorOpacity | The 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 |
| barColors | The barColors attribute defines a set of colors for the bars. Accepts List of values. |
| barColorSaturation | The barColorSaturation attribute defines if saturation should be applied to chart representation. |
| basicGridColor | The basicGridColor attribute defines basic grid color |
| bgcolor | The bgcolor attribute allows to define background color for the chart |
| binding | The attribute takes a value-binding expression for a component property of a backing bean |
| captionX | The captionX attribute defines caption for x values. |
| captionY | The captionY attribute defines caption for Y values. |
| chartType | The chartType defines presentation of the chart(The attribute will be implemented in the future releases). |
| converter | Id of Converter to be used or reference to a Converter |
| diagramHeight | The diagramHeight attribute defines chart height with excluded legend and header |
| diagramWidth | The diagramWidth attribute defines chart width with excluded legend and header |
| displayLegend | The displayLegend attribute defines whether the legend is displayed or hidden |
| displayTooltip | The 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. |
| height | The height attribute defines height for the component |
| id | Every component may have a unique id that is automatically created if omitted |
| legendCaption | The legendCaption attribute displays a caption in the legend header |
| legendColor | The legendColor attribute defines color setting for the legend |
| legendHeaderClass | The legendHeaderClass attribute defines a CSS style class for the legend header |
| legendItemClass | The legendItemClass attribute defines a CSS style class for a legend item |
| legendItemInactiveClass | The legendItemInactiveClass attribute defines a CSS style class for an inactive item |
| legendPosition | The legendPosition attribute defines the position of the legend relatively to the chart. Possible values are right, bottom, top. Default value is right. |
| onchartclick | A JavaScript event handler called when a chart is clicked on |
| onchartdblclick | A JavaScript event handler called when a chart is double clicked on |
| onchartmouseout | A JavaScript event handler called when the pointer is moved away from a chart |
| onchartmouseover | A JavaScript event handler called when a chart is hovered |
| onitemclick | A JavaScript event handler called on when a bar item is clicked on |
| onitemdblclick | A JavaScript event handler called on when a bar item is double clicked on |
| onitemmouseout | A JavaScript event handler called on when the pointer is moved away from a bar item |
| onitemmouseover | A JavaScript event handler called on when a bar item is hovered |
| onlegenditemclick | A JavaScript event handler called when a legend item is clicked on |
| onlegenditemdblclick | A JavaScript event handler called when a legend item is double clicked on |
| onlegenditemmouseout | A JavaScript event handler called when a legend item is double clicked on |
| onlegenditemmouseover | A JavaScript event handler called when a legend item is hovered |
| orientation | The orientation attribute defines orientation of the component |
| rendered | If "false", this component is not rendered |
| rulersColor | The rulersColor attribute sets colors for the rulers |
| rulersMarkerXClass | The legendItemInactiveClass attribute defines a CSS for X ruler markers |
| rulersMarkerYClass | The rulersMarkerYClass attribute defines a CSS for Y ruler markers |
| rulersValuesHighlight | The rulersValuesHighlight attribute defines chart height with excluded Legend and Header |
| styleClass | The styleClass attribute defines a CSS style class for flash background (area under chart, legend and header) |
| subtitle | The subtitle attribute defines the subtitle for the chart header |
| subTitleClass | The subTitleClass attribute defines a CSS class for the subtitle for the chart header |
| title | The title attribute defines the title for the chart header |
| titleClass | The titleClass attribute defines a CSS class for the title for the chart header |
| toolTipClass | The toolTipClass attribute defines a CSS class for the tooltip |
| toolTipValue | The toolTipValue attribute defines tooltip text to be displayed. Tooltip is disabled with displayTooltip if the attribute not defined. |
| value | The current value of this component |
| var | The var attribute stores currently selected value |
| width | The width attribute defines width for the component |
Use the following syntax to create the simplest variant of the component on a page :
...
<fiji:stackedBarChart value="#{bean.data}">
</fiji:stackedBarChart>
...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.
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>
...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>
...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.
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.
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.
Table 5.6. JavaScript API
| Function | Description |
|---|---|
| update() | Updates chart. Could be performed with fetching values from server |
Here you can see an example of <fiji:stackedBarChart> usage details and examples with full code listings.
The <fiji:lineChart> allows to build highly interactive and skinnable line chart on the page, client side functionality is represented with a Flex module.
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 Name | Description |
|---|---|
| additionalGridColor | The additionalGridColor attribute specifies additional grid color |
| application | The application attribute specifies the application name |
| backgroundImage | The backgroundImage attribute allows to define a custom image as a background |
| barCaption | The barCaption attribute defines bar caption to be displayed |
| barCaptionClass | The barCaptionClass attribute defines a CSS style class for bar caption |
| barColorOpacity | The 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 |
| barColors | The barColors attribute defines a set of colors for the bars. Accepts List of values. |
| barColorSaturation | The barColorSaturation attribute defines if saturation should be applied to chart representation. |
| basicGridColor | The basicGridColor attribute defines basic grid color |
| bgcolor | The bgcolor attribute allows to define background color for the chart |
| binding | The attribute takes a value-binding expression for a component property of a backing bean |
| captionX | The captionX attribute defines caption for x values. |
| captionY | The captionY attribute defines caption for Y values. |
| converter | Id of Converter to be used or reference to a Converter |
| diagramHeight | The diagramHeight attribute defines chart height with excluded legend and header |
| diagramWidth | The diagramWidth attribute defines chart width with excluded legend and header |
| displayLegend | The displayLegend attribute defines whether the legend is displayed or hidden |
| displayTooltip | The 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. |
| height | The height attribute defines height for the component |
| id | Every component may have a unique id that is automatically created if omitted |
| legendCaption | The legendCaption attribute displays a caption in the legend header |
| legendColor | The legendColor attribute defines color setting for the legend |
| legendHeaderClass | The legendHeaderClass attribute defines a CSS style class for the legend header |
| legendItemClass | The legendItemClass attribute defines a CSS style class for a legend item |
| legendItemInactiveClass | The legendItemInactiveClass attribute defines a CSS style class for an inactive item |
| legendPosition | The legendPosition attribute defines the position of the legend relatively to the chart. Possible values are right, bottom, top. Default value is right. |
| lineColors | The lineColors attribute specifies custom colors for the chart lines |
| lineWidth | The lineWidth attribute specifies width parameters for the lines |
| markerCaption | The markerCaption attribute defines caption for the chart markers |
| markerCaptionClass | The markerCaptionClass attribute defines a CSS style class for marker caption |
| onchartclick | A JavaScript event handler called when a chart is clicked on |
| onchartdblclick | A JavaScript event handler called when a chart is double clicked on |
| onchartmouseout | A JavaScript event handler called when the pointer is moved away from a chart |
| onchartmouseover | A JavaScript event handler called when a chart is hovered |
| onitemclick | A JavaScript event handler called on when a bar item is clicked on |
| onitemdblclick | A JavaScript event handler called on when a bar item is double clicked on |
| onitemmouseout | A JavaScript event handler called on when the pointer is moved away from a bar item |
| onitemmouseover | A JavaScript event handler called on when a bar item is hovered |
| onlegenditemclick | A JavaScript event handler called when a legend item is clicked on |
| onlegenditemdblclick | A JavaScript event handler called when a legend item is double clicked on |
| onlegenditemmouseout | A JavaScript event handler called when a legend item is double clicked on |
| onlegenditemmouseover | A JavaScript event handler called when a legend item is hovered |
| orientation | The orientation attribute defines orientation of the component |
| rendered | If "false", this component is not rendered |
| rulersColor | The rulersColor attribute sets colors for the rulers |
| rulersMarkerXClass | The legendItemInactiveClass attribute defines a CSS for X ruler markers |
| rulersMarkerYClass | The rulersMarkerYClass attribute defines a CSS for Y ruler markers |
| rulersValuesHighlight | The rulersValuesHighlight attribute defines chart height with excluded Legend and Header |
| showMarkers | The showMarkers attribute defines whether markers are displayed or not |
| styleClass | The styleClass attribute defines a CSS style class for flash background (area under chart, legend and header) |
| subtitle | The subtitle attribute defines the subtitle for the chart header |
| subTitleClass | The subTitleClass attribute defines a CSS class for the subtitle for the chart header |
| title | The title attribute defines the title for the chart header |
| titleClass | The titleClass attribute defines a CSS class for the title for the chart header |
| toolTipClass | The toolTipClass attribute defines a CSS class for the tooltip |
| toolTipValue | The toolTipValue attribute defines tooltip text to be displayed. Tooltip is disabled with displayTooltip if the attribute not defined. |
| value | The current value of this component |
| var | The var attribute stores currently selected value |
| width | The width attribute defines width for the component |
Use the following syntax to create the simplest variant of the component on a page :
...
<fiji:lineChart value="#{bean.data}" />
...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.
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>
...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.
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.
Table 5.8. JavaScript API
| Function | Description |
|---|---|
| update() | Updates chart. Could be performed with fetching values from server |
Here you can see an example of <fiji:lineChart> usage details and examples with full code listings.
The <fiji:columnChart> allows to build highly interactive and skinnable column chart on the page.
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 Name | Description |
|---|---|
| additionalGridColor | The additionalGridColor attribute specifies additional grid color |
| application | The application attribute specifies the application name |
| backgroundImage | The backgroundImage attribute allows to define a custom image as a background |
| barCaption | The barCaption attribute defines bar caption to be displayed |
| barCaptionClass | The barCaptionClass attribute defines a CSS style class for bar caption |
| barColorOpacity | The 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 |
| barColors | The barColors attribute defines a set of colors for the bars. Accepts List of values. |
| barColorSaturation | The barColorSaturation attribute defines if saturation should be applied to chart representation. |
| basicGridColor | The basicGridColor attribute defines basic grid color |
| bgcolor | The bgcolor attribute allows to define background color for the chart |
| binding | The attribute takes a value-binding expression for a component property of a backing bean |
| captionX | The captionX attribute defines caption for x values. |
| captionY | The captionY attribute defines caption for Y values. |
| converter | Id of Converter to be used or reference to a Converter |
| diagramHeight | The diagramHeight attribute defines chart height with excluded legend and header |
| diagramWidth | The diagramWidth attribute defines chart width with excluded legend and header |
| displayLegend | The displayLegend attribute defines whether the legend is displayed or hidden |
| displayTooltip | The 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. |
| height | The height attribute defines height for the component |
| id | Every component may have a unique id that is automatically created if omitted |
| legendCaption | The legendCaption attribute displays a caption in the legend header |
| legendColor | The legendColor attribute defines color setting for the legend |
| legendHeaderClass | The legendHeaderClass attribute defines a CSS style class for the legend header |
| legendItemClass | The legendItemClass attribute defines a CSS style class for a legend item |
| legendItemInactiveClass | The legendItemInactiveClass attribute defines a CSS style class for an inactive item |
| legendPosition | The legendPosition attribute defines the position of the legend relatively to the chart. Possible values are right, bottom, top. Default value is right. |
| onchartclick | A JavaScript event handler called when a chart is clicked on |
| onchartdblclick | A JavaScript event handler called when a chart is double clicked on |
| onchartmouseout | A JavaScript event handler called when the pointer is moved away from a chart |
| onchartmouseover | A JavaScript event handler called when a chart is hovered |
| onitemclick | A JavaScript event handler called on when a bar item is clicked on |
| onitemdblclick | A JavaScript event handler called on when a bar item is double clicked on |
| onitemmouseout | A JavaScript event handler called on when the pointer is moved away from a bar item |
| onitemmouseover | A JavaScript event handler called on when a bar item is hovered |
| onlegenditemclick | A JavaScript event handler called when a legend item is clicked on |
| onlegenditemdblclick | A JavaScript event handler called when a legend item is double clicked on |
| onlegenditemmouseout | A JavaScript event handler called when a legend item is double clicked on |
| onlegenditemmouseover | A JavaScript event handler called when a legend item is hovered |
| orientation | The orientation attribute defines orientation of the component |
| rendered | If "false", this component is not rendered |
| rulersColor | The rulersColor attribute sets colors for the rulers |
| rulersMarkerXClass | The legendItemInactiveClass attribute defines a CSS for X ruler markers |
| rulersMarkerYClass | The rulersMarkerYClass attribute defines a CSS for Y ruler markers |
| rulersValuesHighlight | The rulersValuesHighlight attribute defines chart height with excluded Legend and Header |
| styleClass | The styleClass attribute defines a CSS style class for flash background (area under chart, legend and header) |
| subtitle | The subtitle attribute defines the subtitle for the chart header |
| subTitleClass | The subTitleClass attribute defines a CSS class for the subtitle for the chart header |
| title | The title attribute defines the title for the chart header |
| titleClass | The titleClass attribute defines a CSS class for the title for the chart header |
| toolTipClass | The toolTipClass attribute defines a CSS class for the tooltip |
| toolTipValue | The toolTipValue attribute defines tooltip text to be displayed. Tooltip is disabled with displayTooltip if the attribute not defined. |
| value | The current value of this component |
| var | The var attribute stores currently selected value |
| width | The width attribute defines width for the component |
Use the following syntax to create the simplest variant of the component on a page :
...
<fiji:columnChart value="#{bean.data}" />
...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.
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.
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.
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.
Table 5.10. JavaScript API
| Function | Description |
|---|---|
| update() | Updates chart. Could be performed with fetching values from server |
Here you can see an example of <fiji:columnChart> usage details and examples with full code listings.
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.
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 Name | Description |
|---|---|
| additionalGridColor | The additionalGridColor attribute specifies additional grid color |
| application | The application attribute specifies the application name |
| backgroundImage | The backgroundImage attribute allows to define a custom image as a background |
| barCaption | The barCaption attribute defines bar caption to be displayed |
| barCaptionClass | The barCaptionClass attribute defines a CSS style class for bar caption |
| barColorOpacity | The 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 |
| barColors | The barColors attribute defines a set of colors for the bars. Accepts List of values. |
| barColorSaturation | The barColorSaturation attribute defines if saturation should be applied to chart representation. |
| basicGridColor | The basicGridColor attribute defines basic grid color |
| bgcolor | The bgcolor attribute allows to define background color for the chart |
| binding | The attribute takes a value-binding expression for a component property of a backing bean |
| captionX | The captionX attribute defines caption for x values. |
| captionY | The captionY attribute defines caption for Y values. |
| chartType | The chartType defines presentation of the chart(The attribute will be implemented in the future releases). |
| converter | Id of Converter to be used or reference to a Converter |
| diagramHeight | The diagramHeight attribute defines chart height with excluded legend and header |