Perforce JViews Charts Sample: Using the CSS SDK


Description

This sample demonstrates the styling capabilities of the chart component.

How to Use the Sample

The list located at the upper left of the panel lets you choose the style sheet that must be applied to the chart.

How to Run the Sample as an Application

This sample can be run as an application. The installation directory contains an executable JAR file, chart-css.jar, that allows you to execute the sample with a double click from a file browser. Note that if you are using Internet Explorer, you can open the installation directory and execute the JAR file from the browser. This technique may not work in other Web browsers.

Alternatively, you can run the sample application from the command line. First check that the Ant utility is properly configured. If not, see the instructions on how to configure Ant for Perforce JViews.

Then, go to the installation directory of the sample and type:

ant run

Topics Covered

Detailed Description

In this sample, we load data stored in an .xml file and connect it to a chart. The appearance of the chart is customized with various style sheets. We extend the IlvChart class by adding a highlightng property. When this property is set, the chart uses a highlight interactor. This interactor detects when the mouse passes over the graphical representation of the data, and adds or removes a custom pseudo-class named highlighted on the corresponding data set. The following style sheets are cascaded and applied to the chart component.

The Data Style Sheet

This style sheet (dataStyle.css) is referenced by an xml-stylesheet processing instruction within the .xml file. The style sheets that are defined within the .xml file are then accessible through the IlvXMLDataSource.getStyleSheets() method.

The style sheet contains the following rule:

      series {
          color1: @color;
      }
    

This rule specifies that the primary color used to render a series is equal to the color property of the series elements in the .xml file. When the sample is launched, this style sheet is the only one applied to the chart.

A Style Sheet Specified by the User

This style sheet is chosen from the list located at the upper left corner of the panel. Some style sheets override the rules specified in dataStyle.css, and define other rules to control both the appearance of the chart component and the way series are displayed. The following sample style sheets are available:

The 3-D Style Sheet

This style sheet (3dstyle.css) specifies properties related to 3-D rendering. It contains the following rule:
      chart {
          3D: true;
          interactors: "3DView";
      }
    
The first declaration specifies that 3-D rendering should be turned on. The second declaration sets an IlvChart3DViewInteractor on the chart so that the view angles can be modified interactively. This style sheet is cascaded when the 3-D View toggle is checked.

Installation Directory

The Using the CSS SDK sample is installed here.

Classes Involved

Source Files

Copyright © 2021 Rogue Wave Software, Inc., a Perforce company. All rights reserved. Legal terms.