Rogue Wave Knowledge Base
Browse by category:
Knowledgebase | Glossary | Ask a Question |

Creating Charts using ChartJ Component Beans

Article ID: 801
Last updated: 05 Feb, 2008
Revision: 1
print  Print
share  Share
Views: 2920
Posted: 08 May, 1998
by Dean J.
Updated: 05 Feb, 2008
by Dean J.

How do I use the individual component beans available in ChartJ to create charts?


This page will outline how to reproduce the prebuilt HighLowStockChart from the individual component beans in ChartJ. This Knowledge Base page is aimed at increasing the developer's understanding of the component beans and their properties. This page will also help the developer understand the basics needed to begin creating customized chart types. By using the individual component beans available in ChartJ, a developer may achieve exactly the look and feel desired, while using the smallest possible set of Java classes. This approach will generate small applets and quick downloads for the user.

This example requires the March '98 version of the 1.0 BDK, which is available from Sun at It is suggested that you follow the steps exactly as outlined below for best results. As you become more comfortable with the BDK and ChartJ, you will find that some steps can be altered or eliminated to meet your needs.

Step 1: Start the March '98 BeanBox with Chart.jar from JChart v2.1.x in the jars subdirectory of the BeanBox install directory. Make your BeanBox workspace big enough to comfortably fit two completed charts and ten or so non-visual Beans.

Add a HighLowStockChart Bean to the workspace. To add a component to the workspace in the BDK, simply click on the item in the Toolbox window, then click in the workspace window at the position you wish to place the component. Position the HighLowStockChart in the upper half of the workspace. This is the pre-built chart we will be duplicating in the steps below. The purpose of this chart is to serve as a visual example for what you will be building in the steps below.
Step 2: Add a ScrollableChart . Position it directly beneath the HighLowStockChart. The Scrollable Chart is one of the two available overlay base charts. If you need to select a visible object to reposition it on the BDK palette, click on the outer edge of the object to access the object handles.
Step 3: Add a LinearScale. This is the first of two scales you will be adding. Place this Bean under the left vertical axis of the ScrollableChart.
Step 4: Select Edit from the BDK menu bar, and Bind property. Select the "Overlay" property from the LinearScale and click OK. Position your cursor along the outer edge of the ScrollableChart and click to select this component as the binding target object. Select the "Primary scale overlay" from the list on the ScrollableChart and click OK. Don't worry for now that the scale on your new chart does not match the pre-built exampe. The scales will change later as we add data to the chart. Your chart should now appear as shown in the example below.

Step 5: Add a second LinearScale . Position the second LinearScale under the right vertical axis.
Step 6: Bind the second LinearScale "Overlay" property to the the "Secondary scale overlay" on the ScrollableChart. Note that nothing visible happens until you complete step 7.
Step 7:

Change the second LinearScale "scale" in the BDK Properties window to "Secondary", as shown below.

Your ScrollableChart will now display a vertical scale along the right and left sides.

Step 8: Add FileData . The FileData will change both the vertical axes and the horizontal axes.
Step 9:

With the FileData Bean selected on the workspace, bind the "Data" to "data" on the ScrollableChart. Notice that the values displayed in your chart should now appear as shown below. The date values allong the horizontal axis should now match those on the pre-built chart.

Step 10:

Add RowRangeDataRange . Position this Bean under the left vertical axis. Bind the RowRangeDataRange "dataRange" property to the "Primary axis data range" property on the ScrollableChart. Notice the change in the scale values along both the left hand and the right hand axes. With the RowRangeDataRange Bean selected, change "lowValueMode" to "Minimum" in the BDK Properties window.

Note that the default value for numberOfRows is 1. Later you might expect that this value should be changed to 4 to plot high, low, open, and close prices. However, this is not the case since the HighLowOverlay Bean we will add in Step 13 expects four rows and will override any value you may set here for numberOfRows. It is also tempting to try and adjust the scale values along the left vertical axes to match the pre-built bean in the Property window for the ScrollableChart. Adjusting these values should be postponed until after Step 11 to avoid conflicts with internal algorithms used in setting scale values.

