Chart FX Basics

Transcription

Chart FX Basics
Chart FX Programmer’s Guide
Introduction
Table of Contents
INTRODUCTION.....................................................................................................................................3
ABOUT THIS MANUAL...........................................................................................................................4
OBTAINING TECHNICAL SUPPORT..................................................................................................... 4
INTEGRATING CHART FX.....................................................................................................................6
THE CHART FX SAMPLES ....................................................................................................................9
THE CHART FX OLE SERVER ............................................................................................................ 13
CHART FX INTERNET EDITION COMPATIBILITY NOTES ............................................................... 17
Chapter 1. Chart FX Basics
CREATING A CHART ...........................................................................................................................21
SETTING PROPERTIES AT DESIGN TIME ........................................................................................ 21
SETTING PROPERTIES AT RUN TIME.... .......................................................................................... 22
OBJECT ORIENTED PROGRAMMING AND COM SUPPORT........................................................... 23
THE CHART FX WIZARDS ..................................................................................................................24
Chapter 2. Passing Data to Chart FX
INTRODUCTION...................................................................................................................................29
PASSING DATA USING THE API ......................................................................................... 30
UNKNOWN NUMBER OF POINTS .................................................................................................... 32
HIDDEN POINTS ...........................................................................................................................32
CHANGING EXISTING VALUES ....................................................................................................... 33
PREVENTING SCREEN FLICKERING................................................................................................ 33
CONTROLLING THE SCROLLBAR.................................................................................................... 34
THE CHART FX DATA PROVIDERS ................................................................................................... 35
DATABINDING......................................................................................................................................37
CONNECTING TO ADO RESULTSETS .............................................................................................. 40
READING DATA FROM ARRAYS........................................................................................................ 41
READING DATA FROM COLLECTIONS ............................................................................................. 43
READING DATA FROM TEXT FILES .................................................................................................. 45
Table of Contents
Chapter 3. Working with Axes
INTRODUCTION...................................................................................................................................49
THE AXIS OBJECT...............................................................................................................................50
AXIS FORMATTING .............................................................................................................................51
AXIS LABELING....................................................................................................................................52
AXIS SCROLLING ................................................................................................................................54
GRIDLINES & TICKMARKS .................................................................................................................56
Chapter 4. Working with Chart FX colors
COLOR TYPES.....................................................................................................................................61
CHANGING DEFAULT COLORS ......................................................................................................... 61
COLOR PALETTE.................................................................................................................................62
ASSIGNING INDIVIDUAL COLORS TO MARKERS............................................................................ 63
CHANGING BACKGROUND COLORS................................................................................................ 63
COLOR SCHEMES...............................................................................................................................64
PATTERNS ...........................................................................................................................................64
Chapter 5. Customizing chart markers
POINT SIZES & SHAPES.....................................................................................................................67
CONICAL & CYLINDRICAL SHAPES .................................................................................................. 67
LINES STYLE & WIDTH .......................................................................................................................68
SEPARATING A PIE SLICE PROGRAMMATICALLY ......................................................................... 68
Table of Contents
Chapter 6. 3D Effects
DISPLAYING THE CHART IN 3D MODE............................................................................................. 71
ROTATING THE CHART PROGRAMMATICALLY .............................................................................. 71
CLUSTER CHARTS..............................................................................................................................71
DEPTH & PERSPECTIVE ....................................................................................................................72
Chapter 7. Working with special chart types
XY PLOTS .............................................................................................................................................75
PASSING DATA........................................................................................................................................................ 75
FAQ........................................................................................................................................................................... 77
HIGHLIGHTING POINTS IN A SCATTER CHART ................................................................................................... 78
MULTITYPE CHARTS ..........................................................................................................................79
MULTISTACKED CHARTS...................................................................................................................80
GANTT CHARTS ..................................................................................................................................81
FINANCIAL CHARTS............................................................................................................................84
SURFACE & CONTOUR PLOTS.......................................................................................................... 86
BUBBLE CHARTS ................................................................................................................................89
Chapter 8. Constant Lines & Color Stripes
CONSTANT LINES SAMPLE ...............................................................................................................93
COLOR STRIPES SAMPLE .................................................................................................................94
Chapter 9. Handling Files & Templates
THE IMPORT & EXPORT METHODS.................................................................................................. 97
CHART FX 3.0 FILTERS....................................................................................................................... 98
TIPS & TRICKS.....................................................................................................................................99
Table of Contents
Chapter 10. Capturing mouse events
DRAGGING MARKERS ......................................................................................................................103
MENUS ON DEMAND ........................................................................................................................103
CUSTOMIZING DATATIPS ................................................................................................................103
CUSTOMIZING THE BALLOON.........................................................................................................104
TRACKING THE MOUSE ...................................................................................................................105
Chapter 11. Printing charts
PRINTING THE CHART .....................................................................................................................109
CONTROLLING PAPER ORIENTATION ...........................................................................................109
COLOR OR B&W PRINTING..............................................................................................................109
PRINTING SEVERAL CHARTS IN THE SAME PAGE ......................................................................110
PRINTER & DRIVER SELECTION .....................................................................................................111
Chapter 12. Customizing the Chart FX tools
THE CHART FX TOOLS. OVERVIEW ...............................................................................................115
CUSTOMIZING THE TOOLBAR.........................................................................................................116
RELATION BETWEEN COMMANDS & TOOLBAROBJ OBJECT .......................................................................... 118
SHOWING/HIDING THE TOOLBAR ....................................................................................................................... 119
POSITIONING THE TOOLBAR .............................................................................................................................. 119
REMOVING/HIDING BUTTONS IN THE TOOLBAR .............................................................................................. 120
CHANGING THE COMMAND FOR A TOOLBAR BUTTON ................................................................................... 121
ADDING BUTTONS IN THE TOOLBAR ................................................................................................................. 122
CHANGING THE TOOLTIPS .................................................................................................................................. 124
CHANGING TOOLBAR ICONS .............................................................................................................................. 125
WORKING WITH SUBCOMMANDS ....................................................................................................................... 127
WORKING WITH SELECTORS.............................................................................................................................. 128
ADDING CUSTOM COMMANDS............................................................................................................................ 129
CREATING & DISPLAYING YOUR OWN TOOLBAR............................................................................................. 131
THE CHART FX DATA EDITOR.........................................................................................................133
THE PALETTEBAR.............................................................................................................................134
THE PATTERNBAR ............................................................................................................................135
THE LEGEND BOX.............................................................................................................................136
THE SERIES LEGEND BOX ..............................................................................................................137
Table of Contents
Chapter 13. Real-Time charts
OVERVIEW .........................................................................................................................................141
PASSING DATA IN REALTIME ..........................................................................................................142
SCROLLING LEGENDS .....................................................................................................................144
Chapter 14. Open Painting Architecture
CUSTOMIZING CHART PAINTING. OVERVIEW ..............................................................................147
CPI CONSTANTS ...............................................................................................................................148
PREPAINT SAMPLE...........................................................................................................................150
PAINTMARKER SAMPLE...................................................................................................................151
Chapter 15. Chart FX UI Cross Reference
GENERAL DIALOG.............................................................................................................................155
SERIES DIALOG.................................................................................................................................157
AXIS DIALOG......................................................................................................................................161
AXIS SCALE DIALOG............................................................................................................................................. 163
AXIS LABELS DIALOG ........................................................................................................................................... 165
AXIS GRIDLINES DIALOG ..................................................................................................................................... 166
3D EFFECTS DIALOG........................................................................................................................168
CONSTANT & STRIPES DIALOG ......................................................................................................170
DATA/BEHAVIOR DIALOG ................................................................................................................172
COMMANDS DIALOG ........................................................................................................................174
EXTENSIONS DIALOG.......................................................................................................................175
Table of Contents
Chapter 16. Annotation Objects
OVERVIEW .........................................................................................................................................179
ACTIVATING THE EXTENSION.........................................................................................................179
CREATING OBJECTS PROGRAMMATICALLY ................................................................................181
DEPLOYMENT ISSUES .....................................................................................................................183
Appendix A. Migration Issues
MIGRATING FROM CHART FX 3.0 ..................................................................................................187
CONVERTING PROJECT FILES .......................................................................................................187
OBSOLETE/REPLACED API..............................................................................................................188
Appendix B. Memory Requirements
CHART FX MEMORY REQUIREMENTS...........................................................................................193
Appendix C. Deployment Issues
DEPLOYING YOUR APPLICATION ...................................................................................................197
Appendix D. Compatibility Issues
ACTIVEX OR DLL, WHICH ONE SHOULD YOU USE? ....................................................................201
CHART FX AND VISUAL C++ ............................................................................................................202
CHART FX & BORLAND PRODUCTS ...............................................................................................205
Appendix E. Licensing Issues
HOW DOES THE CHART FX LICENSING SCHEME WORKS .........................................................209
Index
Table of Contents
Chart FX Programmer’s Guide
Welcome to Chart FX
Topics covered in this section
Introduction
About this manual
Obtaining Technical Support
Integrating Chart FX to your development tool
The Chart FX Samples repository
Welcome!
Thank you for selecting Chart FX as your charting tool! You’ll find there’s no other charting
product capable of offering the flexibility and power that Chart FX provides. Chart FX is packed
with new features that will make your application more powerful than ever, for example:
Chart FX was developed using COM. This makes Chart FX easier to program since it exposes
objects that are readily accessible to and compatible with the notions of objects defined by
modern object-based languages and tools. COM will also ensure that the Chart FX API could be
easily called from any compiled or interpreted language without extra development and testing
efforts. Chart FX exposes a complete object oriented API that is easier to understand and
compatible across all development tools, plus it takes advantage of visual development
capabilities provided by Visual Basic and other visual development tools.
Chart FX has been the preferred and leading charting component for developers since its
inception in 1993. With this new release, Chart FX not only presents the most powerful feature
set, but again, we have done it without affecting the overall performance and speed that our user
base recognize and appreciate. The core components present the same memory footprint as
previous versions of Chart FX that makes it so easy to deploy and not affecting the memory or
hardware requirements of your application.
Chart FX was designed with extensibility in mind, this allows powerful add-ons enhance the
capabilities of the product. Separately available extensions make Chart FX even more functional
than ever. For example, we offer ChartFX Financial Edition as a Chart FX extension, a product
specifically designed for financial applications charting stock market data. Another good example
is the royalty-free annotation extension that allows you and your users add floating objects on top
of the chart.
Also, with Chart FX wizard’s you can create incredible charts in seconds, right out of the box! The
wizard guides you step-by-step through setting up your preferred chart and visual attributes
–without writing a line of code.
The ChartFX User interface was also enhanced to accommodate newer operating systems, like
Windows 98, Windows NT 5.0 and Windows 2000. A great example is the palette bar where more
than a dozen color schemes are available so the user can change all the chart elements with just
one click of the mouse.
Chart FX is renowned for its exhaustive selection of chart types. Now, we’ve gone even further by
adding many more chart types like Bubble, Contour, Pyramid, Curved Area, Multistacked, XY
Lines, XY Area, Area spline and more!
3
About this manual
This manual discusses some of the most commonly used features of Chart FX. It is not intended
to be an API Reference. If you want to refer to the Chart FX API, including Objects, Properties,
Methods and Events, please refer to the “Chart FX API Guide” located in the \help directory. This
electronic help file provides detailed information, including syntax, samples and remarks about
the Chart FX API.
Also, this manual is based on sample code provided in Visual Basic 6.0 and using the Chart FX
ActiveX Control. If you are using other development tools that support OCX models you can still
refer for information on general topics covered in this manual. Other specific samples for the
development tool you are using that have been placed in the \samples directory.
Technical Support
ü
Up-to-date information and product updates are always available on our web site at
http://support.softwarefx.com
ü
If you want to contact a Chart FX representative mail to [email protected]
ü
If you want to talk to a technical Support representative please call (561) 391-9494 Or refer to
our web site for latest telephone number information.
Note
Technical support will not be provided through our Toll
Free Number. However, if you require any assistance on
Licensing and Marketing information you can call (800)
392-4278
Please make sure you have your Chart FX serial number handy and the Chart FX Component
Model and version you’re currently using.
4
On-Line Support (http://support.softwarefx.com)
In this site you'll find knowledgebase articles, sample code, documentation, product updates and
other important technical support information. The site has been designed to let you search and
find information quickly and easily. And because it uses some of our web based products (like
WebBarFX), you are required to use this site using a Windows based system (Both, Netscape
and Internet Explorer are supported!).
support.sofwarefx.com is optimized for viewing with Microsoft Internet Explorer version 4.0 or
Netscape Navigator Version 4.0 or later at 800x600 resolution.
We would also like to remind you that this site is restricted to registered users, so if you have not
yet registered your copy of Chart FX, you can do it at http://www.softwarefx.com.
We strongly encourage you to visit this site before contacting Software FX as resolutions to
common problems are posted on a daily basis.
5
Integrating Chart FX to your development tool
Please follow the instructions provided in this section to complete the Chart FX installation for
your specific Development tool.
Visual Basic (6.0)
i) Include the Chart FX 98 ActiveX in your project as follows:
- From the Project menu select Components...
- Choose Chart FX 98 Control from the Controls list.
ii) Include the Chart FX header file (CFXOCX.BAS) as follows:
- From the Project menu select Add Module
- Select CFXOCX.BAS located under ChartFX 98\Include from the Existing modules.
Borland Delphi (4.0) and Borland C++ Builder (4.0)
Note
Chart FX v2.0 is OEM with Borland Delphi and Borland C++ Builder,
you must uninstall the existing version before proceeding.
i) Remove previous version of Chart FX from your component library as follows:
- From the File menu select Close All
- Form the Component menu select Install Packages…
- Select the package called: Borland Sample Imported ActiveX Controls
- Press Remove. Answer Yes upon confirmation.
- Press OK
ii) Import new Chart FX 98 component as follows:
- Form the Component menu select Import ActiveX Control…
- Select Chart FX 98 Control (Version 4.0) from the list
- Press Install... Answer Yes upon confirmation
- Select Into new package
- Type CFX98AX.DPK as the File name
- Type Chart FX 98 ActiveX as the Description
- Press OK. Answer Yes upon confirmation.
- Save changes.
Note: See appendix D for other integration issues.
MS Access (97)
i) Add Chart FX 98 ActiveX control to your form or report as follows:
- Open your form/report for design
- From the Insert menu select ActiveX Control…
- Resize the control to the desired size
6
Visual C++ (6.0)
You can include Chart FX 98 ActiveX in a dialog template from the Resource Editor as follows:
- Right-click inside the dialog and select Insert ActiveX Control…
- Choose Chart FX 98 Control from the ActiveX control list
- Press OK
- Resize the control to the desired size
For other ways of including Chart FX 98 into your VC++ project, see appendix D.
Visual FoxPro (6.0)
i) Include the Chart FX 98 ActiveX in your form as follows:
- Insert an ActiveX Control (OleControl) in your form
- Select Insert Control
- Select Chart FX 98 Control from the Control Type list
- Press OK
- Resize the control to the desired size
- Select ChartFX Control from the Control Type list-box.
- Hit OK.
- Right-click on the chart and select Properties... to change chart attributes.
ii) Include the Chart FX header file in your form as follows:
- From the Form menu select Include File...
- Select CFXOCX.PRG from your ChartFX 98\Include subdirectory
- Add the following line at your form initialization:
SET PROCEDURE TO <ChartFX 98 Path>\INCLUDE\CFXOCX ADDITIVE
Other Tools
Follow the instructions provided by the manufacturer on how to include third party components.
7
Chart FX Samples
Chart FX provides a myriad of samples that you can use as a reference when trying to use a
specific feature provided by this product. These samples will help you get started and they are
included in the \samples directory. They were also developed using different development tools.
Note
If you don’t find samples in your specific development tools,
please refer to our support site (http://support.softwarefx.com)
as we post additional samples that were not included in the
package)
The following sample projects are included with Chart FX:
Colors.
Introduces you to assigning colors to different chart elements.
Constants & Color Stripes.
Introduces you to the API required to create and handle these
elements in the chart area.
Data Aware.
Introduces you to using the Chart FX Data provider to read data
from Arrays, collections and other sources.
Data Binding.
Describes how to connect Chart FX to a ADO Data Control.
Provided for Visual Basic only.
Gridlines.
Introduces you to Gridlines and its different settings.
Import & Export.
Introduces you to save and retrieve chart files and templates.
Labels.
Describes how to assign labels to axis and markers in the chart.
Mouse.
Introduces you to the different mouse related properties and
events.
Palette & Pattern.
Describes and shows how to use the Chart FX Palette and
Patterns.
Passing Data.
Shows how you can pass data to special chart types like bubble
charts, financial charts and others.
Printing.
Shows how you can use properties and methods related to
printing the charts.
RealTime.
Shows how you can create realtime charts using a timer event.
Scroll.
Introduces you to the scrolling capabilities of Chart FX when
handling a large number of points.
Zoom.
Shows how you can use Zoom In/Out related properties and
methods to call out special regions of the chart.
Stacked.
Shows how you can create multistacked charts, where some
series are grouped and stacked accordingly.
9
Surface & Contour.
Shows how you can pass data and assign labels to Surface and
Contour charts.
User Interface.
Shows how you can customize the Chart FX user interface and
the way Chart FX reacts to user interaction.
XY Plots.
Shows how you can pass data and display XY plots.
10
Chart FX Programmer’s Guide
The Chart FX OLE Server
Topics covered in this section
Introduction
11
The Chart FX OLE Server Component
Perhaps one the biggest issues faced by end users is how to take a chart that is displayed in a
custom application or internet site and use it in another productivity tool such as Word, Excel and
PowerPoint.
The problem is that in most cases they will be able to "export" charts as an image (Bitmap, gif,
etc) which imposes major limitations when it comes to modifying the chart inside the Productivity
tool.
You'll be happy to know Chart FX provides an OLE Server that allows users to display interactive
charts inside any productivity tool that works as an OLE Container. This allows users to export
charts directly from the Chart FX 98 Toolbar and paste them into any application and continue
working with the chart as if they were included in the application.
Just imagine, while using your application, users will copy and transfer charts to any productivity
application. Once the charts have been pasted they can still change chart attributes within the
productivity tool, the possibilities are endless!
13
The Chart FX 98 OLE Server Object is a component that when added to an application that uses
Chart FX 98, allows your program to export active charts to desktop applications such as (but not
limited to) MS Word, MS Excel, MS PowerPoint. etc.
This component can be used in three ways:
•
•
•
Through the clipboard: You can export a chart to the clipboard as an OLE Object using the
toolbar or the Export method. Then it can be pasted into any Desktop application (OLE
Container).
Through a file: You can save the chart into a file using the toolbar or the Export method
(.CHD). This file can be inserted into any OLE Document by doing: "Insert Object ..." and
selecting "Create from File" or by dragging the file to a Drag-and-drop enabled container.
By using automation, and doing these operation from your own code using the container's
API.
Once the Chart FX Object is inserted into a document the user can interact with it: change
properties, save it, e-mail it, print it, etc. as depicted in the following picture:
In order for the OLE Object to be exported and viewed properly you need to have CFX4OLE.DLL
registered in your computer.
Note
The Chart FX 98 OLE Server is not royalty free for
distribution.
For redistribution rights please refer to the Chart FX 98
License Agreement, or contact Software FX at (800) 3924278 prior to redistributing this component to your users.
You can also refer to our web site at http://www.softwarefx.com/chartfx/oleserver
14
Chart FX Programmer’s Guide
Chart FX Internet Edition
Topics covered in this section
Compatibility Notes
15
Chart FX Internet Edition Compatibility Notes
- If you bought Chart FX Internet Edition read this carefully, if not please disregard this page -
Because Chart FX Internet Edition shares the same API as Chart FX we include this manual as
part of the Chart FX Internet Edition package. We do this so you can have documentation about
the objects, properties and methods you can use in your ASP scripts. However, some of the
topics or API calls covered in this manual do not apply to Chart FX Internet Edition and therefore
must not be used with that product.
As a rule of thumb, you should avoid using any API that require client-side scripting or code that
must be present at the browser level. In other words, properties or methods that are not used
inside the ASP will not work in some browsers and you will lose the Chart FX Internet Edition
browser independence capability.
For example, Chart FX provides events that you can capture to alter or customize the way Chart
FX respond to user interaction. These events are fired at the browser level and will require you to
have client-side VB scripting on your HTML pages. Although this will work on Internet Explorer
browsers, it will not work on Netscape browsers, so if you rely on browser independence you
should stay away from processing events when using Chart FX Internet Edition.
In most cases, Chart FX Internet Edition provides alternative ways of providing this functionality.
These have been documented in the Chart FX Internet Edition manual.
About Chart FX constant definitions
Throughout this manual we refer to constants you must use with the different properties objects
and methods the Chart FX API provides. When using Chart FX Internet Edition, you must be
aware that these constants are defined in a separate include file that you must use with your ASP
pages. If you fail to include this file, you will not be able to reference these constants and your
ASP scripts will be cryptic and difficult to maintain. You can include this file in the header of your
asp pages as follows:
<!-- Include this file so we can use all the ChartFX constants -->
<!-- #include virtual="/Include/CfxIE.inc" -->
17
Chart FX Programmer’s Guide
Chart FX Basics
Topics covered in this section
Creating a Chart
Object Oriented Programming and COM Support
The Chart FX Wizards
19
Creating a chart
In order to create a chart with Chart FX you must have the control properly registered in your
development system (Registry).
Because Chart FX is supported by a variety of tools, you must refer to your development tool
manual (or help files) for support on ActiveX Controls. If you’re using the Chart FX DLL
component, please refer to the DLL section later in this manual. You may also refer to “Integrating
Chart FX to your development tool” chapter in previous pages of this manual.
In most visual development tools, however, the process of creating a chart is just as simple as
selecting the Chart FX Icon in the application’s toolbox and drawing the bounding rectangle
containing the chart. After that, Chart FX will create a sample 3D bar chart with random data
values so you can actually start customizing how the chart looks. After you are satisfied how the
chart looks you can populate it with real data values.
The Chart’s Name
When you create a chart, by default Chart FX will name it as ChartFX1, ChartFX2, etc. You can
always change these names by modifying the “Name” property in the property list when the
appropriate chart is selected
This name is really important because it is a unique identifier that will allow you to control
properties for the different charts you have created (usually when setting properties at run time).
Setting Properties at Design Time.
Whenever you include a chart in your
application or web page, you want that
chart to provide information (data) with
certain
characteristics
or
visual
attributes. You can achieve this by
handling properties and methods
supported by the component. Chart FX
is no exception to this rule.
Chart FX provides property pages that
allow visual access to the API. In Chart
FX you may right click the chart and
select “Properties” to access the
Property pages or use the properties list
to set different visual attributes to the
chart.
Setting properties at design time is convenient, fast and easy plus it will reduce the coding time
and efforts dramatically. Most of Chart FX visual attributes can be changed at design time.
21
However, some properties are not available at design time since they are inherently run-time
properties that depend on the data displayed by the chart at a particular time in your application
execution. Therefore, you may be required to set additional properties at run time, depending on
what you want to achieve.
In any case, we strongly recommend you carefully review the API provided by Chart FX as it may
contain important objects, properties, methods and events you may want to use in your
application.
Setting properties at run time
Setting properties at design time is a convenient and easy way to customize charts. Sometimes,
however, you want or you are forced to change things programmatically and Chart FX offers a
wide range of Objects, Methods & Properties you can use to change visual attributes or even
numeric data when the application is actually running.
Most Chart FX properties are available at “Design Time”. However, some of them are available
only at run time because they are dependent on the data stored in the chart at a particular time in
your application execution.
As mentioned in previous pages, in order to set properties at run time, you will need the chart’s
unique identifier (or Name) the property name, property indexes and property settings.
The property indexes and settings are constants defined (Hex or Integer Numbers) by Chart FX
that you should always use as specified in the documentation of the specific property you’re
using. In some development tools, you will need an external include file that contains these
constant definitions. You may find it in the /include directory of the Chart FX Installation directory.
Note
If your development tool or platform does not support
external include files, you still may use the Hex or
Integer values associated with those constants when
setting properties at run time. The Chart FX Help file
does provide these numbers or you may locate them in
Appendix A of this manual.
Some properties may require indexes and settings while others may take only settings. In any
case, you should follow the specifications provided in the help file for the property you want to
work with.
OO Programming & COM Support
22
Chart FX 98 goes one step further as it is based completely on COM (Component Object Model)
and its API exposes "objects" that are easier to access and to program. While other ActiveX
controls provide properties and methods that are difficult to recognize and deal with, Chart FX 98
provides a very accessible API that will allow you to accelerate the development process and
reduce the learning curve dramatically.
Chart FX 98 exposes objects representing each element of the chart (like axis, series, toolbar,
etc.) that you can easily recognize and each of these objects provide properties and methods
related to it. For example, If you want to change the color of a particular series, you'll access the
Series object and the Color property for that object, as follows:
ChartFX1.Series(0).Color = RGB(128,255,0)
When used in conjunction with certain
development tools (e.g. Visual Basic), Chart
FX 98 complies with the statement builder
which will make the API even more
accessible as properties and methods related
to a particular object will be exposed as you
type the statement in the VB editor as
depicted in figure shown.
Chart FX 98 is also able to provide additional services without compromising the performance of
your application. For example, Annotation objects support is provided as a COM interface which
allows you to decide if you want to deploy this service or not. This capability is extremely
important for Chart FX 98 as it will not affect the performance of your application with services
you don't ultimately want as part of your application.
Chart FX 98 can extend its capabilities and features without changing the core component. For
example, Software FX offers Chart FX Financial Edition for Financial charting that you can use by
simply installing an additional COM interface, at that point Chart FX 98 detects its presence and
makes it available for special financial charts.
Many developers have asked about the possibility of adding chart types or special features in
Chart FX that are not commercially viable –or features that very few people will take advantage
of-, this usually represents technical problems as it is practically impossible and very costly to
maintain different versions of a commercial product like Chart FX.
With the help of COM, Chart FX 98 now allows the possibility of adding specific functionality
without changing the Chart FX 98 core files. If you're interested in a specific feature or chart type
not currently supported by Chart FX, please contact us at [email protected].
Wizards: Making it easier to configure the chart.
23
As an added feature for developers, Chart FX 98 provides wizards that allow you to easily
customize general settings in the chart without additional programming efforts. When you create
a chart the Chart FX 98 Wizard Manager will automatically pop-up presenting the different
wizards available in Chart FX 98. You may run a wizard or cancel to continue with your
development.
The wizards are usually self-explanatory and walk you through a series of steps (in the form of
dialog boxes) in order to accomplish a complex task in Chart FX 98, without the need of
referencing the Chart FX 98 API.
The Chart FX 98 Wizard Manager looks like:
For example, the “Chart Appearance Wizard” lets you set up different charts and looks without
writing one single line of code.
Disabling/Enabling Chart FX Wizards.
You may disable wizards by disabling the “Show this dialog when a chart is created” checkbox,
when this is done, the wizard manager will not pop-up automatically and if you want to access the
wizards again, you must right-click the chart and select the “Wizards” option. At this point you
may choose if you want to enable the wizard manager at chart creation time or just run a
particular wizard.
24
Wizards as an educational tool.
After running a particular
wizard a final dialog will be
presented with the properties
and methods from the Chart
FX 98 API used by the wizard
to achieve the desired effect.
Although the code presented
has already been set to the
chart, you can use it as an
educational tool or paste it in
your code to achieve the
same effect , for example,
when a user presses a button.
25
Chart FX Programmer’s Guide
Passing Data to Chart FX
Topics covered in this section
Introduction
Passing Data Using the API
The Chart FX Data Providers
Data Binding (ADO)
Reading Data from Arrays
Reading Data from Collections
Reading Data from Text Files
27
Passing Data to Chart FX 98.
One of the greatest improvements in Chart FX 98 is the ability to read or pass data from any
source, including data controls, text files, arrays, collections and through the API provided by
Chart FX.
An interesting point to mention is that all the code required to read data from these sources has
been isolated in an additional COM interface (or Cfx4Data.DLL) allowing Software FX and thirdparty developers to easily build additional "Chart FX 98 Data Providers".
Although this requires an additional DLL to be deployed as part of your application, it allows Chart
FX 98 to provide easy integration of new data sources. For example, Software FX is currently
building a Data provider that allows Chart FX 98 to read data from popular grid controls from
third-party vendors.
In Chart FX 98 there's no need to loop through data points to populate the charts, if you have a
previously filled data array, just pass it to Chart FX and have the chart filled with data with as little
as one line of code. Or if you drop an ADO Data control in your form just set a property in Chart
FX 98 that will allow the chart to take information from the data control directly.
The following topics are covered in this section:
Passing Data using the ChartFX API
Understanding & Integrating a Chart FX 98 Data Provider
Databinding (ADO and OleDB)
Passing Data from Arrays
Passing Data from Collections
Reading Data from Text files
29
Passing Data using the Chart FX API
Passing numeric values using the Chart FX API is as simple as opening a communication
channel using the OpenDataEX Method, setting the values and then closing the communication
channel using the CloseData Method. If your development tool does not support pointer passing,
Chart FX will require point by point passing using the API through any loop command (while, for,
etc.) supported in your development environment.
Note
In this section will explain how to pass numerical
information to Chart FX, if you want to set legends and
other text information to the chart, please refer to later
chapters in this help file.
This section also describes how to pass information to the majority of chart types provided by
Chart FX. If you're creating special chart types, such as financial, scatter and other, please refer
to later chapters in this document, as additional properties need to be set to create these charts
appropriately.
Passing Data using the ValueEX property
Sometimes the easiest or most convenient way to pass numerical data to Chart FX is to use the
ValueEX property which allows you to set the numerical value for a point in a particular series in
the chart. If you want to set points to the entire chart, you can loop through the points and use the
ValueEX property as follows:
‘Open the communication channel
ChartFX1.OpenDataEX COD_VALUES,2,6
For (i=0 to 1)
For (j=0 to 5)
‘Assign the values to the series selected
ChartFX1.ValueEX(i,j) = Rnd * 100
Next j
Next i
‘Close the communication channel
ChartFX1.CloseData COD_VALUES
30
Passing Data Using the Series Object
Also, Chart FX provides a Series object which allows you to set everything related to the series of
the chart including data, legends and visual attributes like colors, chart types among others. To
introduce data in the chart you need to use the YValue property of the selected series.
Sometimes working with the Series object is more convenient as your code will be easier to
debug.
For example, if you need to create a chart with 2 series and 6 points. (Assuming the data is
random for each series.)
‘Open the communication channel
ChartFX1.OpenDataEX COD_VALUES,2,6
For (i=0 to 1)
For (j=0 to 5)
‘Assign the values to the series selected
ChartFX1.Series(i).YValue(j) = Rnd * 100
Next j
Next I
‘Close the communication channel
ChartFX1.CloseData COD_VALUES
Frequently asked questions:
What if I don't know the total number of points?
How do I feed hidden or invisible points?
Once the chart contains data, how do I change existing values?
When I change values at realtime, will the chart produce screen flickering?
How can I control scrolling?
31
Unknown Number of Points (Passing Data)
You probably noticed in the previous sample that we opened the communications channel with a
known number of points. However, knowing the number of points that are to be feed to the chart
sometimes is not possible and you'll end up in a situation where you don't know how to set the
third parameter in the OpendataEX Method.
For example, if you’re retrieving values from a database according to end users requests it will be
impractical to fetch all records and count them just to know the value Chart FX needs to open the
communications channel.
The OpenDataEx method supports a setting called COD_UNKNOWN which will force Chart FX to
allocate memory dynamically as you pass numeric values to it. The following code shows you
how to use the COD_UNKNOWN setting appropriately:
ChartFX1.OpenDataEx COD_VALUES, 1, COD_UNKNOWN
j=0
While Fetching Records
ChartFX1.Series(0).YValue(j) = Field1
j=j+1
Next
ChartFX1.CloseData COD_VALUES
Note: Please notice that COD_UNKNOWN is valid only for an unknown number of points. The
number of series in the chart must be preset when calling the OpendataEX method.
Hidden Points (Passing Data)
Another interesting feature of Chart FX is
the ability to create hidden points in the
chart. Although Chart FX forces the same
amount of points per series, you may
specify hidden points to create the illusion of
some invisible points in the chart.
All you need to do to create hidden point is to assign the CHART_HIDDEN constant when using
the YValue or ValueEX Property to assign the numeric value to a point.
ChartFX1.Series(2).YValue(3) = CHART_HIDDEN
32
Changing Existing Values in the Chart (Passing Data)
If you already populated the chart and all you want is change individual values, you may do so
without sending all the data again. The OpenDataEx Method supports a setting called
COD_UNCHANGE that will cause the data memory to remain intact, yet allowing you to change
values in the chart.
For example, if you want to change programmatically the numeric value for point No. 4 in the
Third Series your code should look like:
ChartFX1.OpenDataEX COD_VALUES, COD_UNCHANGE, COD_UNCHANGE
ChartFX1.ValueEx(2,3) = 560
ChartFX1.CloseData COD_VALUES
Preventing screen flickering (Passing Data)
Some applications need the charts to be updated constantly, because of a change in the data
contained in the chart or because new data needs to be plotted. Some samples are: Stock
Market, Medical and Industrial charts.
When the data is updated or added constantly, we call it a real-time Chart. These charts use
special routines to avoid screen flickering when repainting the chart on screen.
A real-time chart is created and handle the same way as any other chart, except how you pass
data to it.
If you are just changing existing values in a chart on a real-time basis, you can use the
COD_SMOOTH constant in the CloseData method. This constant will enable Chart FX to repaint
the chart using a BitBlitz technique that will prevent a screen flickering when updating the chart.
For example, if you are using a timer to change existing values in a chart on a real-time basis,
you can write the following code in the timer event to change an existing value in the chart and
repaint the chart smoothly once the value is changed:
ChartFX1.OpenDataEX COD_VALUES, COD_UNCHANGE, COD_UNCHANGE
‘Generate a random Value between 0-100
ChartFX1.Series(2).YValue(3) = Rnd * 100
ChartFX1.CloseData COD_VALUES Or COD_SMOOTH
Please note the COD_SMOOTH constant in the CloseData method and how it has been included
with a bitwise OR with the COD_VALUES constant.
The COD_SMOOTH constant in the CloseData Method actually forces Chart FX to use a BitBlitz
technique when repainting the chart. If you always want to enable this feature, you may do so by
using the TypeEx property, as follows:
ChartFX1.TypeEx = ChartFX1.TypeEx Or CTE_SMOOTH
If on the other hand you are adding new values to the chart, you’ll need to use special
properties and constants to make the chart scroll automatically when new points are
added to the chart. So, Please refer to "Real-time charts" chapter later in this help file for
more information on scrolling real-time charts.
Scroll Bar Controlling (Passing Data)
33
Question #1: How can I force Chart FX to display all points in one screen (No scroll bar)?
Although there’s not available space, you can force Chart FX to get rid off the scroll bar, by
handling the Scrollable property as follows:
ChartFX1.Scrollable = FALSE
Or you could use the PixPerUnit property of the Axis object to set the number of pixels per unit in
the selected axis as zero, thus eliminating the scrollbar. For example:
ChartFX1.Axis(AXIS_X).PixPerUnit = 0
Question #2: If I add more points to an existent chart how can I position the scroll bar at
the end to see the last data point?
Chart FX provides the Scroll Method which will allow you to control the scroll bar position, so
when you add new points to the chart the latest data entered will be visible. For example, if you
want to position the scroll at the end of the chart your code should look like:
ChartFX1.Scroll 7,0
Important Note: BAR and CURVE charts do not scroll immediately they need you to UPDATE the
scroll position by calling the Scroll method twice.
Question #3: How can I specify how many points I see per screen?
For this purpose, ChartFX 98 provides a property called PixPerUnit that gives you the ability to
control how many pixels each tick mark takes in an axis. This way, you can easily control how
many points you'll see per screen and if the chart is scrollable or not. However, because the
PixPerUnit property should be set according to the scale in the axis, sometimes it is difficult to
calculate and set the appropriate PixPerUnit value to achieve the desired result. Therefore, Chart
FX provides a method called SetScrollView that allows you to easily specify the amount of points
you want to see per screen by giving easy-to-understand parameters, this method will set the
appropriate PixPerUnit.
Question #4: How can I synchronize scrolling in two or more charts?
Whenever the end user scrolls a chart an event called UserScroll will be posted to your
application with information on where the scroll is positioned. You can use this information to set
the scroll bar position using the Scroll method for the rest of the charts.
Chart FX 98 Data Providers
34
Chart FX 98 was designed with extensibility in mind. The perfect example is the ChartFX 98
extensions where Software FX or third party developers may add functional modules to the
product without affecting the core.
Introducing the Chart FX 98 Data Providers.
Another interesting area where Chart FX can be extended
is the Chart FX Data providers. Many developers asked us
to make ChartFX capable of retrieving data from previously
filled arrays without the need of looping through the arrays.
Other asked about the possibility of reading data from
collections and many asked about the possibility of
interfacing ChartFX with popular grid controls from third
party vendors.
As you can imagine, there are many sources where a chart can take information from. It will be
impossible for Software FX to modify the Chart FX source code so it can read information from all
these sources and other proprietary sources developers may have.
Therefore, Chart FX 98 was designed with extensibility in mind where a Data Provider is a COM
interface that knows how to read information from the data source and knows how to make this
data available in a comprehensive format for Chart FX. Think of it as a bridge between your data
source and Chart FX 98.
The Chart FX Default Data Provider (Cfx4Data.DLL)
When you install ChartFX 98 a Default Data provider will also be installed. This data provider
allows you to read information from arrays, collections, text files and databases (using ADO and
OleDB). In the following pages we will show you how you can use this data provider to read
information and populate the chart from any of these sources.
How to integrate Cfx4Data.dll and other Data providers in your project?
Because data providers are COM interfaces you can integrate them to your project and create
objects with references included in the COM interface, as depicted in the following figure:
35
The Default ChartFX 98 Data provider can be integrated into your project by selecting the Data
Provider Type Library. From the project references
By including this reference as part of your VB project, you can create objects supported by the
data provider and use properties the data provider exposes depending on the data source to be
read. Please refer to later topics in this section for more information on how to use the
Cfx4Data.dll objects with different data sources.
In other development tools, you may need to create the objects using the CreateObject function
with the progID of the data provider you are using.
Bridging the gap between Chart FX and the Data Provider
We mentioned that the data provider exposes properties that allows you to read information from
a particular data source. For example, if you use the object that allows you to read information
from text files, the object exposes a property called File, that you can set to the path and filename
of where to take information from.
Once the Data Provider is in possession of the data; you need a mechanism that allows ChartFX
to read the information from the data provider. This mechanism is a property supported by Chart
FX called GetExternalData that allows Chart FX to read the numerical data the data provider
contains.
In the following pages we will show you how to use the default data provider in Chart FX
(Cfx4Data.dll) to read information from arrays, collections, text files and databases.
Databinding with Data Controls
Microsoft ADO Data Control 6.0 (Visual Basic 6.0)
In most cases, You'll want populate the chart with information coming from a database. ChartFX
98 supports databinding with all data controls supported in Visual Basic 6.0.
36
Important Note:
It is important to mention that databinding is provided through the ChartFX 98 Default Data
provider, so if you use databound charts you must be careful when you deploy your application as
additional files and registration processes will be required to properly run your application on the
client's machine.
Once you have setup the ADO Control on your form (please refer to VB documentation), You can
set the AdoSource Property in the Chart FX 98 with the name of the appropriate ADO Control, as
depicted in the following figure:
Figure 1. Once you have setup the data controls parameters, click the chart and select the data control's
name in the AdoSource Property
Important Note:
If you are using VB 5.0 or below, or the Data Control you're using is not the "Microsoft ADO Data
Control 6.0 (OleDB)", the property you must use to bind ChartFX to the data control is
DataSource and not AdoSource.
The way Chart FX interprets the SQL Statement.
Chart FX will apply default rules to construct the chart when linked to a Data control. These rules
are somehow intelligent in picking the information from the database and assign the legends to it,
so if you send a SELECT statement, Chart FX will create the chart series and point legends
automatically. These rules are:
•
Series Legends will be taken from the numerical field names
37
•
•
All numerical columns will be plotted as different series and all string and/or date columns
will be plotted as point legends (joined by the ‘-’ character).
All string and numerical fields specified in the SELECT statement will be plot.
How to change the default behavior for databound charts?
To change the data binding default behavior Chart FX contains properties that allow you to
change this method of plotting the data values. These properties are only available and can be
set at run time.
DataStyle Property
When having different string or date fields Chart FX will construct a long string with every string
and date field to assign to every legend point in the chart. If you want to avoid this behavior just
turn OFF the appropriate constants using the DataStyle property. For example, if you want to
force Chart FX not to use field names as series legends and use date fields as point legends, you
should use the DataStyle property as follows:
ChartFX1.DataStyle = CHART_DS_USEDATEASLEG And Not CHART_DS_SERLEGEND
DataType Property:
Array property indicates the type of every field in the SELECT statement.
This property is very useful when you want to control how Chart FX retrieves and display the
information from the database. For example in a 5 field SELECT statement such as:
"Select year,sales,projected, returns, name from PRODSALES where prodid = 1234"
The default behavior is that Chart FX will plot the year as another series since it is a number field
and therefore it will be placed in the chart. Now, if the chart you want to make is one with the x
axis containing the year and plot the sales and projected sales in a different series without using
the return and name fields you will fill the DataType array as follows:
‘ 1st we have to convert year field in a string to be selected as a x
axis legend.
ChartFX1.DataType(0) = CDT_LABEL
‘Then assigned the CDT_NUMBER constant to the numeric fields
ChartFX1.DataType(1) = CDT_VALUE
ChartFX1.DataType(2) = CDT_VALUE
‘Finally, assign CDT_NOTUSED to those fields we don’t want to plot.
ChartFX1.DataType(3) = CDT_NOTUSED
ChartFX1.DataType(4) = CDT_NOTUSED
Important Note:
The DataStyle and Datatype properties must be set before assigning the ADO resultset to the
data control. If you created the SQL Statement at design-time, these properties must be set in the
Form_Load event.
38
Connecting to ADO resultsets
Some developers do not use data controls to connect to databases but create the ADO
connection and resultsets directly in code. For these people, the Chart FX Data provider supports
a property called "ResultSet" which will read the information from an ADO resultset.
Because the Ado connectivity is provided through the Chart FX Default data provider, you must
also create the appropriate objects and instantiate the data provider in the code.
For example, the following code creates an Ado resultset and assigns it to a chart:
39
'Create variables for ADO Connection and Resultset
Dim Conn As New ADODB.Connection
Dim RS As ADODB.Recordset
'Create variable to hold the Chart FX Default Data provider
Dim CfxData As Object
'Open the DSN
Conn.Open "CfxData"
'Execute SQL and obtain resultset
Set RS = Conn.Execute("SELECT * FROM Types")
'Create Ado object from the Chart FX Resultset
Set CfxData = CreateObject("CfxData.Ado")
'Assign the resultset to the ChartFX Data Provider
CfxData.ResultSet = RS
'Let Chart FX take information from the data provider
ChartFX1.GetExternalData CfxData
Important Note:
Please refer to previous pages for more information on how Chart FX Interprets the SQL
statement and the way you can change this behavior by using the DataType and DataStyle
properties.
Connecting to BDE Cursors
If you are using a Borland Tool (Delphi, C++ Builder) you are probably working with a BDE
compatible database.
Chart FX 98 is able to read data from a BDE cursor using the GetExternalData method as
follows:
ChartFX1.GetExternalData("CfxData.BDE",LongInt(hCursor));
Important Note: The hCursor can be obtained from a TBDEDataSet.Handle
Reading Data from Arrays
In many situations, the data to populate is contained in a memory array. Although you can use
the ChartFX API to loop through array elements, read and populate the chart, you can let
ChartFX handle that job.
This feature is supported by the ChartFX default Data provider (Cfx4Data.DLL) and all you need
is to reference an object and the GetExternalData property in ChartFX as follows:
Reading Data from Arrays (Using Project References)
40
If you are using Visual Basic is easier to include the Chart FX Data provider as a reference in
your project and create an array object. By doing this, the object will expose all properties
contained and your code will be easier to read, maintain and debug. In order to include the Chart
FX Data provider as a reference, you select the Project - References menu option and check the
CfxData Type Library, as depicted in the following figure:
Once the CfxData Type library has been referenced in your project you can use the following
code to pass a previously filled array to Chart FX :
'Create the Chart FX Data provider array
Dim CfxArray As CfxDataArray
'nValues and nLegend are previously filled arrays
Dim nValues(10) As Integer
Dim nLegend(10) As Variant
'Add the nValues and nLegend arrays to the data provider
CfxArray.AddArray nValues
CfxArray.AddArray nLegend
'Let Chart FX take the information from the data provider
ChartFX1.GetExternalData CfxArray
Please note that you can pass arrays filled with Numerical Data and String or Dates that will be
taken as legends in the chart. In this particular sample there are 2 arrays, one containing the
numerical data to be contained in the chart and the other containing legends for each point in the
nValues array. If you were to pass an additional numerical array (e.g nValues2) ChartFX will
create a chart with two series. This means, there's no limitation as to the amount of arrays you
can pass using this technique.
However, you can not pass multidimensional arrays to Chart FX. This means, if you create
a matrix or a multidimensional array as nData(10,10) Chart FX will not know how to
process this information. An error will occur.
Rading Data from Arrays (Using CreateObject)
41
If you instead want to use the CreateObject function to reference the ChartFX Data Provider you
may do it by using the progId of the Chart FX Data provider as follows:
'Create a variable to contain the Chart FX Data provider
Dim CfxArray As Object
'nValues and nLegend are previously filled arrays
Dim nValues(10) As Integer
Dim nLegend(10) As Variant
'Use the CreateObject function to reference the Chart FX Data Provider
Set CfxArray = CreateObject("CfxData.Array")
'Add the nValues and nLegend arrays to the data provider
CfxArray.AddArray nValues
CfxArray.AddArray nLegend
'Let Chart FX take the information from the data provider
ChartFX1.GetExternalData CfxArray
Reading Data from Collections
Collections provide a more powerful way to store data as they don't have a fixed size (efficient
memory handling) and can grow accordingly (flexibility). Many developers use collections instead
of arrays as it is a more flexible and efficient way to handle data. The ChartFX default Data
provider can also read information from VB collections exactly the same way reading data from
arrays is supported. Please refer to the VB documentation for more information on how to handle
collections in VB.
This feature is supported by the ChartFX default Data provider (Cfx4Data.DLL) and all you need
is to reference an object and the GetExternalData property in ChartFX as follows:
Reading Data from Collections (Using Project References)
42
If you are using Visual Basic is easier to include the Chart FX Data provider as a reference in
your project and create an array object. By doing this, the object will expose all properties
contained and your code will be easier to read, maintain and debug. In order to include the Chart
FX Data provider as a reference, you select the Project - References menu option and check the
CfxData Type Library, as depicted in the following figure:
Once the CfxData Type library has been referenced in your project you can use the following
code to pass a previously filled collection to Chart FX :
'Create the Chart FX Data provider array
Dim CfxArray As CfxDataArray
'nValues and nLegend are previously filled collections
Dim nValues As New Collection
Dim nLegend As New Collection
'Add the nValues and nLegend arrays to the data provider
CfxArray.AddArray nValues
CfxArray.AddArray nLegend
'Let Chart FX take the information from the data provider
ChartFX1.GetExternalData CfxArray
43
Please note that you can pass collections filled with Numerical Data and String or Dates that will
be taken as legends in the chart. In this particular sample there are 2 collections, one containing
the numerical data to be contained in the chart and the other containing legends for each point in
the nValues collection. If you were to pass an additional numerical collection (e.g nValues2)
ChartFX will create a chart with two series. This means, there's no limitation as to the amount of
collections you can pass using this technique.
Reading Data from Collections (Using CreateObject)
If you instead want to use the CreateObject function to reference the ChartFX Data Provider you
may do it by using the progId of the Chart FX Data provider as follows:
'Create a variable to contain the Chart FX Data provider
Dim CfxArray As Object
'nValues and nLegend are previously filled arrays
Dim nValues As New Collection
Dim nLegend As New Collection
'Use the CreateObject function to reference the Chart FX Data Provider
Set CfxArray = CreateObject("CfxData.Array")
'Add the nValues and nLegend arrays to the data provider
CfxArray.AddArray nValues
CfxArray.AddArray nLegend
'Let Chart FX take the information from the data provider
ChartFX1.GetExternalData CfxArray
Because collections are of Variant Type, Chart FX will use the first element in the collection to
determine the data type stored in it. For example if you add the following elements to your
collection:
Dim Col
Col.Add
Col.Add
Col.Add
Col.Add
As New Collection
10.5
12.4
"January"
"February"
Chart FX will use this collection as numerical values (series) and the third and fourth element will
be considered hidden points in that series.
Important Note:
The order you use to add the collections to the data provider is really important as you can use
the DataType property to instruct Chart FX to manipulate the collections differently. For example,
you can use the DataType property to instruct Chart FX to use a particular numerical collection as
legends in the chart.
44
Reading Data from Text files
Chart FX 98 can also read information stored in text files. Both Tab separated values (TSV) and
Comma separated values (CSV) are valid and can be accessed by Chart FX
This feature is supported by the ChartFX default Data provider (Cfx4Data.DLL) and all you need
is to reference an object and the GetExternalData property in ChartFX as follows:
Reading Data from Text files (Using Project References)
If you are using Visual Basic is easier to include the Chart FX Data provider as a reference in
your project and create a CfxDataFile object. By doing this, the object will expose all properties
contained and your code will be easier to read, maintain and debug. In order to include the Chart
FX Data provider as a reference, you select the Project - References menu option and check the
Chart FX 98 Data provider, as depicted in the following figure:
Once the ChartFX 98 Data Provider has been referenced in your project you can use the
following code to read data from a text file :
'Create the Chart FX Data provider (using the CfxDataFile object)
Dim CfxFile As CfxDataFile
'Load the file pointed by the eFile variable (includes path)
CfxFile.FileName = eFile
'Let Chart FX take the information from the data provider
ChartFX1.GetExternalData CfxFile
45
The text file you will generate depends on the actual data you want Chart FX to take. You can
generate a text file with just numerical information or with labels that ChartFX will use to assign
legends.
In any case, the format of the text file must follow these guidelines:
1.
2.
3.
4.
5.
6.
7.
There are as many columns as series in the chart.
There are as many rows as points per series in the chart.
A tab or a comma must separate columns.
Each rows ends in a carriage return.
No empty lines are allowed after the last row of data.
Series Legends will be taken from Column headings.
Point legends (x-axis legends) will be taken from Row headings.
For example, creating a text file that Chart FX will use to:
Plot numerical data only:
10 20
15 80
2 20
4 100
7 35
Plot numerical data with Point legends:
Jan 10 20
Feb 15 80
March 2 20
Apr 4 100
May 7 35
Plot numerical data with series legends:
Sales Projected
10
20
15
80
2
20
4
100
7
35
Plot numerical data with both legends:
Sales Projected
Jan
10
20
Feb
15
80
March 2
20
Apr
4
100
May
7
35
Please note there’s a tab character in the first cell to make the "Sales" label go as a heading for
the first column.
46
Chart FX Programmer’s Guide
Working with Axes
Topics covered in this section
Introduction
The Axis Object
Axis Formatting
Axis Labeling
Axis Scrolling
Gridlines & Tickmarks
47
Working with Axes. Overview
One of the most important improvements in Chart FX 98 is its axis handling. With the Axis object
(and its properties) you'll be able to control settings like scale, gridlines, tickmarks, labels and
major & minor units among others.
It's important to be aware that Chart FX 98 supports three different axes: The main Y Axis, the
Secondary Y axis and the X-Axis, illustrated in the following figure:
Normally, the X-axis is a categorical axis (although it can also be a numerical axis in XY Plots)
and the Y axes are numerical axis that you can independently control through different properties
available in the axis object.
One of the major advantages in Chart FX 98 numerical axis handling is the introduction of major
and minor units which will allow you to control gridlines, tick marks and labels associated with the
axis. For example, you could have a chart where the primary Y axis ranges from 0-100, the labels
are position every 25 with a cross tick mark and gridlines position every 12.5 units, as depicted in
the following figure.
49
Working with Axis Object
All the properties used for axis handling have been wrapped in the Axis object. This object will
make your code easier to maintain and debug, while making the properties more accessible to
you.
The Axis Object receives as a parameter any of the 3 axes supported by Chart FX: The X Axis,
The Primary Y axis and the Secondary Y axis, followed by the property or method you want to
invoke and the setting for that particular property. For example, if you want to set the Maximum
for the Primary Y Axis to 200, your code should look like:
ChartFX1.Axis(AXIS_Y).Max = 200
How to assign series to the Primary or Secondary Y axis?
Because this depends on the amount of series you have in a chart, assigning different series to
any of the Y axis (Primary or Secondary) is a property supported by the Series object through the
YAxis property. By default, Chart FX will assign all available series to the Primary Y Axis. In some
cases it will be impractical to use the primary Y axis for all series, as they may have completely
different scales and a particular series will not be visible in the chart.
For example, if you a two series chart where the first series ranges between 1-100 and the
second series ranges between 10000-20000 the first series will not be visible because the scale
chosen by Chart FX will be between 0 - 20000 making all values between 0-100 invisible to the
eye. In this case, you may want to assign the second series to the secondary Y axis and assign a
completely different scale by accessing the YAxis property in the Series Object as follows:
ChartFX1.Series(1).YAxis = AXIS_Y2
In the following pages you'll learn how to handle independent scales, gridlines and different
settings for a particular axis.
A word of caution when handling objects.
The amount of sub-objects you reference may affect the performance of your application.
Therefore, if your code contains many settings to a particular axis, you can use alternative
methods to optimize your code such as assigning to a variable the Axis object and the assign
properties to that variable as follows:
Set YAxis=ChartFX1.Axis(AXIS_Y)
'Then you use the YAxis variable to access and set all properties
YAxis.Max = 100
YAxis.Min = 1
YAxis.GridColor = RGB(255,128,0)
This way of setting properties is more efficient as your application does not need to solve the Axis
object every time you are setting any of its properties.
50
Axis Formatting
Formatting a numerical axis is as simple of setting any of the pre-defined axis formats in Chart FX
98 using the Format property supported by the Axis object. For example, if you want scientific
notation in the primary y axis, your code should look like:
ChartFX1.Axis(AXIS_Y).Format = AF_SCIENTIFIC
Please make sure you check the Format property for more information on any pre-defined
formats supported by ChartFX 98.
User-Defined Formats
Because Chart FX supports dates as well as numbers in a particular axis, you can define your
own formats by creating a mask that will instruct Chart FX how to format and display labels in the
selected axis. For example, if you set dates for the x-axis you may create the following custom
format:
ChartFX1.Axis(AXIS_X).Format = "Ddd-MMM-yy"
51
Axis Labeling
Labeling a Categorical Axis
In most cases you will want to label a categorical axis (or x-axis), since the Y axis display
numbers according to the scale chosen (by you or ChartFX) for that numerical axis. By default, a
categorical axis (x-axis) is labeled with tag numbers (0,1,2,3...) and you may want to change that
to improve the chart's readability.
For example if you have 12 tick marks in the x axis and you want to label them with the month of
the year, you may use Label the property with the appropriate index to label every tick mark, as
follows:
ChartFX1.Axis(AXIS_X).Label(0) = "January"
ChartFX1.Axis(AXIS_X).Label(1) = "February"
ChartFX1.Axis(AXIS_X).Label(2) = "March"
...
This will display the appropriate labels on each tick mark in the x-axis.
Frequency and Label styles.
When there are too many labels in an axis (or too many points in a chart) they will not fit to the
space alloted to them. This will make the chart difficult to read. In this case you may want Chart
FX to label certain amount of points or change the way the axis displays these labels. Here are
some tips:
To make the Chart label every ten points (Use the LabelValue property)
ChartFX1.Axis(AXIS_X).LabelValue = 10
To make the labels vertical (use the LabelAngle property)
ChartFX1.Axis(AXIS_X).LabelAngle = 90
To make the labels staggered (use the Style property)
ChartFX1.Axis(AXIS_X).Style = AS_2LEVELS
Another interesting tip when handling labels is to use the Axis object Step and MinorStep
properties. Because each label will appear on the major step only, you can control the way labels
are displayed by properly setting these properties. This technique is fully explained in the
"GridLines & Tick Marks" section later in this chapter.
52
Custom labeling on numerical axes.
Assigning custom labels to an axis is as simple as using the Label property supported by the Axis
Object. However, there's a trick to using custom labels on numerical axes, and it's better to
explain it in a real case scenario. For example, if you Primary Y axis ranges between 0 - 100 with
a step of 20. In this case you'll end up with a chart with 6 tick marks in the y axis
(0,20,40,60,80,100).
Let's suppose this chart is used to display "customer satisfaction" ratings where;
0 = Very poor
20 = Poor
40 = Average
60 = Good
80 = Very Good
100 = Excellent
The Y axis, although is a numerical axis, should display these labels. And you must use the
following code to let the Y axis display those labels:
ChartFX1.Axis(AXIS_Y).Label(0)
ChartFX1.Axis(AXIS_Y).Label(1)
ChartFX1.Axis(AXIS_Y).Label(2)
ChartFX1.Axis(AXIS_Y).Label(3)
ChartFX1.Axis(AXIS_Y).Label(4)
ChartFX1.Axis(AXIS_Y).Label(5)
=
=
=
=
=
=
"Very Poor"
"Poor"
"Average"
"Good"
"Very Good"
"Excellent"
However, because the Y axis is a numerical axis, the index specified in the Label property does
not truly identifies where the label should be placed. The LabelValue property allows you to
specify where those labels should be placed in a numerical axis, so if you specify a LabelValue of
20 as follows:
ChartFX1.Axis(AXIS_Y).LabelValue = 20
Each label will be placed exactly where you want them as depicted in the following figure:
53
Axis Scrolling
When displaying charts that contain a large number of points, the most useful tool for the user is
the scrollbar. This tool allows them to see through portions of data without affecting the chart's
readability. In Chart FX 98, both the Primary Y Axis and the X Axis can be setup to display a
scroll bar that will help you setup a readable chart that your users will appreciate.
Important Note: Chart FX 98 does not support scrolling in the secondary Y Axis.
The PixPerUnit property allows you to specify the amount of physical pixels each tick mark will
occupy in the chart. For example if you have labeled the x-axis with long strings you may
increase the size of each tick mark so each label may be visible.
The PixPerUnit property is very useful when you want to create a scroll bar associated with the
selected axis or to increase the separation between tick marks. Its effect varies depending on the
type of axis that is applied to, as follows:
Categorical Axis
When you set a PixPerUnit to a categorical axis (e.g. X Axis) the value is an integer that will set
the separation (physical distance measured in pixels) between major tick marks.
The default PixPerUnit value for the X-axis (when categorical) is 30 pixels.
You may want to change the PixPerUnit value for a categorical axis when:
1) The labels associated with the chart are too long and do not fit in the allotted space. In this
particular case the PixPerUnit should be increased. What will happen is that if all points do not fit
in one screen a scroll bar will be shown. This scenario requires the Scrollable Property to be set
to TRUE.
2) You want to fit more points in one screen. In this particular case the PixPerUnit should be
decreased. You must be careful with Labels associated with each tick mark if the PixPerUnit is
too small.
3) You want to view a specific amount of points per screen. In this particular case we recommend
the use of the SetScrollView Method as it will allow you to set these values without any
calculations on your part.
4) If you don't want to show a scroll bar, you may set the PixPerUnit to zero (0). This will remove
the scroll bar and Chart FX will set the appropriate PixPerUnit to fit all values in one screen.
Numerical Axis
When applied to a numerical axis (e.g. Y Axis), the PixPerUnit property is very useful to display a
scroll bar and allow users to scroll through data without affecting the scale (Min,Max, Step) of the
axis.
Because a numerical axis can be displayed in different units (currency, scientific, date, etc) is
sometimes difficult to imagine what a PixPerUnit measures. This concept is even more complex
when we take into consideration that a numerical axis ranges in different values (millions,
thousands, fractions, etc).
When applied to a numerical axis, the PixPerUnit value is no longer an integer. The general rule
of thumb is to take the size allotted to the chart (in pixels) divide it by the Maximum in the numeric
54
axis and then divide that number by the number of pages you want the scroll bar to have.
For example, if you have a 400 pixels chart that ranges between Min=0 and Max=1 million and
you want to create a scroll bar that contains 5 pages, the PixPerUnit should be set to:
PixPerUnit = (400/1000000)*5 = 0.00008, this means there are 0.00008 pixels per unit in the y
axis.
On the other hand, if the same chart would have ranged between 0 and 1, the PixPerUnit setting
must be calculated as follows:
PixPerUnit = (400/1)*5 = 80
Setting the PixPerUnit to zero(0) will remove the scroll bar and let Chart FX calculate the
appropriate PixPerUnit value.
If the Scrollable Property is set to FALSE, the PixPerUnit will not have any effect on the
axis. So please make sure the Scrollable property is set to TRUE when using the PixPerUnit
property.
If you want to view a specific section of the numerical axis, we recommend the use of the
SetScrollView Method as it will allow you to set these values without any calculations on your
part. For example, you can invoke the SetScrollView method as follows:
ChartFX1.Axis(AXIS_Y).SetScrollView 0,200000
The ZoomIn method is also provided so you can control what portion of the chart you want to
view.
55
Gridlines & Tickmarks
Some people make use of gridlines and tick mark to improve the chart's readability. With Chart
FX 98 you can control major and minor units, gridlines and tick marks independently. This allows
the user to easily detect when a particular value plots in a certain value or range.
The axis object provides several independent properties that allow you to set almost any
parameters to gridlines and tickmarks in any axes of the chart. However, it is important to
understand how gridlines and a tick marks relate to major and minor units in the chart, as
identified in the following picture:
Controlling Major Unit Gridlines and Tickmarks
The important thing to mention is that axis labels are placed in the major unit controlled by the
Step property. The major tick mark is controlled by the Tickmark property and the major unit
gridline is controlled by the Grid, GridStyle and GridColor Properties.
In the figure shown above is easy to identify a step of 10, with tickmarks placed outside the axis
and Dash-Dotted blue gridlines. This can be achieved with the following code:
ChartFX1.Axis(AXIS_Y).Step = 10
ChartFX1.Axis(AXIS_Y).Grid = TRUE
ChartFX1.Axis(AXIS_Y).TickMark = TS_OUTSIDE
ChartFX1.Axis(AXIS_Y).GridStyle = CHART_DASHDOT
ChartFX1.Axis(AXIS_Y).GridColor = RGB(0,0,128)
Controlling Minor Unit Gridlines and Tickmarks
56
When you set a minor unit using the MinorStep properties, labels will not be shown in this location
but gridlines and tickmarks can be set. For example in the figure shown above the MinorStep
property has been to 5 with Minor Tickmarks shown as a cross and a solid Purple gridline
associated with the minor unit, this can be achieved with the following code:
ChartFX1.Axis(AXIS_Y).MinorStep = 5
ChartFX1.Axis(AXIS_Y).MinorGrid = TRUE
ChartFX1.Axis(AXIS_Y).MinorTickMark = TS_CROSS
ChartFX1.Axis(AXIS_Y).MinorGridStyle = CHART_SOLID
ChartFX1.Axis(AXIS_Y).MinorGridColor = RGB(128,128,255)
Important Note:
Because of limitations in the Windows API (Windows 95 and Windows 98), you can not create
gridlines with different styles and widths. This limitation does not occur in Windows NT 4.0 or
later. Therefore, if you want to create a grid line with a special style (dot, dash, etc) the width
must be always 1 pixel.
Interlaced Grids
In some cases interlaced gridlines are very useful to improve the chart's readability, as depicted
in the following figure:
To achieve this effect you need to set the GridColor and the RGB2DBk properties (RGB3DBk if
the chart is in 3D mode) with the color you want, plus set the Style property supported in the Axis
object as follows:
ChartFX1.Axis(AXIS_Y).GridColor = RGB(255,255,0)
ChartFX1.Axis(AXIS_Y).RGB2DBK = RGB(0,255,255)
ChartFX1.Axis(AXIS_Y).Style = AS_INTERLACED
57
Chart FX Programmer’s Guide
Working with Chart FX Colors
Topics covered in this section
Color types
Assigning Colors
Color Palettes & Schemes
Background colors
Patterns
59
Handling Colors
What kind of colors can I assign to the different markers and elements in the chart?
Normally, you would use the RGB macro with any property that assigns and handles a particular
element’s color in the chart, as follows:
ChartFX1.RGBBk = RGB(255,0,255)
If you are using Chart FX palettes and you want to use a particular color in the palette, you could
reference it by using the CHART_PALETTE constant plus the index of the color you want to use.
For example, if you want to assign the tenth color in the current palette to the background you will
set the RGBBk property as follows:
ChartFX1.RGBBk = CHART_PALETTECOLOR Or 10
Some developers want their applications to be system aware. This means, whenever the user
changes the Windows Color schemes, their application accommodates the new system colors. All
Chart FX properties related to colors can also be set to system colors. For example, In Visual
Basic, you would set the RGBBK property to set the chart’s background to a system color as
follows:
ChartFX1.RGBBk = vbInfoBackground
Important Note: If you are not using VB, you can assign a system color, as follows:
ChartFX.RgbBk =
CHART_SYSCOLOR or Index
where index is GetSyscolor Windows API call.
Changing the default colors selected by Chart FX
When you create any type of chart, Chart FX will select from a default palette of solid colors.
These colors can be changed to fit your specific needs. Colors are usually associated with Series,
so if you have three series in the chart each one will have its own color. For example, If you have
a three series bar chart, and you want to change default colors selected by Chart FX, You must
first open a communication channel with the OpenDataEx method with the COD_COLORS
constant and use the Color Property as follows:
Chart1.OpenDataEx COD_COLORS, 3, 0
‘Then, you can change the colors of the series with the "Color"
property
Chart1.Color(0) = RGB(128,255,0)
Chart1.Color(1) = RGB(0,0,128)
Chart1.Color(2) = RGB(128,128,255)
‘Finally close the communications channel for colors
Chart1.CloseData COD_COLORS
61
The Series Object also provides a Color property that you can use to change colors associated
with each series in the chart. For example, the following code will provide the exact same results
as the code shown above:
Chart1.OpenDataEx COD_COLORS, 3, 0
‘Then, you can change the colors of the series with the "Color"
property
Chart1.Series(0).Color = RGB(128,255,0)
Chart1.Series(1).Color = RGB(0,0,128)
Chart1.Series(2).Color = RGB(128,128,255)
‘Finally close the communications channel for colors
Chart1.CloseData COD_COLORS
Changing the default color palette.
Another interesting way to change colors in Chart FX is to use the Palette Property where all
series and different objects (like backgrounds, gridlines, etc) will follow a pre-defined color
palette. By default, Chart FX provides over a dozen pre-defined color-palettes. For example, if
you want the chart to be displayed using the "Dark Pastels" palette, your code should look like:
ChartFX1.Palette = "Dark Pastels"
Important Note:
The Chart FX 98 palettes are deployed as a registry entry on the client machine, so if you use this
property in your application, you must make sure the palettes are properly deployed and
registered in the client machine. For more information please refer to the "Deployment Issues"
topic.
62
Assigning individual colors to markers
In some cases, you don’t want colors associated by series, you want to be able to assign colors
individually by marker. For example, if you have a bar chart and you want bars with negative
values to be red and bars with positive values to be blue, the code shown above will not do the
trick for you because each color is associated with an entire series instead of an specific marker.
In order to associate colors by marker, all you need to do is use the MultipleColors property.
When turned on this property will force Chart FX to paint markers with different colors, even if
they belong to the same series.
For example if you want to assign red to those bars with negative values and blue with values
greater than zero, your code should look like:
‘First Turn on the MultipleColors property
Chart1.MultipleColors = TRUE
‘Then open the comm. channel with COD_COLORS.
Chart1.OpenDataEx COD_COLORS,2,0
‘Obtain the total number of points
nTotalPoints=Chart1.nValues
‘Finally assign colors depending on their value using the Color
Property
for j=0 to (nValues-1)
if (Chart1.Value(j) <0) Then
Chart1.Color(j) = RGB(0,0,255) else
Chart1.Color(j) = RGB(255,0,0)
End If
Next j
Chart1.CloseData COD_COLORS
Changing the background colors of the chart
Chart FX provides three properties that allows you to change the background colors of the chart.
These colors can be changed by the end user by dragging a color from the palette bar located in
the Chart FX ToolBar to any portion of the background. These properties are:
RGBBk: Specifies the color for the background surrounding the chart.
RGB2DBk: Specifies the color for the 2D charts background. This color is used to fill the
internal rectangle (surrounded by the AXIS) where the chart is contained.
RGB3DBk: Specifies the color for 3D charts background. This color is used to fill the 3D
wall that encloses the chart.
For example, if you want to change the color of the 3D wall in a chart to be blue, your code
should look like:
Chart1.RGB3DBk = RGB(0,0,255)
Important Note:
CHART_TRANSPARENT constant can be set to make a transparent 3D background. For
example, if you’re placing a bitmap underneath (BkPicture) the chart you may want to use the
transparent background feature as follows:
Chart1.RGBBK = CHART_TRANSPARENT
63
Color Schemes
Another interesting Chart FX feature related to colors is Color Schemes. This feature allows you
to change from Solid, Colored Patterns and Black & White patterns. This feature is very useful is
your application needs to display markers with patterns to improve readability of the chart.
This feature is accessible from Chart FX end user Interface. From the options dialog, and when
you show the patternbar as another tool in your chart window.
The property is called Scheme and it allows you to select from CHART_CSSOLID (Solid Colors),
CHART_CSBWPATTERN (B&W patterns) or CHART_CSPATTERN (Colored Patterns).For
example if you want to use the Colored pattern Scheme your code should look like:
Chart1.Scheme = CHART_CSPATTERN
When you’re using colored patterns you may set either the foreground or background color of the
pattern. The foreground color takes the setting from the Color property previously explained and
the background color of the pattern can be set using the "BkColor" property.
These pattern colors can also be changed from the Chart FX User Interface as follows:
Foreground: Drag a color to the marker.
Background: Drag a color to the marker while pressing the Shift key
Patterns
Chart FX provides default patterns that you (or your end users) can use to assign to the different
series of a chart. The only way to see these patterns is to show the Patternbar in the Chart. To do
this, you use the PatternBar property as follows:
Chart1.PatternBar = TRUE
When you show the PatternBar your users may Drag&Drop a pattern to any series in the chart
and Chart FX will automatically apply such pattern, changing to a colored pattern scheme.
You can also set patterns programmatically with the Pattern property, as follows:
Chart1.Pattern(1) = 2
Where 1 represent the series index you want to assign the pattern to and 2 represents the
position of the pattern in the pattern bar.
2D Colored Lines
In a 2D Line Chart, Chart FX will paint connecting lines in black, if you want you can instruct
Chart FX to paint lines in the same colors as point markers, you do this using the Border property
as follows:
Chart1.Border = FALSE
Note: When setting the border property to FALSE the color used by the 2D line is the one
controlled by the BorderColor Property
Legend Background Colors
When you decide to show any of the Legend windows (Series or Points Legend) your end users
can easily change the background color of the legends by dragging a color to a background
portion of that window. If you want to do this programmatically, you must use the BkColor
property of the respective object. For example, if you want to change the Series Legend
background color to Green:
ChartFX1.SerLegBoxObj.BkColor = RGB(0,128,0)
64
Chart FX Programmer’s Guide
Customizing chart markers
Topics covered in this section
Point Size & Shapes
Conical & Cylindrical Shapes
Marker Volume
Lines Style & Width
65
Markers
Controlling the Point Size and Shape.
When you create charts that display connecting points (line, scatter, curve, polar, etc) you may
change the size of this marker with the MarkerSize property as follows (The setting for this
property must be between 1 and 20, the default ):
ChartFX1.MarkerSize = 6
The shape of the marker is controlled by the MarkerShape property. For example if you want to
assign a triangle as a marker shape programatically, your code should look like:
ChartFX1.MarkerShape = MK_TRIANGLE
You may also get rid off the point markers as follows:
ChartFX1.MarkerShape = MK_NONE
Setting Individual Marker Sizes and Shapes
All properties related to markers are also exposed by the Series Object. this will allow you to set
individual settings to the different series contained in the chart. For example, if you have a two
series chart you may choose to show triangles in the first series and no point markers in the
second series, as follows:
ChartFX1.Series(0).MarkerShape = MK_NONE
ChartFX1.Series(1).MarkerShape = MK_TRIANGLE
Conic and Cylindrical shapes.
Chart FX can transform bars , cubes or Hi-Lo-Close charts to conical and cylindrical shapes. You
can do this for all or individual series. This means, you can have a bar combined with a conical
shape if you decided to do it that way.
The property associated with conical and cylindrical shapes is CylSides. This property is
presented as a general property and is also exposed by the Series Object. This allows you to set
global changes (all series) or to a particular series in the chart.
This property setting should be a positive (cylindrical) or negative (conical) value of the number of
sides you want the shape to be. For example if you have a two series bar chart, and you want the
first series to be an octagon cylindrical shape and the second series to be and hexagon base
conical shape, your code should look like:
Chart1.Series(0).CylSides = 8
Chart1.Series(1).CylSides = -6
Controlling the Marker Volume
67
When you create a bar chart, the marker (or bar) will occupy only a percentage of the space
allotted (this is the space between tick marks). The Property is called Volume and you can set it
as follows:
Chart1.MarkerVolume = 100
Setting Lines style and width.
When you use charts that have a line associated with markers (such as line, spline, polar, etc)
you can control the style and width for each line independently using the LineStyle and LineWidth
properties.
Again, these properties are exposed by the Series Object as well so you are able to set them
globally (all series) or for individual series in the chart.
Note: When using line styles different than CHART_SOLID, the width must be 1 pixel. This
limitation is imposed in Windows 95/98 only. Windows NT does support different line styles and
widths.
For example, if you have a 2D line chart an you want to set the style of all series to be dotted,
your code should look like:
ChartFX1.LineStyle = CHART_DOT
On the other hand, if you have a 2 series chart and you want the first series to display a dotted
line while the second series shows a dashed line, you can use the same properties exposed by
the series object as follows:
ChartFX1.Series(0).LineStyle = CHART_DOT
ChartFX1.Series(1).LineStyle = CHART_DASHED
Separating a Pie slice programmatically.
If you are plotting a Pie chart and you want to separate a slice programmatically (e.g. Your
application always chooses the biggest pie slice and separates it a little bit from the rest), you can
do it through the SeparateSlice Property.
This property takes the index of the slice (point) you want to separate and receives the separation
distance measured from the center of the pie and expressed in radius percentage. For example
setting this property to 100 will make the vertex of the slice to be on the edge of the pie, as
follows:
Chart1.SeparateSlice(1) = 100
68
Chart FX Programmer’s Guide
3D Effects
Topics covered in this section
Displaying the chart in 3D Mode
Rotating the Chart
Clustered Charts
Perspective
3D Depth
69
3D Effects
Displaying the Chart in 3D mode.
To display the chart in 3D you must use the Chart3D property as follows;
ChartFX1.Chart3D = TRUE
Once you have set this property you can start using different 3D settings like Rotation, Cluster,
Perspective, etc.
Rotating the chart programmatically.
Although Chart FX provides your end users the most advanced way of rotating charts, you may
want to set 3D angles programmatically. You may use this option to rotate the chart on a realtime
basis (with a timer) for presentation purposes.
In order to rotate a chart programmatically, you must use two Properties: the View3D, AngleX and
AngleY properties
First you set the View3D property to TRUE.
Chart1.View3D = TRUE
Then you set the 3D Angles as follows:
Chart1.AngleX = 45
Chart1.AngleY = 60
Note: X axis rotation angle, Must be in [0, 90] U [270, 360) and Y axis rotation angle. Must be in
[0, 360).
Setting 3D Wall Width.
Every 3D chart is enclosed in a 3D wall, and its width is controllable through the WallWidth
Property. The default width is 8 pixels. If you want to make the 3D wall flat, you can set it to 1 as
follows:
Chart1.WallWidth = 1
Cluster Charts
When displaying a clustered chart, each series will have its own position in the z axis. This
means, if you have a 3 series chart and this property is turned on, each data series will occupy
one row of data and there will be 3 rows (z-axis clusters) in the chart. To make a 3D chart
clustered use the Cluster property as follows:
ChartFX1.Cluster = TRUE
AREA charts are always clustered as there is no way to paint different series side by side. On the
other hand, if you have a BAR chart, it is possible to paint bars side-by-side and not clustered in
the z-axis.
Setting the chart Perspective
71
The perspective value specifies the ratio of the front of the chart to the back of the chart. It ranges
from 0 (default) degrees to 100 degrees. The Perspective property allows you to set this value,
For example to set a perspective of 50%, you need to set the Perspective property as follows:
ChartFX1.Perspective = 50
Important Note: In order to apply a perspective the chart must be in 3D (Chart3D property) and
the View3D and Cluster properties must be turned on.
Controlling the 3D Depth
The value is a percentage of the marker's width (the distance between two consecutive points in
the X-Axis). For example;
100% means the marker will have a depth equals to its width.
200% means the marker will have a depth double than its width.
The property that controls this setting is called View3DDepth
72
Chart FX Programmer’s Guide
Working with special Chart Types
Topics covered in this section
XY Plots
MultiType Charts
MultiStacked Charts
Gantt Charts
Financial Charts
Surface & Contour Plots
Bubble Charts
73
XY Plots
An XY Plot is a chart that shows the relationship or degree of relationship between numeric
values in several series, or plot two group of numbers as one series of x-y coordinates.
Because each point in an XY Plot is defined by two coordinates (x, y) , you must make additional
calls to be able to pass numeric data accordingly.
Passing Data to a scatter plot with the ValueEx and XValueEx properties.
The only special case when passing data to an XY Plot is you’re going to make two OpenDataEX
method calls (one with COD_VALUES or y coordinate and another one with COD_XVALUES or x
coordinate) and finally use the "ValueEx" property to assign the appropriate y values and the
"XValueEx" property to assign the x values of each point in the chart. The source code should
look as follows:
' Open the VALUES channel specifying "nSeries" Series and "nPoints"
Points
ChartFX1.OpenDataEx COD_VALUES,nSeries,nPoints
ChartFX1.OpenDataEx COD_XVALUES,nSeries,nPoints
' Code to set the data
For i = 0 To nSeries-1
For j = 0 To nPoints –1
ChartFX1.ValueEX(i,j) = 'Y Coordinate Value
ChartFX1.XValueEX(i,j) = 'X Coordinate value
Next j
Next i
' Close the VALUES and XVALUES channels
ChartFX1.CloseData COD_VALUES
ChartFX1.CloseData COD_XVALUES
Passing Data to a scatter plot with the Series Object.
You can also use the YValue and XValue properties in the Series object to pass data to an XY
Plot.
' Open the VALUES channel specifying "nSeries" Series and "nPoints"
Points
ChartFX1.OpenDataEx COD_VALUES,nSeries,nPoints
ChartFX1.OpenDataEx COD_XVALUES,nSeries,nPoints
' Code to set the data
For i = 0 To nSeries-1
For j = 0 To nPoints –1
ChartFX1.Series(i).YValue(j) = 'Y Coordinate Value
ChartFX1.Series(i).XValue(j) = 'X Coordinate value
Next j
Next i
' Close the VALUES and XVALUES channels
ChartFX1.CloseData COD_VALUES
ChartFX1.CloseData COD_XVALUES
Notes:
75
Chart FX does not limit the amount of Series in a scatter chart. This means, you can create a
scatter chart with multiple series. Also all properties exposed by the Axis Object also apply to
this type of charts.
Please remember that in an XY Plot chart the x-axis becomes a numerical (not a categorical) axis
you can customize with the Axis Object properties. This means that instead of legends you will be
setting scales, min, max and other numerical values to the x-axis.
The following chart types can handle x-values:
Lines, Curve*, Scatter, Area*, Step Lines, Surface, Bubble, Contour*, Curve Area.
* X values must be passed in ascending order.
76
XY Plots. FAQ (Frequently Asked questions).
Which Chart Types are supported as XY Plots?
Although the most common use for XY Plots are Scatter (or point) charts, Chart FX allows
you to change to the following chart types when you set data values as x,y coordinates:
Line, Curve, Area, Step Lines, Surface, Bubble, Contour & Curve Area.
This means that if you want an XY Plot to show connected lines all you need to do is change
the Gallery property to Lines.
How can I instruct a Data control or ADO that I'm creating a scatter plot?
Normally, when a chart is bound to a data control or if you use ADO (or text files) to retrieve
data and populate the chart. Chart FX will assume that you want to create a regular chart
type and not an XY Plot. This means that if you are connecting to a database that contains X
and Y coordinates for an XY Plot, Chart FX by default will create a chart with two series
instead of an XY Plot.
This default behavior can be overwrite by the DataType property. For example if you have a
SQL Statement like:
SELECT YValue,XValue FROM MyTable
You can set the DataType property as follows:
ChartFX1.DataType(0) = CDT_VALUE
ChartFX1.DataType(1) = CDT_XVALUE
This will force Chart FX to take the information appropriately for the XYPlot..
Note: The DataType property must be set before you assign the ADO Resultset to chart.
Can I force lines to display the same color as point markers?
Yes, you may use the "TypeMask" property to force ChartFX to display lines in the same
color of point markers instead of black, as follows:
Chart1.TypeMask = Chart1.TypeMask Or CT_COLORLINE
Can I use different point markers in a scatter plot?
Yes, please refer to the MarkerShape property supported by the Series Object.
77
Can I highlight points in a scatter chart?
For example I have a certain limit I want to control and highlight points that plot above that limit.
The answer to this question not only applies to scatter charts but all types of charts in Chart FX,
You have several options:
Use Chart FX "Constant Lines and Color Stripes" Feature to highlight the limit or range,
respectively.
Use Chart FX "Customizing Chart painting" Feature, to highlight points by enclosing in a
rectangle or any other similar shape.
You may change the color of the points that plot above that limit. If this is what you want, you
can force Chart FX to assign different colors for each point in the chart. The code should look
like:
‘First you must set the MultipleColors Property to indicate Chart FX that each marker (point)
will have its own color. (In our case, you’ll always assign the same color and change only the
ones that plot above the limit).
Chart1.MultipleColors = TRUE
‘You then have to open a communications channel with COD_COLORS and the number of
colors you’ll pass to the chart (in this case 2 colors, one for the points that plot above the limit
and one for the rest of the points)
Chart1.OpenDataEx COD_COLORS, 2, 0
‘Check the value of all points and assign its colors using the
"Color" Property
nTotalPoints=Chart1.nValues
For j=0 to (nValues-1)
if (Chart1.Value(j)>=MyLimit)
‘Red to the points that plot above the limit
Chart1.Color(j) = RGB(255,0,0)
else
‘ Blue color to the points that plot inside the limit
Chart1.Color(j) = RGB(0,0,255)
endif
Next j
Chart1.CloseData COD_COLORS
MultiType Charts
78
One of the most powerful features in Chart FX is MultiType charts. They allow you to specify a
different chart type for the series contained in a chart. Not all chart types in Chart FX can be
combined to create a Multitype chart, only a subset of the chart types available in Chart FX can
be use with this option.
If you have a chart with more than one series, you can use the Gallery Property in the Series
Object to assign a different chart type to different series in the chart. For example, if you have a
three series chart and you want the first series to be bar, the second series to be curves and the
third series to be area, your code should look like:
ChartFX1.Series(0).Gallery = BAR
ChartFX1.Series(1).Gallery = CURVE
ChartFX1.Series(2).Gallery = AREA
All Multitype charts provide 2D/3D support, rotation capabilities and mouse detection.
Important Note: Since the MultiType property is an array of series, it has to be set after you define
the number of series in the chart using the OpenDataEX Method
It is also important to note there's a General property with the same name (Gallery) that when
used will apply the specified chart type to all series in the chart. So you must be careful to
reference the series object when creating multitype charts. For example:
ChartFX1.Gallery = LINES ' Will apply lines to all series in the chart
ChartFX1.Series(0).Gallery = LINES will convert the first data series
to lines.
Here's an example of you what you can achieve using MultiType charts:
79
MultiStacked charts
Most charting tools allow you to stack bar and area charts in different modes. Most common are
regular stack and 100% stack charts. Not only Chart FX allows you to stack charts using these
common methods, but you can easily achieve MultiStacked charts where different series in the
chart can be presented as different groups of stacked bar or area charts.
If you want to stack all series in the chart, you can use the Stacked general property as follows:
‘ Regular stacked
ChartFX1.Stacked = CHART_STACKED
‘ or 100% stacked
ChartFX1.Stacked = CHART_STACKED100
This stacked property is also exposed by the Series Object, with the difference that it will apply to
a specific series in the chart. When you manipulate the Stacked property in the Series object you
will instruct Chart FX to stack that series on top of the previous one which must be of a stacked
type (area or bar). For example, the following code creates a multistacked chart with a curve on
top of the different stacked groups:
'Produce 2 bars and 1 curve
ChartFX1.Series(0).Gallery
ChartFX1.Series(1).Gallery
ChartFX1.Series(1).Stacked
ChartFX1.Series(2).Gallery
ChartFX1.Series(3).Gallery
ChartFX1.Series(3).Stacked
ChartFX1.Series(4).Gallery
ChartFX1.Series(4).Stacked
ChartFX1.Series(5).Gallery
=
=
=
=
=
=
=
=
=
BAR
BAR
True ' On top of 0
BAR
BAR
True ' On top of 2
BAR
True ' On top of 3
CURVE
' Adjust scale
ChartFX1.RecalcScale
This code produces the following chart:
80
Gantt Charts
Gantt charts are commonly used to track activities during time. With little code you can achieve,
in Chart FX, a Gantt chart like the following:
Setting the Gantt type
The first step in creating a gantt style chart is to use the Gallery property with the GANTT chart
type as follows:
ChartFX1.Gallery = GANTT
It is important to understand that when you set this style, the axis will be shifted. The x-axis
(categorical) draws vertically (left side) and the y-axis (numerical) draws in the bottom of the
chart. This is important to mention as all the properties that you set regarding the y axis will affect
the bottom axis and not the left side axis as you would normally expect.
Also, the GANTT type will display horizontal bars in the Plot area.
Passing Data To Gantt Charts
There are two parameters you must pass to a Gantt chart: Where the bar begins and where it
ends, according to the data type the y axis (bottom) has been set. This means that if you set a
Min of 0 and a Max of 200 for the Y axis the bars must contain a beginning value and an ending
value that are numbers.
On the other hand, if you set the Min and Max to be dates, the value of the bars must be set with
dates so they can be represented according to the format of the y axis.
The properties involved in passing data to a Gantt chart are ValueEX and IniValueEX properties
that must be used in conjunction with OpenDataEX and CloseData methods.
81
The following example shows how you can set values to a Gantt chart represented in a numerical
y-axis. Please note how the Y axis is set with numerical values for its min and max before
sending the data to the chart.
'First set the Min and Max for the Y Axis
ChartFX1.Axis(AXIS_Y).Min = 0
ChartFX1.Axis(AXIS_Y).Max = 200
'Then we can use the ValueEX and IniValueEX for the Gantt Chart.
Let's suppose it has 3 bars
ChartFX1.OpenDataEX COD_VALUES,1,3
ChartFX1.OpenDataEX COD_INIVALUES,1,3
ChartFX1.IniValueEX(0,0) = 10
ChartFX1.ValueEX(0,0) = 30
ChartFX1.IniValueEX(0,1) = 40
ChartFX1.ValueEX(0,1) = 80
ChartFX1.IniValueEX(0,2) = 100
ChartFX1.ValueEX(0,2) = 180
ChartFX1.CloseData COD_VALUES
ChartFX1.CloseData COD_INIVALUES
The following example shows how you can set values to a Gantt chart represented in a date
formatted axis. Please note how dates are set for the Min and Max in the Y Axis and values set
with the ValueEX and the IniValueEX properties correspond to dates:
Dim Today As Date
Today = Now()
'First set the Min and Max for the Y Axis
ChartFX1.Axis(AXIS_Y).Min = Today
ChartFX1.Axis(AXIS_Y).Max = Today + 120 '3 months
'Then we can use the ValueEX and IniValueEX for the Gantt Chart.
Let's suppose it has 3 bars
ChartFX1.OpenDataEX COD_VALUES,1,3
ChartFX1.OpenDataEX COD_INIVALUES,1,3
ChartFX1.IniValueEX(0,0) = Today
ChartFX1.ValueEX(0,0) = Today +10
ChartFX1.IniValueEX(0,1) = Today + 30
ChartFX1.ValueEX(0,1) = Today + 80
ChartFX1.IniValueEX(0,2) = Today+90
ChartFX1.ValueEX(0,2) = Today+110
ChartFX1.CloseData COD_VALUES
ChartFX1.CloseData COD_INIVALUES
But my axis is displayed on the bottom of the chart and I want it on top?
82
In order to create the chart displayed in the figure shown above, we made use of the Chart FX
Secondary Y axis capabilities where the data series was assigned to the secondary Y axis and its
settings (Min, Max, etc) while the primary Y Axis Visible property was set to false, as follows:
'First let's assign the first series to the secondary Y Axis
ChartFX1.Series(0).YAxis = AXIS_Y2
'Then we must set the Secondary Y Axis Min, Max, Step, etc so the
chart still displays the same way
'Finally the Primary Y Axis is hidden in the chart
ChartFX1.Axis(AXIS_Y).Visible = FALSE
Assigning Activity Labels
Activity labels are set as any other legend in the chart. Using the Legend Property or the Label
property in the Axis Object.
What about independent colors?
First you must set the MultipleColors Property to indicate Chart FX that each marker (point) will
have its own color.
Chart1.MultipleColors = TRUE
You then have to open a communications channel with COD_COLORS and the number of colors
you’ll pass to the chart (in this case 2 colors, one for the bar displayed in red and the other ones
in blue)
Chart1.OpenDataEx COD_COLORS, 2, 0
‘Check the value of all points and assign its colors using the
"Color" Property
nTotalPoints=Chart1.nValues
For j=0 to (nValues-1)
if (Chart1.Value(j)>=MyLimit)
‘Red to the points that plot above the limit
Chart1.Color(j) = RGB(255,0,0)
else
‘ Blue color to the points that plot inside the limit
Chart1.Color(j) = RGB(0,0,255)
endif
Next j
Chart1.CloseData COD_COLORS
Financial Charts
83
Important Note:
If you are interested in Financial Charts, you may want to know Software FX provides a
Chart FX Financial Edition that allows for creation and handling of special Financial Chart
Types like Renko, Kagi, Money Flow, Three Line Break, among others. Please visit or
web site at http://www.softwarefx.com for more information on this special Financial
Extension for Technical Analysis.
Financial Charts
As part of the standard chart types, Chart FX provides support for three different types of financial
charts: Hi-Lo-Close, Open-Hi-Lo-Close and Candlesticks. Financial charts also provide support
for MultiType charts, so you can plot an Open-Hi-Lo-Close combined with a line or a volume (bar)
chart (Please refer to a sample later in this section).
The method of passing data to a Financial chart is exactly the same as with other charts: opening
a communication channel (OpenDataEx Method), passing the numerical information and finally
closing the communication channel.
Each marker is defined by several values. For a Hi-Lo-Close chart you’ll need three series and for
Open-Hi-Lo-Close you’ll need to set four series. Finally, you’ll need to pass special constants in
the ValueEX property to instruct Chart FX which numerical values go with the Open, Hi, Low and
Close values.
The first step you need to do when plotting a financial chart is to handle the Gallery property
either at design or run time to specify the type of chart you’ll be handling, as follows:
ChartFX1.Gallery = HILOWCLOSE [or OPENHILOCLOSE Or CANDLESTICK]
To pass data to an Open-Hi-Lo-Close chart you must be careful to specify the appropriate
constant in the ValueEX property as follows::
' Open the VALUES channel specifying 4 Series (OPEN, HIGH,LOW and
CLOSE) and "nPoints" Points
ChartFX1.OpenDataEx COD_VALUES,4,nPoints
' Code to set the data
For j = 0 To nPoints –1
ChartFX1.ValueEx(OHLC_LOW,j) = Low value!
ChartFX1.ValueEx(OHLC_OPEN,j) = Open value!
ChartFX1.ValueEx(OHLC_CLOSE,j) = Close value!
ChartFX1.ValueEx(OHLC_HIGH,j) = High value!
Next j
' Close the VALUES channel
ChartFX1.CloseData COD_VALUES
Multitype Financial Charts
84
It’s common practice to combine a financial chart with another chart (i.e. Lines or Bar) to display
other relevant information (e.g Volume Traded). The Gallery Property provided by the Series
Object can be used to achieve this. Another Chart FX feature that can be used with combined
financial charts is double-y axis, because the volume traded moves in a different range of scale
than the price of a stock.
In the following sample we will create a Hi-Lo-Close chart, with a volume chart (bar) and
associating the volume series to a secondary y axis:
' Open the VALUES channel specifying 5 Series (OPEN, HIGH,LOW,CLOSE and
VOLUME) and "nPoints" Points
ChartFX1.OpenDataEx COD_VALUES,5,nPoints
' Code to set the data
For j = 0 To nPoints –1
‘First three series contain Hi-Lo-Close Information
ChartFX1.ValueEx(OHLC_OPEN,j) = Open value!
ChartFX1.ValueEx(OHLC_HIGH,j) = Hi value!
ChartFX1.ValueEx(OHLC_LOW,j) = Low value!
ChartFX1.ValueEx(OHLC_CLOSE,j) = Close value!
‘Fifth Series contains Volume information
ChartFX1.Value(4,j) = Volume Traded in day!
Next j
' Close the VALUES channel
ChartFX1.CloseData COD_VALUES
‘Now that all data is there, we use the Gallery property in the series
object to create a bar volume
Chart1.Series(4).Gallery = BAR
‘Assign the volume chart to a secondary y axis
Chart1.Series(4).YAxis = AXIS_Y2
Surface & Contour Charts
Other interesting chart types in Chart FX are the Contour and Surface Plots.
The surface plot is usually displayed in a 3D representation. The number of series determines the
width of the chart while the number of series determines the depth of the chart. For example if we
85
want to display a 3D surface chart with 10 Points and 10 Points per series with all values set to
zero, it would look like:
As depicted in the figure, you must now locate which data points you want to change in order for
the chart to start looking like a surface plot. For example if we change the value for the points and
series highlighted in the figure, the chart will look like:
In order to achieve the chart displayed in the figure shown above your code should look like:
ChartFX1.Gallery = SURFACE
'Let's assign zero values to all points (Figure 1)
ChartFX1.OpenDataEx COD_VALUES,10,10
For i = 0 to 9
86
For j = 0 to 9
ChartFX1.ValueEx(i,j) = 0
Next j
Next i
'Now let's change Series 2, Point 2 to a value of 9
ChartFX1.ValueEX(1,1) = 9
'Now let's change Series 5, Point 9 to a value of 20
ChartFX1.ValueEX(5,9) = 20
'Now let's change Series 7, Point 5 to a value of 15
ChartFX1.ValueEX(7,5) = 15
ChartFX1.CloseData COD_VALUES
Handling Level Colors
One of the most important settings in a surface plot is the level of detail the chart contains by
displaying different colors according to the value of each data point. Notice that although values
have been set, the level of detail shown in the chart is not enough for the scale selected for the y
axis (-20,20). What we need is this surface plot to show more colors according to the height of
each point.
To achieve this, you simply change the step of the primary Y axis to achieve the level of detail
you need in the surface plot. For example, in the figure shown above the step has been set to 10,
not allowing the surface to display enough colors. However, if we change the step to 2 as follows:
ChartFX1.Axis(AXIS_Y).Step = 2
The surface plot will display more colors depending on the level of each value,
87
Automatic Labeling & Scaling
Because most surface and contour chart displays levels, we have included a method that allows
you to label points automatically according to a specific scale factor. The SetContourLabels
method allows you to automatically assign such legends by giving a step in Y axis units. When
set to zero, the legends will be automatically assign with a best fit step chosen by Chart FX.
Note:
When invoking this method, Chart FX will assign series legends indicating the color for
each level in the CONTOUR Plot. So be aware that any series legend you previously had
in the chart will be erased when invoking this method. This method also modifies the Step
of the primary Y axis with the step specified in this method.
When you invoke this method as follows:
ChartFX1.SetContourLabels 20
A contour chart will look like:
88
Bubble Charts
Bubble charts without X Coordinate
The first type of bubble charts available in Chart FX are Bubble charts that compare a set of two
values with one of the values specifying the size of the bubble marker.
To pass data just set a chart with two data series and set BUBBLE to the Gallery Property as
follows:
ChartFX1.Gallery = BUBBLE
ChartFX1.OpenDataEx COD_VALUES,2,5
For j = 0 to 4
'Set the series that contains the y value for the bubble
marker
ChartFX1.ValueEX(0,j) = 'Bubble Y Value
'Set the series that contains the bubble size
ChartFX1.ValueEX(1,j) = ' Bubble Size
Next j
ChartFX1.CloseData COD_VALUES
After setting these values the bubble chart should look like:
Bubble charts with an X Coordinate
These bubble charts will compare a set of three values with one of the values specifying the size
of the bubble marker. Basically, These bubble charts are pretty much an XY Plot, where the
bubble position is defined by two coordinates (x,y) and a third coordinate that specifies the size of
the bubble.
89
To pass data you must open an additional communications channel to specify the x coordinate
with the XValueEx property, as follows:
ChartFX1.Gallery = BUBBLE
ChartFX1.OpenDataEx COD_VALUES,2,5
ChartFX1.OpenDataEx COD_XVALUES,1,5
For j = 0 to 4
'Set series that contains the y value for the bubble marker
ChartFX1.ValueEX(0,j) = 'Bubble Y Value
'Set the x value for the bubble marker
ChartFX1.XValueEX(0,j) = 'Bubble X Value
'Set the series that contains the bubble size
ChartFX1.ValueEX(1,j) = ' Bubble Size
Next j
ChartFX1.CloseData COD_VALUES
ChartFX1.CloseData COD_XVALUES
For these type of charts the bubble is not restricted to a specific x coordinate but can be painted
anywhere in the x-axis (numerical axis) as described in the XY Plot chapter before.
The Volume Property effect
When creating bubble charts, you must be aware that the Volume Property has a specific effect in
the way bubble charts are displayed as the Size will be divided by the setting in the volume
property.
For example, if the volume property is set to 50. It means that Chart FX will force the marker to
occupy 1/2 of the space allotted. When you set the bubble size to a 100, you would expect the
bubble to occupy the entire space allotted, however in this case the bubble will only occupy 1/2 of
the space allotted. Similarly, if the Volume is set to 50 and the bubble size is 50, the bubble will
occupy 1/4 of the space allotted.
Fancy Bubble Charts
If you're creating 3D bubble charts you can set the CylSides property to achieve a fancy lighting
effect on the bubbles as shown in the following figure:
90
Chart FX Programmer’s Guide
Constant Lines & Color Stripes
Topics covered in this section
Constant Lines Sample
Color Stripes Sample
91
Constant lines Sample
Constant lines are one of the most useful objects when it comes to highlighting information in the
chart area. You may want to create a constant line to highlight limits or specific points of interest
in the chart. For example, in a scientific application, you may want to use the constant line object
to highlight an alarm limit, or in a financial application you may want to use the constant line to
highlight a target price or date.
Constant lines are lines that you can draw anywhere in the chart area and they associate
themselves with a particular value in the axis that they're assigned to, as illustrated in the
following figure.
All Constant lines are handled by the ConstantLine object and its properties, where you can set
color, styles and the axis the constant line is associated to.
To create a constant line you don't need a whole new data series and you can also configure
labels and line styles, colors and width.
The following code creates the constant lines for the figure shown above. Please note the use of
the OpenDataEX method to indicate the amount of constant lines to be included in the chart.
ChartFX1.OpenDataEX COD_CONSTANTS,2,0
ChartFX1.ConstantLine(0).Value = 30
ChartFX1.ConstantLine(0).Color = RGB(255,0,0)
ChartFX1.ConstantLine(0).Axis = AXIS_Y
ChartFX1.ConstantLine(0).Label = "Alarm Limit 1"
ChartFX1.ConstantLine(0).LineWidth = 2
ChartFX1.ConstantLine(1).Value = 8
ChartFX1.ConstantLine(1).Color = RGB(0,255,0)
ChartFX1.ConstantLine(1).Axis = AXIS_X
ChartFX1.ConstantLine(1).Label = "Limit 2"
ChartFX1.ConstantLine(1).LineWidth = 3
ChartFX1.CloseData COD_CONSTANTS
93
Stripes Sample
Stripes are one of the most useful objects when it comes to highlighting information in the chart
area. They allow you to highlight a range of values associated with any of the axis by drawing a
color frame in the chart background.
Stripes allow the user to easily pinpoint data that falls within a range of values associated with
any of the axes. For example, in a scientific application you may want the user to recognize
points that plot between 50 and 80 with a stripe object as depicted in the following figure:
The Stripe Object and its properties handle color stripes, where you can set color, range and the
axis the stripe is associated to.
If you want to highlight a specific value instead of a range, please refer to the Constant Lines
Sample.
The following code creates the stripes for the figure shown above. Please note the use of the
OpenDataEX method to indicate the amount of stripes to be included in the chart.
ChartFX1.OpenDataEX COD_STRIPES,2,0
ChartFX1.Stripe(0).From = 50
ChartFX1.Stripe(0).To = 80
ChartFX1.Stripe(0).Color = RGB(0,0,255)
ChartFX1.Stripe(0).Axis = AXIS_Y
ChartFX1.Stripe(1).From = 3
ChartFX1.Stripe(1).To = 5
ChartFX1.Stripe(1).Color = RGB(0,255,0)
ChartFX1.Stripe(1).Axis = AXIS_X
ChartFX1.CloseData COD_STRIPES
94
Chart FX Programmer’s Guide
Handling Files & Templates
Topics covered in this section
The Import & Export Methods
Tips & Tricks
95
Import & Export Methods
Chart FX provides two important methods (Import and Export) that enables you (or your end
users) to save chart files, images and data in a variety of formats.
There’s also another type of files in Chart FX called "Chart Templates" that allows you to save the
appearance (Colors, Chart Types and Styles, Visible Tools, etc) of the chart in a file so you can
later on apply it to other charts and save a lot of time from coding all these changes to individual
charts.
Note:
Templates save all the information that is not data related. this means, It will not save the
values, number of series or points, or any other property related to this data, such as
MultiType settings and Min, Max values in the chart axes.
The Export Method
This method is used to export the chart data and/or properties to the clipboard , to a file or a OLE
stream using different formats. It's syntax is as follows:
ChartName.Export (Format,vFile) where,
ChartName is the chart name.
Format is any of the following:
CHART_DATA: Exports data using a Tab Separated Values format (TSV)
CHART_BITMAP: Exports the chart Windows Bitmap
CHART_METAFILE: Exports the chart Windows Metafile
CHART_CFXOLEFILE: Export the chart using a OLE Compound Document format.
CHART_CFXOLETEMPLATE: Export the chart's visual attributes (without data) using a OLE
Compound Document format.
vFile
is a variant type that specifies where is the chart going to be export (Clipboard, File or Handle).
The value of vFile depends on the used format:
To export to the clipboard, vFile must be an empty string (or NULL).
To export to a file, vFile must contain the file name including the path.
To export to a file using a handle, vFile contains a file handle from a previously opened file using
the _CreateFile function, the file must be open and ready to receive the data (must be open for
WRITE and the file cursor updated, sometimes a Flush is necessary). Exporting the chart to an
open file is useful when you need to save the chart inside one of your proprietary files, in other
words, it allows you to save the chart and any other data into the same file.
The chart can also be exported to a OLE Stream, this is particularly useful if you want to save the
chart in a database.
The Import Method
97
This method is used to import a chart previously saved with the Export Method. It's syntax is as
follows:
ChartName.Import (Format,vFile) where,
ChartName is the chart name.
Format is any of the following:
CHART_CFXOLEFILE: Imports a previously saved chart using the OLE Compound Document
format.
CHART_CFXOLETEMPLATE: Imports a previously saved chart template using the OLE
Compound Document format.
vFile
is a variant type that contains the file name (including path).
Chart FX 3.0 Filters
If your application relies on previously saved chart files with Chart FX 3.0, you'll need to deploy
and register Cfx4Filters.dll. This is a special COM interface that provides backward compatibility
with Chart FX 3.0 files.
This file (Cfx4Filters.dll) is provided as part of the original ChartFX 98 installation.
This COM interface does not expose any API but it is necessary if you are required to load Chart
FX 3.0 files in an application that uses Chart FX 98.
Tips & Tricks. Chart FX Files
98
How do I control what is saved in a Chart FX 98 File?
Whether if you are saving chart files or templates, you can control what is saved on the file by
manipulating the FileMask Property.
This is a mask property that allows you to specify which visual attributes you want the chart file to
save when you invoke the Export Method. By default, this property is set to save all visual
attributes including the data (for CHART_CFXOLEFILE) and all visual attributes with no data (for
CHART_CFXOLETEMPLATE). However, if you want to save everything but the titles in the chart,
you will set this property before invoking the Export method as follows:
ChartFX1.FileMask = ChartFX1.FileMask And Not FMASK_TITLES
This property is particularly useful because it allows you to customize how chart files are saved,
this way you can build your own chart templates.
This property is a mask property. this means all settings represent a bit in the word that you need
to turn on or off according to what you want. For this purpose you’ll use the bitwise operators
(And, Or, Not, Xor) provided by your development tool.
Because it is a mask property, you must make sure you use these operators to turn on/off bits
and avoid losing previous settings to the property.
For example, if you want to turn ON the FMASK_TOOLS setting. The right way of setting this
property is
Chart1.FileMask = Chart1.FileMask Or FMASK_TOOLS
If you type the following code:
Chart1.FileMask = FMASK_TOOLS (WRONG!)
You’ll erase all other settings in the property causing an erratic behavior of the library when
saving files.
The bitwise operators are used as follows:
OR turn on a bit in the property
XOR switch a bit in the property
AND NOT turn off a bit in the property
I need to place the chart in a picture control for use in another component or application,
How do I do that?
Sometimes, you'll need the chart in a picture control so other components or applications can use
them. For example, many reporting tools provide the capability of importing images from a picture
99
control and this is particularly important when your application is running and a report is being
generated. Therefore, saving the chart to a bitmap or metafile is not useful in this situation.
Placing the chart in a picture control is as easy as invoking the GetPicture method in Chart FX.
For example, if you have a Picture control named "Picture1" you can let the picture control display
the chart with the following code:
Set Picture1.Picture = ChartFX1.GetPicture(CHART_METAFILE)
The results is depicted in the following figure:
100
Chart FX Programmer’s Guide
Capturing Mouse Events
Topics covered in this section
Marker Dragging
Menus on Demand
Customizing Tooltips and Balloons
Tracking the mouse
101
Capturing Mouse Events.
Chart FX 98 provides different properties, methods and events that allow you to control how the
chart reacts to mouse interactions from the user. For example, You can customize the way
tooltips are displayed, if the user is capable of dragging markers thus changing the value for a
particular point or you can add your own code when the user right clicks on a chart title. You can
even simulate mouse clicks at a particular location in the chart to see if the user is positioned over
a particular element in it.
Let's start by introducing the properties provided by Chart FX 98 that will affect how the chart
reacts to mouse interaction.
Marker Dragging
By default, a Chart FX chart is created with the AllowDrag property set to TRUE. This allows the
end user to change the value for a particular marker by positioning the mouse over a particular
data point and dragging the marker to a desired value. Although this is a cool feature it is not
useful if you don't want the user to change the values in the chart. To prevent the user from doing
this, you may set the AllowDrag Property to FALSE as follows:
ChartFX1.AllowDrag = FALSE
Menus on Demand
Another property somehow related to mouse interaction in the chart is called MenusOnDemand.
Whenever the user right-clicks a particular element in the Chart a pull-down menu will appear
with options to customize that particular element. For example, if a user right clicks on the Y Axis,
a menu will appear and the user will be able to access all axis properties. Menus on demand can
be disabled by setting the MenusOnDemand property to FALSE, as follows:
ChartFX1.MenusOnDemand = FALSE
Note:
If you want to customize certain options "inside" each menu that appears when the user
right-clicks a particular element in the chart. Please refer to the "Customizing Tools"
chapter
Customizing DataTips
By default, when the user positions the mouse over an element in the chart (Not the Toolbar) a
tooltip will appear with specifics about the element. Particularly important are data points that
display information such as the series legend, the point legend and value inside the tooltip. This
behavior can be easily changed with the TipMask property, where you can specify the information
you want inside a tooltip.
For example, if in an XY Plot you want to modify the text displayed in the tooltip with just the X &
Y Coordinates of the point, you can set the TipMask property with the variables you want to
display in the tooltip as follows:
ChartFX1.TipMask = %x%v
103
This property can also be combined with custom text to provide a clearer message to the user.
For example if you want the tooltip to display: "Hello I'm Point: 1 and my value is 13.5", you can
set the TipMask property as follows:
ChartFX1.TipMask = "I'm point: "+"%l "+" my value is: "+"%v"
Although the TipMask property is the simplest way to customize data tips, the GetTip event is
provided so you can add context sensitive information to particular data points in the chart. For
example, you want a particular data tip to show a specific text different than other points. When
processing the GetTip event you may detect which data tip is about to be displayed and change
the message for that particular point only.
Customizing the Balloon Text
Some developers prefer the balloon instead of the tooltip when the user double-clicks a particular
data point in the chart. If you want you can intercept the LButtonDblClk event and alter the text
display on this balloon. Or you may want to choose to drill-down route your application to another
module or show another chart with more in-depth information about that point. In this case we will
show you how to change the text displayed on the balloon.
Caution: The following code must be placed in the LButtonDblClk Event
' Capturing default text
sDef = ChartFX1.HText
' Modify default text
sFinal = "Hello Im point No: " + sDef
' Setting the text to be displayed
ChartFX1.HText = sFinal
You may actually check the Nseries and nPoints Parameter to check on what marker the user
double-clicked. These two parameters will contain -1 if the user did not click on a marker (i.e.
chart background). For example if you want to change the balloon text only when the user clicked
on the first series, you may changed the code shown above as follows:
if (nSeries=0)
' Capturing default text
sDef = ChartFX1.HText
' Modify default text
sFinal = "Hello Im point No: " + sDef
' Setting the text to be displayed
ChartFX1.HText = sFinal
End If
Other mouse related events
Just as the LButtonDblClk event, Chart FX 98 provides several mouse events that allow you to
customize how the chart reacts to mouse interaction coming from the user, they are:
LButtonDown, lButtonUp, RButtonDown, RbuttonUp, RButtonDblClk. You may process these
events to add specific functionality in your application.
Tracking the Mouse
104
Sometimes you may need to track mouse movements in the chart area and detect where the
mouse pointer is positioned and at which element in the mouse is pointing. In order to achieve
mouse tracking you must first use the TypeMask property to instruct ChartFX you want to receive
mouse movements in the chart area as follows:
ChartFX1.TypeMask = ChartFX1.TypeMask Or CT_TRACKMOUSE
Once the CT_TRACKMOUSE has been included in the TypeMask property you can use the
MouseMoving event in conjunction with the HitTest method to determine where the mouse
pointer is located and to which chart element is pointing at. For example, if you add the following
code to the MouseMoving event, you can check for the return value on the HitTest method and
easily determine the chart element the mouse in pointing at:
Private Sub ChartFX1_MouseMoving(ByVal X As Integer, ByVal Y As
Integer, nRes As Integer)
Dim nHit As CfxHitTest
nHit = ChartFX1.HitTest(X, Y, nSeries, nPoint)
' Please refer to the HitTest method for more information on
return values
End Sub
105
Chart FX Programmer’s Guide
Printing Charts
Topics covered in this section
Printing the chart
Controlling Paper Orientation
B&W or Color printing
Tips & Tricks
107
Printing Charts. Overview
Among the different objects exposed by the Chart FX 98 API is the Printer object. This object
allows you to set printer attributes before actually printing charts from the Chart FX ToolBar or
from code. You can control print out margins, resolution and other important chart aspects such
as colors and paper orientation.
Printing the chart
Before describing all the properties supported by the Printer Object you must know how to print
the charts. Normally, you would expect the user to print the chart using the toolbar button.
However, if you want to print charts directly from your code you can do it with the PrintIt method
as follows:
ChartFX1.PrintIt 0,0
This method will print out to the default printer unless the hDC property in the printer object has
been changed with other installed printers.
Controlling Paper Orientation
The Orientation property allows you to set the paper orientation and you can set either Portrait or
Landscape mode as follows:
ChartFX1.Printer.Orientation = ORIENTATION_LANDSCAPE , or
ChartFX1.Printer.Orientation = ORIENTATION_PORTRAIT
Note: All Printer object properties must be properly set before invoking the PrintIt method.
Color or B&W printing?
By default, Chart FX will detect if the default printer is a color printer. If it is the chart will print in
color, if not; Chart FX will print the chart in B&W hatched patterns. The property that controls this
behavior is ForceColors.
The default setting of this property is FALSE. This means, Chart FX will automatically print
hatched B&W patterns when the printer does not support colors, this will improve the chart's
readability when printed.
This behavior is particularly useful, as you don't need to preset specific patterns to the series if
the target printer is a B&W printer. Chart FX will automatically print in colors if the target printer is
a color printer.
When this property is set to TRUE and the target printer is a B&W printer, the printer driver will
match the chart colors to a specific grayscale pattern (not hatched). In some cases, the results
are not desirable and will make the chart print out impossible to read.
109
Tips & Tricks Printing Charts
Important Note: ChartFX 98 provides a specific printing sample that will show you different
techniques when printing charts. Please refer to the /Samples directory of your Chart FX
98 installation directory.
Can I print 2 or more charts in the same page?
The Paint method is commonly used when you want to print more than one chart in a page or
when you are working with a third party tool (e.g. Reporting Tool) that provides a Device Context
in which to place the charts.
The following sample prints two charts in one page:
Sub PrintFillingPage ()
Dim l, r, t, b As Integer 'left,right,top and bottom
Printer.Print ""
px = Printer.TwipsPerPixelX
py = Printer.TwipsPerPixelY
w = Printer.Width
h = Printer.Height
gap = 100 / px
t = gap
b = ((h / 2) / py) - gap
l = gap
r = (w / px) - gap / 2
ChartFX1.Paint Printer.hDC, l, t, r, b, CPAINT_PRINT, 0
t = b
b = (h / py) - gap
ChartFX1.Paint Printer.hDC, l, t, r, b, CPAINT_PRINT, 0
Printer.EndDoc
End Sub
110
How can I make the user select printers before printing the chart ?
If you want the end user to be able to use printers other than the default printers, you can use the
PrinterDriver property or create an hDC with another printer information and use the hDC
Property exposed by the Printer object. Both techniques are illustrated in the following lines of
code:
1) Using the PrinterDriver Property:
ChartFX1.Printer.PrinterDriver= "HP LaserJet
IIISi,HPPCL5MS,LPT1:"
In Visual Basic, you can reference the Printer object to obtain valid settings for this
property. The DeviceName, DriverName and Port properties of the Printer object in VB
allows you to set a valid setting for this property and at the same time selecting a different
printer settings (that you may have setup using VB) to print the chart, as follows:
ChartFX1.Printer.PrinterDriver =
Printer.DeviceName+","+Printer.DriverName+","+Printer.Port (VB
only).
To go back and print to the windows default printer you must set this property to NULL (or
"") and make sure the hDC property is also set to NULL
2) Using the hDC Property
If you want, you can drop a CommonDialog object in your form and use the hDC property
of the CommonDialog object as follows:
ChartFX1.Printer.hDC = CommonDialog1.hDC
To go back and print to the windows default printer you must set this property to NULL
and make sure the PrinterDriver property is also set to NULL.
Excerpt from the VB 5 Documentation:
"The Windows operating environment manages the system display by assigning a device
context for the Printer object. You can use the hDC property to refer to the handle for an
object's device context. This provides a value to pass to Windows API calls.
With a CommonDialog control, this property returns a device context for the printer
selected in the Print dialog box when the cdlReturnDC flag is set or an information
context when the cdlReturnIC flag is set.
Note The value of the hDC property can change while a program is running, so don't
store the value in a variable; instead, use the hDC property each time you need it."
Although Chart FX provides a command to show the Print dialog before printing the
charts (See Toolbar and Commands), this property is very useful when your application
pre-sets specific printer settings (using the VB Printer object) that you want all
components in your application to follow, so the end user does not have to select and
change the default windows printer every time a different component is printed.
Also, when you use the Chart FX Print dialog to setup specific printer changes, this dialog
displays settings stored in the Windows default printer setting (Not the VB Printer object)
so changes that you have made to the Printer object in VB will not be reflected when you
show the Chart FX Print dialog.
111
Chart FX Programmer’s Guide
Customizing the Chart FX Tools
Topics covered in this section
Introduction
Customizing the Chart FX Toolbar
The Data Editor
The PaletteBar
The PatternBar
The LegendBox
113
Chart FX 98 Tools
Chart FX 98 tools are overlapped windows containing commands or information relating the chart
being displayed. They are illustrated in the following figure:
These tools give end users the ability to interact with the chart more efficiently and access
features without any additional programming efforts on your part. You, as a programmer, may
restrict access or customize these tools as you please.
In this section you'll learn how to customize the Chart FX 98 tools and specifically the Chart FX
98 Toolbar.
115
The ToolBar & Menubar. Overview
One of the most useful tools in Chart FX is the toolbar, many programmers appreciate it because
they don't need to add additional lines of code in their applications to give end users more
freedom to customize the chart.
Sometimes, customizing the toolbar becomes imperative as you don't want end users to access a
particular feature in it or you want to extend the original functionality provided by it, or you simply
want to change the tooltips the Toolbar buttons display. As a matter of fact there could be
thousands of reasons why you want to modify the original Toolbar displayed by Chart FX.
In Chart FX 98, there is not just one way to access a command available in the toolbar. For
example, to change the chart type, the end user may select the Gallery button in the Toolbar,
MenuBar or right-clicking the marker and changing the gallery type, as depicted in the following
figure:
This introduces an additional level of complexity as customizing the toolbar means customizing
other tools that may display the same command as well. For example, if you don't want end users
to select an AREA chart, you may end up changing the Toolbar, the MenuBar, the right-click
menu, or any other tool where the AREA button may appear.
For this reason, Chart FX 98 introduces the Commands object, which contains all commands
available in Chart FX and their definitions (picture, text, etc...) that all tools use to create and
display the user interface in Chart FX 98.
Another important object supported by the Chart FX 98 API is the ToolbarObj object that allows
a programmer to control toolbar positioning and removing or adding commands to the Chart FX
Toolbar.
116
The following topics are covered in this section:
•
What is the relationship between Commands and the ToolBarObj objects?
•
Showing/hiding the Toolbar
•
Positioning the Toolbar
•
Removing or hiding Toolbar buttons
•
Changing the command for a button
•
Adding Toolbar Buttons
•
Changing the ToolTips
•
Changing Toolbar Icons
•
Working with SubCommand Lists
•
Working with Selectors
•
Adding Custom (User) Commands
•
Creating your own Toolbars
Relation between Commands & ToolbarObj objects
When customizing the Toolbar, it's really important that you understand the relationship between
the ToolbarObj and Commands objects.
When it comes to changing general settings in the Toolbar, like position and visibility. The
117
ToolbarObj object exposes general properties that you can use to change these general visual
attributes of the toolbar.
On the other hand, if you want to customize items (buttons) in the Toolbar many of the features
you may want to change (ToolTips, Picture, etc) are part of the Commands object as some of
these will also be used in other tools in the Chart FX user interface. The role of the ToolbarObj
object and its properties when it comes to items in the toolbar, is just controlling the position,
order and visibility of the buttons.
In the following figure, you'll see that for a particular button in the toolbar the Commands object
and not the ToolbarObj object control many of the important visible attributes like text, picture
(icon), and style.
For this reason, in this section you'll see how we use the Command object and its properties
extensively.
118
Showing/Hiding the Toolbar
The ToolbarObj object exposes and property called "Visible" that allows you to show/hide the
Toolbar according to a boolean setting, as follows:
ChartFX1.ToolBarObj.Visible = True 'Shows the Toolbar
ChartFX1.ToolBarObj.Visible = False 'Hides the Toolbar
Please note that you can also use the Properties list and select the True or False setting at
design time.
Positioning the Toolbar
The ToolbarObj object exposes several properties that allow you to position the toolbar in the
chart's bounding rectangle. By default, the default position of the Toolbar is docked to the top
margin. However, by using the Docked property you can position the Toolbar anywhere in the
chart.
For example, if you want to dock the ToolBar to the right margin programmatically, you can use
the Docked property as follows:
ChartFX1.ToolBarObj.Docked = TGFP_RIGHT
The Toolbar can also be positioned as a floating overlapped window that the user can move
around the desktop. This is particularly useful as it increases the charting area, but sometimes
confuses the end user so it must be used carefully. To convert the Toolbar to a floating tool
programmatically, the Docked property must be set as follows:
ChartFX1.ToolBarObj.Docked = TGFP_FLOAT
Once you have the toolbar as floating window you can use the Left and Top properties to position
the toolbar anywhere inside the chart area. Please be aware that, although a floating toolbar can
be moved anywhere in the desktop, these properties receive a setting in chart coordinates, so the
(0,0) coordinate is in respect to the chart area.
For example, to position a floating toolbar in the 15,30 coordinate, you can set the Left and Top
properties as follows:
ChartFX1.ToolBarObj.Left = 15
ChartFX1.ToolBarObj.Top = 30
119
Removing or hiding buttons in the Toolbar
You may want to remove buttons in the Toolbar or hide them as a result of a specific condition in
your application. For example, for one particular chart, you don't want the end user to switch
between 2d/3d modes and therefore you may want to hide those buttons. Or if you don't want to
allow users to save/open chart files you may want to remove those buttons from the Chart FX
default toolbar.
Removing buttons
To remove items in the Toolbar, the RemoveItems method is provided so you can remove one or
more buttons in the Toolbar. When using this method, please be aware that those buttons will no
longer exists in the toolbar and all the indexes will be recalculated by Chart FX. For example, if
you remove the first button in the toolbar with the RemoveItems method, the index of the second
button will become index 0, the index of the third button will become index 1, etc. To remove the
first two buttons in the Toolbar, you may call the RemoveItems method as follows:
ChartFX1.ToolBarObj.RemoveItems 2,0
The RemoveItems method receives 2 parameters, the first parameter specifies the number of
buttons to remove and the second parameter receives the position from where to start removing
items.
Also, be aware that separators count as additional toolbar items, so if you plan to remove several
buttons and they are separated, you must count separators when calling the RemoveItems
method.
Hiding Buttons
Hiding items in the toolbar means accessing the Visible property provided by the Toolbar Item
object. When you hide buttons in the toolbar, all indexes will be maintained, as the button will still
exists in the toolbar. Normally, hiding buttons is useful if you want to prevent the user from
accessing that functionality as a result of a certain condition in your application. For example, for
a particular chart, you don't want the end user to switch from 2D/3D mode, therefore, you may
want to hide the 3D button in the toolbar as follows:
ChartFX1.ToolBarObj(8).Visible = FALSE
Please note that the index of the button is provided without referencing the Item property. this can
be done, because the default property in the ToolBarObj object is the Item Property. This means,
that the result from executing the following code will be exactly the same:
ChartFX1.ToolBarObj.Item(8) = FALSE
120
Changing the command for a toolbar button
Chart FX exposes a wide variety of pre-defined commands that you can use to overwrite the
functionality of buttons in the toolbar or to add new buttons to the toolbar that perform such
actions.
You can also assign a Custom Command to a toolbar button that you can process internally in
your application.
In this topic, we'll show you how to change the command assigned to any of the toolbar buttons
with a pre-defined Chart FX command. If you want to assign a custom command to a toolbar
button, please refer to "Adding Custom Commands" later in this chapter.
The CommandID property allows you to easily overwrite the default action performed by a toolbar
button with any of the pre-defined Chart FX commands. For example, the Print button in the Chart
FX toolbar allows the end user to print the chart. This button does not prompt the user for a dialog
where they can enter margins and other important print settings. Chart FX, however, provides a
pre-defined command that allows the user to specify these and other print settings.
In this sample we'll show you how to change the default behavior of the Print button so the user
can enter print settings before actually printing the chart.
The first thing you need to do is determine the index of the print button by counting from 0 to the
button you want to change (including separators in the count). By doing this we can see that the
Print button is index 21 in the Chart FX Toolbar.
Next, we must locate the appropriate Chart FX command in the Chart FX pre-defined Commands
list, by doing this we know that the CFX_ID_PAGESETUP is the one that allows the end user to
enter print settings.
Finally, we can use the CommandID property to change the command assigned to that button as
follows:
ChartFX1.ToolBarObj(21).CommandID = CFX_ID_PAGESETUP
121
Adding buttons in the Toolbar
Sometimes, you may want to add additional buttons in the Toolbar. For this, the ToolBarObj
exposes a method called AddItems, that allows you to add additional buttons to the toolbar that
access existing Chart FX Commands or any custom command you may want to add to the Chart
FX Toolbar.
In this section you will learn how to add buttons in the toolbar that access a pre-defined command
in Chart FX. If you want to add custom commands to the Chart FX Toolbar, please refer to the
"Adding Custom Commands", later in this chapter.
Chart FX exposes a wide variety of pre-defined commands that you can use to overwrite the
functionality of buttons in the toolbar or to add new buttons to the toolbar that perform such
actions.
When adding buttons to the Toolbar, please be aware that the Chart FX toolbar can handle up to
32-items (including buttons and separators) so when adding buttons in the toolbar please be
careful not to exceed such limit.
Let's suppose you have a chart where you don't want end users to switch among the vast array of
chart types available in Chart FX. Instead, you want them to access only Line, Area or Bar
Charts. To do this, you want to remove the Gallery Type from the Toolbar and add 3 additional
buttons in the toolbar with the desired chart types, as depicted in the following figure:
The first thing you need to do is get rid of the gallery selector by using the RemoveItems method,
covered in the "Removing/Hiding Toolbar items" chapter. The gallery selector is the third item in
the toolbar, so to remove it we can use the RemoveItems method as follows:
ChartFX1.ToolbarObj.RemoveItems 1,2
Now, with the Gallery selector removed from the Toolbar, we want to add 3 additional buttons in
the beginning of the toolbar with the chart types you want the user to access from the tolbar. For
this, you can use the AddItems method as follows:
ChartFX1.ToolBarObj.AddItems 0,3
Please note that when you use the AddItems method, the indexes for other buttons in the toolbar
will be recalculated appropriately. In other words, because we have added 3 buttons at the
beginning of the toolbar, the index for the button that used to be in the first position is no longer 0
but 3 and the buttons that we have added have the 0,1 and 2 index respectively.
Finally, we need to use the CommandID property to assign a pre-defined Chart FX Command to
the buttons we have added to the toolbar, as follows:
122
ChartFX1.ToolBarObj(0).CommandID = CFX_ID_LINE
ChartFX1.ToolbarObj(1).CommandID = CFX_ID_AREA
ChartFX1.ToolBarObj(0).CommandID = CFX_ID_BAR
when you run this code, the Chart FX Toolbar will look like:
Important Note:
Modifying just the Toolbar is no guarantee that the end user can only switch to those 3 chart
types. The above example, shows how to use the Additems method to add buttons to the toolbar.
If you really want to prevent the end user from switching to other chart types, you have to modify
the Commands list appropriately so those chart types may not be accessed from another tool in
the Chart FX UI. This topic will be covered in detail later in this section.
123
Changing the ToolTips
The tooltip is a text that appears when the user positions the mouse over any button in the
Toolbar. This is very helpful as it informs the end user about the functionality of the button without
actually pressing it and performs the action.
You may think this tooltip is part of the ToolBarObj. However, this text is also used in other parts
of the Chart FX UI and therefore is controlled by the Commands object. This means that when
you change the tooltip (or text) associated with a particular command, this change will be
consistent through out the Chart FX UI.
Therefore, when changing the Tooltip for a particular button in the toolbar, you must be careful
not to assign long strings to it as this text will be used and displayed somewhere else (e.g. the
Chart FX MenuBar shows this text as the menu item).
In order to show tooltips the ToolTips property in the ToolBarObj object must be enabled as
follows:
ChartFX1.ToolBarObj.ToolTips = TRUE
To change the tooltip associated with a particular command, you must first locate the command
ID in the Chart FX pre-defined commands list. For example, if we want to change the Tooltip for
the Gallery selector in the Chart FX Toolbar, we notice that the ID associated with the command
is CFX_ID_GALLERY. Once we have the ID we can use the Text property in the Commands
Object as follows:
ChartFX1.Commands(CFX_ID_GALLERY).Text = "Chart Types"
Once you have changed the text associated with a particular command, the Chart FX UI will
reflect that change in the ToolBar, The MenuBar, The Menus-On-Demand, etc.
Please remember to change the tooltips if you're localizing your application to other languages.
124
Changing Toolbar Icons
The icons used in the toolbar are also used by other Chart FX tools, therefore they are controlled
by the Commands object and when you change an icon for a particular command, that change
will be reflected in other tools that allow access to that command.
For example the Data Editor icon is used in the Toolbar as well as the Right click menu, when
you change the Icon associated with the Data Editor command, both tools will reflect that change,
as depicted in the following figure:
You can change the icon for a particular command by choosing a pre-defined icon from the
Commands picture or by adding new icons to the Commands picture. In this topic we'll show you
both techniques:
Selecting from a predefined icon
Chart FX provides a pre-define list of 16x15 icons that you can use to easily change a default
icon in the Chart FX user interface. To do this, you can use the Picture property in the Commands
object. This property receives the command id (from the pre-defined commands list) and the predefined icon index.
The pre-defined list of icons looks like:
So to change the Data Editor icon with the 10th icon in the list the code should look as follows:
ChartFX1.Commands(CFX_ID_DATAEDITOR).Picture = 9
Adding or replacing icons in the list
125
Although selecting an icon from the pre-defined list is not particularly useful (as most of them are
actually used by other Chart FX commands). You can use the AddPicture or ChangePicture
methods to add or replace icons in the pre-defined list of icons, respectively.
The AddPicture method is particularly useful when you are adding custom commands to the
Chart FX UI. This method will append one or more icons to the pre-defined icons list that you can
use to assign to existing or new commands.
The ChangePicture method is particularly useful if you want to change icons that are currently
being used by Chart FX as it will allow you to replace all or part of the existing icons list.
A very important issue is that each must have 16x15 pixels and if you are adding or replacing
several icons at the same time, you must make sure there are no separation between them.
Because, both methods (AddPicture and ChangePicture) take a Picture object, you must create a
picture object in your form and load the resource into that picture object.
AddPicture Sample
If you have loaded 2 new icons in a Picture object named Picture1 and you want to append such
icons in the icons list and use the first appended icon to change the icon associated with the
"Data Editor" command and the second appended icon to replace the icon for the "Save Chart"
command. The AddPicture icon will return the position in which the icons were appended so you
can use this as a reference when assigning the picture to the command, so your code will look as
follows:
nIndex = ChartFX1.Commands.AddPicture Picture1.Picture
ChartFX1.Commands(CFX_ID_DATAEDITOR).Picture = nIndex
ChartFX1.Commands(CFX_ID_EXPORTFILE).Picture = nIndex+1
ChangePicture Sample
If you want to replace some or all icons currently used by Chart FX you will use the
ChangePicture method which will replace one or more icons in the icons list. Please note that
Chart FX uses icons in a particular order as depicted in the following figure:
This means, if you have loaded two Picture objects, Picture1 that contains 1 16x15 icon that will
be used to replace the 2D/3D icon and Picture2 that contains 2 icons that will be used to replace
the icons used to show/hide horizontal vertical gridlines, you must invoke the ChangePicture
method twice, as follows:
ChartFX1.Commands.ChangePicture Picture1.Picture,4
ChartFX1.Commands.ChangePicture Picture2.Picture,8
Please note in the sample shown above that index 4 (zero based) corresponds to the 2D/3D
image icon and index 8 (zero based) corresponds to the Vertical Gridlines icon.
126
Working with SubCommands
Although most buttons in the Chart FX user interface (ToolBar, MenuBar, etc) perform a specific
action when pressed, there are other buttons that when pressed present a list of subcommands
where the user can choose from. For example, the Tools button in the Chart FX Toolbar present
another list that allows the user to select which tools he wants to show in the chart area, as
depicted in the following figure:
These are called sub commands lists and you can create or modify existing subcommands lists in
the Chart FX user Interface. For this purpose, the Commands object exposes the
SubCommandID property and the RemoveSubCommand and RemoveAllSubCommands
methods.
Removing existing subcommands
In the figure shown above, you can see how the CFX_ID_TOOLS command present a list of
subcommands that allow the end user to select which tools they want to show in the chart area.
Let's suppose you don't want the end user to access the Data Editor from teh Toolbar, you can
easily remove the Data Editor option from the subcommand list by invoking the
RemoveSubCommand method as follows:
ChartFX1.Commands(CFX_ID_TOOLS).RemoveSubCommand 2
Please note that when you remove a particular sub-command from the subcommand list, the
indexes will be shifted to the actual number of subcommands available in the command. For
example, when you remove the Data Editor sub command the Toolbar will be index 2, The
paletteBar will become index 3 and so forth.
By removing a subcommand from the list you will also remove this option from other tools that
may use the same command id.
Adding SubCommands to a list
To add a subcommand to a list you will use the SubCommandID property. If you are adding
subcommands to a specific command you must make sure to keep the indexes in order as nonconsecutive indexes may cause unpredictable results.
This feature is particularly useful when you are working with custom commands. So please refer
to the "Adding Custom Commands" chapter where we show a custom command that contains
several subcommands.
127
Working with Selectors
A selector is a command that contains a list of subcommands that when pressed a list of images
(icons) will be shown so the user can make a selection and when closed the selector will show
the current selection. In Chart FX, the gallery icon in the toolbar is a selector as shown in the
following figure:
Because a selector is a command with a list of subcommands, the API explained in the "Working
with SubCommands" topic also applies to selectors.
The only notable difference between selectors and regular subcommand lists is that the style for
the subcommand has been set to CBIS_SELECTOR. For more information on controlling the
style for a particular command, please refer to the Style Property in the commands object.
128
Adding Custom Commands
In previous topics you learned the API provided by the ToolbarObj and Commands objects to
add, remove or modify the Chart FX pre-defined list of commands. This was useful, as you were
able to customize the default Chart FX Toolbar, by removing existing commands, changing the
icons and other important aspects related to the Chart FX User Interface.
Chart FX 98 not only allows customization of the default toolbar with pre-defined Chart FX
commands, but it allows you to add custom commands that you can process internally in your
application.
Let's say, for example, you want to add a button in the Chart FX toolbar that when pressed loads
another chart with new data and new visual attributes. It is clear that Chart FX will not provide this
functionality as a pre-defined command because it will not know how to react when end users
actually press such button. Therefore, you'll need to add a custom command that will post an
event to your application so you can add your code.
As a matter of fact, you not only can create custom buttons but groups of buttons, lists, selectors
and even new toolbars that will look seamlessly integrated to the chart displayed in your
application. This section explains the necessary steps to add custom commands to the Chart FX
User Interface.
Adding a custom command to the toolbar means completing its attributes in the Commands
object and then use the properties and methods provided in the ToolBarObj object to physically
add (or replace) that button in the toolbar.
Please follow these steps to add a custom command to the Chart FX Toolbar:
1) Adding the Command ID to the Chart FX Commands list
The very first step to add one or more custom commands to the Chart FX UI is to add their IDs to
the Chart FX Commands list. You do this with the AddCommand method supported by the
Commands object.
The ID is an integer that you will use to identify the command when the user press or interacts
with it. This is a unique ID that will be associated to the custom command and no other custom
command may have the same ID. Chart FX defines its pre-defined IDs between CFX_ID_FIRST
(29440) and CFX_ID_LAST (29951), so please make sure you don't use a number in this range
as it will cause unpredictable results.
You can add a custom command with ID 4 as follows:
ChartFX1.Commands.AddCommand 4
2) Setting the visual attributes of the Custom Command
Once the Command ID has been added to the list, you must instruct Chart FX how to display this
command in the UI (is it a button or a list?, what icon is it going to use?, what text is it going to
display?, is it enabled?). There is a property for each particular attribute in the commands object
as follows:
Style. The Style property allows you to tell Chart FX if the command you're adding is a
two-state button,a list, a selector or that the command belongs to a group. If you don't set
129
the Style property the custom command is added as a regular button. If you want to
create a two-state button you can set the Style property as follows:
ChartFX1.Commands(4).Style = CBIS_TWOSTATE
Please note how we use the ID assigned in step 1.
Picture. The Picture property allows you to specify the icon to be used in the button.
Please note that youc an add your own buttons as described in the "Changing/Adding
icons" topic.
Text. The Text property allows you to set the tooltip to be displayed or the text if the
command is to be shown in the menubar. For example to set a new tooltip to the button
you can set the Text property as follows:
ChartFX1.Commands(4).Text = "New Command"
3) Adding the Custom Command to the Toolbar
To add the command id 4 to the Toolbar, you can use the AddItems method and the CommandID
properties exposed by the ToolBarObj object, as follows:
'Let's add a new button in the 4th position of the Toolbar
ChartFX1.ToolBarObj.AddItems 1,3
'Now let's assign the command id to added button
ChartFX1.ToolBarObj(3).CommandID = 4
4) Processing the Custom Command
Now that you have added a Custom command to the Chart FX Commands List and the button
has been added in the Toolbar you need a mechanism to add your custom code that processes
that particular command. The UserCommand Event is posted to your application when the user
clicks or interacts with the custom command you have added. So if you want to display a
message box with the ID of the custom command when the user presses the button you will
process the UserCommand event as follows:
Private Sub ChartFX1_UserCommand(ByVal wParam As Long, ByVal lParam As
Long, nRes As Integer)
MsgBox "User Command:" + CStr(wParam)
End Sub
130
Creating your own Toolbar
Although we have based this entire section on the Chart FX Toolbar (ToolBarObj object), you can
create additional toolbars that may contain Chart FX commands as well as custom commands.
This feature allows an additional level of customization as you may create for example a Toolbar
that only handles Chart FX Chart Types and another Toolbar that handles 3D effects and so forth.
To create a new toolbar you can use Visual Basic's New keyword that enables implicit creation of
an object as follows:
Dim MyTool As New ToolBar
Or you can also use the CreateObject function as follows:
Set MyTool = CreateObject("SfxBar.ToolBar")
Once you have created the new Toolbar and you have its handle in variable (in this case called
MyTool). This variable inherits all the properties available in the ToolBarObj object.
An important issue when you create a Toolbar is that this Toolbar is initialized with an empty
Commands list and no buttons. Therefore, you have two options:
1) Creating a new Toolbar with some of the Chart FX pre-defined commands
If the new toolbar will contain some of the Chart FX pre-defined commands, you can easily assign
the Chart FX Commands list to this new toolbar as follows:
MyTool.Commands = ChartFX1.Commands
Please note that when you assign the Chart FX commands list to the newly created toolbar, there
are still no buttons in the new Toolbar, you just specified that the list of commands is the same as
Chart FX.
You must then start calling the AddItems method and CommandID property to create buttons in
the newly created toolbar (MyTool), as follows:
'For example to add 3 buttons to MyTool
MyTool.AddItems 3, 0
'To assign the commands they will access
MyTool(0).CommandID = CFX_ID_GALLERY
MyTool(1).CommandID = CFX_ID_3D
'Now let's assign a custom command
MyTool(2).CommandID = 4
Please note how the MyTool object inherits the properties and methods exposed by the
ToolbarObj object, and the way to access them is without the Chart name.
131
2) Creating a Toolbar from scratch
If the new toolbar (MyTool) will contain only custom commands as explained in the "Adding
Custom Commands" section, you will use the AddComand method to create the new commands
list containing all proprietary IDs and then use the AddItems method to create toolbar items and
assign with the CommandID property the IDs of the command list you have created. For example,
if MyTool will only contain 2 buttons that perform a custom command, your code will look like:
'Create the Commands list from scratch by adding two new custom
commands
MyTool.Commands.AddCommand 10
MyTool.Commands.AddCommand 11
'Set the Commands Picture with a custom image (Refer to Adding
Pictures)
MyTool.Commands.AddPicture Picture1.Picture
'Set the icon of each custom command
MyTool.Commands(10).Picture = 0
MyTool.Commands(11).Picture = 1
'Set the text of each custom command
MyTool.Commands(10).Text = "Command 1"
MyTool.Commands(11).Text = "Command 2"
' Finally Add two new buttons in the new toolbar
MyTool.AddItems 2,0
' Assign the CommandID to the new buttons
MyTool(0).CommandID = 10
MyTool(1).CommandID = 11
Finally, you must use the AddBar method to let Chart FX know that a new toolbar exists, and use
the Visible property to show the newly created toolbar in the chart window as follows:
ChartFX1.AddBar 3,MyTool
MyTool.Visible = TRUE
Please note the AddBar method receives as first parameter a unique identifier for the Toolbar you
have added to Chart FX. This ID is used when you want to obtain the handle of the newly created
Toolbar by using the GetBar method or to remove the Toolbar by using the RemoveBar method.
This prevents the MyTool variable to be global as you only need to remember the ID of the
Toolbar and later on Obtain the handle or Remove it using the GetBar and RemoveBar methods,
respectively.
As with any Chart FX ID, the ID you use in the AddBar method must not be between
CFX_ID_FIRST (29440) and CFX_ID_LAST (29951).
132
DataEditor Object
Chart FX 98 provides a spreadsheet called "Data Editor" that allows users to see the data
contained in the chart in tabular format. It also allows the user to modify any legend or value
contained in the chart (if allowed by the programmer).
As another Chart FX 98 tool, the Data Editor also allows floating and docked styles so the end
user can control the position and different styles of the Data Editor in the chart area.
The DataEditorObj object controls the Data Editor. With this object you can control the position,
colors and other important aspects of this important tool in the chart. For example, if you want to
show the Data Editor and position it in the top portion of the chart, you can use the DataEditorObj
as follows:
ChartFX1.DataEditorObj.Docked = TGFP_TOP
ChartFX1.DataEditorObj.Visible = True
Please refer to the Chart FX API electronic help file located in the \help directory of the Chart FX
Installation directory.
133
PaletteBar Object
Chart FX 98 provides a tool called the PaletteBar that allows end users to Drag&Drop colors onto
chart elements or change the entire chart palette from a dozen of schemes provided by Chart FX
98.
As other Chart FX 98 tools, the PaletteBar can be docked to a margin or float in the chart area.
The PaletteBar object support properties that allow you to configure its position and style when
displayed in the chart area.
The PaletteBarObj object controls the Palette Bar. With this object you can control the position,
and other important aspects of this important tool in the chart. For example, if you want to show
the Palette Bar and position it in the top portion of the chart, you can use the PaletteBarObj as
follows:
ChartFX1.PaletteBarObj.Docked = TGFP_TOP
ChartFX1.PaletteBarObj.Visible = True
Please refer to the Chart FX API electronic help file located in the \help directory of the Chart FX
Installation directory.
134
PatternBar Object
Chart FX 98 provides a tool called the PatternBar that allows end users to Drag&Drop patterns
onto chart elements. Patterns can be B&W or colored depending on the Scheme property setting.
As other Chart FX 98 tools, the PatternBar can be docked to a margin or float in the chart area.
The Pattern object support properties that allow you to configure its position and style when
displayed in the chart area.
The PatternBarObj object controls the Pattern Bar. With this object you can control the position,
and other important aspects of this important tool in the chart. For example, if you want to show
the Pattern Bar and position it in the top portion of the chart, you can use the PatternBarObj as
follows:
ChartFX1.PatternBarObj.Docked = TGFP_TOP
ChartFX1.PatternBarObj.Visible = True
Please refer to the Chart FX API electronic help file located in the \help directory of the Chart FX
Installation directory.
135
LegendBox Object
The Legend box object is used to display legends associated with data points (not series) and it is
necessary to improve the chart's readability in charts like PIE, DOUGHNUT and PYRAMID where
there's no axis, but point labels are still necessary in the chart.
As with other Chart FX 98 tools, the Legend box can be docked to a margin or float in the chart
area.
If you want to show series legend in the chart area, please refer to the SerLegBox object.
The LegendBoxObj object controls the window that displays the legend values in the chart.
Normally, these labels are displayed within the axis itself. However, there are chart types that do
not display any axis and this window is very important to improve the chart’s readability. With this
object you can control the position, and other important aspects of this important tool in the chart.
For example, if you want to show the Legend Box for a Pie chart and position it in the right portion
of the chart, you can use the LegendBoxObj as follows:
ChartFX1.LegendBoxObj.Docked = TGFP_RIGHT
ChartFX1.LegendBoxObj.Visible = True
Please refer to the Chart FX API electronic help file located in the \help directory of the Chart FX
Installation directory
136
SerLegBox Object
The series legend can be displayed docked to any margin in the chart, or if you prefer, you can
have it as a floating window or fixed at a certain position inside the chart area. The SerLegBox
object provides all properties related to position and style of the Series Legend in the chart area.
In multiple series chart it is customary to add a box containing descriptions for the series
displayed in the Chart. If you have assigned series legend using the Series object or the SerLeg
property, you can control the Series Legend Box with the SerLegBoxObj object. With this object
you can control the position, and other important aspects of this important tool in the chart. For
example, if you want to show the series legend and position it in the left portion of the chart, you
can use the SerLegBoxObj as follows:
ChartFX1.SerLegBoxObj.Docked = TGFP_LEFT
ChartFX1.SerLegBoxObj.Visible = True
Please refer to the Chart FX API electronic help file located in the \help directory of the Chart FX
Installation directory
137
Chart FX Programmer’s Guide
RealTime Charts
Topics covered in this section
Overview
Passing Data in Real-Time
Scrolling Legends
139
RealTime Charts. Overview
Chart FX supports True Realtime Charting capabilities, by giving specific functions, which support
Chart scrolling in a very fast painting mode (without flickering). To prevent data overflow Chart FX
introduces Real Time Charts with an specific maximum number of points which will allow the
library to accept up to that number and after you insert or set a new value to the chart the first set
value is lost.
Chart FX supports two different Real Time Charts:
1) Limited Real Time: Which are charts that have a maximum values of points (previously
allocated buffer). This type of charts are the fastest available in Chart FX, since they allocate
memory only once (when you call MaxValues property). which means that the chart will have the
maximum setting until it begins to lose points (i.e. setting 15 as the maximum number of points
means that you will lose point 1 when passing value for point 16).
If losing previously passed points is not important we suggest you use this type of charts for Real
Time purposes when having a fast data input rate.
Two variations of this kind of chart are also available in Chart FX:
• Standard: When the buffer is full (You have reach the max value limit) and you insert new
point, the data will "scroll" so you will lose the first point and the nth point will become the nth1.
• Loop Position: Same as Standard but every time you set a new value a customizable
vertical line will pass through the point that is being changed "Last acquired point" when
reaching the end of the data set this Looping marker will move to the beginning
2) Unlimited Real Time Charts: These type of charts can add points to the existing ones without
losing any of the previous one. Also, you may choose if the chart will scroll every time it receives
a new point, so you can see the last acquired data. This is to allow you to set if the chart will
automatically scroll depending on the context of your application.
In the following pages we will cover:
How to Create and pass data to a Real Time Chart?
Setting the Real Time Style.
Customizing the Loop Marker
141
Creating and Passing data to Real Time Charts.
Note
A sample project of a Realtime chart have been
included in you Chart FX samples directory (realtime
sub-directory)
To create a Real Time Chart you must follow these steps:
•
Set the CT_EVENSPACING to the chart type using the Type property (either at design or
running time).
•
Set the MaxValues property to an specific number of points if you want to create a Limited
RealTime chart (strongly suggested!).
•
call the RealTimeStyle property to select the Real Time Style you want (Basically showing or
not the Loop marker and hiding the hourglass cursor).
•
Open the communication channel (OpenDataEx Method) to the RealTime Chart using the
COD_ADDPOINTS combined with COD_VALUES. This will cause the pointers to the data
array be relative to the last point added previously, so you don't have to remember neither the
number of points the chart currently has nor the index of the last point passed.
•
Set the corresponding value of the new points using an offset instead of an absolute index to
the points. These means that if you want to add two (2) new points to the chart (before the
CloseData method) you must use index 0 and 1 for the point index in the Value Property.
•
Call the CloseData method with a combination of COD_VALUES with any of the following
constants:
COD_REALTIME
COD_REALTIMESCROLL
Chart FX will not scroll to the end of the data set.
Chart FX will scroll the chart to the end of the data set.
The following sample supposes that you have a timer that calls our application with two new
values every second, so the idea is to include these points in a chart in RealTime mode:
‘Preparing the chart to be RealTime
Chart1.Type = Chart1.Type Or CT_EVENSPACING
‘Setting a buffer size of 50 points
Chart1.MaxValues = 50
‘Add a Loop marker and hiding the hourglass cursor
Chart1.RealTimeStyle = CRT_LOOPPOS Or CRT_NOWAITARROW
...
‘Finally when the timer calls set the new data
Chart1.OpenDataEx COD_VALUES Or COD_ADDPOINTS,1,2
‘Set two new points of series 1
Chart1.Value(0) = Rnd * 100
Chart1.Value(1) = Rnd * 100
‘Close the channel forcing scroll
Chart1.CloseData COD_VALUES Or COD_REALTIMESCROLL
142
Setting the Real Time Style
The RealTime style refers to how the chart is going to be display in your application. Basically the
two different settings available to this feature are showing the Loop Marker and hiding the
hourglass cursor from the RealTime Chart.
The property related in the VBX model is RealTimeStyle. This property is used to get/set the
RealTime style of the chart.
Setting can be a combination of:
CRT_LOOPPOS
Show Loop Marker
CRT_NOWAITARROW
Hide HourGlass cursor
For example, To set both styles:
Chart1.RealTimeStyle = CRT_LOOPPOS Or CRT_NOWAITARROW
Customizing the Loop Marker
The Loop Marker can be customized using the “ItemColor”, “ItemWidth” and “ItemStyle”
properties using the CI_LOOPPOS index.
143
Scrolling the X axis legends in RealTime mode.
If you’re working with a Realtime chart and also assigning legends to the points in the X axis, it is
imperative that you scroll these legends in order to have your Realtime charts the appropriate
legends every time it receives new data.
Note
In the samples subdirectory you will find a Realtime
sample that scroll the legends every time the chart
receives new information.
In order to scroll the x axis legends in the DLL model you must follow these rules:
•
Include in “TypeEX” property the CTE_NOLEGINVALIDATE constant.
•
Open the communication channel (OpenDataEx method) in combination with the
COD_ADDPOINTS constant (you must always do this when working with RealTime charts).
•
Set the value for the new point using the relative position in the Value property and have
ready the legend that you want to assign to that new point.
•
If you’re setting a BufferSize (Limited RealTime charts) with the MaxValues property you will
need to erase the first legend every time you receive a new point and the chart already
completed its first cycle reaching the Max values limit.To erase the first legend you use the
Legend property and set chr(1) to the Index 0.
•
After erasing the first legend you can set the new legend (also with the Legend property)
including in the Index the MaxValue-1*** (for a 50 point buffersize you will set point legend
no. 49, remember that all indexes in Chart FX are zero based), and the setting containing
such legend.
•
Finally, in the CloseData Method include the COD_SCROLLLEGENDS constant to force
Chart FX to scroll the legends.
•
Note: scrolling legends does not apply when having the Loop marker on in your RealTime
chart.
Note
If you are not working with a buffersize assigned to your
realtime chart (Max Values assigned) you must use the
actual number of points in order to set the last point
legend.. You can read the nValues property and set the
legend using the nValues-1 index instead of the
MaxValues-1 index
144
Chart FX Programmer’s Guide
Open Painting Architecture
Topics covered in this section
Customizing Chart Painting. Overview
CPI Constants
PrePaint sample
PaintMarker Sample
145
Customizing Chart Painting
Note
In order to customize the chart painting you must be familiarized
with the different objects in the Windows API (such as: pen and
brushes). Therefore, if you’re a novice windows developer or
you’re not familiarized in handling these objects in the Windows
environment we suggest you refer to the Windows 32 SDK.
When customizing the chart paint process you, as a programmer, are able to capture three
different events (notification messages) and different methods and properties that will allow you to
place any object in the chart window (whether it is in the chart background or on top of the chart).
These objects can be fonts, rectangles, circles, arrows, bitmaps and even proprietary objects that
you had created and know how to handle them appropriately (painting procedure) in any device
context.
With this open architecture Chart FX provides virtually any kind of customization that you will
need in your applications.
Due to this fact, in this section we will describe the process of customizing the chart painting with
specific samples. Nevertheless, depending on your application you may want to use them
differently.
You will receive three different notification messages as explained in the following diagram:
PrePaint event:
This event is sent before the
chart is painted. Therefore, it
is very useful for customizing
the chart background. If you
want place a gradient
background or want to place a
special picture or bitmap in the
background chart this is the
place to do it. Although the
chart is not yet painted all the
calculations for the markers
and axis of the chart are
available (CPI_*). please refer
to following pages.
PaintMarker event:
This event is sent every time a
marker is being painted. This
event is very useful when you
want to highlight certain
information in your chart. You
will be able to place any object
you want highlighting the
marker that is being painted.
Also in this event all the
calculations for the markers
and axis of the chart are
available (CPI_*). Please refer
to the following pages for more
information.
PostPaint event:
After the chart finishes
painting another event is
posted for further
customization. This event is
very useful when you want to
make final touches to the
chart, like adding arrows,
placing other fonts and
general make-up to the final
chart. Also in this event all
calculations for the markers
and axis (CPI_*) are still
available. Please refer to
following pages for more
information.
147
Obtaining pertinent information when customizing chart
painting.
When placing your objects you may want to know the location of the different items that are to be
painted in the chart. For example, in order to highlight the point 4 in the chart you must know
where this point is (coordinates) in order to be able to enclose it in a rectangle. The PaintInfo
method with the appropriate CPI_* constant is used for this purpose.
CPI Constants.CPI_GETDC:
Description:
lSetting:
Return Value:
Get the Device Context of the chart so you can paint anything on it.
Important: If you are calling this info and you are not within paint events
(PrePaint, PostPaint, PaintMarker) you must call the CPI_RELEASEDC
when you finish using it
Read-Only
Device context (HDC)
CPI_ RELEASEDC:
Description:
lSetting:
Return Value:
Release the chart device context.
hDC returned in the CPI_GETDC
Write-Only
CPI_MARKERTOPIXEL:
Description:
lSetting:
obtain
Return Value:
Transform the correspondent nSerie-nPoint to coordinates relative to the
chart window.
LOWORD = nSerieHIWORD = nPointSetting nSerie to -1 will
center of that marker.
LOWORD = XHIWORD =Y
CPI_POSITION
Description:
lSetting:
Return Value:
Retrieves the upper-left corner of the chart.
Read-Only
LOWORD = left HIWORD = topThis values are ZERO if the chart is
being painted in the screen in a standard paint event.
CPI_DIMENSION
Description:
lSetting:
Return Value:
Retrieves the Width and Height of the chart (In pixels)
NONE
LOWORD = Width HIWORD = Height
148
CPI_PRINTINFO
Description:
lSetting:
Return Value:
This code is used when you want to know if the chart is being printed or
you want to convert a value to printer resolution.
NONE if you only want to know if the chart is being printed or a pixel
value to be converted to printer coordinates.
LOWORD=Page being printed, 0 = not being
printed. HIWORD=Converted value in printer coordinates
CPI_SCROLLINFO
Description:
lSetting:
Return Value:
Retrieve the actual position of the scroll and the number of points per
scroll page
Axis Index
LOWORD=Actual Pos.HIWORD=Maximum.
CPI_3DINFO
Description:
lSetting:
Return Value:
Retrieve the depth of each marker and total depth of the chart (Z axis
dimension).
Read-Only
LOWORD = Marker DepthHIWORD = Total chart depth (Z axis)
CPI_3DTO2D
Description:
lSetting:
Return Value:
Convert a coordinate from 3D to 2D.
Pointer to a CHART_P3D structure
LOWORD = 2D X-Coordinate HIWORD = 2D Y-Coodinate
149
PrePaint Event Sample
The following code places a gradient background underneath the chart by processing the
PrePaint event and using the Windows API to draw the background:
Note
The following code must be placed in the PrePaint
event. You can find a sample project containing this
code in the samples subdirectory.
' Draw gradient background
hDeviceC = ChartFX1.PaintInfo(CPI_GETDC)
' get the chart position (useful when printing or using chart_paint)
lPos& = ChartFX1.PaintInfo(CPI_POSITION)
x = CHART_LOWORD(lPos&)
y = CHART_HIWORD(lPos&)
hOldPen% = SelectObject(hDeviceC, GetStockObject(NULL_PEN))
nHeight% = (h / 20) + 1
nWidth% = (w / 20) + 1
h = h + y
w = w + x
For i = 0 To 9
l& = RGB(255 - (i * 20), 255 - (i * 20), 100)
hBrush% = CreateSolidBrush(l&)
hOldBrush% = SelectObject(hDeviceC, hBrush%)
l& = Rectangle(hDeviceC, x + nWidth% * i, y + nHeight% * i, w (nWidth% * i) + 1, h - (nHeight% * i) + 1)
hOldBrush% = SelectObject(hDeviceC, hOldBrush%)
hBrush% = DeleteObject(hBrush%)
Next i
hOldPen% = SelectObject(hDeviceC, hOldPen%)
ChartFX1.PaintInfo CPI_RELEASEDC, hDeviceC
150
PaintMarker Event Sample
The following code detects which points in the chart are greater than 50 and then encloses in a
rectangles such points:
As we mentioned, this event is very useful when you want to highlight or make-up different
markers (points, bars, etc.) in the chart. This event is sent every time a marker is going to be
painted, so you can retrieve important information (such as in what position the marker is being
painted) to customize the different markers in the chart.
Note
The following code must be placed in the PaintMarker
event. You can find a sample project containing this
code in the samples subdirectory.
ChartFX1.ThisSerie = nSerie
f# = ChartFX1.Value(nPoint)
If f# > 50 Then
nRadio% = 3 * ChartFX1.MarkerSize
l& = nRadio%
l& = ChartFX1.PaintInfo(CPI_PRINTINFO, l&)
If l& Then
nRadio% = CHART_HIWORD(l&)
End If
hDeviceC = ChartFX1.PaintInfo(CPI_GETDC)
hOldBrush% = SelectObject(hDeviceC, GetStockObject(NULL_BRUSH))
i = Rectangle(hDeviceC, x - nRadio%, y - nRadio%, x + nRadio%, y
+ nRadio%)
hOldBrush% = SelectObject(hDeviceC, hOldBrush%)
ChartFX1.PaintInfo CPI_RELEASEDC, hDeviceC
End If
151
Chart FX Programmer’s Guide
Chart FX UI Cross Reference
Topics covered in this section
General Dialog
Series Dialog
Axis Dialog
Axis Scale Dialog
Axis Labels Dialog
Axis Gridlines Dialog
3D Effects Dialog
Constants & Stripes Dialog
Data/Behavior Dialog
Commands Dialog
Extensions Dialog
153
General Dialog
This dialog allows you to set general settings in the chart, like 3D Stacked styles, Major Unit
Gridlines and Colors for the chart.
1) This option allows the user to switch from 2D/3D views. You can do this programmatically:
ChartFX1.Chart3D = True / False
2) When displaying a clustered chart, each series will have its own position in the z axis. This
means, if you have a 3 series chart and this property is turned on, each data series will occupy
one row of data and there will be 3 rows (z-axis clusters) in the chart. You can do this
programmatically:
ChartFX1.Cluster = True / False
3) This option allows the user to stack all series in the chart. You can do this programmatically:
ChartFX1.Stacked = True / False
Note: You can also stack series by pairs with the Stacked property provided by the Series object
4) This option allows the user to change the axis drawing style. You can do this
programmatically:
ChartFX1.AxesStyle = CAS_MATH (other settings are available)
155
5) This option allows the user to draw vertical and/or horizontal gridlines. You can do this
programmatically:
ChartFX1.Grid = CHART_HORZGRID Or CHART_VERTGRID
Note: the Axis Object provides More properties related to grids
6) This option allows the user to change the entire chart palette. This will affect all elements in
the chart. You can do this programmatically:
ChartFX1.Palette = “Dark Pastels”
Note: The Chart FX 98 palettes are deployed as a registry entry on the client machine, so if you
use this property in your application, you must make sure the palettes are properly deployed and
registered in the client machine. For more information please refer to "Deployment Issues" topic
7) This option allows the user to change the color scheme for markers. You can do this
programmatically:
ChartFX1.Scheme = CHART_CSPATTERN
Note: This option allows the user to change from solid to hatched patterns. B&W is also
supported.
8) This option allows the user to set a color for the chart box. This is the background where the
markers are enclosed. You can do this programmatically:
ChartFX1.RGB2dBk = RGB(255,0,255) ‘ For 2D Charts
ChartFX1.RGB3DBk = RGB(255,0,0) ‘ For 3D Charts
9) This option allows the user to set a color for the background. This background is the box
where the chart is enclosed. You can do this programmatically:
ChartFX1.RGBBk = RGB(255,0,255)
Note: You can also assign a Background picture using the BkPicture Property.
10) This option allows the user to set a Top Title for the chart. You can do this programmatically:
ChartFX1.Title(CHART_TOPTIT) = “My Top Title”
156
Series Dialog (<<All Series>> is selected)
This dialog allows you to set specific settings, including visual attributes for series in the chart.
When the <<All series>> is selected in the ComboBox. Settings will apply to all series in the chart
and the property set is different if a specific series is selected. Therefore, we are including 2
different screen shots for this particular dialog.
1) This option allows the user to change colors for series. You can do this programmatically:
ChartFX1.Color = RGB(255,0,255)
Note: You must use the OpenDataEX and CloseData methods.
2) This option allows the user to show borders for series. You can do this programmatically:
ChartFX1.Border = True/False
3) This option allows the user to change the border color. You can do this programmatically:
ChartFX1.BorderColor = RGB(255,0,255)
4) This option allows the user to change the border LineStyle. You can do this programmatically:
ChartFX1.LineStyle = CHART_DASH
157
5) This option allows the user to change the border line width. You can do this programmatically:
ChartFX1.LineWidth = 3
Note: In Windows 95/98, the LineWidth may not be combined with a line style different than solid.
6) This option allows the user to change the chart type. You can do this programmatically:
ChartFX1.Gallery = AREA
7) This option allows the user to change the space allotted for each marker. You can do this
programmatically:
ChartFX1.Volume = 50
) This option allows the user to change the marker shape to cylinders or cones for a bar or cube
chart. You can do this programmatically:
ChartFX1.CylSides = 12 (Cylindric)
ChartFX1.CylSides = -12 (Conic)
8) This option allows the user to show/hide point markers on the series. You can do this
programmatically:
ChartFX1.PointLabels = True/False
9) This option allows the user to show/hide a particular series in the chart. Please refer to the
following pages for more information on how to achieve this programmatically.
158
Series Dialog
This dialog allows you to set specific settings, including visual attributes for series in the chart.
When a particular series is selected this dialog settings will apply only to the series selected.
Also, this dialog will change according to the series gallery selected. This means some of the
settings explained here may not be available to the type the series is displaying.
The main difference when a particular series is selected is that properties and methods invoked in
this dialog belong to the Series Object and not general properties of the Chart FX API.
1) This option allows the user to change colors for a specific series. You can do this
programmatically:
ChartFX1.Series(1).Color = RGB(255,0,255)
2) This option allows the user to show borders for series. You can do this programmatically:
ChartFX1.Series(1).Border = True/False
3) This option allows the user to change the border color. You can do this programmatically:
ChartFX1.Series(1).BorderColor = RGB(255,0,255)
4) This option allows the user to change the border LineStyle. You can do this programmatically:
ChartFX1.Series(1).LineStyle = CHART_DASH
159
5) This option allows the user to change the border line width. You can do this programmatically:
ChartFX1.Series(1).LineWidth = 3
Note: In Windows 95/98, the LineWidth may not be combined with a line style different than solid.
6) This option allows the user to change the chart type for a particular series. You can achieve
MultiType charts using this property. You can do this programmatically:
ChartFX1.Series(1).Gallery = AREA
7) This option allows the user to change the space allotted for each marker. You can do this
programmatically. This property applies to all series in the chart:
ChartFX1.Volume = 50
) This option allows the user to change the marker shape to cylinders or cones for a bar or cube
chart. You can do this programmatically:
ChartFX1.Series(1).CylSides = 12 (Cylindric)
ChartFX1.Series(1).CylSides = -12 (Conic)
8) This option allows the user to show/hide point markers on the series. You can do this
programmatically:
ChartFX1.Series(1).PointLabels = True/False
9) This option allows the user to show/hide a particular series in the chart. You can do this
programmatically:
ChartFX1.Series(1).Visible = True/False
160
Axis Dialog
This dialog allows you to manipulate axis settings, including Major Interval, Minor Intervals,
Scales, Min, Max, and Gridlines & Tickmarks.
1) This option allows the user to set the Major interval for the selected axis. You can do this
programmatically:
ChartFX1.Axis(AXIS_Y).Step = 10
2) This option allows the user to Control the Tickmark type for the major interval. You can do this
programmatically:
ChartFX1.Axis(AXIS_Y).TickMark = TS_CROSS
3) This option allows the user to set the Minor Unit for the selected axis. You can do this
programmatically:
ChartFX1.Axis(AXIS_Y).MinorStep = 5
4) This option allows the user to show/hide a particular axis, including labels and tickmarks. You
can do this programmatically:
ChartFX1.Axis(AXIS_Y).Style = AS_HIDE
5) This option allows the user to show/hide gridlines on the major interval. You can do this
programmatically:
161
ChartFX1.Axis(AXIS_Y).Grid = True/False
6) This option allows the user to show/hide gridlines on the minor interval. You can do this
programmatically:
ChartFX1.Axis(AXIS_Y).MinorGrid = True/False
7) This option allows the user to Control the Tickmark type for the minor interval. You can do this
programmatically:
ChartFX1.Axis(AXIS_Y).MinorTickMark = TS_INSIDE
162
Axes Scale Dialog
This dialog allows you to manipulate axis Scales including, Min, Max, Logarithmic scales among
others.
1) This option allows the user to set the minimum for the selected axis. You can do this
programmatically:
ChartFX1.Axis(AXIS_Y).Min = 0
2) This option allows the user to set the maximum for the selected axis. You can do this
programmatically:
ChartFX1.Axis(AXIS_Y).Max = 100
3) This option allows the user to set the scale unit for the selected axis. You can do this
programmatically:
ChartFX1.Axis(AXIS_Y).ScaleUnit = 1
4) This option allows the user to set the Axis Format. You can do this programmatically:
ChartFX1.Axis(AXIS_Y).Format = AF_DATE
5) This option allows the user to set the number of decimals for the selected axis. You can do
this programmatically:
ChartFX1.Axis(AXIS_Y).Decimals = 2
163
6) This option allows the user to set logarithmic or linear scales. You can do this
programmatically:
ChartFX1.Axis(AXIS_Y).LogBase = 10
7) This option allows the user
to set the starting point at zero. For example, if you have a bar
chart with a minimum value of -50 and turn on this flag the starting point will be zero and you will
have bars that go up or down, depending on their value.You can do this programmatically:
ChartFX1.Axis(AXIS_Y).Style = AS_BREAKZERO
164
Axes Labels Dialog
This dialog allows you to manipulate labels displayed on the axis, including Rotation, Fonts and
Axis Title.
1) This option allows the user to set a rotated angle for labels in the selected axis. You can do
this programmatically:
ChartFX1.Axis(AXIS_Y).LabelAngle = 45
2) This option allows the user to set a title for the selected axis. You can do this
programmatically:
ChartFX1.Axis(AXIS_Y).Title = “In Millions”
3,4,5) This option allows the user to set
label styles for the selected axis. You can do
this programmatically:
‘To hide labels
ChartFX1.Axis(AXIS_Y).Style =
AS_HIDETEXT
‘To make staggered labels
ChartFX1.Axis(AXIS_Y).Style =
AS_2LEVELS
Because it is a word property, you must make sure you use
these operators to turn on/off bits and avoid losing previous
settings to the property.The right way of setting this property
is
Chart1.Axis(AXIS_Y).Style =
Chart1.Axis(AXIS_Y).Style Or AS_ROTATETEXT
(RIGHT!)
If you type the following code:
Chart1.Axis(AXIS_Y).Style = AS_ROTATETEXT
(WRONG!)
165
Axes GridLines Dialog
This dialog allows you to customize gridlines on both the major and minor intervals.
1) This option allows the user to colors for gridlines in the selected axis. You can do this
programmatically:
ChartFX1.Axis(AXIS_Y).GridColor = RGB(192,192,192)
2) This option allows the user to set grid line styles in the selected axis. You can do this
programmatically:
ChartFX1.Axis(AXIS_Y).GridStyle = CHART_DASH
3) This option allows the user to set grid lines width in the selected axis. You can do this
programmatically:
ChartFX1.Axis(AXIS_Y).GridWidth = 3
4) This option allows the user to align labels with tickmarks and gridline sin the selected axis.
You can do this programmatically:
ChartFX1.Axis(AXIS_Y).Style = AS_CENTERED
166
5) This option allows the user to set interlaced gridlines. You can do this programmatically:
ChartFX1.Axis(AXIS_Y).Style = AS_INTERLACED
Note: The interlaced colors are achieved with the major grid lines color and the background of the
chart (Rgb2DBk or RGB3DBk property).
6) This option allows the user to colors for minor gridlines in the selected axis. You can do this
programmatically:
ChartFX1.Axis(AXIS_Y).GridColor = RGB(192,192,192)
7) This option allows the user to set minor grid line styles in the selected axis. You can do this
programmatically:
ChartFX1.Axis(AXIS_Y).GridStyle = CHART_DASH
8) This option allows the user to set minor grid lines width in the selected axis. You can do this
programmatically:
ChartFX1.Axis(AXIS_Y).GridWidth = 3
167
3D Dialog
This dialog allows you to customize 3D aspects of a 3D chart.
1) Interactive drawing feature. Please refer to the AngleX and AngleY properties to do this
programmatically.
2) This option allows the user to enable/disable 3D view of the chart.You can do this
programmatically:
ChartFX1.Axis(AXIS_Y).View3D = True/False
3) This option allows the user to rotate the chart around the x axis.You can do this
programmatically:
ChartFX1.AngleX = 25
4) This option allows the user to rotate the chart around the y axis.You can do this
programmatically:
ChartFX1.AngleX = 35
5) This option allows the user to set the drawing style for the 3D markers.You can do this
programmatically:
ChartFX1.View3DLight = 1
168
6) This option allows the user to control the chart 3D Depth.You can do this programmatically:
ChartFX1.View3DDepth = 300
7) This option allows the user to set the chart’s perspective.You can do this programmatically:
ChartFX1.Perspective = 80
169
Constants & Stripes Dialog
This dialog allows you to customize Constant Lines & Color Stripes in the chart. This dialog is
available only at design time and it is not presented to the user. Constant lines are controlled by
the “ConstantLine” object and Color stripes are controlled by the “Stripe” object. In this section we
will reference only constant lines. However, you can check the API related to Color Stripes in the
Chart FX 98 API Guide.
Important Note:
To create constant lines and color stripes you must first invoke the OpenDataEX and CloseData
methods. For more information, please refer to the Constant Lines and Color Stripes topics in
previous pages of this manual.
1) This option allows you to set the axis associated with the Constant Line.You can do this
programmatically:
ChartFX1.ConstantLine(0).Axis = AXIS_Y
2) This option allows you to set the value of the Constant Line.You can do this programmatically:
ChartFX1.ConstantLine(0).Value = 30
3) This option allows you to set the style associated with the Constant Line.You can do this
programmatically:
ChartFX1.ConstantLine(0).Label = ‘Alarm Limit”
170
4) This option allows you to set the color associated with the Constant Line.You can do this
programmatically:
ChartFX1.ConstantLine(0).Color = RGB(128,255,0)
5) This option allows you to set the label associated with the Constant Line.You can do this
programmatically:
ChartFX1.ConstantLine(0).LineStyle = CHART_DASH
6) This option allows you to set the width associated with the Constant Line.You can do this
programmatically:
ChartFX1.ConstantLine(0).LineWdith = 3
171
Data/Behavior Dialog
This dialog allows you to show tools and other important settings in the UI of the chart. This
dialog is available only at design time and it is not presented to the user
1) This option allows you to set the number of series and values for previewing purposes only.
To set actual data to the chart, please refer to the “Passing Data” chapter in previous pages of
this manual.
2) This option allows you to select the end user tools you want to display in the chart.You can do
this programmatically:
‘ Show the Toolbar
ChartFX1.Toolbar = True/False
‘ Show the MenuBar
ChartFX1.MenuBar = True/False
‘Show the Series Legend
ChartFX1.SerLegBox = True/False
‘Show the Values Legend
ChartFX1.LegendBox = True/False
‘Show the Data Editor
ChartFX1.DataEditor = True/False
‘Show the Palette Bar
ChartFX1.PaletteBar = True/False
‘Show the PatternBar
ChartFX1.PatternBar = True/False
172
3) This option allows you to set how the chart reacts to user interaction.You can do this
programmatically:
‘Allow user to drag points with the mouse
ChartFX1.AllowDrag = True/False
‘Allow the user to edit values in Data Editor
ChartFX1.AllowEdit = True/False
‘Allow the user to resize the chart
ChartFX1.AllowResize = True/False
‘Allow the user to scroll the chart
ChartFX1.Scrollable = True/False
‘Show ToolTips when user positions the mouse over a marker
ChartFX1.ShowTips = True/False
‘Display menus when user right clicks an element
ChartFX1.ContextMenus = True/False
4) This option allows you to configure how Chart FX reacts when the user double clicks an
element in the chart.You can do this programmatically:
ChartFX1.DblClk CHART_BALLOONCLK
5) This option allows you to configure how Chart FX reacts when the user right clicks an element
in the chart.You can do this programmatically:
ChartFX1.RigClk CHART_PROPERTIESCLK
173
Commands Dialog
This dialog allows you to customize the Toolbar. This dialog is available only at design time and it
is not presented to the user.
Important Note:
Please refer to the “Customizing the Toolbar” chapter for more information on the properties and
methods you should use to customize the toolbar and other tools available in Chart FX.
174
Extensions Dialog
This dialog allows you enable/disable installed ChartFX 98 extensions. This dialog is available
only at design time and it is not presented to the user.
Important Note:
Chart FX provide sthe Annotation Extension free of charge. There are other Extensions that you
can purchase from Software FX. Particularly, Chart FX Financial Edition which is an extension
specifically designed to provide financial charting capabilities.
In order to activate an extension, you must invoke the AddExtension method as follows
AnnotX= ChartFX1.AddExtension "AnnotationX.AnnList"
Another way to enable the Annotation extension is using the New Command as follows:
Set AnnotX = New AnnotationX
ChartFX1.AddExtension AnnotX
Important Note: The return value of the AddExtension Method is really important as you will use it to
handle objects (Add, Remove, Count, etc), so it may be a good idea to set a global variable with this
return value. However, if you don't like global variables or you prefer to retrieve the handle to the
Annotation Objects List. The GetExtension Method is also provided in the Chart FX 98 API.
Please refer to the Extension Documentation for more information on objects, properties and
methods supported by that extension.
For more information please refer to our web site at http://www.softwarefx.com
175
Chart FX Programmer’s Guide
Annotation Objects
Topics covered in this section
Overview
Activating the Extension
Creating objects programmatically
Deployment issues
177
The Chart FX Annotation Extension.
Chart FX 98 provides an Annotation Extension that you can use to add text, arrows, different
shapes and even images that you can freely move around the chart. As a matter of fact a whole
new toolbar will be added to the chart so your users can add these shapes and rotate them,
group them and even flip them around. Just take a closer look:
As with any other Chart FX extension, you must first enable the extension. You can do this
programmatically, by using the Design-Time properties dialog or you can add them
programmatically in your code by invoking the AddExtension method.
To enable the annotation extension at Design Time, follow these steps:
At Design Time, right click the chart and select "Properties"
Select the "Extensions" Tab
Check "Annotation Objects"
When you run the application an additional toolbar will be added to the chart so you can add
these annotation objects. The API is now accessible in your code so you can add annotation
objects dynamically to the charts.
If you want to add the annotation extension programmatically, just use the AddExtension method,
as follows:
AnnotX= ChartFX1.AddExtension "AnnotationX.AnnList"
Another way to enable the Annotation extension is using the New Command as follows:
Set AnnotX = New AnnotationX
ChartFX1.AddExtension AnnotX
Important Note:
179
The return value of the AddExtension Method is really important as you will use it to handle
objects (Add, Remove, Count, etc), so it may be a good idea to set a global variable with this
return value. However, if you don't like global variables or you prefer to retrieve the handle to the
Annotation Objects List. The GetExtension Method is also provided in the Chart FX 98 API.
You will invoke the AddExtension method only once (And usually in the Form_Load event).
Once the annotation extension has been enabled, you can start creating objects
programmatically.
180
Creating Annotation objects programmatically
Once the Annotation Extension has been enabled in your project, you can let your users annotate
the chart using the toolbar provided in the Annotation extension, or you may want to use this
extension to highlight markers or create annotation objects dynamically.
This guide will introduce you to the different objects available in the Annotation extension and
how you can use them programmatically in your project.
The Annotation extension exposes the following objects:
AnnArc : Arcs
AnnArrow : Arrows & Lines
AnnBalloon : Text displayed in a Balloon
AnnCircle : Circles & Ellipses
AnnGroup : Groups of Objects
AnnPicture : Pictures
AnnRect : Rectangles
AnnText : Text
These are objects that you can create dynamically and position them anywhere you want in the
chart area.
To create one of these objects you must first create a variable containing a pointer to the object
and use properties associated with them. For example, if you want to create a circle dynamically,
you must define the variable as follows:
Dim MyCircle As AnnCircle
Important Note: In order to have access to these objects you must first include references to the
Annotation Extension Type Library. You can do this by Selecting the Project Menu, click on
References and check the Annotation extension Type Library, as depicted in the following figure:
181
With this variable (MyCircle) you can add the object using the Add method with the pointer
returned by the AddExtension method, as follows:
Set MyCircle = AnnotX.Add(OBJECT_TYPE_CIRCLE)
Then you'll need to access properties that allow you to set attributes such as position, colors,
among others, for the particular object you are creating. For example:
MyCircle.Top = 100
MyCircle.Left = 50
Important Note:
All Annotation objects, properties and methods have been documented in the Annotation
Extension Help file (located in the Chart FX /Help directory)
182
Annotation Extension Deployment
ANNOTATEX.DLL IS REQUIRED!
If you use the Annotation Extension as part of your application, you must make sure you
redistribute and register the ANNOTATEX.DLL in the client's machine.
Please refer to the Chart FX Programmer's Guide for more information on redistributing Chart FX
98 and other files that may be required as part of your application.
Registering components:
Most of the files used by Chart FX 98 need to be registered in order for them to work correctly.
These files are "Self Register". This means that virtually any setup utility will be able to register
them upon installation. Check your setup utility documentation for more information on this topic.
If your setup utility does not include this option, you can use Microsoft's REGSVR32.EXE to
register these modules.
183
Chart FX Programmer’s Guide
Appendix A. Migration Issues
Topics covered in this section
Migrating from Chart FX 3.0
Converting Project Files
Obsolete/Replaced API.
185
Migrating from Chart FX 3.0
There are basically three (3) steps that you have to consider when migrating from Chart FX 3.0 to
Chart FX 98:
1.- Converting Project Files
In order to convert your Chart FX 3.0 project files, your development tool needs to support "OLE
Auto Conversion". Here are some of the tools that support this paradigm:
Visual Basic 6.0
Visual C++ 6.0
MS Access 97
Visual FoxPro 6.0
Borland Delphi 4.0 (*)
Borland C++ Builder 3.0
If your tool supports this, follow this procedure:
1) Save all your project forms/dialogs using Chart FX 3.0 build 35 (version 3.0.35) or
later.
2) Run "Chart FX 3.0 to 98 Conversion Utility" (Cfx3to4.exe) provided with Chart FX 98.
And turn conversion ON.
3) Open your project. Make some changes to the chart (e.g. change its size slightly) to
ensure re-saving and save your project. Do this with all the forms/dialogs that contain
charts.
Note: Chart FX 3.0 File Filters need to be installed in order to make this conversion
2.- Making changes to your code
Most of the old API is still provided for compatibility. However, some of the old API has been
replaced with new, improved API. We suggest you migrate to this API as soon as possible. This
will help you to learn the philosophy behind the Chart FX 98 object oriented API.
Although we have tried to be compatible with Chart FX 3.0, some properties, methods and events
simply can not be converted because an entirely different approach was taken in the new version.
Check the Chart FX 98 Help file for information on obsolete properties, methods and events.
3.- Importing Chart FX 3.0 files (.CHF) and templates (.CHT)
Chart FX 98 includes a file filter library that will enable you and your users to read from Chart FX
3.0 files and templates. If these filters are installed, the import method will automatically read from
those files. Make sure to install the Chart FX 3.0 filters if you want to have this functionality.
If your tool does not support ActiveX conversion, you will need to modify your forms manually so
they point to the new component.
(*) Same class name has to be given to the new component when installed into the component
library. Only ActiveX projects can be converted. A VCL is not provided in Chart FX 98.
187
Chart FX 3.0 Replaced/Obsolete API
The following properties and methods exist only for compatibility reasons. New programs should
use the new API:
OLD property/method
ChartType
MarkerVolume
PointType
Type
Shape
PixFactor
FixedGap
Angles3D
MultiType
MultiShape
MultiLineStyle
MultiYAxis
MultiPoint
VertGridGap
Const
FixLeg
Adm
DecimalsNum
BarBitmap
Value
XValue
IniValue
LegStyle
ConstType
SetStripe
AutoIncrement
ThisSerie
ThisPoint
ThisValue
ThisColor
NEW property/method
Gallery
Volume
PointType
TypeMask
CylSides
Axis(AXIS_Y).PixPerUnit
Axis(AXIS_X).PixPerUnit
AngleX, AngleY
Series(i).TypeMask, Series(i).Gallery
Series(i).CylSides
Series(i).LineStyle, Series(i).LineWidth
Series(i).YAxis
Series(i).MarkerShape
Axis(AXIS_X).Step
ContantLine(i).Value
ContantLine(i).Label
Axis(AXIS_*),Min, Axis(AXIS_*),Max, Axis(AXIS_*).Step,
Axis(AXIS_*).LogBase
Axis(AXIS_*).Decimals
Series(i).Picture
ValueEx, Series(i).YValue
XValueEx, Series(i).XValue
IniValueEx, Series(i).YFrom
Axis(AXIS_*).Style
ConstantLine(i).Style
Stripe(i).Color, Stripe(i).From, Stripe(i).To
ValueEx
ValueEx
ValueEx
ValueEx
Color
188
The following properties are no longer supported and its functionality has radically changed. You
can not use these properties in Chart FX 98:
OLD property/method
BarHorzGap
RGBBarHorz
GalleryTool
CurrentAxis
CustomTool
TBBitmap
TBItemStyle
EnableTBItem
ToolStyle
ToolSize
ToolPos
TBItemID
ShowStatus
StatusText
SetStatusItem
Status
Comment
See ToolBar customization
See ToolBar customization
See ToolBar customization
See ToolBar customization
See ToolBar customization
See ToolBar customization
See ToolBar customization
See ToolBar customization
See ToolBar customization
See ToolBar customization
Status bar no longer supported
Status bar no longer supported
Status bar no longer supported
Status bar no longer supported
189
Chart FX Programmer’s Guide
Appendix B. Memory
Requirements
Topics covered in this section
Chart FX Memory Requirements
191
Chart FX Memory Requirements
Other than the physical limitations that your computer or OS configuration may impose, Chart FX
98, imposes the following limitation on the size of your data:
•
•
•
The number of series is limited to 32,767 and total number of points to 2,147,483,647.
This means that you can have a chart with 2,147,483,647 and one series, a chart with
536,870,911 and 4 series, or any other combination.
The size of each string (axis label, title, etc.) is limited to 255 characters.
32,767 Labels per Label List (X-axis, Y-axis, Series Legend, etc.)
The size of ONE chart Object can be calculated as follows:
Global Memory:
•
•
•
•
•
•
•
•
•
About 2.5 KB of core data per chart +
Eight (8) Bytes for each data point. +
Eight (8) Bytes for each data point if X-Values are used (X/Y Chart) +
Eight (8) Bytes for each data point if Ini-Values are used +
Four Bytes per color (if not using default schemes) +
2 Bytes per pattern (if not using default schemes) +
256 Bytes per label list (if used) + (4 + Label String + 1) * Number_Of_Elements
28 Bytes per constant line +
24 Bytes per color stripe
GDI Resources:
Only a few global GDI resources are created when you load Chart FX. All the rest of resources
are created when the chart displays (paint) and destroy right after.
The number of resources used in a chart varies a lot depending on the chart configuration but it is
optimized for both speed and resource consumption.
Other memory
Chart FX ActiveX control is about 530K
Chart FX COM DLL is about 460K
SfxBar.DLL (required for both) is about 110K
You usually use either the ActiveX or the DLL not both (they are completely independent).
Other DLLs like COMCAT.DLL and OLEAUT32.DLL are also required to be loaded, but these are
usually loaded by the system itself or by your own application.
Extensions (e.g. CFX4DATA.DLL, CFX4FILTERS.DLL, CFX4OLE.DLL, ANNOTATEX.DLL) are
loaded only if they are being used.
193
Chart FX Programmer’s Guide
Appendix C. Deployment Issues
Topics covered in this section
Deploying your application
195
Deploying your application
Several modules compose chart FX 98. You need to redistribute those that you use. Here is the
list of redistributable files along with a rule that tells you when to redistribute them:
Program files:
SFXBAR.DLL
You must redistribute this file always. This file needs to be registered.
CFX4032.OCX
Redistribute this file ONLY if you are using the ActiveX control. This file needs to be registered.
CFX4032.DLL
Redistribute this file ONLY if you are using the DLL. Usually, you don't need to re-distribute this
file if you are developing from VB, Delphi, VC++, VFP or Access. See related articles for more
information on when to use the DLL. This file needs to be registered.
CFX4FILTERS.DLL
Redistribute this file only if you want your application to be able to read Chart FX 3.0 files. This
file needs to be registered.
CFX4DATA.DLL
Used when using Data Binding (DataSource property) and/or the GetExternalData method. This
file needs to be registered.
ANNOTATEX.DLL
Redistribute this file only when you use Annotation Objects. This file needs to be registered.
CFX4OLE.DLL
This file requires a user license to run (subject to a royalty fee). Redistribute this file only if you
have purchase Chart FX 98 OLE Server licenses for each of your users. This file needs to be
registered.
All program files usually go in the WINDOWS\SYSTEM (WINNT\SYSTEM32) folder. They have
to be in the same directory or in your path.
Registering components:
Most of the files used by Chart FX 98 need to be registered in order for them to work correctly.
These files are "Self Register". This means that virtually any setup utility will be able to register
them upon installation. Check your setup utility documentation for more information on this topic.
If your setup utility does not include this option, you can use Microsoft's REGSVR32.EXE to
register these modules.
Additional Files:
PALETTES.REG: Merge this file into your client's computer registry to provide multiple color
palettes/schemes.
Always consult your license agreement on re-distribution rights before you deploy any of
the Chart FX files.
197
Chart FX Programmer’s Guide
Appendix D. Compatibility Issues
Topics covered in this section
ActiveX or DLL. Which one should you use?
Chart FX and Visual C++
Chart FX and Borland Products
199
Chart FX ActiveX vs. Chart FX DLL. Which one should you use?
Chart FX 98 contains 2 Independent modules that provide similar functionality:
CFX4032.OCX (ActiveX control) and CFX4032.DLL (DLL COM Component)
While the ActiveX control provides design-time capabilities, the DLL is slightly smaller and faster.
Both DLL and ActiveX provide a similar COM interface that allows you to access all object
properties and methods in the same way. The DLL also offers a standard (not COM-based)
interface for tools that are not COM enabled and for compatibility with older versions. You must
use the COM interface whenever possible..
As opposed to the ActiveX control, the DLL is not an OLE automation (IDispatch) object. This
gives the DLL a higher performance since it doesn't have to do type conversions, this is
particularly important when a lot of strings (labels) are used.
The ActiveX control is recommended for most applications. Using the DLL requires more
programming expertise in C++ and COM (OLE). Here are some cases in which you may want to
use the DLL:
-
Your development tool doesn't support ActiveX controls (VC++ supports ActiveX controls
only through MFC).
You use a high performance development tool (e.g. VC++) and have charts with lots of
data.
Your application is a "batch process" that takes data and generates chart files or pictures.
In other words, your application never displays the charts.
Please have in mind that what you gain in performance you may loose in ease of use.
201
Chart FX & Microsoft Visual C++
There are 2 ways of importing an ActiveX control into a Visual C++ MFC application:
1) By allowing the Class Wizard to generate wrapper classes for each one of the components
contained inside the ActiveX. This is done automatically when you assign a member variable to
the object.
2) By using the #import directive as follows:
In your precompiled header (STDAFX.H)
// DEFINITION of COM wrappers
#import "sfxbar.dll" no_namespace no_implementation
#import "Cfx4032.ocx" no_namespace no_implementation
In your implementation (STDAFX.CPP)
// IMPLEMENTATION of COM wrappers
#import "sfxbar.dll" no_namespace implementation_only
#import "Cfx4032.ocx" no_namespace implementation_only
There are quite a few differences between these two approaches:
While #import uses DIRECT calls to the ActiveX component via dual interfaces, the classes
generated by Class Wizard make the calls through the Dispatch interface only. This makes it very
inefficient since parameters have to be packed and unpacked with each call.
Class Wizard will generate a different file for each class (Interface) inside the ActiveX control. In
complex controls (like Chart FX 98) that means a lot files added to your project which makes it
very confusing.
You can use the #import directive for any COM interface. Not only for ActiveX controls.
You can use extended COM syntax to access the object's properties and methods. For instance,
using the classes generated by the Class Wizard you would do:
m_ChartFX.SetChart3D(TRUE);
Using #import, you would do:
m_pChartFX->Chart3D = TRUE;
We suggest using #import when using Chart FX 98 since it poses all these advantages. The only
complication of the #import approach, is that you have to map the component to a variable
manually, but don't worry, a couple of lines of code is all that is needed:
Define two members in your class:
CWnd m_ChartFX; // Chart FX Window
IChartFXPtr m_pChartFX; // Chart FX Object Pointer
202
Inside DoDataExchange (make sure you add this code outside the VC++ generated comments)
DDX_Control(pDX, IDC_CHART1, m_ChartFX); // Link variable to control
if (!pDX->m_bSaveAndValidate) // Link Chart FX pointer to control
window
m_pChartFX = m_ChartFX.GetControlUnknown();
Or if you want to create your chart dynamically, you can do this instead:
m_ChartFX.CreateControl(__uuidof(ChartFX), "", WS_VISIBLE, rc, this,
IDC_CHART2,NULL,<Licence String*>); // Create Control Window
m_pChartFX = m_ChartFX.GetControlUnknown(); // Attach to Chart pointer
You will use m_ChartFX when you want to use the control as a Window (e.g. to move it, re-size
it, etc.) and you use m_pChartFX to access all the properties and methods.
* The license string is printed in your license card.
203
And, If you are not using MFC:
You can still take advantage of the #import directive and Chart FX 98 COM DLL to use ChartFX
almost in the same way you use the ActiveX under MFC. Here is how:
First, import Chart FX and related libraries as follows:
In your precompiled header (STDAFX.H)
// DEFINITION of COM wrappers
#import "sfxbar.dll" no_namespace no_implementation
#import "Cfx4032.dll" no_namespace no_implementation
In your implementation (STDAFX.CPP)
// IMPLEMENTATION of COM wrappers
#import "sfxbar.dll" no_namespace implementation_only
#import "Cfx4032.dll" no_namespace implementation_only
In your declarations:
IChartFXPtr m_pChartFX;
HWND m_hwndChartFX;
Then, you can dynamically create Chart FX objects as follows:
m_pChartFX.CreateInstance(__uuidof(ChartFX));
m_pChartFX->CreateWnd((long) hwndParent,IDC_CHART1,0,0,500,500,WS_CHILD
| WS_VISIBLE);
m_hwndChartFX = (HWND) m_pChartFX->hWnd;
You do not need to call CreateWnd unless you want to make the chart visible and active. You can
call all the properties and methods without having a window. Batch applications and system
services may take advantage of this feature to keep resource usage at a minimum.
Note: You need to call CoInitialize() when your application starts and CoUninitialize() when it
ends.
204
Chart FX ActiveX and Borland products
Integrating an ActiveX control into Borland Delphi and C++ Builder is not as easy as it should be.
Here are some tips that will help you get through:
Delphi 4.0
The support for ActiveX controls seems to be very complete but there are a few issues to
consider:
1) You need to remove any package containing previous versions of Chart FX. By default, a
package named "Delphi Sample Imported ActiveX Controls" contains Chart FX 2.0. Since the
source for this package is not installed, you need to remove the package as a whole. You can
import other components that are in that package by selecting "Import ActiveX Control" from the
"Components" menu.
2) Import the ActiveX into a new package. This will make it easier to remove or disable it later on.
3) Because of a bug in the engine that reads the ActiveX type library and generates PASCAL
classes, an extra parameter is added to each and every method. This parameter is not used so
you can eliminate it without consequences. The parameter name is retval.
This BUG is fixed in Delphi 4.0 Update #1.
Another bug in Delphi 4.0 Import Library engine: Default properties are not declared as default.
This forces you to type (for example):
ChartFX1.Axis.Item[AXIS_Y].Min := 20;
Instead of just:
ChartFX1.Axis.[AXIS_Y].Min := 20;
We have already made those changes and have Pascal classes in which those parameters have
been removed and default properties has been declared properly. You can just copy the following
files to your Delphi4\Imports subdirectory after following step 1 and 2. This will replace some of
the files that were generated in step 2.
ChartFX 98\Lib\ChartFX_TLB.PAS
ChartFX 98\Lib\SfxBar_TLB.PAS
Then remove their respective .DCU files (so they will be recompiled).
All of our samples and documentation assume that these fixes have been made.
Note: Although this solution is the easiest one, it may not work in future versions of Delphi since
the base classes may change from one version to another. The files included were generated
using Delphi 4.0 Build 5.37 (from the About-Box). If this doesn't do it (because you have a
different version) repeat step 1-2 and then make the changes on the files previously mentioned.
205
C++ Builder 3.0 & 4.0
There are several issues when integrating Chart FX to Borland C++ Builder 3.0. Although some
of the problems have been fixed in Service Pack 1. We strongly encourage you to download the
samples we have built and the knowledgebase articles related to this tool.
For more information, please visit our support site at http://support.softwarefx.com and search for
the keyword “Borland”.
Delphi 3.0 and 2.0, C++ Builder 1.0
Enumerated types are not supported as parameters to properties and methods. The classes
generated by the "import engine" will generate compiler errors.
As of today, Chart FX 98 is not compatible with these versions of Delphi. For updated information
on these tools please refer to our support site at http://support.softwarefx.com and search for the
keyword “Delphi”
206
Chart FX Programmer’s Guide
Appendix E. Licensing Issues
Topics covered in this section
The Chart FX Licensing scheme
207
Chart FX License Scheme. How does it work?
Chart FX 98 is a licensed control, this means that it can not be used to develop applications
unless a license of the control is installed in the computer.
If you use the ActiveX control and create the charts from the IDE, this is completely transparent
for you, but why?
The answer is inside COM. Chart FX 98 supports IClassFactory2, an enhanced class factory that
provides functionality for design-time and run-time licensing. Here is how it works:
At design time, the container (e.g. Visual Basic) creates the control using CoCreateInstance (or
IClassFactory::CreateInstance) which makes Chart FX look for a license installed. If it doesn't find
it, CreateInstance will fail. If it is found, it creates the control. When the container creates an
executable (or similar binary image) it will ask Chart FX for the license string. If the license was
previously found, Chart FX will return a valid license string which the container will save it inside
the executable.
When the program runs later on (maybe in another computer which doesn't have a Chart FX
license), it will create the chart object using IClassFactory2::CreateInstanceLic and passes the
saved license string as a parameter. Chart FX will check that this string is a valid license string, if
it is valid, it will create the control.
But remember, all this is hidden from you if you create the Chart FX objects from the IDE. But
what happens if you are creating the Chart FX objects dynamically ? Well that's when all this
knowledge comes handy.
If you are using the OCX or the DLL as a COM object, you must create your Chart FX objects
using IClassFactory2. In C++ you would do something like this:
if (SUCCEEDED(hr = CoGetClassObject(<ChartFX 98 Class
ID**>,CLSCTX_INPROC_SERVER,NULL,IID_IClassFactory2,(LPVOID FAR *)
&pFactory2))) {
hr = pFactory2->CreateInstanceLic(NULL,NULL,IID_IUnknown,<Chart FX 98
License string*>,(LPVOID FAR *) &pUnk);
if (SUCCEEDED(hr))
p = CChartFXDll::Create(pUnk);
pFactory2->Release();
}
In MFC, IClassFactory2 is encapsulated into CWnd. If you are using the ActiveX control (you can
not do this with the DLL), you can do:
CWnd m_ChartFX;
m_ChartFX.CreateControl(<ChartFX 98 Class ID**>, NULL, WS_VISIBLE, rc,
this, IDC_CHART1,NULL,NULL,<Chart FX 98 License string*>);
So this takes care of COM. Both the ActiveX and the DLL is used as a COM object.
If you are using the DLL as a standard library (using chart_Create, chart_Send, etc.) you will not
be helped by COM but Chart FX will still require a license to run. You must call:
chart_SetLicense(<Chart FX 98 License string*>);
Before you can create any chart. Otherwise, the chart_Create function will fail.
209
A valid license string is printed in your license card. It can also be obtained by running
Cfx98Info.exe (About Chart FX 98)
** Chart FX 98 class ID's are:
ActiveX (OCX) :
{0x608E8B11,0x3690,0x11D1,{0x8F,0xD4,0x00,0xAA,0x00,0xBD,0x09,0x1C}} //
{608E8B11-3690-11D1-8FD4-00AA00BD091C}
DLL:
{0xFFF90AC1,0x4659,0x11D1,{0x8F,0xD4,0x00,0xAA,0x00,0xBD,0x09,0x1C}} //
{FFF90AC1-4659-11d1-8FD4-00AA00BD091C}
210
Chart FX Programmer’s Guide
Index
211
2
2D background color, 63
2D Colored Lines, 64
2D/3D views, 154
3
3D angles, 71
3D background color, 63
3D Depth, 72
3D Effects, 71
3D representation, Surface, 86
3D view, 167
3D Wall, 71
A
Access, 6
acquiring points
in Real-Time mode, 141
ActiveX, 199, 208
Activities, Gantt, 83
AddExtension, 177
add-on, 3
Adm, 186
ADO, 29, 37, 39, 40
ADO, creating an XY Plot, 77
AdoSource, 37
Analysis, Technical, 84
angles, 3D, 71
Angles3D, 186
AngleX, 167
AngleY, 167
ANNOTATEX.DLL, 195
Annotation Extension, 177
Annotation objects, creating, 179
API Reference, 4
API, obsolete, 185
Arcs, 179
Area, 77
Arrays, 41
arrows, 177
ASP, Scripts, 17
AutoIncrement, 186
automation, OLE, 199
Axis
custom labeling, 53
Formatting, 51
labeling, 52
scrolling, 54
User-Defined Formats, 51
axis drawing style, 154
Axis Format, 162
axis, showing/hiding, 160
Axis, working with, 49
B
B&W printing, 109
background color, 155
background colors, 63
Background picture, 155
background, transparent, 63
Balloon, 104
BarBitmap, 186
BarHorzGap, 187
BDE Cursors, 40
Binding, 9
BitBlitz, 33
BkColor, 64
Black & White patterns, 64
border, color, 156
border, line style, 156
border, line width, 157
borders, showing, 156
Borland, 203
browsers, 17
Bubble, 77, 89
BufferSize, 144
builder, 23
Builder, 203
button, changing behavior, 121
buttons, adding to the toolbar, 122
buttons, removing from toolbar, 120
buttons, toolbar, 118
C
C++ Builder, 6, 40, 203
Candlesticks, 84
Categorical Axis, 52
CFX4032.DLL, 195
CFX4032.OCX, 195
CFX4DATA.DLL, 195
CFX4FILTERS.DLL, 195
CFX4OLE.DLL, 195
Chart FX 3.0, migrating from, 185
Chart's Name, 21
ChartType, 186
Circles, 179
class ID's, 208
Class Wizard, 200
clipboard, 14, 97
CloseData, 30
Cluster Charts, 71
clustered chart, 154
CoCreateInstance, 207
COD_ADDPOINTS, 142
COD_REALTIME, 142
COD_REALTIMESCROLL, 142
Collections, reading data, 43
color scheme, 155
Color schemes, 64
Color Stripes, 94
color, dragging, 63
Color, handling, 61
Colored Lines, 64
Colors, 9
colors, assigning to markers, 63
colors, background, 63
COM, 3, 23, 35, 98, 199, 207
Comma separated, 45
commands, 116
Common Dialog, 111
compatibility, 185
Compatibility, 17
compatibility, backward with Chart FX 3.0, 98
cones, 157
Conic shapes, 67
Const, 186
Constant lines, 93
constants, 22
CPI_, 148
Constants, 9
Constants Lines, 169
ConstType, 186
Container, OLE, 14
Context, device, 110
ContextMenus, 172
Contour, 10, 77, 86
control, picture, 100
conversion, project, 185
coordinates, x and y, 75
CPI Constants, 148
CreateWnd, 202
Creating, 21
CRT_LOOPPOS, 143
CRT_NOWAITARROW, 143
CT_EVENSPACING, 142
CTE_NOLEGINVALIDATE, 144
CurrentAxis, 187
Cursors, BDE, 40
curve, 67
Curve, 77
Customizing Chart Painting, 147
CustomTool, 187
cylinders, 157
Cylindrical shapes, 67
D
Data Aware, 9
Data Editor, 171
Data Providers, 29
Data, changing values, 33
Data, Controls, 37
Data, hidden, 32
Data, Pasing using Series Object, 31
Data, Passing, 9, 29
Data, Passing to Gantt, 81
Data, Providers, 35
Data, reading from arrays, 41
Data, reading from collections, 43
Data, reading from text files, 45
Data, scrolling, 34
Data, unknown, 32
databases, connecting, 40
databinding, 37
DataEditor, 133
DataStyle, 38
DataTips, 103
DataType, 38, 44
decimals, 162
DecimalsNum, 186
default colors, 61
Delphi, 6, 40, 203
Deployment, 62, 195
Deployment, Annotation objects, 181
Depth, 72, 168
Design Time, 21
design-time licensing, 207
Device Context, 110
DeviceName, 111
Dialog
3D, 167
Axis, 160
Axis Gridlines, 165
Axis Labels, 164
Axis Scale, 162
commands, 173
Constant Lines & Color Stripes, 169
Data/Behavior, 171
Extensions, 174
General, 154
Series, 156
Dispatch interface, 200
DLL, 199, 208
docked
toolbars, 119
Document, OLE Compound, 97
drag points, 172
Dragging markers, 103
Driver, printer, 111
E
edit values, 172
Effects, 3D, 71
Ellipses, 179
EnableTBItem, 187
Excel, 13
Export, 9, 97
extensibility, 3, 23, 35
Extension, Financial Edition, 84
Extensions, 174
F
field, SQL, 38
File, 97
files, reading data from text, 45
Filters, Chart FX 3.0, 98, 185
Financial charts, 84
FixedGap, 186
FixLeg, 186
flickering
avoiding, 141
flickering, preventing, 33
215
floating, toolbar, 119
Fonts, 164
Format, Axis, 162
format, OLE Compound, 97
FoxPro, 7
frame, color, 94
G
gallery, 157
Gallery, 79
GalleryTool, 187
Gantt, 81
GDI Resources, 191
GetExtension, 178
GetExternalData, 36, 40, 41, 45
Global Memory, 191
grayscale, printing, 109
grid, 133
grid controls, 29, 35
gridline, colors, 165
gridlines, 49, 155
Gridlines, 9, 56
GridLines, 165
Gridlines, interlaced, 57
gridlines, showing/hiding, 161
gridlines, styles, 165
H
hatched patterns, 109, 155
hDC, printer, 109, 111
Hex, 22
Hidden Points, 32
Hi-Lo-Close, 84
HTML, 17
I
IClassFactory2, 207
icon selectors, 128
Icons, changing, 125
icons, toolbar, 118
IDE, 207
identifier, 22
IDispatch, 199
IDs, class, 208
images, 177
images, obtaining, 100
Import, 9, 97
Importing, Cfx 3.0 files, 185
include, 17
independent colors, 83
indexes, 22
IniValue, 186
input rate
Real-Time charts, 141
Integrating, 6
interaction, configuring, 172
interaction, mouse, 103
Interface, User, 10, 171
interlaced, 166
Interlaced Grids, 57
Internet, Chart FX, 17
invisible points, 32
ItemColor, 143
ItemStyle, 143
ItemWidth, 143
K
Kagi, 84
knowledgebase, 5
L
Labeling, surface & contour, 88
Labels, 9
Labels, frequency and style, 52
labels, rotating, 164
LANDSCAPE, 109
LButtonDblClk, 104
LegendBox, 136
legends
scrolling in real time mode, 144
LegStyle, 186
Level colors, surface, 87
License, 207
Licensing, 4
limits, highlighting, 93
line, 67
Line, 77
Lines, 179
Lines, style & width, 68
Lines, coloring, 64
logarithmic, 163
Logarithmic, 162
Loop Marker
Real-time charts, 143
Loop Position
Real-Time charts, 141
M
Major interval, 160
major unit, 49, 56
Manager, wizard, 24
marker colors, 63
Marker Volume, 68
marker, dragging, 103
Markers, 67
MarkerVolume, 186
Marketing, 4
matrix, 42
Max, 162
MaxValues, 141, 144
Memory requirements, 191
MenuBar, 116, 171
menus, 172
Menus on Demand, 103
MFC, 200
Migrating, 185
216
Min, 162
Minor Interval, 160
minor unit, 49, 56
MinorStep, 52
Model, Component Object, 23
Money Flow, 84
Mouse, 9
Mouse, events, 103
Mouse, tracking, 105
MultiLineStyle, 186
Multiple Colors, 63
MultiPoint, 186
MultiShape, 186
MultiStacked, 80
MultiType, 186
MultiType charts, 79
Multitype, financial charts, 85
MultiYAxis, 186
N
numerical axis, 49
Numerical Axis, 54
O
Object, Axis, 50
Object, Data Editor, 133
Object, LegendBox, 136
Object, PaletteBar, 134
Object, PatternBar, 135
Object, Printer, 109
Object, SerLegBox, 137
objects, handling, 50
obsolete API, 185
OEM, 6
OLE automation, 199
OLE Compound Document, 97
OLE Server, 13
OLE stream, 97
OleDB, 35
On-Line Support, 5
OOP, 23
OpenDataEx, 61, 142, 144
OpenDataEX, 30
Open-Hi-Lo-Close, 84
Orientation, paper, 109
P
Painting
customizing, 147
PaintMarker, 147
Sample, 151
palette, 61, 155
Palette, 9
Palette Bar, 171
palette, changing default, 62
PaletteBar, 134
PALETTES.REG, 195
Paper orientation, printing, 109
Pattern, 9
patternbar, 64
PatternBar, 135, 171
patterns, 155
Patterns, 64
patterns, hatched, 109
perspective, 168
Perspective, 72
picture, background, 155
picture, obtaining, 100
Pictures, 179
PIE Legends, 136
Pie slice, separating, 68
PixFactor, 186
PixPerUnit, 34, 54
Plot, contour, 88
plot, surface, 86
Plots, 10
Plots, XY, 75
point markers, 157
Point Shape, 67
Point Size, 67
PointType, 186
polar, 67
Port, printer, 111
PORTRAIT, 109
PostPaint, 147
PowerPoint, 13
PrePaint, 147
Sample, 150
Printer, Driver, 111
Printing, 9, 109
Printing, two or more charts, 110
programmatically, 22
Programming, OOP, 23
Project, converting, 185
properties indexes, 22
Providers, Data, 29, 35
pull-down menu, 103
R
Real-time, 33
RealTime, 9, 141
RealTimeStyle, 142
Rectangles, 179
redistributing, 181, 195
redistribution, 14
References, 41, 43, 45
references, Data Provider, 36
registry, 62
Registry, 21
Renko, 84
repainting, prevent flickering, 33
reporting tools, 100
Requirements, Memory, 191
resize, 172
resultsets, ADO, 40
RGBBarHorz, 187
rights, distribution, 195
Rotation, 71, 167
run-time licensing, 207
217
S
Samples, 9
scale, 49
Scales, 162
scatter, 67, 75
scheme, color, 155
Schemes, color, 64
scientific, 93
screen flickering, preventing, 33
screen, visible points, 54
scroll, 172
Scroll, 9
Scroll, controlling, 34
Scrollable, 34, 55
scrolling
Real-Time, 141
Scrolling
in real time mode, 144
Scrolling, Axis, 54
Secondary Y axis, 50, 83
Selectors, 128
Series Legend, 171
series, color, 156
series, showing & hiding, 157
SerLegBox, 137
Server, OLE, 13
SetScrollView, 34
SetStatusItem, 187
SetStripe, 186
SFXBAR.DLL, 195
Shape, 67
ShowStatus, 187
Size, point, 67
slice, separating, 68
solid colors, 61
source, data, 36
spreadsheet, 133
SQL statement, 40
SQL Statement, 38
stack, 154
Stacked, 9, 80
Statement, SQL, 38
Status, 187
StatusText, 187
Step, 52
stream, OLE, 97
Stripes, 9, 94, 169
style, lines, 68
SubCommands, 127
Support, 4, 5
Surface, 10, 77, 86
system aware colors, 61
T
Tab separated, 45
Tab Separated Values, 97
TBBitmap, 187
TBItemID, 187
TBItemStyle, 187
Technical Analysis, 84
Technical Support, 4
telephone, 4
Templates, 97
Text files, reading data, 45
ThisColor, 186
ThisPoint, 186
ThisSerie, 186
ThisValue, 186
Three Line Break, 84
Tickmark, 160
tickmarks, 49
Tickmarks, 56
TipMask, 104
Title, 155
Title, axis, 164
Toolbar, 171
adding custom commands, 129
changing icons, 125
creating your own, 131
positioning, 119
removing buttons, 120
selectors, 128
showing, 119
subcommands, 127
toolbar, annotation extension, 177
ToolBar, overview, 116
ToolPos, 187
Tools, 115
ToolSize, 187
ToolStyle, 187
tooltips, 103
ToolTips, 118, 124, 172
tooltips, balloon, 104
Tracking the Mouse, 105
transparent, background, 63
type conversions, 199
type, chart, 157
TypeEX, 144
U
UI, 171
UserScroll, 34
V
ValueEx, 75
ValueEX, 30
Values Legend, 171
Values, changing, 33
values, editing, 172
VB scripts, 17
VCL, 185
VertGridGap, 186
View3D, 71
View3DDepth, 72
Visual Basic, 6
Visual C++, 7, 200
Visual FoxPro, 7
volume, 84
Volume, marker, 68
218
W
Wall Width, 71
width, lines, 68
Wizard, Class MFC, 200
Wizards, 24
Word, 13
X
X axis
scrolling in real time, 144
X-axis, 49
XValue, 186
XValueEx, 75
XY, 10, 75
XY Plots, FAQ, 77
Y
Y Axis, 49
Y axis, secondary, 50, 83
YValue, 31
Z
z axis, 71
Zoom, 9
219