skip to main content
Getting started > Introducing JViews Charts > Developing with JViews Charts > Basic steps for building a chart component
 
Basic steps for building a chart component
Populating the chart
*To populate your chart you have to load data from data sources. The following predefined types of data sources are available:
*XML
*Flat File
*Database (JDBC)
*In-memory
*Data Writeback
*Customized Data Sources
XML
This type of data source allows you to load data from an XML file. The expected format is an application of the W3C XML language. You can find the full Document Type Definition of this format in Document Type Definition for XML data file in Using the Designer.
Flat File
This type of data source is a text file containing the same number of values on each line. The values are separated by a separator character. The supported separator characters are comma, semicolon, space, and tab. You can request automatic detection of the separators. If a flat file contains values exported from Microsoft® Excel, it is sometimes referred to as a CSV (comma-separated values) file. In a flat file, there is an implicit data model in which the first line contains the names of the model properties and each subsequent line contains the property values for an object, with the properties in the same order as on the first line.
Database (JDBC)
This type of data source allows you to retrieve data values from database servers by using the JDBC interface. JDBC technology offers a platform and server independent way to retrieve data stored in a database. A database contains tables of columns and rows. Each row in a table represents an object in the data model. Each column in a table represents an attribute and can be mapped for use in the chart. An Excel file ( .xls ) is recognized as a database; the worksheets are treated as tables.
In-memory
The supplied in-memory data model comprises Java™ classes that conform to the JViews Charts data model, with the data belonging to the Basic template. This type of data source supports writing operations such as appending a new data point or changing values of an existing data point.
Data Writeback
The XML data source ( IlvXMLDataSource ) and the flat file data source (based on the class IlvSwingTableDataSource ) are read-write. This means that the IlvDataSet.setData method can be used on them; the modified values are held in memory but not automatically written to a file. If you need modified values to be written to a file, you can implement this functionality. In the XML case, the class IlvXMLDataWriter is useful for this purpose.
The JDBC data source (class IlvJDBCDataSource ) operates in a similar way when created in read-only mode. When created in read-write mode, it writes back modifications to the database.
Customized Data Sources
If the data you want to display is not of one of these predefined types, you can extend the data model to create a customized data source. To see how to do this, see the section Extending the Data Model in Developing with the SDK.
Before you move on to the next step, that is, styling your chart using the Designer, you need to create a snapshot of the data source in XML format. This JViews Charts XML file serves as input to the Designer. To create this file, you can use the IlvXMLDataWriter class, as explained in Reading and writing data from an XML source in Developing with the SDK.
Styling your chart.
The representation in your chart of the objects that form the business data, including the way your users interact with them, can be customized by applying Cascading Style Sheets (CSS).
1. You can change the representation of the data, by adjusting the styling properties of the objects, affecting the following features:
*The color and the outline of the graphical representation of the series.
*The shapes of the data points marker.
*The graduation of the scale.
*The appearance of the grid lines.
*The position of the legend.
See Customizing your chart in Using the Designer.
2. You can also apply styling conditions by creating and editing rules. This capability is particularly useful if you need to style data dynamically as the model changes. JViews Charts provides an easy-to-use natural language editor to help you write style rules without having to know the detailed CSS syntax. It allows you to develop conditions for applying specific styling features. See Managing data style rules in Using the Designer.
3. The result of the work you have done within the Designer is a project file with the extension .icpr (JViews Chart Project) and a style sheet with the extension .css (Cascading Style Sheet).
If the data to be displayed comes from one of the predefined data source types, you can integrate the styling and the data source together into the chart, by using the method setProject.
If the data to be displayed comes form a custom data source, you need to integrate the styling into the chart by using the method setStyleSheet.
Adding interaction.
JViews Charts provides interactors that allow the user to interact with a chart. Chart interactors let you associate one or several behaviors to a chart object; they define atomic interactions that can be combined together and extended to achieve complex interactive functionalities.
*To add interactions, see the following sections:
*Interacting With Charts in Developing with the SDK for a Java application.
*Installing interactors in a chart in Building Web Applications for a thin-client JavaScript-based JavaServer™ Faces chart component.
Integrating your chart into an application.
Now that you have created your JViews chart, you need to integrate it into an application.
*To integrate your chart component into an application see Integrating your development into an application and Writing an application in Using the Designer.
You can deploy the application in different ways:
*Swing GUI, JavaScript thin client. See Developing JViews Charts JavaScript Web applications in Building Web Applications).
*JavaScript-based JSF thin client. See Developing JViews Charts JSF applications in Building Web Applications.
Essentially, to integrate a chart component into a GUI, you load a project. The project construct groups the data source and style sheet which are the basis for a chart.
Deployment as a thin client is facilitated by the servlet support in the Java API, and by the JSF tag library for the thin client (see The JViews Charts JSF component set in Building Web Applications).

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.