Step 11:

Add SingleRowDataRange . Position this bean under the right vertical axis. Bind SingleRowDataRange property "dataRange" to "Secondary axis data range" on the ScrollableChart. With the SingleRowDataRange Bean selected, change the "dataRow" value to "4".

The right axis should now match the axis on the pre-built chart.

Step 12:

With the ScrollableChart selected, set the value of "Primary axis increment" to "1.0" in the Properties window. Set the "Primary axis min" property to "8.0". The scale property values for the scondary axis do not need to change from the default values. Note that there is no way to change the precision so that 300000.0, for example, appears as 300000 (as it does in the pre-built chart) without writing some Java code. This is because the pre-built chart uses some code in Rogue Wave's JTools product to adjust the precision.

Your chart should now appear as shown in the image below:

Step 13: Add HighLowOverlay . Bind the "overlay" property from the HighLowOverlay to the "overlay1" property in the ScrollableChart. Notice that the high, low, open, and close (HLOC) prices are properly displayed immediately. All of the default values in the property editor now match those in the pre-built chart, so no further modifications are necessary for the primary axis scale. Also notice that a "tickWidth" of "2" refers to each of the individual open and close ticks. This means that the entire marker for each of the prices would be: 2 (open tick) + 1 (vertical marker)+ 2 (close tick) = 5 pixels.
Step 14:

You will now need to make two changes in the horizontal axis properties in order to make the time scales (trade dates) match. Using the property editor on the ScrollableChart, change "Space between columns" to a value of "1". Also change the "Column line period" to a value of "5". Your chart should now appear as shown below.

Step 15:

Add BarOverlay . Bind the "overlay" property in the BarOverlay Bean to the "overlay2" property in the ScrollableChart. Using the Property editor window for the BarOverlay, set the "barWidth" to "5" which will set the width of the bar to match the width of the pricing tick set in Step 15. Change the "color" property to a value set of "0,178,0", which is a medium green. You will also need to set the "dataRow" property to "4", and the "scale" property should be set to "Secondary" as shown below.

Step 16:

To make the color of the "Secondary axis label" in the ScrollableChart match the color of the bars in the BarOverlay, you will need to change blue to medium green. Select the LinearScale Bean under the right side of the chart and change the "labelColor" property to a value set of "0,178,0". Note that this illustrates the tradeoffs in using a pre-built chart versus a component based implementation. The pre-built chart will set labels and color values automatically, where the component Beans will give you more control, but also require a bit more work to achieve the same result.

An alternate approach to setting the color would be to bind the "Secondary axis color" for the ScrollableChart to "labelColor" for the right LinearScale. Then you would bind the "Secondary axis color" property for the ScrollableChart to the "color" property for the BarOverlay. In this case, binding would automate the match between these properties.

Your chart should now appear as shown below.

Step 17:

Add a Text Bean and position it under the left vertical axis of the ScrollableChart. Bind the "overlay" property for the Text Bean to "overlay3" from the ScrollableChart. Select the Text Bean and change the "font" property to a 14 point italic font, and change the "text" property to "Price". Change the "placement" property to "Above and left of" from the drop down box as shown below.

Step 18:

Add a second Text Bean and position it under the right vertical axis of the ScrollableChart. Bind the "overlay" property for the Text Bean to "overlay4" from the ScrollableChart. Select this Text Bean and change the "font" property to a 14 point italic font, and change the "text" property to "Volume". Change the "placement" property to "Above and right of" from the drop down box. Change the "yBase" to "Grid Top", "xBase" to "GridRight", "y" to a value of "-10", and "x" to a value of "0" as shown.

Step 19:

The final step is to add a HighLowKey . Bind the "overlay" property of the HighLowKey to the "overlay5" property of the ScrollableChart.

Your completed chart should appear as shown below.

This article was:   Helpful | Not helpful Report an issue

Prev     Next
How to use the Rogue Wave Informix Access Library for...       How do I implement a select count (*) in DBTools.h++?

Others in this category
b Internationalization of Blend.J TextField
b How do I add a subject header to my SMTP application?
b Core dumps described in the Tools.h++ Professional readme document
b Failure building Standard C++ Library with aCC 3.25
b How can I print charts from Chart.J?
b Installation of StudioJ on Unix or Mac
b The StockCursor SizeCursor is not working in zApp
b Catching exceptions from the inet module in Tools.h++ Professional
b Can Money.h++ be used in multi-threaded applications?
b Objective Grid/J: Database Connectivity
b Software Parts Manager Builds on Unsupported/Non-GUI platforms
b Standard C++ Library manual examples will not build on Solaris
b Using custom build configurations
b The Use of Virtual Destructors in Tools.h++ classes
b Runtime error in DBTools.h++
b How to create a custom overlay
b The addSubItem() method causes the Tree application or applet to freeze at runtime
b RWMutexLock Recursive Acquisition error in Debug - Not True! - Threads 2.0.1 only
b Using DBTools.J with the Oracle Driver: Objects Are Not Getting Released Correctly
b JDK 1.1.6 JIT update and later versions cause Labels to disappear in StudioJ
b How do I create a list of lists?
b UnsatisfiedLinkError when installing StudioJ
b StudioJ product unlock code not accepted during installation
b Column titles using center justification disappear when using JFC/Swing
b Retrieving return parameters from oracle Storedprocedures
b Specifying a frozen column attribute does not lock the selected column
b Building native Win32 applications with Visual Cafe using Grid.J.
b When trying to establish a connection to my database using DBTools.h++, I get the error: DB NOT FOUND
b How do I use binaryStoreSize and recursiveStoreSize?
b Using the clipboard paste function with a JMaskEdit control
b Passing strings containing quotes causes problems with DBTools.J
b Location of Visual CASE
b Unlock keys do not work
b Retrieving Blobs from Oracle using DBToolsJ
b RW virtual streams and RWCollectableString ambiguity error
b TreeControl image not updating correctly in JWidgets
b RWDBTracer and asString() method behave differently in DBTools 4.0.0
b Objective Grid/J: Footprint
b Throwing exceptions using Sybase or MS SQL Server corrupts connections
b Changing the state of a GXCheckBox with a single click when the control does not have focus?
b I cannot execute the script for Software Parts Manager
b Submitting HTML GET/POST Requests to a CGI Program
b Undefined Symbol RWAll when Linking Application
b What relation does the RW Standard C++ Library 1.x have to the ANSI Standard?
b Informix stored procedure does not execute an INSERT
b How to avoid a database hit when instantiating a RWDBStoredProc
b The commit / rollback transaction request has no corresponding BEGIN TRANSACTION
b Trapping shift, escape and return keys for a ComboBox
b How to add ESQL function calls to the Informix Access Library
b Using char datatype in C++ Application for char(1) datatype of the database
b LAPACK.h++ with Math.h++ v0613 gives dependancy check failure on Solaris 2.5 and SunOS 4.1.x
b Using the schema from an existing table to create a new table
b Creating custom configurations with SPM 1.4
b RWTime/RWDate displays incorrect time and date
b The zApp isShown() function does not work correctly
b Creating image buttons of the correct size
b Adding a scroll bar to a non-overlay chart in JChart 2.1
b How do I trap the enter key in zComboBox (any type, portable solution)?
b How RWDecimal classes cast ints and doubles
b Modifying zApp 3.0 Makefiles to use Borland v5.02 compiler
b Horizontal Scroll Bars on Combo Boxes
b Can I use DBTools.h++ 3.1.0 with MSVC 5.0?
b Memory Leak in Threads.h++ with POSIX Threads
b Control object minimizes or disappears when moving to another window or dialog.
b Re-definition of parent table alias inside the sub-query of DML
b How can I do Oracle row-level locking with DBTools.h++?
b RAISE ERROR statement in my RWDBStoredProc never catches that error.
b Having problems with the server when using callbacks.
b Default and Explicit Connections and the DBTools Connection Pool
b Can't compile Math.h++ source files on SunOS4.1.3 with SunPro 4.0.1 compiler
b Why does JFactory flicker between the object manager and the integrated editor when I'm trying to edit the source?
b JFactory won't open; gives error
b In Chapter 4 of the tutorial, why can't I find the Menu Edit button?
b When compiling, why can't JDK find LogFontLayout.class?
b SPM doesn't install correctly under Windows
b 'Tried to dereference a null RWENode handle' error running SPM
b 'Unresolved external symbol opinit' runtime error
b Porting Tools Pro.h++ 1.1.2 to Linux
b Command line builds for Threads 2.0.1 on Solaris7 with SunPro 4.2
b When bulk reading a database column that allows NULL values, you must check for null in the receiving vector object.
b Improving the performance of an application that uses a lot of RWCStrings on the heap.
b Resizing a connection pool with the defaultConnections() method does not work
b Changing source code to support link time template instantiation
b Can't Enter Information Into Dialog Boxes
b can't insert an RWDBDateTime object into the database, formatted as a UTC time.
b How to deal with lost database connections?
b Euro conversion rates as of Jan 1, 1999.
b Error when Building DBTools Access library for Oracle8 with Microsoft Standard Library
b Rounding Errors in RWDecimal<T>
b I get error C2065: 'localtime_r' : undeclared identifier
b Tools.h++ compile error: C2065: 'localtime_r' : undeclared identifier
b Why won't the InfoBrowser contents update in response to selection changes in ClassView or FileView?
b I've installed Visual CASE and loaded a project. Now what?
b Why aren't the ATL and MFC libraries just loaded at startup?
b Blend.J's ShortcutBar demo throws exceptions
b Blend.J vertically-oriented sliders don't respond correctly
b How can I tell if my socket's peer closes the socket?
b RWCString::operator[] doesn't compile in MSVC
b Software Parts Manager doesn't run
b hasChanged() method never set to TRUE
b How do I kill all the running threads in RWThreadPool?
b No insertion (<<) or extraction (>>) operator to stream a bool
b Having problems using Standard C++ Library 2.x with Orbix 2000
b Building Tools.h++ 7.1.1 with Visual Age 5.x
b Linux multithreaded limitation with the Oracle8 805 client
b RWMetro Supported Platforms, Metro-Platforms
b SQL Server Access Library 3.x does not support bulk operations
b Color printouts of Grid.J lose the background colors
b Using Chart.J with Swing/jfc
b Using RWDBConnection in nested RWDBReaders
b Running setup.exe to install StudioJ
b getNumberRowCol() method in Grid.J throwing exceptions
b Assertion failure with DBTools.h++ examples
b Problems Compiling Math.h++ 6.x on HP, DEC and Windows 3.1
b Binary Files downloaded using Tools.h++ Professional are the Wrong Size
b How to build an RWDBCriterion with dynamic restrictions
b Oracle8 AL: How can I use a RWDBBlob with LONG RAW or BLOB columns that hold 32k or more
b How Do I Send a Basic Password to a Web Page?
b Building .h++ products with +DAportable
b Building zApp 3.0 as a DLL under Windows 16-bit crashes with Borland C++ 4.52
b Understanding Rogue Wave Build Codes
b Trying to rollback a transaction and it is not working
b Building on Solaris with the g++ compiler
b Sybase AL: syntax error when trying to bulk insert a vector object of size 1
b Unresolved symbol opinit at runtime
b Establishing a connection to Personal Oracle 8
b Compile problems with View.h++ v.1.3.0
b Building zApp 3.1 with MSVC 6.0
b Viewing a JFactory-made ComboBox with Netscape
b Adding a Timeout to an RWSocket::connect() Call
b Creating a Global Database Object
b Application crashing in the RWDBBlob destructor in DBTools 3.1.3 version
b RWZone::os() Returns Unexpected Result
b Errors installing products with SPM and RedHat Linux
b Accessing _servInst in zApp 3.x on NT
b Error compiling on SGI
b Building zApp with the CTL3D option turned on
b RWDBTracer and asString() method behave differently in DBTools 4.0.0
b I get the error: [DBNOTFOUND] No access library
b Transaction control with DBTools 3.1
b Porting Math 6.1.8 to Redhat Linux 6.0 (Linux 2.2.5-15)
b Assertion failed, attempting to add intrusive link...
b How can I force RWDate to display a four digit year?
b Undefined symbols when linking the Math.h++ on SGI
b How Do Math.h++ Random Number Classes Generate Random Numbers?
b Compiling Math.h++ 6.x with MSVC 4.2 results in errors in the file <tt>rwlpbla.cpp</tt>
b Compiler trouble on IRIX 5.3
b My Sun compiler reports a Sig 10 error when building with Tools.h++
b When using Money.h++ as a DLL in my application, the symbol NaN is undefined during a link.
b Warning messages in link phase using Math.h++ in OWL project
b RWTime Can Only Represent Times Up to the Year 2037
b Visual CASE and Visual C++ 6 Service Pack 3
b Assigning the Empty String to an RWCString
b Installing products with SPM as root accidentally deletes device /dev/null
b Unresolved symbols during linking with DBTools static libraries
b Fix for modeless MDI dialog when modal non-MDI Dialog is opened
b Table will not accept data
b How can I enable and disable radio buttons in a zRadioController?
b Accelerator keys in modal dialog
b Detecting changes in text in an edit line
b SPM error - file truncated
b How can I have a timestamp inserted with a row into my Oracle table
b JChart 1.0 will not print charts to the printer
b Compiler errors involving min() and max() macros
b Problems compiling .c files in the rogue/mathsrc directory
b RWDBCursor write fails at runtime sometimes with a syntax error
b MDI menus appending items instead of inserting
b Assertion failure in rw/, line 0
b Does DBTools.h++ support the Oracle Array type?
b How do I construct an unbounded Producer-Consumer Queue (or Stack)
b How do I stop a thread that is blocked on a system call or performing I/O?
b Trouble transferring binary files with FTP examples
b Error installing parts using SPM
b Borland C++ 5.02 and SPM 1.3 Edition 5, November 1997
b Stored procedure on Sybase returns empty result set.
b How To build RW-Metro examples on WINNT4-MSVC6.0 ?
b Will DBTools.h++ operate properly with WIN32s?
b Is Informix transaction logging required?
b Memory leaks reported on different calls to DBTools.h++ or Tools.h++ methods.
b My RWIFtpClient is behaving erratically.
b Tools.h++ PC Patches
b _ex_keylock undefined symbol problem
b How do I access tables on different databases on the same server?
b Library Mismatch with MSVC4.x Compiler
b Installation order of Math.h++ and Tools.h++ is critical
b Moving Unix applications to Windows when using RPC
b Can DBTools.h++ run under DOS?
b Problems Running the Software Parts Manager (Unix)
b Link Error when Building DBTools Application
b Beanbox integration for JWidgets
b When installing JFactory from InstallShield, why does it start installing other programs?
b Memory leaks in Tools.h++ code?
b DBTools.h++ generates a unique table alias each time a select statement is executed
b RWCString::toLower() function call creates runtime error.
b How to use the Rogue Wave Informix Access Library for DBTools.h++ in a multi-threaded application
b How do I implement a select count (*) in DBTools.h++?
b Informix DB-Access Library fails to build on HP/aCC platforms.
b Integrating JWidgets into Symantec Visual Cafe version 2.0
b Error ORA-12154 while connecting to ORACLE via DBTools.h++.
b Executing multiple SQL statements with RWDBDatabase::executeSql() on ORACLE
b Does DBTools.h++ support Dynamic SQL?
b Error when executing a stored procedure.
b Establishing connectivity between an RDBMS and DBTools.h++
b Error ORA-06401 while connecting to ORACLE via DBTools.h++
b Are project files (IDE files) provided for building DBTools.h++ under Windows?
b Objective Grid/J: Which .class files do I deploy with OG/J?
b Using RWDBBlob with a stored procedure on Sybase
b rwMakeThreadFunctions and Passing Parameters By-reference
b Problems Running the Software Parts Manager (Windows)
b DB2 AL guide: RWDate should map with DB2 DATE type, instead of RWDBDateTime
b How can I get the port number from an RWSocket?
b Building Rogue Wave Products on Solaris 2.6 with SunPro 5.2
b How to produce an interleaved output in a multithreaded program?
b RWDBInserter.isValid() always returns OK even the SQL generated is incorrect
b Symbol Table Program fails to compile
b Reading a Sybase user defined type results in an error
b Installing a DBTools error handler
b The Software Parts Manager(SPM) cannot find CL.EXE
b JChart 2.1 Java Beans do not work well with certain Java IDEs
b How to change the font in a zTable cell and column and row label
b Determining what style bit is set from inside your program
b How do I move to the end of my grid
b Repository Read Error in Unix for SPM
b The details of RW_CENTURY_REQD
b Math.h++ Allocates Excessive Memory for Vector, Matrix, and Array Classes
b Distributing Visual CASE Diagrams and Projects
b Visual CASE Errors After Installation of Another Stingray Product
b Refreshing the Contents in the UML View
b Why is the UML InfoBrowser no longer updating its contents in response to selection changes?
b No UML Diagraming Without an Active Project
b Base Class Shows Up Empty in UML Diagram
b No Visual CASE Tab in the Tools|Options Property Sheet
b Removing UML modeling Information from a Workspace
b Add UML Model and Integrated UML Modeling Buttons
b Location of MFC and ATL UML Libraries
b Location of Visual CASE Project Files
b All Visual CASE Menus and Toolbars Disabled
b Using absolute paths with a URL in SerializableImage
b Control Size Problems from Win16 to Win32
b JChart pie piece value = 0 gives error message
b zApp 3.0.3 Online Documentation for Windows
b Multiple radio buttons are checked and will not disable.
b zHelp crashes when F1 is pressed twice
b What platforms and compilers will View.h++ build on?
b Adding a menu item dynamically when ID of DropDown is not known
b Assertion Failure Running DBTools Examples
b Drag-and-drop columns not working in cellgrid
b Which Tools.h++ classes require the Standard C++ Library?
b Why am I still connected to my database after my RWDBConnections have gone out of scope?
b How do I use an RWDBCursor for Write?
b Putting a static frame around a zStaticText
b Compiler error when building zApp as shared library
b Help and On Apply buttons call the same function from zNoteBookDialog
b zComboBoxFull on tab stop on zNoteBkDialog prevents tab from reaching any farther
b zFont does not display the size I specified.
b Unresolved externals when trying to link zApp application with MSVC4.2
b How to store/retrieve large blobs in SybaseCT
b Second constructor for zFormDialog
b Updating sliders after calling setCurrent()
b How do I delete a row in a cell grid?
b How to create and run Stored Procedures in DB2
b In zHelp, the <A NAME=> tag does not work correctly
b Radio buttons on zNotebookDialog pages
b Making a vertically scrolling zEditBox
b How to call Oracle PL/SQL functions from DBTools
b Building Tools.h++ as a DLL with Borland C++ Builder
b zApp Error Codes
b Restore button does not work in MDI apps
b Memory leak when using zNotebook and zWizard dialogs
b Placing combo boxes on the tool bar
b NullPointerException with JWidgets 3.0 and Netscape 4.04
b Accessing command line arguments in zApp
b RWDBDateTime is Returning an Incorrect Time
b Sybase warning: Changed database context