Anda di halaman 1dari 262

Olectra® Chart

2D / 3D OCX
User’s Guide and Programmer’s Manual

Version 6.0.2

4516 Henry Street


Pittsburgh, PA 15213-3785 USA
(412) 681-4343
www.apexsc.com

August 1999 RefNo: OCXUP-CH/602-8/99


Copyright  1999 by APEX Software Corporation.
Portions copyright  1996 – 1999 by KL Group Inc.

APEX and the APEX logo are registered trademarks of APEX Software Corporation.
KL Group, Olectra, and Olectra Chart are trademarks or registered trademarks of KL Group Inc.

Microsoft, MS-DOS, Visual Basic, and Windows are registered trademarks, and Windows NT is a trademark
of Microsoft Corporation.
All other products, names, and services are trademarks or registered trademarks of their respective companies
or organizations.
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Part I: Using 2D Chart


1 Chart Basics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15
1.1 Chart Terminology . . . . . . . . . . . . . . . . . . . . 16
1.2 Using the Property Editor . . . . . . . . . . . . . . . . . . 16
1.3 Interacting with the Chart . . . . . . . . . . . . . . . . . . 17
1.4 Choosing the Chart Type . . . . . . . . . . . . . . . . . . 19
Plot Charts . . . . . . . . . . . . . . . . . . . . . . 19
Area Charts . . . . . . . . . . . . . . . . . . . . . . 20
Bar Charts . . . . . . . . . . . . . . . . . . . . . . 21
Stacking Bar Charts . . . . . . . . . . . . . . . . . . . 21
Pie Charts . . . . . . . . . . . . . . . . . . . . . . . 22
Candle Charts . . . . . . . . . . . . . . . . . . . . . 22
HiLo Charts . . . . . . . . . . . . . . . . . . . . . . 23
HiLoOpenClose Charts . . . . . . . . . . . . . . . . . 24
Polar Charts . . . . . . . . . . . . . . . . . . . . . . 25
Radar Charts . . . . . . . . . . . . . . . . . . . . . 26
Filled Radar Charts . . . . . . . . . . . . . . . . . . . 27

Olectra Chart OCX


Bubble Charts . . . . . . . . . . . . . . . . . . . . . 28
1.5 Understanding Data Layout . . . . . . . . . . . . . . . . . 29
1.6 Loading and Saving Charts and Data . . . . . . . . . . . . . 31

2 Special ChartType Properties . . . . . . . . . . . . . . . . . . . . . . . .33


2.1 Special Bubble Chart Properties . . . . . . . . . . . . . . . 34
2.2 Special Bar Chart Properties . . . . . . . . . . . . . . . . . 34
2.3 Special Stacking Bar Chart Properties . . . . . . . . . . . . . 35
2.4 Special Candle Chart Properties . . . . . . . . . . . . . . . 37
2.5 Special HiLoOpenClose Chart Properties . . . . . . . . . . . 38
2.6 Special Pie Chart Properties . . . . . . . . . . . . . . . . . 39
2.7 Special Polar Chart Properties . . . . . . . . . . . . . . . . 42

iii
3 Programming Considerations . . . . . . . . . . . . . . . . . . . . . . . .45
3.1 Object Hierarchy . . . . . . . . . . . . . . . . . . . . . 46
3.2 Programming With Objects . . . . . . . . . . . . . . . . . 46
3.3 Setting the Error Offset . . . . . . . . . . . . . . . . . . . 48
3.4 Programming In C++ . . . . . . . . . . . . . . . . . . . 49
3.5 Programming in Delphi . . . . . . . . . . . . . . . . . . 51
3.6 Using Array Data in Delphi . . . . . . . . . . . . . . . . . 52
3.7 Compatibility Issues . . . . . . . . . . . . . . . . . . . . 54
3.8 Upgrading Visual Basic 4.0 Projects from Olectra Chart 1.1 . . . . 54

4 Distributing Olectra Chart Applications . . . . . . . . . . . . . . . . .57


4.1 Distributing 32-bit OCX Applications . . . . . . . . . . . . . 58

5 Building a Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61


5.1 Axis Annotation Overview . . . . . . . . . . . . . . . . . 62
5.2 Annotating Axes . . . . . . . . . . . . . . . . . . . . . 63
Annotating with Values . . . . . . . . . . . . . . . . . 63
Using Custom Values Formatting . . . . . . . . . . . . . 64
Annotating with ValueLabels . . . . . . . . . . . . . . . 68
Annotating with PointLabels . . . . . . . . . . . . . . . 68
Annotating with TimeLabels . . . . . . . . . . . . . . . 69
Axis Labelling Programming Considerations . . . . . . . . . 72
5.3 Using a Time-axis . . . . . . . . . . . . . . . . . . . . . 73
5.4 Positioning Axis Annotation . . . . . . . . . . . . . . . . 73
5.5 Chart Orientation and Axis Direction . . . . . . . . . . . . . 74
5.6 Setting Axis and Data Bounds . . . . . . . . . . . . . . . . 76
5.7 Titling Axes and Rotating Axis Elements . . . . . . . . . . . 77
5.8 Logarithmic Axes . . . . . . . . . . . . . . . . . . . . . 78
Olectra Chart OCX

5.9 Adding a Second Y-axis . . . . . . . . . . . . . . . . . . 79


5.10 Changing the Axis Appearance . . . . . . . . . . . . . . . 80
5.11 Customizing Origins . . . . . . . . . . . . . . . . . . . . 81
5.12 Adding Grid Lines . . . . . . . . . . . . . . . . . . . . 82
5.13 Creating Stacking Charts . . . . . . . . . . . . . . . . . . 83
5.14 Creating Combination Charts using ChartGroups . . . . . . . . 85
5.15 Converting Data Coordinates . . . . . . . . . . . . . . . . 86
5.16 Storing Chart Descriptions in Files . . . . . . . . . . . . . . 88
5.17 Printing Charts . . . . . . . . . . . . . . . . . . . . . . 89

6 Working with Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .91


6.1 Data Overview . . . . . . . . . . . . . . . . . . . . . . 92
6.2 Loading Data From a File . . . . . . . . . . . . . . . . . . 95

iv Contents
6.3 Charting Data Directly From Your Program . . . . . . . . . . 96
6.4 Charting Data Using Data Binding . . . . . . . . . . . . . . 97
6.5 Hiding and Excluding Data Series . . . . . . . . . . . . . . 98
6.6 Fast Update Methods . . . . . . . . . . . . . . . . . . . 99
6.7 Copying Data . . . . . . . . . . . . . . . . . . . . . . 100
6.8 Batching Chart Updates . . . . . . . . . . . . . . . . . . 103
6.9 Double Buffering . . . . . . . . . . . . . . . . . . . . . 103

7 Customizing Chart Elements . . . . . . . . . . . . . . . . . . . . . . . . 105


7.1 Adding Header and Footer Titles . . . . . . . . . . . . . . . 106
7.2 Using a Legend . . . . . . . . . . . . . . . . . . . . . . 107
7.3 Changing ChartStyles . . . . . . . . . . . . . . . . . . . 108
7.4 Programming ChartStyles . . . . . . . . . . . . . . . . . . 110
7.5 Adding Images to Chart Elements . . . . . . . . . . . . . . 113
7.6 Changing the ChartArea Appearance . . . . . . . . . . . . . 114
7.7 Using Borders . . . . . . . . . . . . . . . . . . . . . . 115
7.8 Choosing Fonts . . . . . . . . . . . . . . . . . . . . . . 116
7.9 Setting Colors . . . . . . . . . . . . . . . . . . . . . . 116
7.10 Positioning Chart Elements . . . . . . . . . . . . . . . . . 117
7.11 Adjusting PlotArea Margins . . . . . . . . . . . . . . . . . 118
7.12 Adding the 3D Effect . . . . . . . . . . . . . . . . . . . 120
7.13 Resizing Forms . . . . . . . . . . . . . . . . . . . . . . 121
7.14 Using ChartLabels . . . . . . . . . . . . . . . . . . . . 122
7.15 Programming ChartLabels . . . . . . . . . . . . . . . . . 124
7.16 Adding Markers . . . . . . . . . . . . . . . . . . . . . 127
7.17 Programming Markers . . . . . . . . . . . . . . . . . . . 128

8 Programming User Interaction . . . . . . . . . . . . . . . . . . . . . . 131

Olectra Chart OCX


8.1 Programming Actions . . . . . . . . . . . . . . . . . . . 132
8.2 Returning Coordinate Values . . . . . . . . . . . . . . . . 136
8.3 Customizing the Property Editor . . . . . . . . . . . . . . . 138

9 Adding an Olectra Chart 2D Control to a Web Page . . . . . . . . 139


9.1 Getting Started . . . . . . . . . . . . . . . . . . . . . . 140
9.2 Creating a Web Page . . . . . . . . . . . . . . . . . . . 140
9.3 Creating a Licence Pack File . . . . . . . . . . . . . . . . 144
9.4 Packaging the Control . . . . . . . . . . . . . . . . . . . 144
9.5 Testing your Web Page . . . . . . . . . . . . . . . . . . . 146

Contents v
Part II: Using 3D Chart
10 Chart Basics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
10.1 Chart Terminology . . . . . . . . . . . . . . . . . . . . 152
10.2 Using the Property Editor . . . . . . . . . . . . . . . . . . 152
10.3 Interacting with the Chart . . . . . . . . . . . . . . . . . . 153
10.4 Choosing the Chart Type . . . . . . . . . . . . . . . . . . 154
10.5 3D Bar and 3D Surface Charts . . . . . . . . . . . . . . . . 155
10.6 Understanding Data Layout . . . . . . . . . . . . . . . . . 163
10.7 Loading and Saving Charts and Data . . . . . . . . . . . . . 167

11 Distributing Olectra Chart Applications . . . . . . . . . . . . . . . . 169


11.1 Distributing 32-bit OCX Applications . . . . . . . . . . . . . 170

12 Programming Considerations . . . . . . . . . . . . . . . . . . . . . . . 173


12.1 Object Hierarchy . . . . . . . . . . . . . . . . . . . . . 174
12.2 Programming with Objects . . . . . . . . . . . . . . . . . 174
12.3 Programming In C++ . . . . . . . . . . . . . . . . . . . 176
12.4 Programming in Delphi . . . . . . . . . . . . . . . . . . 179
12.5 Using Array Data in Delphi . . . . . . . . . . . . . . . . . 179
12.6 Compatibility Issues . . . . . . . . . . . . . . . . . . . . 181
12.7 Upgrading Visual Basic 4.0 Projects from Olectra Chart 1.1 . . . . 182

13 Building a Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183


13.1 Creating Histogram Bar Charts . . . . . . . . . . . . . . . 184
13.2 Annotating the Axes . . . . . . . . . . . . . . . . . . . . 184
13.3 Axis Labelling Programming Considerations . . . . . . . . . . 186
13.4 Setting Axis Bounds . . . . . . . . . . . . . . . . . . . . 187
Olectra Chart OCX

13.5 Titling Axes . . . . . . . . . . . . . . . . . . . . . . . 187


13.6 Customizing the PlotCube . . . . . . . . . . . . . . . . . 188
13.7 Positioning the Chart . . . . . . . . . . . . . . . . . . . 189
13.8 Modifying the 3D View . . . . . . . . . . . . . . . . . . 190
13.9 Adding and Formatting Grid Lines . . . . . . . . . . . . . . 190
13.10 Creating 4D Charts . . . . . . . . . . . . . . . . . . . . 192
13.11 Displaying 4D Data . . . . . . . . . . . . . . . . . . . . 193
13.12 Storing Chart Descriptions in Files . . . . . . . . . . . . . . 195
13.13 Printing Charts . . . . . . . . . . . . . . . . . . . . . . 195

14 Working with Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197


14.1 Data Overview . . . . . . . . . . . . . . . . . . . . . . 198
14.2 Grid and Irregular Grid Data . . . . . . . . . . . . . . . . 198

vi Contents
14.3 Point Data . . . . . . . . . . . . . . . . . . . . . . . . 201
14.4 Loading Data From a File . . . . . . . . . . . . . . . . . . 202
14.5 Charting Data Directly From Your Program . . . . . . . . . . 204
14.6 Copying Data . . . . . . . . . . . . . . . . . . . . . . 205
14.7 Double Buffering . . . . . . . . . . . . . . . . . . . . . 206

15 Customizing Chart Elements . . . . . . . . . . . . . . . . . . . . . . . . 207


15.1 Adding Header and Footer Titles . . . . . . . . . . . . . . . 208
15.2 Modifying the Surface Appearance . . . . . . . . . . . . . . 209
15.3 Formatting the Legend . . . . . . . . . . . . . . . . . . . 210
15.4 Legend Labels Programming Considerations . . . . . . . . . . 212
15.5 Formatting the Mesh . . . . . . . . . . . . . . . . . . . . 213
15.6 Using Borders . . . . . . . . . . . . . . . . . . . . . . 214
15.7 Choosing Fonts . . . . . . . . . . . . . . . . . . . . . . 215
15.8 Setting Colors . . . . . . . . . . . . . . . . . . . . . . 218
15.9 Positioning Chart Elements . . . . . . . . . . . . . . . . . 219
15.10 Form Resizing . . . . . . . . . . . . . . . . . . . . . . 220
15.11 Using ChartLabels . . . . . . . . . . . . . . . . . . . . 220
15.12 ChartLabels Programming Considerations . . . . . . . . . . . 223
15.13 Using ContourStyles . . . . . . . . . . . . . . . . . . . . 225
15.14 Customizing ContourStyles . . . . . . . . . . . . . . . . . 227
15.15 Adding Images to Chart Elements . . . . . . . . . . . . . . 229
15.16 Contour and Zone Projection . . . . . . . . . . . . . . . . 230
15.17 Customizing the Distribution Table . . . . . . . . . . . . . . 231
15.18 Distribution Table Programming Considerations . . . . . . . . . 232
15.19 Special Bar Chart Properties . . . . . . . . . . . . . . . . . 233
15.20 Special Scatter Plot Properties . . . . . . . . . . . . . . . . 233

16 Programming User Interaction . . . . . . . . . . . . . . . . . . . . . . 237

Olectra Chart OCX


16.1 Programming Actions . . . . . . . . . . . . . . . . . . . 238
16.2 Returning Coordinate Values . . . . . . . . . . . . . . . . 242
16.3 Customizing the Property Editor . . . . . . . . . . . . . . . 244

17 Adding an Olectra Chart 3D Control to a Web Page . . . . . . . . 245


17.1 Getting Started . . . . . . . . . . . . . . . . . . . . . . 246
17.2 Creating a Web Page . . . . . . . . . . . . . . . . . . . 246
17.3 Creating a License Pack File . . . . . . . . . . . . . . . . 249
17.4 Packaging the Control . . . . . . . . . . . . . . . . . . . 249
17.5 Testing your Web Page . . . . . . . . . . . . . . . . . . . 251

Contents vii
Contents
viii
Olectra Chart OCX
Preface
Introduction n Assumptions
Typographical Conventions Used in This Manual n Related Documents

Introduction
Windows contains many different pre-defined OLE controls such as buttons, scrollbars,
and list boxes. Conceptually, the 2D and 3D Charts add new OLE controls to Windows
that display data graphically in a window and can interact with a user.

The chart is made up of a logical hierarchy of objects, and each object has its own
properties and methods that determine how the chart looks and functions. Writing
programs using Olectra Chart is similar to writing any other kind of Windows program;
you now have one more control to work with.

2D Chart Control

2D Chart has properties which allow control of:


n Chart type (plot, area, bar, stacking bar, bubble, pie, HiLo, HiLoOpenClose, candle,
polar, radar, filled radar or combination).
n Header and footer title positioning, border style, text, font, and color.
n Chart Styles: line colors and patterns, fill colors and patterns, line thickness, point
style, size, and colors.
n Legend positioning, orientation, border style, anchor, font, and color.

Olectra Chart OCX


n Chart positioning, border style, color, width, height, and 3D effect.
n Axis labelling using data values, PointLabels, ValueLabels, or TimeLabels.
n Axis and data minimums and maximums, axis numbering methods, numbering and
ticking increments, grid increments, font, origins, axis directions and precisions.
n Chart orientation and axis direction.
n Placement of axes, annotation, and origins.
n Markers and ChartLabels.

2D Chart also provides several methods which:


n Allocate and load data containing the numbers to be displayed.
n Display new data very quickly in certain circumstances.
n Assist the developer in dealing with user-events.

9
3D Chart Control

3D Chart has properties which allow control of:


n Drawing (whether to draw the mesh, surface, contours and/or zones) and chart type
(surface, bar or scatter chart).
n Contour styles: line widths, colors and patterns, and fill colors.
n Distribution table and number of contour levels.
n Hidden-line display, surface colors and mesh colors.
n 3D rotation and perspective.
n Legend positioning, orientation, style, border style, anchor, font and color.
n Header and footer positioning, border style, text, font and color.
n Chart positioning, border style, color, width, and height.
n Axis maximums and minimums, fonts, gridlines, titles and labels.
n Window background and foreground color.

3D Chart also provides several methods which:


n Allocate and load data containing the numbers to be displayed.
n Assist the developer in dealing with user-events.
n Assist the developer in dealing with interactive rotation, zooming and shifting of the
3D view by the end-user.

Assumptions
This manual assumes that the reader is familiar with the Visual Basic programming
language. An understanding of basic Windows and OLE programming, including event-
driven programming, using standard Windows controls, and OLE automation is helpful to
use this manual. See page 11 for information on Windows programming references.
Olectra Chart OCX

10 Preface
Typographical Conventions Used in This Manual
Bold n Chart object, property, and method names.
n Language-specific keywords, constants, variables, and
function names.
n Commands that you enter at a command prompt.

Italic Text n Parameter names and information you specify.


n New terms as they are introduced, and to emphasize
important words.
n The names of other documents referenced in this manual,
such as the Getting Started with Olectra Chart booklet.

UPPERCASE n File and directory names, key names, and key sequences.

Monospace n Code examples, variables in body text, and error text.

Related Documents
The following documents are useful references for OLE application development:
n Microsoft Visual Basic Programmer’s Guide, Microsoft Corporation.
n Windows 3.1 SDK and Windows 3.1 API online documentation, Microsoft
Corporation.
n Inside OLE by Kraig Brockschmidt, Microsoft Press.
n Win32 SDK and Win32 API online documentation, Microsoft Corporation.

Olectra Chart OCX

Preface 11
Preface
12
Olectra Chart OCX
Olectra Chart OCX
1
Chart Basics
Chart Terminology n Using the Property Editor
Interacting with the Chart n Choosing the Chart Type
Understanding Data Layout n Loading and Saving Charts and Data

Successful charting requires that you are familiar with basic chart processes and
vocabulary, specifically as they relate to the 2D Chart control. The following topics cover
basic information that anyone who uses 2D Chart should be familiar with.

Olectra Chart OCX

15
1.1 Chart Terminology
The following shows the terms used to describe chart elements.

Header
Title
ChartArea

PlotArea

Y-Axis
Y2-Axis

X-Axis

Legend

Footer
Title

Pie charts contain the same elements except for the axes.

1.2 Using the Property Editor


The 2D Chart Property Editor enables you to customize the properties of any chart.
Olectra Chart OCX

Immediate Feedback Model

As you edit properties, the changes are immediately applied to the chart and displayed.
This enables you to quickly see how a change affects the chart so that you can make
further changes without leaving the Property Editor. However, once you have changed a
property the only way to “undo” it is to change the property back to its previous value.

16 Part I n Using 2D Chart


To Display the Property Editor:
n Click the right mouse button over any part of the chart and select “Properties...” from
the pop-up menu.

To Edit Chart Properties:


1. Select the tab that corresponds to the element of the chart that you want to edit.

Tabs contain one or more inner tabs that group related properties together. Some tabs
also contain a list that selects a specific object to edit.
2. If the tab contains a list on the left side, select the specific object to edit from that list.
3. Select the inner tab that corresponds to the kind of property you want to edit.
4. Click on a control and change the value of that property.

The change is immediately applied to the chart and displayed unless the IsBatched
property (located on the Control tab’s General inner tab) is set. When IsBatched is set,
click the Apply button to display property changes.
5. Make further changes to the same property or change other properties on this tab or
other tabs.

To Close the Property Editor:


n Click the OK or Cancel button to close the Property Editor.

1.3 Interacting with the Chart


You can interact with the chart as it is running to examine data more closely or visually
isolate a part of the chart. The interactions described here affect the chart displayed inside
the ChartArea; other chart elements like the header are not affected.

Olectra Chart provides users with 2 different mechanisms for zooming the chart: Graphics
zoom and Axis zoom. Performing a Graphics zoom enlarges the selected area of a chart,

Olectra Chart OCX


while not necessarily showing the axes. Performing an Axis zoom changes the minimum
and maximum data values to those selected, and redraws only that data with axes.

Special Notes
n The keyboard/mouse combinations that perform the different interactions can be
changed or removed by a programmer. The interactions described here may not be
enabled for your chart.
n Scaling, moving, or graphics zooming the chart sets the PlotArea margin properties,
so the chart will not automatically control margins anymore when other chart
properties change.

To Scale the Chart:


1. Press CTRL, and hold down both mouse buttons (or middle button on 3-button
mouse).

Chapter 1 n Chart Basics 17


2. Move the mouse down to increase chart size, or move the mouse up to decrease chart
size.

To Move the Chart:


1. Press SHIFT, and hold down both mouse buttons (or the middle button on 3-button
mouse).
2. Move the mouse to change the positioning of the chart inside the ChartArea.

To Graphics Zoom an Area of the Chart:


1. Press CTRL, and hold down left mouse button.
2. Drag mouse to select zoom area and release the mouse button.

To Axis Zoom the Chart:


1. Press SHIFT, and hold down left mouse button.
2. Drag the mouse to select the zoom area and release the mouse button.

To Rotate the Chart (Bar/pie charts displaying 3D effect only):


1. Hold down both mouse buttons (or middle button on 3-button mouse)
2. Move mouse up or down to change the 3D inclination
3. On bar charts, you can also move mouse left or right to change the 3D rotation angle

To Reset to Automatic Scale and Position:


n Press the “r” key to remove all scaling, moving, and zooming effects; chart regains
control of PlotArea margins.
Olectra Chart OCX

18 Part I n Using 2D Chart


1.4 Choosing the Chart Type
The 2D Chart can display data as one of 12 basic chart types. More specialized chart types,
such as Pareto charts and Gantt charts, can also be created using one of the basic 12 types.
A powerful feature of the chart is its ability to change the type of chart independently of
the data or other properties. For example, the same data can be displayed as a plot and then
later as a bar chart.

The following topics explain each of the chart types in detail.

1.4.1 Plot Charts


A plot chart draws each series as connected points of data. By customizing ChartStyles,
you can remove the connecting lines to emphasize the data values themselves, or remove
the points to emphasize the relationship between points. The series can be drawn
independently, or stacked. You can also customize the line and symbol properties of each
series.
Data Layout:
Array or General

Data point
(SymbolStyle)

Connecting line
(LineStyle)

Use the ChartGroup object’s IsStacked property to create a stacking Plot chart. Stacking
charts represent the data by stacking the values for each series on top of the values from
the previous series.

Olectra Chart OCX

For more information on stacking charts, see Stacking Bar Charts on page 21.

Chapter 1 n Chart Basics 19


To Change the Chart Type:
n Use the ChartType property to set the chart type for one ChartGroup. ChartType is
located on the ChartGroups tab’s General inner tab on the Property Editor.

1.4.2 Area Charts


An area chart draws each series as connected points of data, filled below the points. Each
series is drawn “on top” of the preceding series. The series can be drawn independently, or
stacked. Using ChartStyles, you can customize the fill properties of each series.

Use the ChartGroup object’s IsStacked property to create a stacking Area chart. Stacking
charts represent the data by stacking the values for each series on top of the values from
the previous series.
Olectra Chart OCX

For more information on stacking charts, see Creating Stacking Charts on page 83.

To Change the Chart Type:


n Use the ChartType property to set the chart type for one ChartGroup. ChartType is
located on the ChartGroups tab’s General inner tab on the Property Editor.

20 Part I n Using 2D Chart


1.4.3 Bar Charts
A bar chart draws each series as a bar in a cluster. The number of clusters is the number of
points in the data. Each cluster displays the nth data point in each series. Using
ChartStyles, you customize the fill properties of each series. You can also customize bar
cluster properties and 3D display properties.

Data Layout:
Array only

Bar fill
(FillStyle)

Point-labels
X-axis annotation

To Change the Chart Type:


n Use the ChartType property to set the chart type for one ChartGroup. ChartType is
located on the ChartGroups tab’s General inner tab on the Property Editor.

1.4.4 Stacking Bar Charts


A stacking bar chart draws each series as a portion of a stacked bar cluster, the number of
clusters being the number of points in the data. Each bar displays the nth data point in each
series. Positive values are displayed above the X-axis, and negative values are displayed
below the X-axis. Using ChartStyles, you customize the fill properties of each series. You
can also customize bar cluster properties and 3D display properties.

Data Layout:
Array only

Olectra Chart OCX


Bar fill
(FillStyle)

Point-labels
X-axis annotation

To Change the Chart Type:


n Use the ChartType property to set the chart type for one ChartGroup. ChartType is
located on the ChartGroups tab’s General inner tab on the Property Editor.

Chapter 1 n Chart Basics 21


1.4.5 Pie Charts
A pie chart draws each series as a slice in a pie. The number of pies is the number of points
in the data. Each pie displays the nth data point in each series. Using ChartStyles, you
customize the fill properties of each series. You can also customize special pie properties
and 3D display properties.

Data Layout:
Array only

Pie fill
(FillStyle)

Point-labels X-axis
annotation only

To Change the Chart Type:


n Use the ChartType property to set the chart type for one ChartGroup. ChartType is
located on the ChartGroups tab’s General inner tab on the Property Editor.

1.4.6 Candle Charts


A candle chart is a special type of HiLoOpenClose Chart used in financial applications to
show the opening, closing, high and low prices of a given stock. The "candle" (the solid
bar between the opening and closing values) represents the change in stock price from
opening to closing. With simple candle charts, a filled candle indicates a rising stock price
(close was higher than open), and a hollow candle indicates a falling stock price (open was
higher than close). With complex candle charts, the series2 FillColor represents a rising
stock price, and the series3 FillColor represents a falling stock price.

Using ChartStyles, you can customize the fill and line properties of each series.
Olectra Chart OCX

Data Layout:
Array only

Bar fill
(FillStyle)

To Change the Chart Type:


n Use the ChartType property to set the chart type for one ChartGroup. ChartType is
located on the ChartGroups tab’s General inner tab on the Property Editor.

22 Part I n Using 2D Chart


Programming Considerations

The four different series used to draw a candle chart creates a "logical" data set. When
programming chart labels, point and set labels and markers, make sure you refer to this
logical data set, and not the individual series themselves. For example, if there are 8 series
forming 2 different candles, series 0 refers to the first logical data set, and series 1 refers to
the second logical data set.

1.4.7 HiLo Charts


A HiLo chart combines 2 series to form a logical data set. HiLo charts are used primarily
in financial applications to show the high and low price for a given stock. The first series
of each pair in a HiLo chart represents the "high" value, and the second represents the
"low" value.

Using ChartStyles, you can customize the fill and line properties of each series.

Data Layout:
Array only

Line width
(LineStyle)

To Change the Chart Type:


n Use the ChartType property to set the chart type for one ChartGroup. ChartType is
located on the ChartGroups tab’s General inner tab on the Property Editor.

Programming Considerations

Olectra Chart OCX


The 2 different series used to draw a HiLo chart creates a "logical" data set. When
programming chart labels, point and set labels and markers, make sure you refer to this
logical data set, and not the individual series themselves. For example, if there are 4 series
forming 2 different HiLo bars, series 0 refers to the first logical data set, and series 1 refers
to the second logical data set.

Chapter 1 n Chart Basics 23


1.4.8 HiLoOpenClose Charts
HiLoOpenClose charts are similar to HiLo charts except that they combine 4 series to
form a logical data set. In addition to showing the high and low value of a stock, the third
and fourth series represent the stock’s opening and closing price, respectively.

Using ChartStyles, you can customize the fill and line properties of each series.

Data Layout:
Array only

Line width
(LineStyle)

To Change the Chart Type:


n Use the ChartType property to set the chart type for one ChartGroup. ChartType is
located on the ChartGroups tab’s General inner tab on the Property Editor.

Programming Considerations

The 4 different series used to draw a HiLoOpenClose chart creates a "logical" data set.
When programming chart labels, point and set labels and markers, make sure you refer to
this logical data set, and not the individual series themselves. For example, if there are 8
series forming 2 different HiLoOpenClose bars, series 0 refers to the first logical data set,
and series 1 refers to the second logical data set.
Olectra Chart OCX

24 Part I n Using 2D Chart


1.4.9 Polar Charts
A polar chart draws the x and y coordinates in each series as (theta,r), where theta is
amount of rotation from the origin and r is the distance from the origin. theta may be
specified in either degrees (default), radians or grads. Since the x-axis is a circle, the x-
axis maximum and minimum values are fixed. The series can be drawn independently, or
stacked.

Using ChartStyles, you can customize the line and symbol properties of each series.

Data Layout:
Array or General

Symbol style
(SymbolStyle)

Point-labels
X-axis annotation

Use the ChartGroup object’s IsStacked property to create a stacking Polar chart. Stacking
charts represent the data by stacking the values for each series on top of the values from
the previous series.

Olectra Chart OCX


For more information on stacking charts, see Creating Stacking Charts on page 83.

To Change the Chart Type:


n Use the ChartType property to set the chart type for one ChartGroup. ChartType is
located on the ChartGroups tab’s General inner tab on the Property Editor.

Chapter 1 n Chart Basics 25


1.4.10 Radar Charts
A radar chart draws the y value in each data set along a radar line (the x value is ignored).
If the data set has n points, then the chart plane is divided into n equal angle segments, and
a radar line is drawn (representing each point) at n/360 degree increments. By default, the
radar line representing the first point is drawn vertically (at 90 degrees). The series can be
drawn independently, or stacked.

Using ChartStyles, you can customize the line and symbol properties of each series.

Data Layout:
Array only

Point-labels
X-axis annotation

Symbol style
(SymbolStyle)

Use the ChartGroup object’s IsStacked property to create a stacking Radar chart. Stacking
charts represent the data by stacking the values for each series on top of the values from
the previous series.
Olectra Chart OCX

For more information on stacking charts, see Creating Stacking Charts on page 83.

To Change the Chart Type:


n Use the ChartType property to set the chart type for one ChartGroup. ChartType is
located on the ChartGroups tab’s General inner tab on the Property Editor.

26 Part I n Using 2D Chart


1.4.11 Filled Radar Charts
A filled radar chart draws the y value in each data set along a radar line (the x value is
ignored). If the data set has n points, the chart plane is divided into n equal angle
segments, and a radar line is drawn (representing each point) at n/360 degree increments.
Each series is drawn "on top" of the preceding series. The series can be drawn
independently, or stacked.Filled radar charts are the same as Radar charts, except that the
area between the origin and the points is filled.

Using ChartStyles, you can customize the fill and line properties of each series.

Data Layout:
Array only

Point-labels
X-axis annotation

Fill color
(FillStyle)

Use the ChartGroup object’s IsStacked property to create a stacking Radar chart. Stacking
charts represent the data by stacking the values for each series on top of the values from
the previous series.

Olectra Chart OCX


For more information on stacking charts, see Creating Stacking Charts on page 83.

To Change the Chart Type:


n Use the ChartType property to set the chart type for one ChartGroup. ChartType is
located on the ChartGroups tab’s General inner tab on the Property Editor.

Chapter 1 n Chart Basics 27


1.4.12 Bubble Charts
A bubble chart combines 2 series to draw a plot chart with varying point sizes. Bubble
charts are used to represent an additional data value at each point by changing its size. The
first series determines the cartesian position (as in a plot chart), and the Y-values from the
second series determine the size of the bubble at each point. The size of the points can be
encoded according to area or diameter. Using ChartStyles, you can specify the symbol
style and color, and whether connecting lines appear.

Data Layout:
Array or General

Symbol Style

Encoding Method:
Area or Diameter

To Change the Chart Type:


n Use the ChartType property to set the chart type for one ChartGroup. ChartType is
located on the ChartGroups tab’s General inner tab on the Property Editor.

Programming Considerations

The 2 different series used to draw a Bubble chart create a "logical" data set. When
programming chart labels, point and set labels and markers, make sure you refer to this
logical data set, and not the individual series themselves. For example, if there are 4 series
forming 2 different Bubble chart plots, series 0 refers to the first logical data set, and series
1 refers to the second logical data set.
Olectra Chart OCX

28 Part I n Using 2D Chart


1.5 Understanding Data Layout
The 2D Chart displays data supplied in one of two basic layouts, Array and General. Data
can come from many different sources, one common source being a data file. You can load
and save data files, and customize the data itself, using the Property Editor.

Array Layout

Use Array layout with bar, stacking bar, HiLo, HiLoOpenClose, bubble, candle, radar,
filled radar and pie charts. Plots, polar and area charts can also use Array data when the Y-
values in their series share common X-values.

Array Data
2 Series of 3 Points

Point Point Point


1 2 3
1 2 3 Common X-values
150 175 160 Series 1 Y-values
125 100 200 Series 2 Y-values

The important Array layout characteristics illustrated above are:


n The X-values of the points in each series are common to all series.
n Each series contains the same number of points (although by using a data hole, a
series can appear to have fewer points).

Note

Olectra Chart OCX


n When using Array data, do not try to set separate X values for each series, since each
series shares common X values.

General Layout

Use General layout with plots, polar area charts. Candle, bar, stacking bar, HiLo,
HiLoOpenClose, radar, filled radar and pie charts cannot display General data.

Chapter 1 n Chart Basics 29


General Data
2 Series, Maximum of 4 Points

4 Series 1 Num. Points


1 1.25 1.75 3 Series 1 X-values
120 140 160 170 Series 1 Y-values
2 Series 2 Num. Points
1.5 2.5 Series 2 X-values
130 190 Series 2 Y-values
Point 1 Point 2 Point 3 Point 4

The important General layout characteristics illustrated above are:


n The points in each series have their own X- and Y-values.
n Each series can contain a different number of points.

To Load and Save Data Files:


n Use the Load and Save buttons to load and save data files. These are located on the
ChartGroups tab’s Data inner tab on the Property Editor.

To Edit Data:
n Use the Layout, Hole, NumSeries, and NumPoints properties to set the format, size, and
hole value for the data. Use the ThisSeries and ThisPoint properties to select a specific
data point, and edit the values of the XValue and YValue properties. These properties
are also located on the ChartGroups tab’s Data inner tab on the Property Editor.
n Use the Edit Chart Series dialog to add, remove, hide or show a data series. Access
this dialog by clicking the Series button on the ChartGroups tab’s Data inner tab on the
Property Editor.
Olectra Chart OCX

n Use the Edit Chart Data dialog to edit X and Y values. Access this dialog by clicking
the Data button on the ChartGroups tab’s Data inner tab on the Property Editor.

30 Part I n Using 2D Chart


1.6 Loading and Saving Charts and Data
The two main components of any chart are the data it’s displaying and the properties that
control its appearance. You can save the current chart data and load new chart data from a
file. You can also load and save chart descriptions, which are settings for all of the chart
properties.

Olectra Chart includes sample chart descriptions and data files that you can use as
templates to build a more highly-customized chart.

To Load and Save Data:


n Use the Load and Save buttons on the ChartGroups tab’s Data inner tab on the
Property Editor to load and save data. See Understanding Data Layout on page 29 for
information on data layouts.

To Load and Save Chart Descriptions:


n Use the Load and Save buttons on the Control tab’s General inner tab on the Property
Editor to load and save chart descriptions.

Olectra Chart OCX

Chapter 1 n Chart Basics 31


Olectra Chart OCX

32 Part I n Using 2D Chart


2
Special ChartType Properties
Special Bubble Chart Properties n Special Bar Chart Properties
Special Stacking Bar Chart Properties n Special Candle Chart Properties
Special HiLoOpenClose Chart Properties n Special Pie Chart Properties
Special Polar Chart Properties

Certain ChartTypes have special properties or features that should be taken into
consideration when using them in your chart. For a detailed description of each
ChartType, see Choosing the Chart Type on page 19.

The following topics cover the special properties of each ChartType.

Olectra Chart OCX

33
2.1 Special Bubble Chart Properties
A bubble chart combines 2 series to draw a plot chart with varying point sizes. The
encoding method for the size of the bubbles, as well as their minimum and maximum size
can be specified.

Encoding Method

Use the EncodingMethod property to set whether to size the bubbles according to
diameter or area. When specifying the size of the bubble, both the diameter and area are
measured as a percentage of the total diameter or area of the plot area. Inverting these
values (making the Minimum value larger than the Maximum) draws large bubbles for
small values, and small bubbles for large values.

The EncodingMethod property is located on the ChartGroups tab’s Bubble inner tab on
the Property Editor.

Maximum and Minimum Size

The maximum and minimum allowable size for bubbles can be set using the
MaximumSize and MinimumSize properties respectively. These properties are located
on the ChartGroups tab’s Bubble inner tab on the Property Editor.

2.2 Special Bar Chart Properties


A bar chart draws each series as a bar in a cluster. You can customize the sizing and
spacing of the clusters for bar and stacking bar charts.

Cluster Overlap

Use the bar ClusterOverlap property to set the amount that bars overlap each other in a
cluster. The value represents the percentage of bar overlap, with valid values between -100
and 100.
Olectra Chart OCX

34 Part I n Using 2D Chart


Cluster Width

Use the bar ClusterWidth property to set the space used by each bar cluster. The value
represents the percentage available space, with valid values between 0 and 100.

All Bar properties are located on the ChartGroups tab’s Bar inner tab on the Property
Editor.

2.3 Special Stacking Bar Chart Properties


A stacking bar chart draws each series as a portion of a stacked bar cluster, the number of
clusters being the number of points in the data. Each bar displays the nth data point in each
series. Positive values are displayed above the X-axis, and negative values are displayed
below the X-axis. You can create floating bars by either hiding or excluding specific data
sets, or draw the chart as a 100 percent stacking bar chart.

Floating Bar Charts

Each series in a stacking bar chart can be either hidden (where the series is charted as a
blank set) or excluded (where the series is not considered part of the chart data). Use the

Olectra Chart OCX


SeriesDisplay property of the Chart2DData Object to determine if each series in the chart
is either shown, hidden or excluded.

In the following examples, the third series is shown, hidden, and then excluded.

Chapter 2 n Special ChartType Properties 35


Olectra Chart OCX

100 Percent Stacking Bar Charts

Use the IsYAxis100Percent and IsY2Axis100Percent properties of the Axis object to scale
the Y axis of stacking bar charts to a common 100 percent value. When
IsYAxis100Percent or IsY2Axis100Percent is False, the actual series data is used. When

36 Part I n Using 2D Chart


IsYAxis100Percent or IsY2Axis100Percent is True, the data is scaled so that all bars are
the same height and each series is scaled to a total of 100 percent.

Negative values

For stacking bar charts, series with negative values are displayed below the X-axis, as is
shown in the example below:

2.4 Special Candle Chart Properties Olectra Chart OCX

A candle chart draws 4 series together to form a logical data set. For example, the first and
second series show the high and low value of a stock, and the third and fourth series
represent the stock’s opening and closing price. You can specify how the candle is drawn
by setting the IsComplex property.

Complex Candle Charts

Use the candle IsComplex property to specify the type of candle chart drawn. Simple
candle charts (IsComplex is False) are drawn with a filled candle to indicate a falling

Chapter 2 n Special ChartType Properties 37


stock price (open was higher than close), and a hollow candle to indicate a rising stock
price (close was higher than open). Complex candle charts are drawn with the Series2
FillStyle color to indicate a rising stock price, and the Series3 FillStyle color to indicate a
falling stock price.

All candle properties are located on the ChartGroups tab’s Candle inner tab on the
Property Editor.

2.5 Special HiLoOpenClose Chart Properties


A HiLoOpenClose chart draws 4 series together to (typically) represent the high, low open
and close value for a stock. The first and second series show the high and low value of a
stock, and the third and fourth series represent the stock’s opening and closing price. You
can specify how the open and close tick marks are displayed on the chart.

To Display Open and Close Ticks:

Use the IsShowingOpen, IsShowingClose and IsOpenCloseFullWidth properties to


determine how the open and close tick marks are displayed. Enable IsShowingOpen to
Olectra Chart OCX

display the open tick marks (Series 3) and enable IsShowingClose to display the close tick
marks (Series 4). Enable IsOpenCloseFullWidth to draw the open and close tick marks
on both sides of the vertical range.

38 Part I n Using 2D Chart


All HiLoOpenClose properties are located on the ChartGroups tab’s HiLoOpenClose
inner tab on the Property Editor.

2.6 Special Pie Chart Properties

Olectra Chart OCX


Pie charts are quite different from the other chart types you can use. They do not have the
concept of a two-dimensional grid or axes. Pie charts also introduce a special category
called ”Other”, into which all data values below a certain threshold are grouped. You can
customize properties of the Other slice and other properties unique to pie charts.

Building the “Other” Slice

Pie charts are often more effective if unimportant values are grouped into an “Other”
category. Use the pie ThresholdMethod property to select the grouping method to use.
“SliceCutoff” is useful when you know the data value that should be grouped into the
“Other” slice. “Percentile” is useful when you want a certain percentage of the pie to be
devoted to the “Other” slice.

Use the ThresholdValue property to specify the value used for the ThresholdMethod.
These properties are located on the ChartGroups tab's Pie inner tab on the Property
Editor.

Chapter 2 n Special ChartType Properties 39


ThresholdValue = 0.0
No “Other” slice

Slice Cutoff method


ThresholdValue = 10.0

Percentile method
ThresholdValue = 30.0
Olectra Chart OCX

Use the MinSlices property to finetune the number of slices displayed before the “Other”
slice. For example, when set to 5, the chart tries to display 5 slices before grouping data
into the “Other” slice.

Note:
n You can use a value of "0" to represent the "other" slice in code that would normally
expect a set value. For example, the series value returned by CoordToDataIndex will
be 0 when the other slice is picked.

40 Part I n Using 2D Chart


“Other” Slice Style and Label

Use the FillStyle Pattern and Color properties to define the appearance of the “Other”
slice. These properties are located on the ChartStyles tab’s FillStyle inner tab on the
Property Editor.

Use the Text label property to change the label of the “Other” slice. Text is located on the
ChartGroups tab’s Labels inner tab on the Property Editor.

Pie Ordering

Use the SortOrder property to specify whether to display slices largest-to-smallest,


smallest-to-largest, or the order they appear in the data. SortOrder is located on the
ChartGroups tab’s Pie inner tab on the Property Editor.

Starting Angle

Use the StartAngle property to specify the angle at which the slices for the first series
start. The default angle is 135 degrees. StartAngle is located on the ChartGroups tab’s
Pie inner tab on the Property Editor.

Exploding Pies

A slice of a pie chart can be emphasized by exploding it, which extrudes the slice from the
rest of the pie. Use the Offset property to set the exploded slice’s offset from the center of

Olectra Chart OCX


the pie. The offset is measured as a percentage of the radius of the pie.

Chapter 2 n Special ChartType Properties 41


Exploding slices must be set programmatically, and can be set by series, or by a single
slice. To set the properties for an exploding slice for a specific slice of all pies, access the
Slice object through the Style object for the corresponding series.
‘ Sets the offset for the first series to 10% of the pie’s radius
Chart2D1.ChartGroups(1).Styles(1).Slice.Offset = 10
‘ Resets the exploded slices.
Chart2D1.ChartGroups(1).Styles(1).Slice.Offset = 0

To set the properties for an exploding slice for a single point, access the Slice object
through the PointStyles collection. The first number in the PointStyle’s Item method
specifies the Series, and the second number specifies the point.
‘ Sets the offset for the third point of the second
‘ series to 15% of the pie’s radius
Chart2D1.ChartGroups(1).PointStyles.Item(2,3).Slice.Offset = 15
‘ Resets the exploded slice.
Chart2D1.ChartGroups(1).PointStyles.Item(2,3).Slice.UseDefault = True

Missing Slices

A slice of the pie chart can be excluded, so that an empty gap in the pie appears where the
slice would otherwise be.

Missing slices must be set programmatically, and can be set by individual slices via the
PointDisplay property of the ChartGroup object. Unlike exploding pies, missing slices
cannot be specified by series. The PointDisplay property takes Display Constant values.
Olectra Chart OCX

‘ PointStyles do not exist by default. Add them before using them.


Chart2D1.ChartGroups(1).PointStyles.Add 1, 1
‘ Sets the first point of the first series to be missing.
Chart2D1.ChartGroups(1).PointDisplay(1,1) = oc2dDisplayHide

Note:

Setting the PointDisplay property to ocdDisplayExclude has no effect.

2.7 Special Polar Chart Properties


A polar chart draws the x and y coordinates in each series as (theta,r), where theta is
amount of rotation from the origin and r is the distance from the origin. The x-axis is
represented in either degrees, radians, or grads.

42 Part I n Using 2D Chart


Full or Half-Range X-Axis

Use the IsHalfRange property to determine if the x-axis is represented in full-range


(where IsHalfRange is false) or half-range (where IsHalfRange is true).

The IsHalfRange property is located on the ChartGroups tab’s Polar inner tab on the
Property Editor.

Setting the Origin

Use the OriginBase property to set the number of degrees along the Y-axis to place the X-
axis. OriginBase can be from 0 to 359 degrees.

Olectra Chart OCX

The OriginBase property is located on the Axes tab's Polar/Radar inner tab.

Chapter 2 n Special ChartType Properties 43


Specifying the Annotation Angle

Use the AnnotationAngle property to specify where on the Y-axis to place the annotation.
The AnnotationAngle property is located on the Axes tab’s Polar/Radar inner tab.

Allowing Negative Values

Use the AxisAllowNegative property to specify whether or not to permit negative values
for r. When AxisAllowNegative is enabled, the chart shifts the axis to accommodate
negative values. When AxisAllowNegative is disabled, a negative radius is interpreted as
a positive radius rotated 180 degrees.
Olectra Chart OCX

The AxisAllowNegative property is located on the Axes tab’s Polar/Radar inner tab

44 Part I n Using 2D Chart


3
Programming Considerations
Object Hierarchy n Programming With Objects
Setting the Error Offset n Programming In C++
Programming in Delphi n Using Array Data in Delphi
Compatibility Issues n Upgrading Visual Basic 4.0 Projects from Olectra Chart 1.1

Controlling the chart in an application program is generally quite straightforward once you
are familiar with the programming basics and the object hierarchy. For most chart objects,
the examples and overviews in the Object Reference provide all the information needed to
program them.

Olectra Chart OCX

45
3.1 Object Hierarchy
The following are the high-level objects defined as children of the 2D Chart control:

Chart2D Legend Object Collection

Header
Title Object

ChartGroups

Data

ChartArea

Axes

PlotArea

Legend

Footer
Title Object

ChartLabels Not shown here...

3.2 Programming With Objects


Olectra Chart OCX

When you create a 2D Chart control, a Chart2D object is created. This object, like other
Visual Basic objects, has properties defined for it. You can change the behavior of your
chart by changing these properties.

The Object Reference describes the Chart2D object, the sub-objects automatically created
when the Chart2D object is created, and the properties defined for each object. Properties
which are read-only are indicated as such in their object description.

A Simple Example

The following statement turns off the chart’s double-buffering feature by setting the
IsDoubleBuffered property of the Chart2D object to False:
Chart2D1.IsDoubleBuffered = False

By default, the first Chart2D object created in an application is named Chart2D1, the
second is named Chart2D2, and so on. This is standard Visual Basic behavior.

46 Part I n Using 2D Chart


Navigating the Object Hierarchy

As with other Visual Basic objects, you can access a specific object by navigating its
object hierarchy. For example, the following code retrieves the background color of the
main body of the chart:
Dim BackColor As Long
BackColor = Chart2D1.ChartArea.Interior.BackgroundColor

Default Properties

If an object is referenced in a statement without a property being specified, the object’s


default property is assumed. For example, the default property for the Border object is the
Type property, which means that the following two statements are equivalent:
Chart2D1.Header.Border.Type = oc2dBorderShadow
Chart2D1.Header.Border = oc2dBorderShadow

Both of the above statements change the value of the Type property to
oc2dBorderShadow.

Using Collections

Many 2D Chart objects are organized into collections. For example, the chart axes are
organized into the Axes collection.

All collections are indexed by number, with 1 referring to the first element of the
collection, 2 the second, and so on. If the objects in a collection have a Name property, the
collection can also be indexed by object name. For example:
Chart2D1.ChartArea.Axes("X").Max = 25.1

This statement accesses the axis named “X” (the X-axis), and sets the maximum value of
this axis to 25.1. Note that Visual Basic recognizes the default Item property of the
collection, whereas other environments may require an explicit reference to the Item
property:
Chart2D1.ChartArea.Axes.Item("X").Max = 25.1

Olectra Chart OCX


Some 2D Chart collections are static, whereas others are dynamic. Dynamic collections
have Add and Remove methods defined. Elements cannot be added to or removed from
static collections.

For more details on the behavior of Visual Basic collections, refer to the Visual Basic
documentation.

Accessing Each of the Elements of a Collection

Visual Basic enables you to access each of the elements of a collection in turn using the
For Each statement. For example, the following code positions all of the chart labels over
their attachment locations:
For Each Label in Chart2D1.ChartLabels
Label.Anchor = oc2dAnchorCenter
Next

Chapter 3 n Programming Considerations 47


Each collection defines a Count property whose value is the current number of objects in
the collection. You can use Count to access some or all of the elements of a collection. For
example, the following is another way to position all of the chart labels:
Dim Counter As Integer
For Counter = 1 To Chart2D1.ChartLabels.Count
Chart2D1.ChartLabels(Counter).Anchor = oc2dAnchorCenter
Next

Calling Methods

To call a 2D Chart method, access the object with which it is associated. For example, the
following statement uses the DataCoordToCoord method, defined by the ChartGroups
collection, to convert the chart coordinates (5.1, 10.2) to their equivalent pixel
coordinates:
Chart2D1.ChartGroups(1).DataCoordToCoord 5.1, 10.2, PixelX, PixelY

Each method is described in the help page for its associated object. For example,
DataCoordToCoord is described in the ChartGroups collection help page.

3.3 Setting the Error Offset


2D Chart ensures that its error numbers do not overlap existing Visual Basic error numbers
by adding a special error offset to each of its error numbers. This error offset is specified
by the ErrorOffset property of the Chart2D object.

If the chart’s error numbers overlap the error numbers generated by another Visual Basic
custom control, you can change this ErrorOffset property. Note that you will need to
change the ErrorOffset property of every instance of a Chart2D object that you create.
Olectra Chart OCX

48 Part I n Using 2D Chart


3.4 Programming In C++
The 2D Chart can be used in the Visual C++ version environment (version 4.0 or greater),
which creates programs written in the C++ programming language. The chart will not
work properly with earlier versions of Visual C++.

To Insert the 2D Chart Control into an OLE Container Project:

In the Visual C++ environment, a 2D Chart control behaves like any other OLE control,
which means that it can be incorporated into a container such as a dialog or an application
window.

To add the 2D Chart control to an OLE container project, use Component Gallery as
follows:
1. From the Insert menu, select Component. The Component Gallery dialog box ap-
pears.
2. Select the OLE Controls tab.
3. Select the 2D Chart control icon in the Component Gallery window.
4. Click the Insert button. This displays a Confirm Classes dialog box, which lists the
2D Chart control classes.
5. Click the OK button to accept the class generated by Component Gallery.
6. Click the Close button to close Component Gallery.

At this point, the 2D Chart wrapper class, CChart2D, is added to your project. This means
that the 2D chart control can now be added to your application’s main dialog box, as
shown below.

To Add the 2D Chart Control to the Main Dialog Box:

To add the 2D Chart control to your dialog template, perform the following steps:
1. Load the container project into Developer Studio.
2. In the Project Workspace window, click the ResourceView button.

Olectra Chart OCX


3. Open the Dialog folder.
4. Double-click the main dialog box template.
5. Choose the 2D Chart control icon from the Controls toolbar.
6. Position the mouse in the dialog box, and click to position the 2D Chart control.
7. From the File menu, choose Save All.

To Add a Member Variable to a Project:

Once the 2D Chart control has been added to the project and placed in the dialog box
container, you can access this control from other parts of your project. The easiest way to
do this is to create a member variable of the dialog class, CContainerDlg, of type
CChart2D (the 2D Chart wrapper class). To create a member variable, perform the
following steps:

Chapter 3 n Programming Considerations 49


1. Load the OLE container project.
2. Choose ClassWizard from the View menu.
3. Choose the Member Variables tab.
4. From the Class Name list box, select the main dialog class (CContainerDlg).
5. From the ControlIDs list box, select the control ID of the embedded 2D Chart con-
trol.
6. Click the Add Variable button to display the Add Member Variable dialog box.
7. In the Member Variable edit box, enter a name.
8. Select Control from the Category list box.
9. Click OK to close the Add Member Variables dialog box.
10. Click OK to exit ClassWizard.

The member variable you have just added can now be used to access the embedded 2D
Chart control.

Programming the 2D Chart Control

At this point, you are ready to actually program the control. To do this, note the following:
n A wrapper class header file is defined for each 2D Chart object. Examples: the
wrapper class header file for the Chart2D object is named chart2d.cpp, and the
wrapper class header file for the Border object is named border.cpp.
n The wrapper class header file for an object defines two routines for each of its
properties: a routine that gets the current value of the property, and a routine that sets
the value of the property. For example, the chart2d.cpp file defines two routines for
the IsDoubleBuffered property of the Chart2D object: GetIsDoubleBuffered(),
which gets the current value of the IsDoubleBuffered property, and
SetIsDoubleBuffered(), which sets the value of the IsDoubleBuffered property.
n Methods defined for an object are included in the wrapper class header file for the
object.
Olectra Chart OCX

Setting an Object Property

The following statement sets the background color of the chart area. The variable m_chart
contains an instance of a Chart2D object (the main 2D Chart object).
m_chart.GetChartArea().GetInterior().SetBackgroundColor
(RGB(247,206,151));

This statement navigates the 2D Chart object hierarchy by retrieving the values of
successive properties. First, the value of the ChartArea property is retrieved, which is a
ChartArea object. Then, this ChartArea object’s Interior property is retrieved, which is
an Interior object. Finally, the Interior object’s BackgroundColor property is set.

Using Collections

Many 2D Chart objects are organized into collections. For example, the chart axes are
organized into the Axes collection.

50 Part I n Using 2D Chart


To access a particular element of a collection, specify the index which uniquely identifies
this element. For example, the following code changes the maximum value of the X axis
to 25.1:
Caxis axisX(m_chart.GetChartArea().GetAxes().GetItem(COleVariant("x")));
axisX.GetMax().SetValue(25.1);

Note that the index 1 refers to the first element of a collection.

Calling Methods

To call a 2D Chart method, access the object with which it is associated. For example, the
following statement uses the DataCoordToCoord method, defined by the ChartGroups
collection, to convert the chart coordinates (5.1, 10.2) to their equivalent pixel
coordinates:
long pixelx, pixely;
m_chart.GetChartGroups().GetItem(COleVariant(short(1)))
.DataCoordToCoord(5.1, 10.2, &pixelx, &pixely);

Each method is described in the help page for its associated object. For example,
DataCoordToCoord is described in the ChartGroups collection help page.

Demo Programs

Sample C++ programs, created using Visual C++, are included as part of the Olectra Chart
distribution. These sample programs are contained in the \CHART\2D\DEMOS\VC
directory.

3.5 Programming in Delphi


The 2D Chart can be used in the Delphi version 3.0 and later environment, which creates
programs written in the PASCAL programming language. The following are special
considerations that should be taken into account when programming with Olectra Chart.

Olectra Chart OCX


Adding Olectra Chart 2D OCX to Delphi 4
1. Run Delphi.
2. On the Component menu, click Import ActiveX Control.... The Import ActiveX dialog
appears.
3. In the list of controls select Olectra Chart 2D Control (Version 6.0).
4. Click the Install button. The Install dialog appears.
5. Select an existing package or create a new one for the control.
6. Click the OK button to install the control. The confirm dialog appears.
7. Click Yes to build and install the Control.

Adding the Olectra Chart 2D OCX to Delphi 3


1. Run Delphi.

Chapter 3 n Programming Considerations 51


2. On the Component menu, click Install. The Install Components dialog appears.
3. Click the OCX button. The Import OLE Control dialog appears.
4. In the Import OLE Control dialog, select the Olectra 2D OCX and click OK. The In-
stall Components dialog appears.
5. Click OK. Delphi adds the Olectra Chart OCX to the OCX tab of the Components
toolbar.

3.6 Using Array Data in Delphi


In order to pass Array data to Olectra Chart from Delphi, you must use Delphi’s Variant-
type arrays. For more information on using Variant arrays in Delphi, refer to the "OLE
Automation Example" chapter of your Delphi User’s Guide. The following code shows
how to use Array data with Delphi:
x: OleVariant;
y: OleVariant;

// Create the variant arrays


x := VarArrayCreate([1,10000], varDouble);
y := VarArrayCreate([1,10000,1,16], varDouble);

// Set up the Chart with the correct number of series and points.
Chart2D1.ChartGroups.Item(1).Data.NumSeries := 16;
Chart2D1.ChartGroups.Item(1).Data.NumPoints(1) := 10000;

// Load the x and y arrays appropriately


{ ... code omitted ... }

// Pass data to the Chart


Chart2D1.ChartGroups.Item(1).Data.CopyFromXVector( 1, x );
Chart2D1.ChartGroups.Item(1).Data.CopyFromYArray(y);

// Release the variants


x := Unassigned;
y := Unassigned;
Olectra Chart OCX

Upgrading Olectra Chart Projects from Delphi 2

Due to the changes made when Borland introduced Delphi 3 and Delphi 4, there are a
number of coding changes that are required to use Olectra Chart. Below is the current list
of known changes that may be required:
1. The name of the file inserted into the code by the IDE on the uses line has changed
from OLCH2X32 to OlectraChart2D_TLB.
2. In order to use the Safe Array functions, you now have to declare the arrays for use
with these functions as type OleVariant instead of Variant.
3. Code located in the OnCreate() event that used to work fine in Delphi 2.01 will not
work in later versions. There are two work-arounds for this (Borland is currently
working on a Patch that should hopefully cure this problem):
Solution A:

52 Part I n Using 2D Chart


Around any code that deals with Olectra Chart, use the Chart2[3]D1.IsBatched
:= True/False; statements to put the Chart in Batch mode.

Solution B:

Move the code to the OnActivate() event and use a flag to ensure that this code only
runs once.
4. Due to the stronger typing introduced in Delphi 3 and Delphi 4, there are five methods
in Olectra Chart that have been renamed automatically by Delphi. The following is the
Conversion Log appearing at the top of a Delphi 3 PASCAL file created during the
OCX import process:

’Label’ is a reserved word. Label changed to Label_


’Type’ is a reserved word. IBorder.Type changed to Type_
’Unit’ is a reserved word. ITimeScale.Unit changed to Unit_
’Label’ is a reserved word. IValueLabel.Label changed to Label_
’String’ is a reserved word. Parameter ’String’ in
IStringCollection.Add changed to ’String_’

Note that although these changes still occur in Delphi 4, a Conversion Log is not
generated.
5. In order to access the font object associated with various objects in Olectra Chart, you
now have to access them using a Variant. Here is an example:
var
f: Variant;
begin
f := Chart2D1.Header.Font;
f.Name := ’Times New Roman’;
f.Size := 15;
f.Bold := True;
f := UnAssigned;
end;

6. Accessing properties that are of the following types involves an extra reference in
Delphi 3 that was not required in Delphi 2.01.
n The additional reference is the explicit use of ’Value’. Here is a list of the objects

Olectra Chart OCX


that require this:

DerivedDouble:
Chart2D1.ChartArea.Axes[’X’].Max.Value := 50;

DerivedLong:
Chart2D1.Header.Location.Top.Value := 5;

DerivedString:
Chart2D1.ChartArea.Axes[’X’].TimeScale.Format.Value =
’dd/mm/yy’;
n Additionally, the Text object requires an extra reference as well. The additional
reference is the explicit use of ’Text’. Here are a couple examples:
Chart2D1.ChartLabels.Item[LabelName].Text.Text := ’’;
Chart2D1.Header.Text.Text := ’Rain Fall Data’;

Chapter 3 n Programming Considerations 53


7. When accessing the data object in Olectra, Delphi 2.01 lets you do it using either
round brackets () or square brackets []. In Delphi 3 you must use square brackets when
accessing the data object. Here is an example:
Chart2D1.ChartGroups.Item[1].Data.x[1, 1] := 1;
Chart2D1.ChartGroups.Item[1].Data.y[1, 1] := 5;

Note
n In the above examples, it also shows that the .Item[] reference also requires the use of
square brackets now, where in Delphi 2.01 it also allowed the use of round brackets ().

3.7 Compatibility Issues


The following compatibility issues affect the behavior of the 2D Chart control in various
Windows environments.

Predefined Dash Styles used in Windows 95/98

In the Windows 95/98 environments, lines are drawn using the dash styles predefined by
Microsoft Windows. As a consequence, some 2D Chart dash styles are not displayed
exactly as specified. The following dash styles are affected:
n The short dash pattern (oc2dLineShortDash) is represented as a dash-dot pattern.
n The long-short-long dash pattern (oc2dLineLongShortLongDash) is represented as a
dash-dot-dot pattern.

Non-solid lines of thickness greater than 1 in Windows 95/98

In the Windows 95/98 environment, any non solid lines of thickness greater than 1 are
rendered as lines with thickness 1.

3.8 Upgrading Visual Basic 4.0 Projects from Olectra Chart 1.1
Olectra Chart OCX

For most development environments, upgrading your chart from version 1.1 of the OCX
to version 6.0 is as easy as loading the .OC2 file into your environment with Olectra Chart
6.0 installed. Saving the file will automatically update your project.

Projects created with Visual Basic 4.0 record the version of the OCX inside the .VBP file.
After you upgrade to Olectra Chart 6.0, your projects containing Olectra Chart 1.1 will not
load correctly. The log file will contain this message:
Class OlectraChart2D.Chart2D of control Chart was not a loaded control
class.

To Update your .VBP File:


1. Open the Visual Basic 4.0 project file (.VBP) in Notepad (or another text editor). You
will need to change the line reading:
Object={92D71E90-25A8-11CF-A640-9986B64D9618}#1.1#0; OLCH2X32.OCX

54 Part I n Using 2D Chart


2. Replace the version number 1.1 with 6.0, as in the following:
Object={92D71E90-25A8-11CF-A640-9986B64D9618}#6.0#0; OLCH2X32.OCX
3. Save the .VBP file. Now the project will load correctly.
4. Note that this is only required if you are using Visual Basic 4.0. Visual Basic 5.0 and
up will detect and correct this problem automatically.

Olectra Chart OCX

Chapter 3 n Programming Considerations 55


Olectra Chart OCX

56 Part I n Using 2D Chart


4
Distributing Olectra Chart Applications
Distributing 32-bit OCX Applications

The following topics cover distributing applications created with the 32-bit
Olectra Chart control.

Olectra Chart OCX

57
4.1 Distributing 32-bit OCX Applications
You can freely distribute any applications that you create with Olectra Chart. An Olectra
Chart application needs its dynamic link libraries present on the system it is run on.

Distributable Files

When distributing 2D 32-bit OCX applications, you may only distribute the following file:
OLCH2X32.OCX

The following MFC and OLE support files must also be installed on the end-user’s system
for Olectra Chart OCX applications to work:
MFC42.DLL
MSVCRT.DLL
OLEPRO32.DLL
OLEAUT32.DLL

If OLEPRO32.DLL has not previously been installed, it must be registered before it can
be used. To register this DLL, follow the same steps used to register the Olectra Chart
Control. If this DLL is installed already, you can assume that it has been registered.

Distributing Olectra Chart in Visual Basic

In order to distribute Olectra Chart using VB 6, you must run the Package & Deployment
wizard (located in your VB directory\Wizards\PDWizard ) once to create a file vb6dep.ini.
For VB5, you must run the Setup wizard (located in your VB directory\Setupkit\kitfile32)
once to create a file vb5dep.ini. The following dependences must be added to this file so
you can distribute an application created with Olectra Chart:
[OLCH2X32.OCX]
Register=$(DLLSelfRegister)
Dest=$(WinSysPath)
Uses1=MFC42.DLL
Uses2=MSVCRT.DLL

[OLCH3X32.OCX]
Register=$(DLLSelfRegister)
Olectra Chart OCX

Dest=$(WinSysPath)
Uses1=MFC42.DLL
Uses2=MSVCRT.DLL

[MFC42.DLL]
Register=$(DLLSelfRegister)
Dest=$(WinSysPath)

[MSVCRT.DLL]
Dest=$(WinSysPath)

Note that the above file contains the dependencies for both the 2D and 3D Olectra Chart
controls.

Once you have added the above dependencies, run the Setup wizard and follow the
directions on each screen. On the Confirm Dependency screen, make sure you include the
OCX files.

58 Part I n Using 2D Chart


In VB 6, on the Included Files Screen, make sure the following files have been included:
OLCH2X32.OCX
OLCH3X32.OCX
MSVCRT.DLL
MFC42.DLL

In VB 5, on the File Summary screen, make sure the following files have been included:
OLCH2X32.OCX
OLCH3X32.OCX
MSVCRT.DLL
MFC42.DLL

End-user Online Help

If your applications allow the end-user to access the 2D Chart Property Editor, you should
also distribute the Property Editor’s end-user online help, contained in the following files:
OLCH2D-U.HLP
OLCH2D-U.CNT

If you have disabled end-user property editing, you do not need to distribute these files.

Registering the 2D Chart Control

Before the 2D Chart control can be used in an application, appropriate entries must be
added to the Microsoft Windows registration database.

To register the control for 32-bit applications, pass the complete path and filename of the
Olectra Chart OCX file, OLCH2X32.OCX, to the REGSVR32.EXE control registration
program.

Olectra Chart OCX

Chapter 4 n Distributing Olectra Chart Applications 59


Olectra Chart OCX

60 Part I n Using 2D Chart


5
Building a Chart
Axis Annotation Overview n Annotating Axes n Using a Time-axis
Positioning Axis Annotation n Chart Orientation and Axis Direction n Setting Axis and Data
Bounds
Titling Axes and Rotating Axis Elements n Logarithmic Axes n Adding a Second Y-axis
Changing the Axis Appearance n Customizing Origins n Adding Grid Lines
Creating Stacking Charts n Creating Combination Charts using ChartGroups
Converting Data Coordinates n Storing Chart Descriptions in Files n Printing Charts

Building a chart is quite easy. The chart can automatically set properties based on the data,
so axis numbering and data display usually don’t need much customization.

The following topics cover information on the various steps required to create a chart.

Olectra Chart OCX

61
5.1 Axis Annotation Overview
The annotation along each axis is an extremely important part of any chart. The 2D chart
can annotate any axis with numbers based on the data (Values) or with text you supply
that is displayed at axis coordinates (ValueLabels). The X-axis can also be annotated with
text for each point in the data (PointLabels) or with automatically-generated time values
(TimeLabels).

Whatever annotation method you choose for each axis, the chart goes to considerable
effort to automatically produce the most natural annotation possible, even as chart data
changes. You can change annotation properties to finetune this process.

Values Annotation

Perhaps the most common type of annotation, Values automatically generates numeric
annotation based on the data itself. Values annotation can be used for any axis, with any
chart type, and with any data layout.

See Annotating with Values on page 63 for details on using Values annotation.

ValueLabels Annotation

A very flexible type of annotation, ValueLabels displays text you define at a specific axis
coordinate. This is useful to label only specific coordinates, or to produce annotation in a
form that the chart does not provide. ValueLabels annotation can be used for any axis,
with any chart type, and with any data layout, with the following exceptions:
n When used for the X-axis, the chart type cannot be either Pie, Radar or Filled Radar
n When used for the Y-axis, the chart type cannot be Pie

See Annotating with ValueLabels on page 68 for details on setting up ValueLabels.

PointLabels Annotation (X-axis only)

PointLabels displays text you define at each point along the X-axis. PointLabels
annotation can be used with the X-axis of any chart type.
Olectra Chart OCX

See Annotating with PointLabels on page 68 for details on setting up PointLabels.

TimeLabels Annotation (X-axis only)

TimeLabels automatically generates X-axis annotation along a time scale, based on the
data and using the starting point and format you specify. This is useful for charts that
measure something in seconds, minutes, hours, days, weeks, months, or years.
TimeLabels annotation can be used for the X-axis with any data layout, with the
following exception:
n The chart type for TimeLabels cannot be either Pie, Radar, Filled Radar or Polar

See Annotating with TimeLabels on page 69 for details on setting up TimeLabels.

62 Part I n Using 2D Chart


To Choose the Annotation Method:
n Use the axis AnnotationMethod property to specify the method used to annotate an
axis. AnnotationMethod is located on the Axes tab’s Annotation inner tab on the
Property Editor. The button beside this property displays a dialog of properties that
apply to the current annotation method.

5.2 Annotating Axes


The following section illustrates the different ways to annotate the chart axes.

5.2.1 Annotating with Values


Values annotation produces numeric labelling along an axis, based on the data itself. The
chart can produce very natural-looking axis numbering automatically, but you can finetune
properties that control this process.

Numbering Method

Use the NumMethod axis property to select the method used to number an axis. “Round”
rounds the numbering determined by the precision, numbering and ticking increments and
usually provides the most pleasing display. “Precision” determines numbering by the
precision, numbering and ticking increments and produces coarser and more irregular
numbering. NumMethod is located on the Axes tab’s Annotation inner tab on the
Property Editor.

Olectra Chart OCX

Numbering Precision

Use the Precision axis property to set the number of decimal places to use when
displaying each number. Its IsDefault property allows the chart to automatically
determine precision based on the data. The effect of Precision depends whether it is
positive or negative:

Chapter 5 n Building a Chart 63


n Positive values add that number of places after the decimal place. For example, a
value of 2 displays an annotation of 10 as “10.00”.
n Negative values indicate the minimum number of zeros to use before the decimal
place. For example, a value of -2 displays annotation in multiples of 100.

Precision properties are located on their own dialog on the Axes tab’s Annotation inner
tab on the Property Editor. Set AnnotationMethod to Values for an axis and click the
button beside that property to display the dialog.

Numbering and Ticking Increments

Use the NumSpacing axis property to set the increment between labels along an axis. Its
IsDefault property allows the chart to automatically determine the increment.

Use the TickSpacing axis property to set the increment between ticks along an axis. This
should generally divide equally into NumSpacing on axes using Values annotation. The
TickSpacing IsDefault property allows the chart to automatically determine the
increment.

These properties are located on their own dialog on the Axes tab’s Annotation inner tab
on the Property Editor.

5.2.2 Using Custom Values Formatting


If you are using values to annotate your axes, you can format them using one of Olectra's
predefined formats, or create your own. Use the LabelFormat axis property to set the
formatting to either Accounting, Currency, Fraction, Number, Percentage, Scientific
predefined formats, or a custom format.

To Specify the Values Format:

Use the ValueFormat Object's Category property to specify which format method you
want to use. Each of the value formats have properties that can be modified from the
Values Format dialog. To view the Values Format dialog:
Olectra Chart OCX

1. From the Annotation subtab of the Axes tab, select Values from the Annotation
Method field.
2. Click the Annotation Method button. The Select Annotation Values dialog appears.
3. Click the Format button. The Value Format dialog appears.
4. In the Category list, select the type of formatting you want to apply to the axes values.
The dialog will change to display the properties for that value format.
5. Edit the appropriate formatting options, as required.

64 Part I n Using 2D Chart


Format Codes:
The following lists and describes the valid format codes you can use in a format
specification.

#0? Creates a placeholder for a number. Use with . (period) code to specify the
number of digits to display. # does not display extra zeros. 0 displays extra
zeros when there are fewer digits than in the format. ? works like 0 and adds
space for insignificant zeros to align decimal points and fractions.
For example, “#.0#” formats 16 as 16.0, and 98.666 as 98.67.

. (period) Positions the decimal point, used with #, 0, and ? to specify the number of digits
and rounding.
For example, “###.0000” formats 123.45 as 123.4500.
, (comma) When between digits, acts as a thousands separator. When at the end of a value,
divides value by a thousand.
For example, “#,###” formats 21000 as 21,000. “0.0,” formats 12000 as 1.2.

$-+/() Inserts character where it appears in the format.


For example, “$#.00” formats 21.3 as $21.30.

\ <character> Inserts <character> where it appears in the format.


For example, “\%” inserts a percent sign (without multiplying).

_<character> Inserts a space the width of <character>.


For example, “_-” displays a space the width of the minus sign.

% Multiplies value by 100 and inserts % character.


For example, “#.##%” formats .85 as 85%.

[multiplier <n>] Multiplies following value by <n>.


For example, “[multiplier 1.6]” formats 10 as 16.

E+ e+ E- e- Converts value to scientific notation, placing “E” or “e” in front of the exponent.
E+ and e+ displays “+” before positive exponents and “-” before negative
exponents. E- and e- only displays “-” before negative exponents. For example,
“0.0E+00” formats 18987 as 1.8E+04.
*<character> Pads the annotation space with <character>.
For example, “$* ##.##” displays as much space as possible between the $ and
value.

Olectra Chart OCX


[Black] [White] Sets the color of following value or formats. <named color> specifies an
[Red] [Green] Olectra Chart named color string. Use <COLOR=<value> to specify an RGB
[Blue] [Magenta] color reference.
[Yellow] [Cyan]
[<named color>]
[COLOR=<value>]

[height <n>] Sets the font size of the value or formats that follow. <n> represents the number
of logical units.
For example, “0[height 50%].00[height 100%]” formats 75.5 as (75. 50 ).

[align <value>] Sets the vertical position of the value or formats that follow. Only effective when
used with the [height] code. <value> is either top, bottom, center, baseline, or
top(x). When top(x), the character specified by x is aligned at the top.
For example, “0.0[height 75%][align top(0)]E+00” formats 100 as 1.0 E+02.
[hide] [show] [hide] hides the value or formats that follow. [show] turns off format/value
hiding.
For example, “0.0[hide]E[show]+00” formats 70 as 7.0+01.

Chapter 5 n Building a Chart 65


; (semicolon) Ends one group and begins another format group.
For example, “#.##%” formats .85 as 85%.

Defining Special Ranges for Formatting

Several format codes enable you to define formatting for a range of numbers, in finer
details than the built-in positive, negative and zero groups. The codes that define
conditional formatting are [>value], [<value], [=value], [<>value], [>=value], and
[<=value]. Use these codes to define new groups whose format codes are applied only
when the condition is true. Each group is separated by a semicolon (;). The following
example defines special formatting for values greater than 1000:
###.##;-###.##;#.#;[>1000]0.0E+00

Accounting Format

Use the Accounting Object to determine how this ValueFormat appears. The Accounting
format puts a dollar sign in front of the value, pads the value with zeros (2 is the default)
for the cents, and pads the value with spaces so that the dollar signs and decimals are
aligned. The default format code is:
_-$* #,##0.00;-$* #,##0.00

n The underscore adds a space the size of a dash (-) to the beginning of the annotation,
and the asterisk (*) adds space between the dollar sign and the value to make sure the
dollar signs align correctly.
n Use the OrderCurrencySignValue property to change the order of the negative sign,
dollar sign, and value.
n Use the NegativeValueColor property to specify the color used to display negative
values.

Currency Format

Use the Currency Object to determine how this ValueFormat appears. The Currency
format puts a dollar sign in front of the value, pads the value with zeros (2 is the default)
Olectra Chart OCX

for the cents. The default format code is:


$#,##0.00;-$#,##0.00
n Use the OrderCurrencySignValue property to change the order of the negative sign,
dollar sign, and value.
n Use the NegativeValueColor property to specify the color used to display negative
values.

Fraction Format

Use the Fraction Object to determine how this ValueFormat appears. The Fraction format
converts all decimal values to fractions, up to the number of digits specified or with a
fixed denominator. The default format code is:
0 ?/?

66 Part I n Using 2D Chart


n Use the Denominator property to manually set the denominator for all fractions. Note
that if you set this property, DenominatorDigits is set to 0.
n Use the DenominatorDigits property to set the maximum number of digits to use as
the denominator. The chart automatically calculates the closest possible match to use.
Note that if you set this property, Denominator is set to 0.

Percentage Format

Use the Percentage Object to determine how this ValueFormat appears. The Percentage
format multiplies all values by 100 and displays a percent sign. The default format code is:
0.00%;-0.00%

n Use the DecimalPlaces property to set the maximum number of decimal places to
display.
n Use the OrderPercentSignValue to specify the order of the percent sign, negative
sign and value.

Number Format

Use the Number Object to determine how this ValueFormat appears. The default format
code is:
0.00

n Use the OrderSignValue property to change the order of the negative sign and value.
n Use the NegativeValueColor property to specify the color used to display negative
values.

Scientific Notation Format

Use the Scientific Object to determine how this ValueFormat appears. The Scientific
format converts values to scientific notation and places an E in front of the exponent. The
default format code is:

Olectra Chart OCX


0.00E+00

n Use the DecimalPlaces property to set the maximum number of decimal places to
display.
n Use the UseSmallExponent property to display the exponent as a superscript without
the E/e.
n Multipliers, commas and percent signs are ignored with Scientific notation.

Notes
n With scientific notation, using an E- or e- converts values to scientific notation and
places a minus sign in front of negative exponents. Using E+ or e+ converts values to
scientific notation, places a minus sign in front of negative exponents, and a plus sign
in front of positive exponents.

Chapter 5 n Building a Chart 67


n Each custom format string can have up to 3 sections (not including sections for
specific ranges)- one each for positive values, negative values and zeros, in that order.
Each section in the string should be separated by a semi-colon.

5.2.3 Annotating with ValueLabels


ValueLabels annotation displays the labels you define at the axis coordinate you specify.
This is useful for displaying special text at a specific axis coordinate, or when you need a
kind of annotation that the chart does not support. You can set the axis coordinate and the
text to display for each ValueLabel, and also add and remove individual ValueLabels.
ValueLabels annotation can be used for any axis, with any chart type, and with any data
layout, with the following exceptions:
n When used for the X-axis, the chart type cannot be either Pie, Radar or Filled Radar
n When used for the Y-axis, the chart type cannot be Pie
Olectra Chart OCX

Every label displayed on the axis is one ValueLabel. Each ValueLabel has a Value
property and a Label property.

Use the Value property to set the axis coordinate to display the label. Use the Label
property to specify the text to display. All ValueLabels properties are located on their own
dialog on the Axes tab’s Annotation inner tab on the Property Editor. Set
AnnotationMethod to ValueLabels for an axis and click the button beside that property
to display the dialog.

5.2.4 Annotating with PointLabels


PointLabels annotation displays the labels you define along the X-axis. This is useful for
annotating the X-axis of any chart using Array data layout, including bar, stacking bar,

68 Part I n Using 2D Chart


candle, HiLo, HiLoOpenClose, radar, filled radar and pie charts. You can add, remove,
and edit PointLabels.

PointLabels are a collection of labels. The first label applies to the first point, the second
label applies to the second point, and so on.

Use the PointLabels ChartGroup properties to define and edit PointLabels. These are
located on the ChartGroup tab’s Labels inner tab on the Property Editor. Remember to set
the X-axis AnnotationMethod to PointLabels.

5.2.5 Annotating with TimeLabels


TimeLabels annotation interprets the X-values in your data as units of time along the X-
axis. The chart calculates and displays a time-axis based on the starting point and format
you specify. A time-axis is useful for charts that measure something in seconds, minutes,
hours, days, weeks, months, or years. TimeLabels annotation can be used for the X-axis
with any data layout, with the following exception:

Olectra Chart OCX

Chapter 5 n Building a Chart 69


n •The chart type for TimeLabels cannot be either Pie, Radar, Filled Radar or Polar

Four properties are used to control the display and behavior of TimeLabels:
1. Unit
2. Base
3. Format
4. AnnotationMethod

Time Unit

Use the Unit property to specify how to interpret the X-values in the data. You can select
either Seconds, Minutes, Hours, Weeks, Months, or Years. For example, when set to
Years, X-values that range from 5 to 15 become a time-axis spanning 10 years.

Time Base
Olectra Chart OCX

Use the Base property to set the starting point that the time-axis is measured from. You
can specify the base in a common “mm/dd/yy hh:mm:ss” format, between January 1, 1970
and January 19, 2038. For example, to specify 3:00 pm on June 15, 1996, set the Base
property to “06/15/96 15:00”.

Time Format

Use the Format property to specify what text to display at each annotation point. Its
IsDefault property allows the chart to automatically determine an appropriate format
based on the Unit property and the data, so you often do not need to customize the format.

70 Part I n Using 2D Chart


Format specifies a time format. You build a time format using special format codes. The
chart displays only the parts of the date/time specified by Format. The following lists all
of the valid format codes:

%a Weekday name, abbreviated

%A Weekday name

%b Month name, abbreviated

%B Month name

%c Appropriate date/time representation

%d Day of month (01 to 31)

%H Hour (0 to 23)

%I Hour (0 to 12)

%j Day number of year (001 to 366)

%m Month number (01 to 12)

%M Minute of hour (00 to 59)

%p AM or PM

%S Seconds (00 to 61)

%U Week number of year (00 to 53), Sunday first day


of week 1

%w Weekday number (0 to 6), Sunday = 0

%W Week number of year (00 to 53), Monday first day


of week 1

%x Appropriate date representation

%X Appropriate time representation

%y Year number within century (00 to 99)

Olectra Chart OCX


%Y Year

%Z Time zone (shows nothing if time zone not known)

All TimeLabels properties are located on their own dialog on the Axes tab’s Annotation
inner tab on the Property Editor. Set AnnotationMethod to TimeLabels for the X-axis and
click the button beside that property to display the dialog.

Chapter 5 n Building a Chart 71


5.2.6 Axis Labelling Programming Considerations
If the AnnotationMethod property is set to oc2dAnnotateValueLabels, the chart places
labels at explicit locations along an axis. The ValueLabels property, which is a
ValueLabels collection, supplies this list of strings and their locations. For example, the
following code sets chart labels at the locations 10, 20 and 30:
With Chart2D1.ChartArea.Axes("X")
.AnnotationMethod = oc2dAnnotateValueLabels
With .ValueLabels
.Add 10#, "Label 1"
.Add 20#, "Label 2"
.Add 30#, "Label 3"
End With
End With

The ValueLabels collection can be indexed either by subscript or by value:


’ this retrieves the label for the second Value-label
Value = Chart2D1.ChartArea.Axes("X").ValueLabels(2).Value;
’ this retrieves the label at chart coordinate 2.0
Value = Chart2D1.ChartArea.Axes("X").ValueLabels(2.0).Value;

If the AnnotationMethod property is set to oc2dAnnotatePointLabels, the chart evenly


spaces the points across the axis, and annotates them with a list of strings. This labelling
method can only be used on the X-axis. The labels are supplied by setting the PointLabels
property of the ChartGroup object for this chart. For example, the following code
specifies labels for each of the three points on the X-axis:
With Chart3D1
’ assume three points on X-axis
.ChartArea.Axes("X").AnnotationMethod = oc2dAnnotatePointLabels
With ChartGroups(1).PointLabels
.Add "Point 1"
.Add "Point 2"
.Add "Point 3"
End With
End With

If the AnnotationMethod property is set to oc2dAnnotateTimeLabels, the chart treats


the axis as a Time-axis. This labelling method can only be used on the X-axis. To define
Olectra Chart OCX

the values to appear on a Time-axis, access the TimeScale property, which is a TimeScale
object, and set its properties as follows:
n Set the Base property to the starting date and/or time.
n Set the Unit property to the time unit to be used. This property must be set to a time
unit constant.
n Set the Format property to the format string to use when generating the time labels.
See Annotating With TimeLabels for details on the contents of this format string.

72 Part I n Using 2D Chart


5.3 Using a Time-axis
2D Chart enables you to draw charts displaying data that changes over time. To do this,
specify that the X-axis is to be treated as a time dimension by setting the properties of the
TimeScale object (which is accessible via the Axis object representing the X-axis).

The following TimeScale properties define a Time-axis:


n The Base property specifies the starting point of the Time-axis. Its value is a standard
OLE Date value.
n The Unit property specifies the unit of time used in the Time-axis.

For example, the following statement sets the starting point to January 15, 1985:
Chart2D1.ChartArea.Axes("X").TimeScale.Base = #1/15/85#

And the following sets the starting point to the current time in Visual Basic:
Chart2D1.ChartArea.Axes("X").TimeScale.Base = Now

Date Methods

The DateToValue method converts an OLE Date value into a Time-axis position (a
floating-point value). To convert a Time-axis position to a Date, use the ValueToDate
method.

To convert a Date to a formatted text string, use the FormatDate method. For information
on date format strings, see Annotating with TimeLabels.

5.4 Positioning Axis Annotation


Axis annotation typically appears beside its axis. This may be a problem on charts with an
origin that is not at the axis minimum or maximum. The chart can automatically determine
where to place annotation in different situations, depending on the chart type. If this does
not give the desired results, you can specify exactly where to place the annotation for each
axis.

Olectra Chart OCX

Chapter 5 n Building a Chart 73


X- and Y-axis
annotation set to
“Min”

Specifying Annotation placement

Use the AnnotationPlacement property to specify annotation placement for an axis.


When set to Auto, annotation on plot and area charts is placed at the origin; on bar and
stacking bar charts it is placed at the end of the axis closest to the origin. You can also
explicitly place annotation at the origin, the axis minimum, or the axis maximum.

AnnotationPlacement is located on the Axes tab’s Annotation inner tab on the Property
Editor.

Note
Olectra Chart OCX

AnnotationPlacement for the Y-axis is ignored for the Y-axis when the Y2-axis is
displayed.

5.5 Chart Orientation and Axis Direction


A typical chart draws the X-axis horizontally from left-to-right and the Y-axes vertically
from bottom-to-top. You can reverse the orientation of the entire chart, and/or the direction
of each axis.

Chart Orientation

Use the ChartArea IsHorizontal property to change the chart orientation. When set to
Horizontal, the X-axis is drawn vertically and the Y-axes are drawn horizontally. Any
properties set on the X-axis apply to the vertical axis, and Y-axis properties apply to the

74 Part I n Using 2D Chart


horizontal axis. IsHorizontal is located on the ChartArea tab’s General inner tab on the
Property Editor.

Note that IsHorizontal has no effect on polar, radar or filled radar charts.

Axis Direction
Use the Axis IsReversed property to reverse the direction of an axis. For polar, radar and
filled radar charts, reversing the X-axis changes the direction of rotation. IsReversed is
located on the Axes tab’s General inner tab on the Property Editor.

Normal X- and
Y-axes

Olectra Chart OCX

Chapter 5 n Building a Chart 75


Reversed X-
and Y-axes

5.6 Setting Axis and Data Bounds


Normally a graph displays all of the data it contains. Sometimes you may want to display
only part of the data. There are two ways to frame a specific part of the chart: by fixing
data bounds, or by fixing axis bounds.

Fixing axis bounds generally gives better results than fixing data bounds. The chart
determines the extent of each axis by considering the lowest and highest data value, the
origin, and the numbering increment.

Axis Min and Max

Use the Axes Min and Max properties to frame a chart at specific axis values. Their
IsDefault properties allow the chart to automatically determine axis bounds based on the
data bounds. These properties are located on the Axes tab’s Scale inner tab on the Property
Editor.

Note that you cannot set the X axis for Polar charts.
Olectra Chart OCX

Data Min and Max

Use the Axes DataMin and DataMax properties to frame a chart at specific data values.
Their IsDefault properties set the chart to use the minimum and maximum values in the
data. These properties are located on the Axes tab’s Scale inner tab on the Property Editor.

Note that you cannot set the Axes DataMin and DataMax properties for Polar, Radar and
Filled Radar charts.

76 Part I n Using 2D Chart


5.7 Titling Axes and Rotating Axis Elements
Adding a title to an axis clarifies what is charted along that axis. You can add axis titles to
area, plot, bar, HiLo, HiLoOpenClose or candle charts. You can also rotate the title or the
annotation along the axis, as shown below.

Adding an axis title

Use the axis Title property to add a title to an axis. To remove the title, delete the text.
Title is located on the Axes tab’s Title inner tab on the Property Editor.

Note that you cannot add an axis title to either polar, radar or filled radar charts.

Rotating axis title

Use the axis TitleRotation property to rotate the axis title to either 90 or 270 degrees

Olectra Chart OCX


counterclockwise. Rotation is only visible on vertical axes (that is, Y or Y2 unless the
ChartArea IsHorizontal property has been set to invert the chart orientation). 270-degree
rotation usually looks best on the Y2-axis.

TitleRotation is located on the Axes tab’s Title inner tab on the Property Editor.

Rotating axis annotation

Use the axis AnnotationRotationAngle property to rotate the axis annotation


counterclockwise the specified number of degrees; 270-degree rotation usually looks best
on the Y2-axis. AnnotationRotationAngle is located on the Axes tab’s Annotation inner
tab on the Property Editor.

Chapter 5 n Building a Chart 77


Rotation Note

The axis font must be scalable to rotate the annotation or title. TrueType fonts such as
Arial or Courier New are scalable. Bitmap fonts such as System, Small Fonts, or MS Sans
Serif are not scalable, and cannot be used if you want to rotate annotation or title.

5.8 Logarithmic Axes


Axis annotation is normally interpreted and drawn in a linear fashion. You can set any axis
to be interpreted logarithmically (log base 10), as shown below. Logarithmic axes are
useful for charting certain types of scientific data.

Because of the nature of logarithmic axes, they impose the following restrictions on the
chart:
n Any data that is less than or equal to zero is not graphed (it is treated as a data hole),
since a logarithmic axis only handles data values that are greater than zero. For the
same reason, axis and data minimum/maximum bounds and origin properties cannot
be set to zero or less.
Olectra Chart OCX

n Axis numbering increment, ticking increment, and precision properties have no effect
when the axis is logarithmic.
n For a logarithmic X-axis, the chart type must be either plot, bubble, area, HiLo,
HiLoOpenClose or candle. For the Y-axis, the chart type must be either plot, bubble,
area, polar, HiLo, HiLoOpenClose, candle, radar or filled radar.
n The annotation method for the X-axis cannot be TimeLabels.

Specifying a Logarithmic axis

Use the Axis IsLogarithmic property to make an axis logarithmic. IsLogarithmic is


located on the Axes tab’s General inner tab on the Property Editor.

Notes
n Pie charts are not affected by logarithmic axes.

78 Part I n Using 2D Chart


n Polar, radar and filled radar charts are not affected by a logarithmic X-axis.

5.9 Adding a Second Y-axis


There are two ways to create a second Y-axis (called the Y2 axis) on a chart. The simplest
way is to define a numeric relationship between the Y and Y2 axes, as shown below. Use
this to display a different scale or interpretation of the same graph data.

The other way to create a Y2-axis is to create a combination chart. See Combination
Charts using ChartGroups for a complete discussion.

Defining Y2-axis Multiplier

Use the Multiplier Y2-axis property to define the multiplication factor for the Y2-axis.
This property generates Y2-axis values from the Y-axis annotation. The multiplication

Olectra Chart OCX


factor can be positive or negative. Multiplier is located on the Axes tab’s Annotation
inner tab on the Property Editor.

Using a Constant Value

Use the Constant Y2-axis property to define a value to be added to or subtracted from the
Y2-axis values generated by Multiplier. Constant is located on the Axes tab’s
Annotation inner tab on the Property Editor.

Hiding Y2-axis

Use the IsShowing axis property to remove the Y2-axis from the display. IsShowing is
located on the Axes tab’s General inner tab on the Property Editor.

Chapter 5 n Building a Chart 79


Other Y2-axis Properties

You can customize most axis properties for the Y2-axis, including AnnotationMethod,
Min, Max, IsLogarithmic, NumMethod, NumSpacing, and Title.

5.10 Changing the Axis Appearance


You can customize the appearance of the X, Y, and Y2 axes by changing the tick lengths,
colors, and line patterns using the Axes AxisStyle object.

Tick Length

Use the AxisStyle TickLength property to change the length of the ticks on the axis. The
IsStyleDefault property allows the chart to set the tick length automatically. These
properties are located on the Axes tab’s Axis/GridLines inner tab on the Property Editor.
’ Set tick length on X axis to 5
Chart2D1.ChartArea.Axes("X").AxisStyle.TickLength = 5

Axis Appearance

The AxisStyle object has a LineStyle sub-object that controls the line pattern, thickness,
and color properties of the axis lines and ticks. These are located on the Axes tab’s
AxisStyle tab on the Property Editor, and available via the LineStyle Object .
’ Set tick and axis width on X axis to 2
Chart2D1.ChartArea.Axes("X").AxisStyle.LineStyle.Width = 2
Olectra Chart OCX

80 Part I n Using 2D Chart


5.11 Customizing Origins
The chart can choose appropriate origins for the axes automatically, based on the data. You
can customize how the chart determines the origin, or directly specify the coordinates of
the origin.

Origin Placement

The easiest way to customize an origin is by controlling its placement, using the Axes
OriginPlacement property. When set to Auto, the origin is placed at the axis minimum or
at zero, if the data contains positive and negative values or is a bar chart. You can also
explicitly place an origin at zero, the axis minimum, or the axis maximum.
OriginPlacement is located on the Axes tab’s Annotation inner tab on the Property
Editor.

Origin Coordinates

Olectra Chart OCX


When you need to place the origin at an arbitrary coordinate, use the Axes Origin
property. Its IsDefault property allows the chart to automatically determine the origin
coordinate based on the data. These properties are located on the Axes tab’s Scale inner
tab on the Property Editor.

Note
n When you explicitly set or fix an origin coordinate, the chart ignores the
OriginPlacement property.
n The Y-axis origin cannot be by the user for polar and radar chart types. For these chart
types the origin is automatically set to equal the DataMax property.

Chapter 5 n Building a Chart 81


5.12 Adding Grid Lines
Displaying a grid on a chart can make it easier to see the exact value of data points. You
can set the spacing between lines on the grid, and define how the grid looks.

Horizontal gridlines are a property of the Y-axis. Vertical gridlines are a property of the X-
axis. You cannot set grid properties on the Y2-axis. For polar and radar charts, circular
gridlines are a property of the Y-axis. Radial gridlines are a property of the X-axis. The
following charts show the difference between radial and circular gridlines:
Olectra Chart OCX

Grid Spacing

Use the gridlines Spacing property to customize the grid spacing for an axis. Its IsDefault
property allows the chart to space the grid automatically, drawing a gridline wherever

82 Part I n Using 2D Chart


there is annotation. These properties are located on the Axes tab’s Axis/GridLines inner
tab on the Property Editor.

Grid Appearance

Use the grid Style properties to customize the line pattern, thickness, and color of the
gridlines. These are located on the Axes tab’s GridStyle tab on the Property Editor. Use
the IsStyleDefault grid property to allow the chart to determine the grid style. The
IsStyleDefault property is located on the Axes tab’s Axis/GridLines inner tab on the
Property Editor.

Special Considerations for Radar Charts

Radar and filled radar charts use the X-axis gridlines to display radar lines. The radar lines
will not be displayed unless the X-axis gridline spacing is set to IsDefault.

5.13 Creating Stacking Charts


Stacking charts represent the data in a chart in a cumulative fashion by stacking the values
for each series on top of the values from the previous series. You can apply stacking using
the IsStacked property for Plot, Area, Polar, Radar, and Filled Radar charts.

Olectra Chart OCX

Chapter 5 n Building a Chart 83


This property is located on the ChartGroup tab’s General subtab on the Property Editor.

Note

To remain backwards compatible with previous versions of Olectra Chart, Stacking Bar
charts are implemented as a separate chart type from Bar Charts.

100 Percent Stacking

Use the IsYAxis100Percent and IsY2Axis100Percent properties to scale the Y and Y2


axes of stacking charts to a common 100 percent value. When Is[YY2]Axis100Percent is
False, the actual series data is used. When Is[YY2]Axis100Percent is True, the data is
scaled so that all points are the same height and each series is scaled to a total of 100
percent.
Olectra Chart OCX

This property is located on the Axes tab’s General subtab on the Property Editor.

Note

The implementation of 100 Percent Stacking for Stacking Bar charts is the same.

84 Part I n Using 2D Chart


Hidden and Excluded Series

Hidden and excluded series do not appear in stacking charts, with the exception of
Stacking Bar Charts, in which hidden series create a floating bar chart .

5.14 Creating Combination Charts using ChartGroups


A combination chart displays two separate groups of data in the same chart. Combination
charts are useful for comparing two groups of data against the same X-axis.

Each group of data is part of a ChartGroup. A ChartGroup also has a set of ChartStyles,
SeriesLabels, PointLabels, and properties that define the chart type and drawing order.
Use the first ChartGroup when creating a chart having just one group of data. Use the
second ChartGroup when adding a second data group to the chart. The second ChartGroup
only works when data exists in the first.

Olectra Chart OCX


The X-axis is common to both ChartGroups. The first Y-axis applies to the first
ChartGroup’s data. The second Y-axis (Y2) applies to the second ChartGroup’s data.

Special Rules

When displaying a combination chart, the chart has the following limitations:
n Pie, radar, filled radar and polar charts cannot be used in combination charts.
n When annotating the X-axis using PointLabels, only the first ChartGroup’s
PointLabels are used.

Chapter 5 n Building a Chart 85


Loading Second ChartGroup Data

Use the Load button on the ChartGroups tab’s Data inner tab on the Property Editor, to
load data into the second ChartGroup. See Understanding Data Layout for information on
data layouts.

Setting Second ChartGroup Chart Type and Drawing Order

Use the ChartType ChartGroups property to set the chart type for the second ChartGroup.
ChartType is located on the ChartGroups tab’s General inner tab on the Property
Editor. See Choosing the Chart Type for information on chart types.

Use the DrawingOrder ChartGroups property to set which ChartGroup to draw first.
When set to 1, that ChartGroup is drawn first and appears behind the other.
DrawingOrder is located on the ChartGroups tab’s General inner tab on the Property
Editor.

Legend

The legend in a combination chart combines the SeriesLabels for the first and second
ChartGroups. Use the SeriesLabels property to add, remove, or change SeriesLabels.
SeriesLabels is located on the ChartGroup tab’s Labels inner tab on the Property Editor.
See Using a Legend for information on legends.

Customizing Second ChartGroup ChartStyles

Use the FillStyle, LineStyle, and SymbolStyle ChartStyle properties to set or change
ChartStyles for the second ChartGroup. ChartStyles properties are located on the
ChartStyles tab on the Property Editor. See Changing ChartStyles for information on
ChartStyles.

5.15 Converting Data Coordinates


The ChartGroups collection provides methods which enable you to do the following:
Olectra Chart OCX

n Convert from data coordinates to pixel coordinates and vice versa.


n Determine the pixel coordinates of a given data point in a series, or the closest point to
a given set of pixel coordinates.

To convert from data coordinates to pixel coordinates, call the DataCoordToCoord


method. For example, the following code obtains the pixel coordinates corresponding to
the screen coordinates (5.1, 10.2):
Dim PixelX As Long
Dim PixelY As Long
...
With Chart2D1.ChartGroups(1)
.DataCoordToCoord 5.1, 10.2, PixelX, PixelY
End With
’ PixelX and PixelY now contain the pixel coordinate value

86 Part I n Using 2D Chart


If the chart coordinate is out of the visible range of the chart, both of the pixel X- and Y-
coordinates are set to -1.

To convert from pixel coordinates to data coordinates, call CoordToDataCoord. For


example, the following converts the pixel coordinates (225, 92) to their equivalent data
coordinates:
Dim ScreenX As Double
Dim ScreenY As Double
Dim Region As Integer
...
With Chart2D1.ChartGroups(1)
Region =.CoordToDataCoord (225, 92, ScreenX, ScreenY)
End With
’ ScreenX and ScreenY now contain the data coordinate value

CoordToDataCoord returns, as its return value, the region of the chart in which the pixel
coordinates are located. This region is represented as a region constant.

To determine the pixel coordinates of a given data point, call DataIndexToCoord. For
example, the following code obtains the pixel coordinates of the third point in the first data
series:
Dim PixelX As Long
Dim PixelY As Long
...
With Chart2D1.ChartGroups(1)
.DataIndexToCoord 1, 3, PixelX, PixelY
End With
’ PixelX and PixelY now contain the pixel coordinate value

To determine the closest data point to a set of pixel coordinates, call CoordToDataIndex:
Dim Series As Long
Dim Point As Long
Dim Distance As Long
Dim Region As Integer
...
With Chart2D1.ChartGroups(1)
Region =.CoordToDataIndex (225, 92, oc2dFocusXY, Series, _
Point, Distance)

Olectra Chart OCX


End With

The third argument passed to CoordToDataIndex specifies how the nearest series and
point value are determined. This argument must be a focus constant.

CoordToDataIndex returns the series and point value corresponding to the closest data
point, and also returns the distance in pixels between the pixel coordinates and the point.
CoordToDataIndex returns, as its return value, the region of the chart in which the pixel
coordinates are located. This region is represented as a region constant. When the returned
region is oc2dRegionInLegend, the returned point value is also set to
oc2dRegionInLegend, and the returned series is the closest element in the legend.

Chapter 5 n Building a Chart 87


Converting Visual Basic Coordinates

In Visual Basic, coordinate values are measured in twips (1,440 twips equals one inch).
The following code converts the height and width of a chart from twips to pixels:
pixwidth = Chart2D1.Width / Screen.TwipsPerPixelX
pixheight = Chart2D1.Height / Screen.TwipsPerPixelY

Converting Coordinates Passed By Reference

If passing parameters by reference is not supported in your development environment


(such as VBScript), the ChartGroups collection provides methods for converting
coordinates that return an object instead of a reference. Otherwise, these methods function
like DataCoordToCoord, CoordToDataCoord, DataIndexToCoord, and
CoordToDataIndex.
n DataCoordToCoordObject maps a chart coordinate to a pixel coordinate. A
Chart2DCoordResult object is returned with the X pixel and Y pixel values for the
corresponding chart coordinate.
n CoordToDataCoordObject maps a pixel coordinate to a chart coordinate. A
Chart2DDataCoordResult object is returned with the X and Y values indicating
chart region in which the coordinate is found.
n DataIndexToCoordObject determines the closest pixel coordinate given a chart
group series and point. A Chart2DCoordResult object is returned with the X Pixel
and Y Pixel values.
n CoordToDataIndexObject picks the displayed data closest to the given pixel
coordinate. A Chart2DDataIndexResult object is returned with the Series, Point and
Distance values that indicate the chart region in which the coordinate is found.

5.16 Storing Chart Descriptions in Files


To save a chart description in a file, access the Chart2D object and call the Save method:
Chart2D1.Save "C:\OLECTRA\CHART1.OC2"
Olectra Chart OCX

To load a previously saved chart description from a file, call the Load method:
Chart2D1.Load "C:\OLECTRA\CHART1.OC2"

Both methods return True if the file operation was successful and False if an error
occurred.

Saving Chart Data

Chart data is normally stored with the other chart properties. If you don’t want the data
saved, set the IsSaved property in the Chart2DData object to False. If you want the chart
data saved to a file, set the FileName property to the name of the file. Saved data can be
loaded from this file using the Load method.

If the IsSaved property is set to True, data is saved with the chart, and the value of the
FileName property is ignored.

88 Part I n Using 2D Chart


5.17 Printing Charts
Many applications need to provide the user with a way of getting a hardcopy of the chart.
This includes printing the chart, copying it to a file or the clipboard. Olectra Chart
provides several methods to output charts to one of these destinations.

Output/Printing Methods

The methods listed below allow you to output the chart. See the Chart2D Object for more
information.

CopyToClipboard Copies the chart to the clipboard using the


graphics format you specify
DrawToDC Draws the chart on a specified device at the scale
and graphics format you specify
DrawToFile Draws the chart into a file using the graphics
format you specify
PrintChart Prints the chart using the Windows Print dialog
box

Each of these methods enables you to produce a copy of the chart in bitmap format,
Metafile format, or enhanced Metafile format.

Printing Charts

To print a chart using the standard Windows Print dialog, use the PrintChart method.
This method allows you to specify the image format and the size and position of the chart.
The following code example illustrates how to print a chart:
’ Prints the chart as a Windows bitmap and scaled to fit the entire page
Chart2D1.PrintChart oc2dFormatBitmap, oc2dScaleToMax, 0, 0, 0, 0

Outputting Charts to Device Contexts

Olectra Chart OCX


Use the DrawToDC for more complicated chart output, such as printing multiple charts
on a single page, or for printing directly to a printer without using the Windows Print
dialog. For example, to print several charts on one page, call DrawToDC for each chart,
and specify the top, left, width and height arguments to specify each chart’s different size
and position. The following example shows how to use DrawToDC for a printing function

Chapter 5 n Building a Chart 89


that prints a chart that fills the page to the default printer without using the Windows Print
dialog box:
’ Prints a title
Printer.Print "Simple Chart Example"

’ Prints the chart directly to the printer as an enhanced


’ metafile with top and left margins of 0 pixels, and a
’ height and width to fit the page
Chart2D1.DrawToDC Printer.hDC, oc2dFormatEnhMetafile, oc2dScaleToMax,
0, 0,
Printer.ScaleWidth/Printer.TwipsPerPixelX,
Printer.ScaleHeight/Printer.TwipsPerPixelY

’ Ends the print job


Printer.EndDoc
Olectra Chart OCX

90 Part I n Using 2D Chart


6
Working with Data
Data Overview n Loading Data From a File
Charting Data Directly From Your Program n Charting Data Using Data Binding
Hiding and Excluding Data Series n Fast Update Methods
Copying Data n Batching Chart Updates n Double Buffering

The following topics explain how to plot, setup and configure your data for use with
Olectra Chart.

Olectra Chart OCX

91
6.1 Data Overview
The 2D Chart control enables you to add or modify data at runtime.

Data Organization

Data in a chart is organized into chart groups. Each chart contains two chart groups
(although most charts will only use the first ChartGroup), each of which is treated as a
separate entity. In 2D Chart, a chart group is represented by a ChartGroup object.

Within a chart group, data is represented by the Data property, which is a Chart2DData
object. The Chart2DData object defines the following properties which control the data
to be displayed in the chart:
n The NumSeries property defines the number of data series in the chart group.
n The NumPoints property defines the number of data points in a series. This property
is indexed by series. For example, the statement:
NumPoints = Chart2D1.ChartGroups(1).Data.NumPoints(1)
assigns the number of data points in the first series to the NumPoints variable.
n The Layout property specifies the data layout. Its value must be a data layout constant
specifying either array or general data. If array data is specified, each series is
assumed to have the same number of data points.
n The X and Y properties specify the X- and Y-coordinates of a particular data point.
These properties are indexed by series and point. For example, the statement:
Xval = Chart2D1.ChartGroups(1).Data.X(1,3)
assigns the X-coordinate of the third point in the first data series to Xval.

The following diagram is an example of a plot of array data:


Olectra Chart OCX

92 Part I n Using 2D Chart


And here is a plot of general data:

Batching Data Updates

Normally, the displayed chart is updated whenever a Chart2DData object property is


changed. If you are changing or creating several data points, you can improve
performance by batching the changes. To do this, set the IsBatched property to True.

When IsBatched is set to True, the chart data is not updated when a Chart2DData object
property is changed. Updating does not take place until IsBatched is reset to False.

Changing Data Values

To change a data value displayed in the chart, all you need to do is set its X and Y
properties. For example, the following statements change the fourth data point in the
second series to (10.5, 7.7):
With Chart2D1.ChartGroups(1).Data
.X(2, 4) = 10.5
.Y(2, 4) = 7.7
End With

Olectra Chart OCX


Adding Points and Series

To add points to an existing data series, do the following:


n Add the number of new points to the NumPoints property for that series. (NumPoints
must always equal the number of points in the series.)
n Set the X and Y properties for the new points.

For example, the following code adds a fifth and sixth point to the first data series:

Chapter 6 n Working with Data 93


With Chart2D1.ChartGroups(1).Data
.IsBatched = True
.NumPoints(1) = 6
.X(1, 5) = 2.4
.Y(1, 5) = 3.77
.X(1, 6) = 2.85
.Y(1, 6) = 4.11
.IsBatched = False
End With

If the data is in array format, the new points are added to all of the series.

To add a new data series, do the following:


n Add one to the value of the NumSeries property.
n Set the NumPoints property for the new series to the number of points to be added.
n Set the X and Y properties for the new points.

The following code adds a second data series containing two points:
With Chart2D1.ChartGroups(1).Data
.IsBatched = True
.NumSeries = 2
.NumPoints(2) = 2
.X(2, 1) = 1.0
.Y(2, 1) = 3.14159
.X(2, 2) = 2.0
.Y(2, 2) = 6.02
.IsBatched = False
End With

When a new series is created, a new ChartStyle object is automatically created for it. This
chart style controls how the new data points are to be displayed. By changing the
properties of this ChartStyle object, you can control the appearance of the new data.

Handling Missing Data

If the Y property for a data point is set to a special value known as the hole value, 2D
Chart treats the data point as a missing value, and does not display it on the chart. This
Olectra Chart OCX

hole value is specified by the HoleValue property of the Chart2DData object.

For example, the following code treats the third point in the first data series as a missing
value:
With Chart2D1.ChartGroups(1).Data
.HoleValue = 999.1
.Y(1, 3) = 999.1
End With

Fast Update

If the data points being changed fall within the current axis bounds, the 2D Chart control
enables you to use the Fast Update methods to update the graph efficiently.

94 Part I n Using 2D Chart


6.2 Loading Data From a File
A common task in any Olectra Chart program is to load the chart data (called a dataset)
from a file into a format that the chart can use.

In order for Olectra Chart to allocate and load the data from a file, it must be in one of two
basic layouts, Array or General. The following examples show the contents of the
MM63.DAT file, in both Array and General formats. The first line of the file tells the
control that the data which follows is in either Array or General format, and is made up of
2 sets of 4 points.

Array File Format


Array 2 4
Hole 1000
# X-values
1.0 2.0 3.0 4.0
# Y-values set 1
200.0 234.0 274.0 320.0
# Y-values set 2
200.0 218.0 237.0 258.0

Line 4 of the MM63.DAT file defines the X-value (i.e. points) shared by both of the sets
(Y-values). Lines 6 and 8 in MMF95.DAT define each of the sets of Y-values. Lines
beginning with "#" are comment lines.

General File Format


General 2 4
Hole 1000
# line 1, 4 points
4
1 2 3 4
200.0 234.0 274.0 320.0
# line 2, 4 points
4
1 2 3 4
200.0 218.0 2237.0 258.0

Lines 4 and 8 tell the control how many points are in each series. Lines 5 and 9 represent

Olectra Chart OCX


the actual X values for each series, and lines 6 and 10 represent the Y values. Lines
beginning with "#" are comment lines.

See Understanding Data Layout on page 29 for more information on Array and General
data layout.

Loading the Data

To allocate and load the data from a file, you can either use the Property Editor’s Load
button, which is located on the Data subtab of the ChartGroup tab, or do it
programmatically. Loading the MMF95.DAT file into your chart can be done as follows:
’ Load the data from a file MMF95.DAT
Chart2d.ChartGroups(1).Data.Load "MMF95.DAT"

Chapter 6 n Working with Data 95


Loading Data From a URL

Instead of using the Load method to specify the location of a data file, you can specify a
URL where the chart can find the data. Olectra Chart provides two different methods to
load data from the Internet:
n Use the Chart2D Object’s LoadURL method to load a chart description file (.OC2).
n Use the Chart2DData Object’s LoadURL method to load a data file (.DAT) into an
existing chart.

In addition, if you want to set a URL location but do not want to load the data, use the
Chart2DData Object’s Datapath property. This property can be set at design time, and
used to initialize the chart data at run-time.

6.3 Charting Data Directly From Your Program


Often it may not be convenient to load chart data from a file. For example, if the data is
created from within the program using a mathematical calculation, it makes more sense to
read it into the chart directly instead of saving it to a file and then reading it again. Not
only can this method be quicker, it can also be quite easy to program.

The following example creates a 2-dimensional array, populates the array with data, and
then charts the data:
Sub Main
’ Declare the arrays needed to do the calculations
Dim Rates(1 To 2) As Double
Dim Values(1 To 2, 1 To 12) As Double
’ Set the number of series and points in the chart
Chart2D1.ChartGroups(1).Data.NumSeries = 2
Chart2D1.ChartGroups(1).Data.NumPoints(1) = 12
Chart2D1.ChartGroups(1).Data.NumPoints(2) = 12

’ Set the different rates


Rates(1) = 0.17
Rates(2) = 0.089
Olectra Chart OCX

’ Set the initial values for the first and second series
Values(1, 1) = 200
Values(2, 1) = 200

’ Populate the Values arrays with data


For i = 1 To 2
For j = 2 To 12

’ Calculate the current value of the investment using the


’ following calculation:
Values(i, j) = Values(i, j - 1) * Rates(i) + Values(i, j - 1)
Next j
Next i

’ Set the common X values


For i = 1 To 12

96 Part I n Using 2D Chart


Chart2D1.ChartGroups(1).Data.x(1, i) = I
Next i

’ Set the Y values


For i = 1 To 2
For j = 1 To 12
Chart2D1.ChartGroups(1).Data.y(i, j) = Values(i, j)
Next j
Next I
End Sub

6.4 Charting Data Using Data Binding


If the data you want to chart comes from an external database, you can add it directly to
the chart in its native format. Using data binding is useful to:
n Bind the values in one column of a database to be the Y-values for one series on the
chart
n Bind the values in one column of a database to be the strings for point labels
n Bind the values in one column of the database to be the X-values for the points
n Bind column names to be the strings for series labels

To Bind an External Database to Your Chart:


1. Add a Data control to your form. For more information, refer to your Visual Basic
documentation.
2. Set the Data control’s DatabaseName property to the database’s name and location,
the Connect property to the database type, and the RecordSource property to the
record source from within the database.
3. Set the Chart2D Object’s DataSource property to the name of the data control. The
chart is now bound to the external database.

To Specify Series Data:

Olectra Chart OCX


Once your chart is bound to a datasource, you must specify which columns are to be used
as chart data. Set the ChartGroup Object’s SeriesFields property to specify which database
fields to chart. Each bound field is charted as a separate series. Set the PointLabelsField
property to use a database column for PointLabels, or set the PointValuesField property
to use a database column for X-values.

To Use Column Headings as SeriesLabels:

Use the ChartGroup Object’s AreSeriesLabelsBound property to use the database column
headings as SeriesLabels.

Chapter 6 n Working with Data 97


Notes
n Data for a bound chart must be in array format
n If you set the PointValuesField or PointLabelsField properties, you must also set the
Axis Object’s AnnotationMethod property to the appropriate annotation type.
n Each column (as opposed to row) in the database is treated as a separate series.

6.5 Hiding and Excluding Data Series


You can set the display properties for each data series to either hide or exclude each series.
Hiding a series includes the series in the data set, but does not draw it. Excluding a series
removes the series from the data set.

To Hide or Exclude a Series:


Set the Chart2dData object’s SeriesDisplay property to either oc2dDisplayHide (to hide
the series) or oc2dDisplayExclude (to exclude the series).The following examples show
the difference between shown, hidden and excluded series.
Olectra Chart OCX

98 Part I n Using 2D Chart


Excluding Series with Bubble, HiLo, HiLoOpenClose and Candle Charts

With these chart types, multiple series are combined to create a single logical data set.
Excluding one series will exclude the entire logical data set. Any excluded logical data set
will not be used in calculating data bounds.

Hiding Series with HiLoOpenClose and Candle Charts

With these chart types, hiding either of the first two series (the Hi and Low values) will
hide the entire logical data set. With HiLoOpenClose charts, hiding either the third or
fourth series (the Open and Close values) will hide only that series; with Candle charts,
hiding either the third or fourth series will hide both the Open and Close series (the candle
portion of the chart).

Hiding Series with Bubble and HiLo Charts

With these chart types, hiding either of the series will hide the entire logical data set.

6.6 Fast Update Methods


Normally, when new data is added to a chart, the entire chart area is repainted. The Fast
Update methods provide an alternative and potentially much faster way to add new data to
an existing chart if the data falls within the chart’s current axes bounds. Only plots, area
and polar charts can be fast updated.

The following Fast Update methods are defined by the Chart2DData object:

CheckNewPoints(series, npoints, isxmin, isxmax, isymin, isymax)


n Checks whether new data to be added falls within the axes bounds. Series specifies the
data series to be added to if the data is in general format; if the data is in array format,
all data series are added to. npoints is the number of points to be added; the index of
the first point to be added is assumed to be one greater than the value of the LastPoint
property. In addition, npoints plus the value of LastPoint must be less than or equal to

Olectra Chart OCX


the value of the NumPoints property. (For example, if LastPoint is 15 and npoints is
3, the indices of the added points are 16, 17 and 18, and NumPoints must be greater
than or equal to 18.) isxmin, isxmax, isymin and isymax are return values; the data is
inside the current axes bounds only if all four of these values are set to False.

CheckNewPoints returns True if all data is within the axes bounds.

DrawNewPoints(series, npoints)
n Draws the new points as quickly as possible. Series specifies the data series to be
added to if the data is in general format; if the data is in array format, all data series are
added to, and the value of series is ignored. npoints is the number of points to be
added; the index of the first point to be added is assumed to be one greater than the
value of the LastPoint property.
n DrawNewPoints returns True if fast update was possible (if the data falls within
existing axes bounds, as verified by CheckNewPoints). When DrawNewPoints
returns, the LastPoint property is incremented by npoints.

Chapter 6 n Working with Data 99


ShiftPoints(series, npoints, dest, src)
n Shifts a block of points in a data series. Series specifies the data series to be shifted.
npoints is the number of data points to shift. src is the start index of the data to be
shifted, and dest is the destination index. Shifted-out points are set to the value of the
HoleValue property.
n For example, the following call shifts the three points indexed 7, 8 and 9 to locations
3, 4 and 5 respectively:
Chart2D1.ChartGroups(1).Data.ShiftPoints 1, 3, 3, 7
n This method is used in charts that plot a continuous stream of real-time data. The
stripper demo, included with Olectra Chart, is an example of a chart that uses this
method.

Examples

Here is a simple example of code that uses the Fast Update methods:
With Chart2D1.ChartGroups(1).Data
’ .LastPoint is assumed to have the value 9
.x(1, 10) = 15.4
.y(1, 10) = 23.1
.x(1, 11) = 7.2
.y(1, 11) = 20.8
.DrawNewPoints 1, 2
End With

For a more practical example of code that uses the Fast Update methods, refer to the
Timer1 procedure defined in the stripper demo program.

6.7 Copying Data


Before you can create a chart, you must provide it with data. Olectra provides users with 6
different methods that allow you to copy data arrays directly to and from the chart, making
it easy to quickly create chart data. These methods pass data using OLE SafeArrays. To
use these methods, your development environment must support SafeArrays, either
Olectra Chart OCX

directly (as in Microsoft Visual Basic), or using a special mechanism (such as Delphi’s
Variant arrays). For more information, refer to your development environment
documentation.

The following copying data methods are defined by the Chart2DData object:

CopyXVectorIn(value,array), CopyXVectorOut(value,array)
n Copies the X values for a specified series of data either from an array into a chart
(CopyXVectorIn), or from a chart into an array (CopyXVectorOut). value is the
series number for the data that is to be copied. array is either the name of the array
where the X values are stored (CopyXVectorIn), or the name of the array where the X
values are copied (CopyXVectorOut). Note that to use CopyXVectorIn and
CopyXVectorOut, the array must be a one-dimensional array of singles, doubles,
longs, integers, or dates.

100 Part I n Using 2D Chart


n CopyXVectorIn and CopyXVectorOut return True when the copy is successful,
False otherwise.
n The following example uses the CopyXVectorIn method to copy the fourth series
from an array "MyArray":
Dim MyArray (1 to 10) as Double
Chart2d1.ChartGroups(1).Data.CopyXVectorIn 1,MyArray

CopyYVectorIn(value,array), CopyYVectorOut(value,array)
n Copies the Y values for a specified series of data either from an array into a chart
(CopyYVectorIn), or from a chart into an array (CopyYVectorOut). value is the
series number for the data that is to be copied. array is the name of the array where the
Y values are stored (CopyYVectorIn) where the Y values are copied
(CopyYVectorOut). Note that to use CopyYVectorIn and CopyYVectorOut, the
array must be a one-dimensional array of singles, doubles, longs or integers.
n CopyYVectorIn and CopyYVectorOut return True when the copy is successful,
False otherwise.

CopyYArrayIn(array), CopyYArrayOut(array)
n Copies an array of Y data to multiple series (CopyYArrayIn) or from multiple series
into an array (CopyYArrayOut). array is a two-dimensional array of singles,
doubles, longs or integers. where the data is located or is to be copied. The common X
values are usually set with CopyXVectorIn, and the Y values for all series can be set
with CopyYArrayIn. Note that to use this method the size of the array passed must
match the number of series and points declared by NumSeries and NumPoints.
Arrays must be declared with the number of points as its first element, and the number
of series as its second element. Note that to use CopyYArrayIn or CopyYArrayOut,
your data must be in Array format. Otherwise, use CopyYVectorIn.

Example

Adding a lot of points (in the following example, four series of 10,000 points each) can be
quite slow. The chart must add each point to the chart as it is generated. to copy data arrays
directly to and from the chart, making it easy to quickly create chart data.

Olectra Chart OCX


The following code example uses the CopyYArrayIn method to quickly copy an entire
array of data to the chart. The array passed is a two-dimensional array of singles, doubles,
longs or integers. Note that to use this method the size of the array passed must match the
number of series and points declared by NumSeries and NumPoints. Arrays must be
declared with the number of points as its first dimension element, and the number of series
as its second element.
Sub Main
’ Setup the chart so it will display correctly
Chart2D1.ChartGroups(1).Styles(1).Symbol.Size =
0Chart2D1.ChartGroups(1).Styles(2).Symbol.Size =

Chapter 6 n Working with Data 101


0Chart2D1.ChartGroups(1).Styles(3).Symbol.Size =
0Chart2D1.ChartGroups(1).Styles(4).Symbol.Size = 0
With Chart2D1.ChartGroups(1).Data
.IsBatched = True
.NumSeries = 4
.NumPoints(1) = 10000
End With

’ Declare a variable
Dim Yarray(1 To 10000, 1 To 4) As Double

’ Generate some data, and add it to the chart


For j = 1 To 4
With Chart2D1.ChartGroups(1).Data
.x(1, j) = j
For i = 1 To 10000
‘Create a random number for our data
Yarray(i, j) = (i / j) + (0.5 * Int(((i / j) * Rnd) + 1))
Next i
End With
Next j
Chart2D1.ChartGroups(1).Data.CopyYArrayIn
(Yarray)Chart2D1.ChartGroups(1).Data.IsBatched = False
End Sub
Olectra Chart OCX

102 Part I n Using 2D Chart


6.8 Batching Chart Updates
Normally, the chart is repainted immediately after a property is set. To make several
changes to a chart before causing a repaint, set the IsBatched property of the Chart2D
object to True. Property changes do not cause a repaint until IsBatched is reset to False.

For convenience, the IsBatched property is also defined for the Chart2DData object and
the ChartLabel object. In these cases, IsBatched batches the modifications to that object.
These IsBatched properties are independent of Chart2D.IsBatched.

It is recommended that you batch around the creation or updating of multiple chart labels.

6.9 Double Buffering


Double buffering is a graphics technique which will reduce the amount of flashing
perceived by a user when a chart changes. By default, double buffering is in effect. To turn
off double buffering for a Chart2D object, set its IsDoubleBuffered property to False.

When double buffering is turned on, every time the chart changes, it will:
n Allocate (if necessary) and clear an off-screen bitmap.
n Render the complete graph to the off-screen bitmap.

When double buffering is turned off, the chart clears the screen image every time a chart is
changed (possibly causing a visual flash). Then, it renders the complete image to the
visible window (possibly allowing the user to see the chart being drawn piece by piece).

Turning off double buffering can improve the chart’s graphing performance and reduce its
memory requirements.

Olectra Chart OCX

Chapter 6 n Working with Data 103


Olectra Chart OCX

104 Part I n Using 2D Chart


7
Customizing Chart Elements
Adding Header and Footer Titles n Using a Legend
Changing ChartStyles n Programming ChartStyles n Adding Images to Chart Elements
Changing the ChartArea Appearance n Using Borders n Choosing Fonts
Setting Colors n Positioning Chart Elements n Adjusting PlotArea Margins
Adding the 3D Effect n Resizing Forms n Using ChartLabels
Programming ChartLabels n Adding Markers n Programming Markers

When the chart data and axes are formatted properly, you can customize its elements to
make it clearer and professional-looking. The following topics cover tasks that customize
the appearance of a chart.

Olectra Chart OCX

105
7.1 Adding Header and Footer Titles
A chart can have two titles, called the header and footer. A title consists of one or more
lines of text with an optional border, both of which you can customize. You can also set
the text alignment, positioning, colors, and font used for the header or footer.

Title Text and Alignment

Use the Text title property to add, change, or remove text for a title. Text is located on the
Titles tab’s Label inner tab on the Property Editor. To enter multiple lines of text, press
Enter between each line.

Use the Adjust title property to specify whether to center, left-justify, or right-justify a
multi-line title. Adjust is located on the Titles tab’s General inner tab on the Property
Editor.

Title Positioning

Use the Left and Top location properties to customize the location of the title. When their
IsDefault properties are used, the header is centered over the PlotArea and the footer is
centered below the PlotArea. These properties are located on the Titles tab’s Location
inner tab on the Property Editor. See Positioning Chart Elements on page 117 for more
information.

Title Border

Use the Type and Width border properties to customize the title’s border. These properties
are located on the Titles tab’s Border inner tab on the Property Editor. See Using Borders
on page 115 for more information.

Title Colors

Use the interior properties to customize background and text colors of a title. These are
located on the Titles tab’s Interior inner tab on the Property Editor. See Setting Colors on
page 116 for more information.
Olectra Chart OCX

Title Font

Use the font properties to customize the font used for a title. These are located on the
Titles tab’s Font inner tab on the Property Editor. See Choosing Fonts on page 116 for
more information.

106 Part I n Using 2D Chart


7.2 Using a Legend
A legend shows the visual attributes (or ChartStyle) used for each series in the chart, with
text that labels the series. You can customize the series labels, positioning, border, colors
and font used for the legend.

Legend Text and Orientation

The legend displays the text contained in the SeriesLabels (a ChartGroups property), so
the legend does not appear unless at least one SeriesLabel exists. SeriesLabels are a
collection of labels. The first label applies to the first series, and so on. The SeriesLabels
property is located on the ChartGroup tab’s Labels inner tab on the Property Editor.

Olectra Chart OCX


Use the legend Orientation property to lay out the legend horizontally or vertically, and
the IsReversed property to specify whether to display the SeriesLabels in reverse order.
These properties are located on the Legend tab’s General inner tab on the Property Editor.

Legend Positioning

Use the legend Anchor property to specify where to position the legend relative to the
PlotArea. You can select from eight compass points around the PlotArea. Anchor is
located on the Legend tab’s General inner tab on the Property Editor.

Use the Left and Top location properties to finetune the positioning. When their IsDefault
properties are used, the chart automatically positions the legend. These properties are
located on the Legend tab’s Location inner tab on the Property Editor. See Positioning
Chart Elements on page 117 for more information.

Chapter 7 n Customizing Chart Elements 107


Legend Title

Use the legend Text property to specify the legend title. The legend title appears centred at
the top of the legend. Text is located on the Legend tab’s Title inner tab on the Property
Editor.

Legend Border

Use the Type and Width border properties to customize the title’s border. These properties
are located on the Legend tab’s Border inner tab on the Property Editor. See Using
Borders on page 115 for more information.

Legend Colors

Use the interior properties to customize background and text colors of the legend. These
are located on the Legend tab’s Interior inner tab on the Property Editor. See Setting
Colors on page 116 for more information.

Legend Font

Use the font properties to customize the font used for the legend. These are located on the
Legend tab’s Font inner tab on the Property Editor. See Choosing Fonts on page 116 for
more information.

7.3 Changing ChartStyles


The attributes that define how a series of data looks in the chart are called a ChartStyle.
Each series has its own ChartStyle, which you can customize. For example, you can
change the fill pattern and color of bars in a bar chart or the symbol used for data points in
a plot or bubble chart.
Olectra Chart OCX

Every ChartStyle has a FillStyle, a LineStyle, a SymbolStyle, and a SliceStyle. FillStyles


are used for bar, stacking bar, area and pie charts. LineStyles and SymbolStyles are used
for plot and bubble charts. SliceStyles are used for pie charts.

FillStyle

Use the Pattern property to set the fill drawing pattern for a ChartStyle. The Color
property sets the color used to draw the pattern (the foreground color), and the
BackGroundColor property sets the color used to fill the background. The valid patterns
are shown below:

108 Part I n Using 2D Chart


None DiagHatched

Solid CrossHatched

25Percent BackwardDiagonal

50Percent Cross

75Percent DiagonalCross

HorizontalStripe ForwardDiagonal

VerticalStripe Horizontal

45DegreeStripe Vertical

135DegreeStripe

These properties are located on the ChartStyles tab’s FillStyle inner tab on the Property
Editor.

LineStyle

Use the Pattern property to set the line drawing pattern, the Width property to set its
width, and the Color properties to set the line color for a ChartStyle. The valid patterns are
shown below:

None

Solid

LongDash

Dotted

Olectra Chart OCX


ShortDash

LongShortLongDash

DashDot

These properties are located on the ChartStyles tab’s LineStyle inner tab on the Property
Editor.

Chapter 7 n Customizing Chart Elements 109


SymbolStyle

Use the Shape property to set the symbol type, the Size property to set its size, and the
Color properties to set the symbol color for a ChartStyle. The valid symbols are shown
below:

None VerticalLine

Dot HorizontalLine

Box Cross

Triangle Circle

Diamond Square

Star

These properties are located on the ChartStyles tab’s SymbolStyle inner tab on the
Property Editor.

SliceStyle

Use the Offset property to set the offset for exploding pie slices. See Special Pie Chart
Properties on page 39 for details.

7.4 Programming ChartStyles


A ChartStyle object defines the characteristics of a slice of a pie chart, a bar in a bar chart,
or the points and lines in a plot, bubble, or radar chart. ChartStyles can be specified by
series or by individual points. One ChartStyle object is defined for each series within a
chart group, and for each point in a series. As new series or chart groups are added, new
ChartStyle objects are automatically created by the chart.

Customizing ChartStyles
Olectra Chart OCX

The 2D Chart control enables you to programmatically change the following properties of
a ChartStyle object:
n The Fill property, which specifies the pattern, color, and background color inside area,
bar, pie and filled radar charts. This property is of type FillStyle.
n The Line property, which defines the line style for the object. This specifies the color,
pattern and thickness of lines in plots. This property is of type LineStyle.
n The Symbol property, which defines the symbol style for the object. This specifies the
color, size and shape of points in plots. This property is of type SymbolStyle.
n The Slice property, which defines the slice style for the object. This specifies the
offset for the exploding pie slices. This property is of type SliceStyle.

110 Part I n Using 2D Chart


The ChartStyles Collection

The ChartStyles collection contains the ChartStyle objects defined for each series. The
following methods are defined for the ChartStyles collection:

Add(index) Add a new ChartStyle object to the collection

Remove(index) Remove a ChartStyle object from the collection

Normally, you will not need to add or remove ChartStyle objects from the collection
yourself. If a ChartStyle object already exists when its corresponding series is created, the
previously created ChartStyle object is used to display the data in this series.

By looping through the ChartStyles collection, you can quickly change the behavior of all
of the bars, lines or points in a chart. For example, the following code lightens all of the
bars in a chart whenever the mouse is clicked:
Private Sub Chart2D1_Click()
Dim Style As Object
For Each Style in Chart2D1.ChartGroups(1).Styles
Style.Fill.Color = Style.Fill.Color + &H50505
Next Style
End Sub

Note that this only works if the Color property is initially set to an RGB color value (if the
most significant bit is set to 0).

Examples

The following statement sets the color of the first bar in a chart to green:
Chart2D1.ChartGroups(1).Styles(1).Fill.Color = RGB(0,128,0)

The following sets the line pattern for the second line in a plot to a dotted line:
Chart2D1.ChartGroups(1).Styles(2).Line.Pattern = oc2dLineDotted

And the following statement sets the symbol style for the third line in a plot to an unfilled
circle:
Chart2D1.ChartGroups(1).Styles(3).Symbol.Shape = oc2dShapeCircle

Olectra Chart OCX


The PointStyles Collection

The PointStyles collection contains the ChartStyles objects defined for each point. The
behavior of the PointStyles collection is similar to that of the ChartStyles collection
described above, except that the PointStyles collection is indexed by 2 variables, the
series and point. When specifying the style for a single point in a series, the child objects
make available an additional method called UseDefault that sets the style for the
individual point to the style used by its series.

Chapter 7 n Customizing Chart Elements 111


PointStyles for different Chart types

PointStyles can be set for these Chart types:


n For Plot, Bubble, Polar and Radar charts, point styles can be applied to the point style,
size, and color.
n For Bar and Stacking Bar charts, point styles can be applied to the fill color and fill
pattern of individual bars.
n For Pie charts, point styles can be applied to the fill color and fill pattern of individual
pie slices, including the other slice.
n For HiLo, HiLoOpenClose, and Candle charts, all elements of their point styles can be
altered.

Note: PointStyles cannot be applied to Area and Filled Radar Charts

Examples

The following statement sets the color of the second bar in the first series in a chart to
green.
Chart2D1.ChartGroups(1).PointStyles(1,2).Fill.Color = RGB(0,128,0)

The following sets the offset for the fourth slice in the third pie in a plot to 10% of the
radius.
Chart2D1.ChartGroups(1).PointStyles(4,3).Slice.Offset = 10

The following sets the fill style for the second point in the third series to the default style
used by the series:
Chart2D1.ChartGroups(1).PointStyles(4,3).Fill.UseDefault = True

The following is the object hierarchy for the ChartStyle and PointStyle objects and their
children:
Olectra Chart OCX

For more information, see the PointStyles Collection.

112 Part I n Using 2D Chart


7.5 Adding Images to Chart Elements
You can add a Windows bitmap (.BMP) or Metafile (.WMF or .EMF) image to the
background of any chart element. You can add separate images to the following chart
elements:
n Chart
n ChartArea
n ChartLabels
n PlotArea
n Header and Footer
n Legend

To Add an Image to a Chart Element:

Use the Image Object’s FileName property to specify the name and location of the image
you want to display. The image must be in either Windows bitmap or Metafile format. Use
the IsEmbedded property to include the specified image with the chart. If IsEmbedded is
True, the image will be included with your chart (when the chart is saved). If IsEmbedded
is False, the chart will look for the image file in the specified location. Note that if you set
IsEmbedded, you should not change or remove the value of FileName. This property is
still required to point to the graphic you want to use so that it can be embedded into the
chart at runtime.

To Set the Image Layout:

Use the Layout property to specify how the image is to be displayed. You can set Layout
to one of the following:
n Centered - places the image in the center of the chart element
n Fitted - resizes the image to fit as much of the chart element as possible, while
maintaining the image’s aspect ratio (so that the image remains in proportion)
n Stretched - resizes the image to fit the entire chart element area. For best results with

Olectra Chart OCX


stretching images, use either a Metafile or Enhanced Metafile format.
n Stretch to Width - stretches the image horizontally to match the chart element width.
For best results with stretching images, use either a Metafile or Enhanced Metafile
format.
n Stretch to Height - stretches the image vertically to match the chart element height.
For best results with stretching images, use either a Metafile or Enhanced Metafile
format.
n Tiled - repeats the image to fill the entire chart element
n Cropped Fit - resizes the image to fit the shorter of the two chart element dimensions
(either the height or the width), and crops the other dimension

These properties are located on the Control, ChartArea, PlotArea, Legend,


ChartLabels, and Titles Image Tab.

Chapter 7 n Customizing Chart Elements 113


Using Images as Labels

Use the HasMinimumSize property to use an image as a label. When HasMinimumSize


is enabled the text area in which the image appears will be sized according to the image
dimensions, so when a text area is empty, the image itself will appear as the label. When
HasMinimumSize is disabled, the text area will be sized according to the text. If
HasMinimumSize is enabled and the text is larger than the image, then the text determines
the size. HasMinimumSize applies to Titles and ChartLabels, and can be found on their
respective Image tabs.

Notes
n Enhanced Metafiles are only supported under Windows 95/98 and Windows NT.
n If the background image type either a Metafile (.WMF) or Enhanced Metafile (.EMF)
format, the image will not draw when the chart is either copied to the clipboard or
copied to a file when using the Metafile format. To get around this limitation, it is
recommended that you set the drawing format to a Bitmap format when you want to
copy your chart to the printer, clipboard or file.
n When text areas containing background images are rotated, the image is not rotated
with the text area.
n The background image is not clipped to the circular PlotArea when rendering to a
Metafile for Polar and Radar chart types.

7.6 Changing the ChartArea Appearance


You can customize how the Chart looks from the ChartArea’s General subtab of the
Property Editor.

Changing Axes Orientation

The default orientation for your chart is with the X-axis displayed horizontally, and the Y-
axis displayed vertically. Use the IsHorizontal property to switch the orientation of the X-
Olectra Chart OCX

and Y-axes. You can change the axes orientation for all ChartTypes except for Pie, Polar,
Radar and Filled Radar types.

Showing and Hiding Chart Outlines

By default, an outline is drawn around each series for Area, Bar, Stacking Bar and Pie
charts. Use the IsShowingOutlines property to turn the outlines on or off.

Viewing Stacking Charts as 100 Percent

Use the IsYAxis100Percent and IsY2Axis100Percent properties to scale the Y and Y2


axes of stacking charts to a common 100 percent value. When Is[YY2]Axis100Percent is
False, the actual series data is used. When Is[YY2]Axis100Percent is True, the data is
scaled so that each stacked set is the same height and each series is scaled to a total of 100
percent.

114 Part I n Using 2D Chart


These properties are located on the Axes tab’s General subtab on the Property Editor.

7.7 Using Borders


Adding a border to part of the chart can help highlight important information, or simply
make the chart look more attractive. You can customize the border type and width of the
following chart elements:
n Header and Footer titles
n Legend
n ChartArea
n each ChartLabel added to the chart
n the entire chart

The valid border types are shown below; you can also specify that no border is used.

Olectra Chart OCX

To change a border

Use the border Type property to set the type of border and the Width property to set its
thickness. These properties are located on the Border inner tab, found on the Control,
ChartArea, Titles, Legend, and ChartLabels tabs of the Property Editor.

Chapter 7 n Customizing Chart Elements 115


7.8 Choosing Fonts
A chart can have more impact when you customize the fonts used for different chart
elements. You may also want to change the font size to make an element better fit the
overall size of the chart. Any font available when the chart is running can be used. You can
set the font for the following chart elements:
n Header and Footer titles
n Legend
n Axis annotation and title
n each ChartLabel added to the chart

To Change a Font:

Use the font properties to set the font, style, and size attributes. Font properties are located
on their own dialog on the Font inner tab, found on the Titles, Legend, Axes, and
ChartLabels tabs on the Property Editor. Click the button on the tab to display the dialog.

Notes
n Olectra Chart uses the container’s exposed Ambient font (if available) as its own
default font.
n The Color control in the font chooser dialog has no effect on the text color. To set the
color of text, use the ForegroundColor property, located on the Interior inner tab of
that element (located on the ChartArea tab for the axis text color).
n When you want to rotate the axis annotation or title, you must use a scalable font
(such as any TrueType font) for the axis. See Titling Axes and Rotating Axis Elements
for more information.

7.9 Setting Colors


Color can powerfully enhance a chart’s visual impact. You can customize colors using
Olectra Chart OCX

color names, RGB values, or interactively using a color chooser. Each of the following
visual elements in the chart has a background and foreground color that you can
customize:
n the entire chart
n Header and Footer titles
n Legend
n ChartArea
n PlotArea (background only)
n each ChartLabel added to the chart

The other chart elements that have color properties are ChartStyles, GridLines, and
Markers.

116 Part I n Using 2D Chart


Specifying named colors

You can specify a color as one of over 200 recognized named colors. Choose common
colors like Blue or Orange, or more exotic colors like Chartreuse or HotPink. Most of
these colors look best on systems that can display 256 colors or more.

Choosing colors interactively

You can choose colors interactively using a color chooser dialog that works just like the
standard Windows Control Panel color chooser. Choose from Windows basic colors,
custom colors, or interactively with a full color spectrum.

Specifying RGB colors

Alternately, you can specify a color by its RGB components, useful for matching another
RGB color. RGB color values combine hexadecimal values for the red, green, and blue
components of a color. 00 is the smallest value a component can have; ff is the largest
value. For example, #ff00ff specifies magenta (the maximum value of red and blue
combined with no green).

Using Automatic colors

The background and foreground of all elements except the chart itself can be Automatic.

When a background or foreground is automatic, the chart uses the color of the element
outside it for the background. For example, the header would have the background of the
chart itself when its background is set to Automatic.

To Change a Color:

Use the BackgroundColor and ForegroundColor properties to set background and


foreground colors. These properties are located on the Interior inner tab, found on the
Control, Titles, Legend, ChartArea, PlotArea, and ChartLabels tabs of the Property
Editor. RGB and named colors have their own controls. The button displays the interactive
color chooser dialog.

Olectra Chart OCX


7.10 Positioning Chart Elements
Each of the main chart elements (header, footer, legend, ChartArea, and ChartLabels) has
properties that control its position and size. While the chart can automatically control
these properties, you can also customize the following:
n Positioning of any element except ChartLabels
n Size of the ChartArea only

When the chart controls positioning, it first allows space for the header, footer, and legend,
if they exist (size is determined by contents, border, and font). The ChartArea is sized and
positioned to fit into the largest remaining rectangular area. Positioning adjusts when other
chart properties change.

Chapter 7 n Customizing Chart Elements 117


To Change or View Location:

Use the Left location property to specify the number of pixels from the edge of the chart to
the left edge of the chart element. Use the Top location property to specify the number of
pixels from the edge of the chart to the top of the chart element. Left and Top have
IsDefault properties that allow the chart to automatically position the element.

These properties are located on the Location inner tab, found on the ChartArea, Titles,
Legend, and ChartLabels tabs of the Property Editor.

To Change Width and Height (ChartArea only):

Use the Width and Height location properties to specify the width and height of the
ChartArea. These properties have IsDefault properties that allow the chart to
automatically size the ChartArea.

These properties are located and enabled on the ChartArea tab’s Location inner tab on
the Property Editor.

7.11 Adjusting PlotArea Margins


The distance between the edges of the ChartArea and the PlotArea is called a margin.
There are separate margins for the top, bottom, left, and right edges. You can allow the
chart to automatically control margins, or you can customize them.
Olectra Chart OCX

118 Part I n Using 2D Chart


When the chart controls a margin, it sets enough space to display axis annotation and axis
title. As axis and data properties change, the chart adjusts the margins as necessary.

You can fix a margin so that it does not change as axis and data properties change, and to
achieve effects such as:
n Scaling or zooming a chart. When margins are all negative, axes and annotation are
clipped outside the PlotArea; the chart appears zoomed-in. When margins are all high
positive values, there is a lot of space around the PlotArea; the chart appears zoomed-
out.
n Moving or translating a chart. For example, when top margin is increased and bottom
margin decreased by the same amount, the chart moves down.

It is easier to achieve these effects interactively. See Interacting with the Chart for details.

To Set Margins

Use the PlotArea Top, Bottom, Left, or Right properties to set the value of a margin.
When you set a margin value, it remains fixed at that value until you change it or set its
IsDefault property.

To Use Automatic Margins

Use the IsDefault properties of the Top, Bottom, Left, and Right margin properties to
allow the chart to automatically determine appropriate margins.

All PlotArea margin properties are located on the PlotArea tab’s General inner tab on the
Property Editor.

Olectra Chart OCX

Chapter 7 n Customizing Chart Elements 119


7.12 Adding the 3D Effect
Bar, stacking bar, and pie charts can be enhanced with a 3D effect. You can set the visual
depth and the elevation angle of the 3D effect. You can also set the rotation angle on bar
and stacking bar charts.
Olectra Chart OCX

3D Depth

Use the Depth View3D property to set the visual depth of the 3D effect, as a percentage of
the chart width. The maximum value is 500.

3D Elevation

Use the Elevation property to set the distance above the X-axis for the 3D effect, in
degrees. This can be from -45 to 45 degrees.

3D Rotation

Use the Rotation property to set the distance right of the Y-axis for the 3D effect, in
degrees. This cannot be higher than 45 or lower than -45.

120 Part I n Using 2D Chart


All View3D properties are located on the View3D tab’s General inner tab on the Property
Editor.

Shading

Use the Shading property to set the shading method for the 3D areas of the chart. Using
the Dithering method takes the graph color and uses white or black dots to make the 3D
portion of the graph either lighter or darker, respectively. Using the Color shading method
uses either a lighter or darker shade of the graph color to create the 3D effect.

7.13 Resizing Forms


Some applications permit the resizing of a Form object at runtime. This resizing is
enabled at design time by setting the form's BorderStyle property to either 2 (Sizable) or 5
(Sizable ToolWindow).

To adjust the size of a Chart2D object when the Form object is resized, define a Resize
procedure for the form, and adjust the chart's height and width to correspond to the form's
height and width. For example, the following Resize procedure is defined by the chlabels
demo:
Private Sub Form_Resize()
’ Match the graph to the size of the form.
If Width > 700 Then ’ Check the width of the window
’ This keeps a consistent border around the
’ sides of the chart
Chart2D1.Width = Width - 700
Else
’ Sets the width to 0 because the window
’ is smaller than the size of the chart
Chart2D1.Width = 0
End If

If Height > 1360 Then ’ Check the height of the window


’ This keeps a consistent border around the
’ top and bottom of the chart

Olectra Chart OCX


Chart2D1.Height = Height - 1360
Else
’ Sets the height to 0 because the window is smaller than
’ the size of the chart
Chart2D1.Height = 0
End If
End Sub

Chapter 7 n Customizing Chart Elements 121


7.14 Using ChartLabels
A ChartLabel is a label that displays in front of the chart data. The chart does not adjust to
make room for ChartLabels, they are completely independent. ChartLabels are useful
when you want to highlight an important data point, but can also be used generally to
provide information on data or on the chart.

There is no limit to the number of ChartLabels a chart can contain. Each ChartLabel has
label, interior color, border and attachment attributes that you can customize.

Attaching and Positioning ChartLabels

When you define a ChartLabel, you need to specify how to attach it to the chart and where
to position it relative to its attachment point.

The attachment method you choose depends on what you are using the ChartLabel for.
The following illustrates and describes the valid attachment methods:
Olectra Chart OCX

n Coord attaches to anywhere on the chart. You specify the number of pixels between
the top-left corner of the chart to the ChartLabel.
n DataCoord attaches to anywhere inside the PlotArea. You specify the data
coordinates. This method is not allowed on pie charts using PointLabels for the X-axis
annotation. If any part of the ChartLabel falls outside of the ChartArea, it is clipped.
n DataIndex attaches to a specific data point on the chart. You specify the series and
point indices, and the ChartGroup.
n DataIndex & Data Y attaches to a distance above or below a specific data point. You
specify the series and point indices, the ChartGroup, and the Y-coordinate. This is
most useful for bar and stacking bar charts.

Use the AttachMethod ChartLabel property to set the attachment method, and the
AttachCoord, AttachDataCoord, or AttachDataIndex properties to set the attachment

122 Part I n Using 2D Chart


point. These properties are located on their own dialog on the ChartLabels tab’s General
inner tab on the Property Editor. Click the AttachMethod button to display the dialog.

Once attached to a point on the chart, you can choose the anchoring position that works
best for that ChartLabel. The following shows the valid anchoring positions:

Use the Anchor ChartLabel property to specify where to position the ChartLabel relative
to its attachment point. In addition to the eight compass points, you can choose Home to
center the ChartLabel over its attachment point or Best to allow the chart to determine the
best position. Anchor is located on the ChartLabels tab’s General inner tab on the
Property Editor.

Connecting Line and Offset

Use the IsConnected property to draw a line connecting the ChartLabel to its attachment
point and the Offset property to set the distance between the ChartLabel and its

Olectra Chart OCX


attachment point. IsConnected and Offset are located on the ChartLabels tab’s General
inner tab on the Property Editor.

ChartLabel Text and Alignment

Use the Text label property to set or change a ChartLabel’s text. Text is located on the
ChartLabels tab’s Label inner tab on the Property Editor. To enter multiple lines of text,
press ENTER between each line. You can add up to 100 lines of text for each ChartLabel.

Use the Adjust property to specify whether to center, left-justify, or right-justify a multi-
line ChartLabel. Adjust is located on the ChartLabels tab’s General inner tab on the
Property Editor.

Chapter 7 n Customizing Chart Elements 123


Rotating ChartLabels

Use the Rotation label property to set or change the rotation of a ChartLabel. Rotation is
located on the ChartLabels tab’s General inner tab on the Property Editor. ChartLabels
can be rotated by 0, 90 or 270 degrees.

ChartLabel Border

Use the Type and Width border properties to customize the title’s ChartLabel. These
properties are located on the ChartLabels tab’s Border inner tab on the Property Editor.
SeeUsing Borders on page 115 for more information.

ChartLabel Colors

Use the interior properties to customize background and text colors of a ChartLabel. These
are located on the ChartLabels tab’s Interior inner tab on the Property Editor. See Setting
Colors on page 116 for more information.

ChartLabel Font

Use the font properties to customize the font used for a ChartLabel. These are located on
the ChartLabels tab’s Font inner tab on the Property Editor. See Choosing Fonts on page
116 for more information.

ChartLabel Location

Use the Left, Top, Width and Height location properties to see the current size and
position of a ChartLabel. You cannot change these properties because the size/location is
determined by the label text and the attachment method. These properties are located on
the ChartLabels tab’s Location inner tab on the Property Editor.

7.15 Programming ChartLabels


Olectra Chart OCX

A ChartLabel object defines an independent rectangular region which can be attached to


a chart. The ChartLabels collection contains all of the chart labels defined for a particular
chart.

To create a ChartLabel object, call the Add method:


Dim label As Object
Set label = Chart2D1.ChartLabels.Add

The Remove method removes a ChartLabel from the collection:


Chart2D1.ChartLabels.Remove 1

You can pass either the chart label's index or its name to Remove.

To quickly remove all ChartLabels from the collection, use the RemoveAll() method:
Chart2D1.ChartLabels.RemoveAll()

124 Part I n Using 2D Chart


Defining the ChartLabel

The ChartLabel object provides a number of properties that help you define and position
the chart label. The most important of these properties are:
n The Text property specifies the text to appear in the chart label, and is of type Label.
n The Anchor property specifies the location of the chart label relative to the location to
which it is attached. The location is specified as an anchor constant, which represents
a compass direction.
n The IsConnected property is a Boolean which specifies whether a line is to be drawn
from the chart label to its attached location. If True, the line is drawn.
n The Offset property specifies the distance, in the anchor direction, from the chart label
to its attached location, and is of type Long.

The following code sets the above properties:


With Chart2D1.ChartLabels(1)
.Text = "Here is my chart label"
.Anchor = oc2dAnchorSouthWest
.Offset = 20
.IsConnected = True
End With

Attaching the ChartLabel

Chart labels can be attached to a chart in one of four ways:


n to a pixel (x,y) coordinate
n to a data (x,y) coordinate in the chart area
n to a (series, point) in the chart area
n to a (series, point, Y-value) in the chart area

To attach a chart label to a pixel coordinate, set the AttachMethod property to


oc2dAttachCoord, and then set the AttachCoord property to the coordinates at which
the chart label is to be attached. For example, the following attaches a chart label to the top
left corner of the legend:

Olectra Chart OCX


With Chart2D1.ChartLabels(1)
.AttachMethod = oc2dAttachCoord
.AttachCoord.X = Chart2D1.Legend.Location.Left
.AttachCoord.Y = Chart2D1.Legend.Location.Top
End With

To attach a chart label to a data coordinate on the chart, set the AttachMethod property to
oc2dAttachDataCoord, and then set the AttachDataCoord property to the coordinates
of the value. For example, the following attaches a chart label to the data coordinate (1.1,
15.8):
With Chart2D1.ChartLabels(1)
.AttachMethod = oc2dAttachDataCoord
.AttachDataCoord.X = 1.1
.AttachDataCoord.Y = 15.8
End With

Chapter 7 n Customizing Chart Elements 125


Chart labels can only be attached to a data coordinate if the chart is an area or plot, and the
X-axis is not annotated using point labels. Any part of the chart label that falls outside of
the chart area is clipped.

To attach a chart label to a data point, set the AttachMethod property to


oc2dAttachDataIndex, and then set the AttachDataIndex property to the series and
point values that reference the specified data item. For example, the following attaches a
chart label to the second point in the first data series:
With Chart2D1.ChartLabels(1)
.AttachMethod = oc2dAttachDataIndex
.AttachDataIndex.Series = 1
.AttachDataIndex.Point = 2
End With

You can also combine the above two methods, and attach a chart label to a location whose
X-coordinate is specified by a data point and whose Y-coordinate is specified by a chart
value. To do this, set the AttachMethod property to oc2dAttachDataIndexDataY, as in
the following example:
With Chart2D1.ChartLabels(1)
.AttachMethod = oc2dAttachDataIndexDataY
.AttachDataIndex.Series = 1
.AttachDataIndex.Point = 2
.AttachDataCoord.Y = 15.8
End With

In this example, the chart label location is specified as follows:


n The X-coordinate of the second point in the first data series becomes the X-coordinate
of the chart label.
n The Y-coordinate specified by the AttachDataCoord property becomes the Y-
coordinate of the chart label.

This method is not supported in pie charts.

The following is the object hierarchy for the ChartLabels collection and the properties
described above:
Olectra Chart OCX

Chart2D Legend
Object
ChartLabels ChartLabel Collection

AttachCoord
Coord Object

Attach DataCoord
DataCoord Object

AttachDataIndex
DataIndex Object

126 Part I n Using 2D Chart


Batching ChartLabel Changes

To improve efficiency, you can batch changes to a chart label. To do this, set the
IsBatched property to True before changing any chart label properties, and set IsBatched
to False once you have finished. This ensures that the chart will be updated only once,
instead of after each property change.

Example

The following code defines a chart label that points to the chart’s legend:
Dim label As Object
...
Set label = Chart2D1.ChartLabels.Add
With label

’ Batch everything for even faster processing


.IsBatched = True
.Text = "That’s the legend!"

’ Set the method of the label attachment


.AttachMethod = oc2dAttachCoord

’ Set the actual X-axis location for the label


.AttachCoord.X = Chart2D1.Legend.Location.Left

’ Set the actual Y-axis location for the label


.AttachCoord.Y = Chart2D1.Legend.Location.Top

’ Set the anchor point for the label


.Anchor = oc2dAnchorNorthWest

’ Give it some room to draw a pointer line


.Offset = 20
.Border.Type = oc2dBorderShadow
.Border.Width = 4

’ Draw the line between the label and the region


.IsConnected = True
.IsBatched = False

Olectra Chart OCX


End With

7.16 Adding Markers


A marker is a vertical or horizontal line drawn on top of the chart. Markers are used to
identify a particular data point or chart coordinate. A programmer can write code that
moves markers as you move the mouse, or displays a marker when you click on part of a
chart. You can set where to display X- or Y-markers, and customize their visual attributes.

The chart can have two markers, X and Y. Each marker has positioning and LineStyle
attributes that you can customize.

Chapter 7 n Customizing Chart Elements 127


Markers and Chart Types

Plot, area, bar and stacking bar charts can display both markers. The X-marker is drawn
through the X-axis and the Y-marker is drawn through the Y-axis. Pie, polar, radar and
filled radar charts use the X-marker only. When using markers with combination charts,
you can specify the ChartGroup to apply the marker to.

Positioning Markers

When you add a marker, you need to specify how to position it on the chart. The method
you use depends on what you are using the marker for:
n Value (ByValue) positions the marker at the X- or Y- chart coordinate you specify.
The X-marker cannot use this method when the chart is pie using PointLabels X-axis
annotation.
n Index (ByData) positions the marker at a specific data point. You specify the series
index and point index within that series. You specify the chart coordinates. The X-
marker must use this method when the chart is a pie using PointLabels X-axis
annotation.

Use the Method marker property to set the method to use, and the marker’s Index or
Value properties to set the marker position. These properties are located on the Markers
tab’s Attach inner tab on the Property Editor.

Use the IsShowing marker property to display or hide a marker once you have positioned
it. IsShowing is located on the Markers tab’s General inner tab on the Property Editor.

Customizing Marker LineStyle

Use the LineStyle Pattern, Width, and Color properties to define the appearance of each
marker. These properties are located on the Markers tab’s LineStyle inner tab on the
Property Editor.

Use the IsStyleDefault marker property to reset marker style to a 1-pixel wide black
dashed line. IsStyleDefault is located on the Markers tab’s General inner tab on the
Property Editor.
Olectra Chart OCX

7.17 Programming Markers


Markers provide a way to identify a particular data element on the screen or a particular
value in a plot.

On plots, area graphs and bar charts, two markers are defined: an X-marker and a Y-
marker. The X-marker is a line perpendicular to the X-axis, and the Y-marker is a line
perpendicular to the Y-axis.

On stacking bar charts, the X-marker is a short line drawn through one of the bar blocks,
and the Y-marker is a line perpendicular to the Y-axis.

On pie charts, only the X-marker is defined, and is a line drawn from the center of the pie
outward through the center of the selected slice.

128 Part I n Using 2D Chart


In the 2D Chart control, the X- and Y-markers are represented by the Markers collection,
and are named X and Y respectively. To display a marker, set its IsShowing property:
Chart2D1.ChartArea.Markers("Y").IsShowing = True

Once the marker is displayed, it can be positioned. For example, the following code
positions the Y-marker at the point where the mouse is currently located. As the mouse
moves, the Y-marker moves with it.
Private Sub Chart2D1_MouseMove(Button As Integer, Shift As Integer, _
x As Single, y As Single)
Dim px As Long
Dim py As Long
Dim vx As Double
Dim vy As Double
px = x / Screen.TwipsPerPixelX ’ Get the current mouse X position
py = y / Screen.TwipsPerPixelY ’ Get the current mouse Y position

’ Convert to chart coordinates


Chart2D1.ChartGroups(1).CoordToDataCoord px, py, vx, vy

’ Set position of Y-marker


Chart2D1.ChartArea.Markers("Y").Value.y = vy
End Sub

This procedure positions the marker using chart coordinates. You can also position a
marker by specifying a dataset and point through which the marker should be drawn. To
do this, use the Index property instead of the Value property.

Performance Issues

Updating the marker positioning properties occurs very quickly. This is because the 2D
Chart does not repaint the entire chart window to reposition the markers. Marker
performance is improved by setting the IsDoubleBuffered property of the Chart2D
object to True. (However, general chart performance is improved by turning double
buffering off.)

Markers and Data Styles

Olectra Chart OCX


Note that both the X- and Y-marker data styles can have a different appearance by using
separate X- and Y-marker data styles.

Chapter 7 n Customizing Chart Elements 129


Olectra Chart OCX

130 Part I n Using 2D Chart


8
Programming User Interaction
Programming Actions n Returning Coordinate Values n Customizing the Property Editor

Olectra Chart allows you to interact with the user, reacting to specific mouse, menu and
keyboard actions. You can also determine which tabs from the Property Editor you want
users to see. The following topics cover the different types of user interaction.

Olectra Chart OCX

131
8.1 Programming Actions
A chart action is a user event that causes some interactive action to take place in the
control. There are three stages of user interaction defined in 2D Chart:
n Starting a user interaction
n Updating a user interaction
n Ending a user interaction

Chart actions are defined for each of these stages. The complete list of actions is specified
by the Action Constants.

Action Maps

An action map is a mapping of a mouse operation and/or key pressing to a chart action.
Each action map consists of three parts:
n The message (indicating what mouse operation or key pressing occurred)
n Any modifier flags
n The keycode (if the message is WM_KEYDOWN or WM_KEYUP)

The ActionMaps collection specifies the action maps currently defined for the 2D Chart
control.

Recognized Messages

The following messages are recognized:

WM_LBUTTONDBLCLK double-click left mouse button

WM_MBUTTONDBLCLK double-click both mouse buttons

WM_RBUTTONDBLCLK double-click right mouse button

WM_LBUTTONDOWN press left mouse button


Olectra Chart OCX

WM_MBUTTONDOWN press both mouse buttons

WM_RBUTTONDOWN press right mouse button

WM_LBUTTONUP release left mouse button

WM_MBUTTONUP release both mouse buttons

WM_RBUTTONUP release right mouse button

WM_MOUSEMOVE move mouse

WM_KEYDOWN press key

WM_KEYUP release key

132 Part I n Using 2D Chart


These constants are defined in oc_api.bas, which is located in the \CHART\INCLUDE
directory.

If you have a three-button mouse, holding down the middle mouse button is equivalent to
simultaneously holding down the left and right mouse buttons.

Modifier Flags

The following modifier flags are recognized:

MK_LBUTTON left mouse button

MK_MBUTTON both mouse buttons

MK_RBUTTON right mouse button

MK_ALT Alt key

MK_SHIFT Shift key

MK_CONTROL Ctrl key

These constants are defined in oc_api.bas, which is located in the \CHART\INCLUDE


directory.

Recognized Keycodes

Any valid VK_ value is treated as a recognized keycode. Note the following, however:
n All alphabetic characters are forced to upper case.
n MK_SHIFT must appear in the modifier if capitals are desired.
n The CapsLock key toggles the meaning of the MK_SHIFT modifier.

Determining Action Mappings

Olectra Chart OCX


To determine which action is mapped to a particular Microsoft Windows message, use the
Item property, which is defined by the ActionMaps collection. For example, the
following statement returns the action performed when the left mouse button is clicked:
Dim LeftMouse As Object
...
Set LeftMouse = Chart2D1.ActionMaps.Item WM_LBUTTONDOWN, 0, 0

An exception is generated if no action is mapped to a particular message.

Chapter 8 n Programming User Interaction 133


By default, the following action maps are defined (message and modifier flags shown):

WM_MBUTTONDOWN, oc2dActionModifyStart (start rotation)


MK_MBUTTON,0

WM_MBUTTONDOWN, oc2dActionModifyStart (start translation)


MK_MBUTTON+MK_SHIFT, 0

WM_MBUTTONDOWN, oc2dActionModifyStart (start scaling)


MK_MBUTTON+MK_CONTROL, 0

WM_LBUTTONDOWN, oc2dActionZoomStart (start graphics zooming)


MK_MBUTTON+MK_CONTROL, 0

WM_LBUTTONDOWN oc2dActionZoomStart (start axis zooming)


MK_MBUTTON+MK_SHIFT, 0

WM_MOUSEMOVE, MK_MBUTTON, 0 oc2dActionRotate

WM_MOUSEMOVE, MK_MBUTTON + oc2dActionTranslate


MK_SHIFT, 0

WM_MOUSEMOVE, MK_MBUTTON + oc2dActionScale


MK_CONTROL, 0

WM_MOUSEMOVE, MK_LBUTTON + oc2dActionZoomUpdate


MK_CONTROL, 0

WM_MOUSEMOVE, MK_LBUTTON + oc2dActionZoomUpdate


MK_SHIFT, 0

WM_MBUTTONUP, 0, 0 oc2dActionModifyEnd (end rotation)

WM_MBUTTONUP, MK_SHIFT, 0 oc2dActionModifyEnd (end translation)

WM_MBUTTONUP, MK_CONTROL, 0 oc2dActionModifyEnd (end scaling)

WM_LBUTTONUP, MK_CONTROL, 0 oc2dActionZoomEnd (end zooming)


Olectra Chart OCX

WM_LBUTTONUP, MK_SHIFT, 0 oc2dActionZoomAxisEnd (end axis zooming)

WM_KEYDOWN, 0, ’R’ oc2dActionReset

WM_RBUTTONDOWN, MK_MBUTTON,0 oc2dActionProperties

WM_KEYDOWN, MK_LBUTTON, oc2dActionZoomCancel


VK_ESCAPE

Programming Action Mappings

To program an action mapping, use the Add method to add the new action mapping to the
collection.

134 Part I n Using 2D Chart


For example, the following tells 2D Chart to undo all scaling and translations when the left
mouse button is double-clicked:
Dim NewLeft As Object
...
With Chart2D1.ActionMaps
Set NewLeft = .Add WM_LBUTTONDBLCLK, 0, 0, oc2dActionReset
End With

All 2D Chart actions are can be customized: you can determine which Microsoft Windows
message will call a particular action, and decide on the appropriate steps to perform in
each case.

Removing Action Mappings

To remove an existing action mapping, use the Remove method to remove the action
mapping from the collection:
With Chart2D1.ActionMaps
.Remove WM_LBUTTONDBLCLK, 0, 0
End With

Note that Remove generates an exception if the action does not exist.

Calling an Action Directly

To call an action directly, call the CallAction method, which is defined by the Chart2D
object. This method is passed the action to be performed and the X- and Y- coordinates of
a window location.

For examples of code using CallAction, refer to the actions demo provided with your
Olectra Chart distribution.

Actions and Events

Each of the actions defined in the Action Constants maps to a 2D Chart event method. The
following mappings are defined:

Olectra Chart OCX


oc2dActionNone no event method called

oc2dActionModifyStart ModifyStart()

oc2dActionModifyEnd ModifyEnd()

oc2dActionRotate View3DModify()

oc2dActionScale PlotAreaModify()

oc2dActionTranslate PlotAreaModify()

oc2dActionZoomStart ModifyStart()

oc2dActionZoomUpdate no event method called

oc2dActionZoomCancel PlotAreaModify()

Chapter 8 n Programming User Interaction 135


oc2dActionZoomEnd PlotAreaModify(), ModifyEnd()

oc2dActionZoomAxisEnd ZoomAxisModify(), ModifyEnd()

oc2dActionReset ModifyStart(), PlotAreaModify(), ModifyEnd()

oc2dActionProperties Property Editor is displayed

The event methods are defined in the Event Reference section. Note that some actions
trigger multiple events.

8.2 Returning Coordinate Values


The ChartGroups collection provides methods which enable you to do the following:
n Determine the pixel coordinates of a given data point, or the closest point to a given
set of pixel coordinates.
n Convert from data coordinates to screen pixel coordinates and vice versa.

Determining Coordinate Values

To determine the pixel coordinates of a given data point, call DataIndexToCoord. For
example, the following code obtains the pixel coordinates of the point in the second row
and third column:
Dim PixelX As Long
Dim PixelY As Long
...
With Chart2D1.ChartGroups(1)
.DataIndexToCoord 2, 3, PixelX, PixelY
End With
’ PixelX and PixelY now contain the pixel coordinate value

Converting Data Coordinates to Pixel Coordinates


Olectra Chart OCX

To convert from data coordinates to screen pixel coordinates, call the


DataCoordToCoord method. For example, the following code obtains the pixel
coordinates corresponding to the data coordinates (5.1, 10.2):
Dim PixelX As Long
Dim PixelY As Long
...
With Chart2D1.ChartGroups(1)
.DataCoordToCoord 5.1, 10.2, PixelX, PixelY
End With
’ PixelX and PixelY now contain the pixel coordinate value

If the data coordinate is out of the visible range of the chart, both of the pixel X- and Y-
coordinates are set to -1.

136 Part I n Using 2D Chart


Converting Pixel Coordinates to Data Coordinates

To convert from pixel coordinates to data coordinates, call CoordToDataCoord. For


example, the following converts the pixel coordinates (225, 92) to their equivalent data
coordinates:
Dim DataX As Double
Dim DataY As Double
Dim Region As Integer
...
With Chart2D1.ChartGroups(1)
Region = CoordToDataCoord 225, 92, DataX, DataY
End With
’ DataX and DataY now contain the data coordinate value

CoordToDataCoord returns, as its return value, the region of the chart in which the pixel
coordinates are located. This region is represented as a region constant.

Picking Data Points

To determine the closest data point to a set of pixel coordinates, call CoordToDataIndex:
Dim Row As Long
Dim Column As Long
Dim Distance As Long
Dim Region As Integer
...
With Chart2D1.ChartGroups(1)
Region = CoordToDataIndex 225, 92, Row, Column
End With

CoordToDataIndex returns the row and column of the closest data point, and also returns
the distance in pixels between the pixel coordinates and the point. CoordToDataIndex
returns, as its return value, the region of the chart in which the pixel coordinates are
located. This region is represented as a region constant. When the returned region is
oc2dRegionInLegend, the returned point value is also set to oc2dRegionInLegend, and
the returned series is the closest element in the legend.

Converting Visual Basic Coordinates

Olectra Chart OCX


In Visual Basic, coordinate values are measured in twips (1,440 twips equals one inch).
The following code converts the height and width of a chart from twips to pixels:
pixwidth = Chart2D1.Width / Screen.TwipsPerPixelX
pixheight = Chart2D1.Height / Screen.TwipsPerPixelY

Chapter 8 n Programming User Interaction 137


8.3 Customizing the Property Editor
Depending on the type of chart you create, you may want to allow users to view the entire
Property Editor, or only part of it. By hiding a Property Editor tab or subtab, you can
determine what chart components users can customize.

To Hide a Property Editor Tab

Use the ShowChartEditorElement method to set the display state of the Property Editor
tab. The following example hides the Control tab and the Font subtab of the Axes tab:
Chart2d1.ShowChartEditorElement oc2dceeControl, False
Chart2d1.ShowChartEditorElement oc2dceeAxesFont, False

To Display a Property Editor Tab Display State

Use the IsChartEditorElementVisible method to determine if the tab is currently hidden


or visible. The method returns True if the element is visible, and False otherwise. The
following example gets the display state for the Font subtab of the Axes tab, and shows the
tab if it is currently hidden:
If Chart2d1.IsChartEditorVisible (oc2dceeAxesFont) = False then
Chart2d1.ShowChartEditorElement oc2dceeAxesFont, True
EndIf
Olectra Chart OCX

138 Part I n Using 2D Chart


9
Adding an Olectra Chart 2D Control to
a Web Page
Getting Started n Creating a Web Page
Creating a Licence Pack File n Packaging the Control
Testing your Web Page

You can add an Olectra Chart 2D control to a web page. Steps 1-5 provide detailed
information on the tools you need, how to insert the control, how to create the license pack
file, how to optimize the download process and what to look for when testing the web
page.

Olectra Chart OCX

139
9.1 Getting Started
Before you can add Olectra Chart to your web page, you will need the following tools:

Microsoft ActiveX SDK - Use this SDK to create the License Pack File (.LPK) that users
will download when viewing a web page containing an Olectra Chart ActiveX control.
You can download the ActiveX SDK from:
http://msdn.microsoft.com/developer/sdk/inetsdk/asetup/

For more information about the ActiveX SDK, go to:


http://msdn.microsoft.com/developer/sdk/inetsdk/help/default.htm

Microsoft Cabinet SDK - Use this SDK to create the Cabinet file which stores all the
files to be downloaded. Creating a .CAB file helps to minimize the download time, and to
keep all downloaded files together You can download the Cabinet SDK from:
http://www.microsoft.com/workshop/management/cab/cabdl.asp

9.2 Creating a Web Page


The first step in adding an ActiveX control to a web page is to create the HTML page, and
add the required code to insert, size and access the chart. The following three steps outline
how to do this:
1. Create the web page that you want to add Olectra Chart to.
2. Insert and size the ActiveX control. To do this, add an <OBJECT> tag to your HTML
code as follows:

<OBJECT ID="Chart2D1" WIDTH=473 HEIGHT=352


CLASSID="CLSID:92D71E93-25A8-11CF-A640-9986B64D9618"
CODEBASE="olectra.cab">
</OBJECT>

When this HTML code is processed, the browser checks to see if you have Olectra
Chart registered, and if not it will download and register the control.
Olectra Chart OCX

If you also want to specify a version the control to check for, add the Version element.
This will avoid such problems as using new functionality with a prior version of the
control. The following example shows how to specify the control version to search
for:
<OBJECT ID="Chart2D1" WIDTH=473 HEIGHT=352
CLASSID="CLSID:92D71E93-25A8-11CF-A640-9986B64D9618"
CODEBASE="http://www.yoursite.com/olectra.cab#Version=6,0,0,0">
</OBJECT>
3. To set properties, load data or access the chart, you must write VBScript code. For ex-
ample, the following code sets the header, footer, ChartType and adds some data:

140 Part I n Using 2D Chart


<SCRIPT LANGUAGE="VBScript">
<!--
Sub Window_OnLoad()
’Declare a Variable
Dim x

’Batch the updates to the Chart


Chart2D1.IsBatched = True

’Setup the Header


Chart2D1.Header.Text = "Statistics By Region"
Chart2D1.Header.Border.Type = 3 ’oc2dBorderShadow
Chart2D1.Header.Border.Width = 4
Chart2D1.Header.Interior.BackgroundColor = RGB(190, 190, 190)
Chart2D1.Header.Font.Bold = True

’Setup the Footer


Chart2D1.Footer.Text = "Nowhere"
Chart2D1.Footer.Border.Type = 3 ’oc2dBorderShadow
Chart2D1.Footer.Border.Width = 4
Chart2D1.Footer.Interior.BackgroundColor = RGB(210, 210, 210)
Chart2D1.Footer.Font.Size = 10
Chart2D1.Footer.Font.Bold = True

’Add some data to the Chart


Chart2D1.ChartGroups(1).ChartType = 3 ’oc2dTypePie
Chart2D1.ChartGroups(1).Data.NumSeries = 5
Chart2D1.ChartGroups(1).Data.NumPoints(1) = 1
Chart2D1.ChartGroups(1).Data.y(1, 1) = 20
Chart2D1.ChartGroups(1).Data.y(2, 1) = 15
Chart2D1.ChartGroups(1).Data.y(3, 1) = 25
Chart2D1.ChartGroups(1).Data.y(4, 1) = 30
Chart2D1.ChartGroups(1).Data.y(5, 1) = 20
’Give the Chart a 3D look
Chart2D1.ChartArea.View3d.Depth = 20
Chart2D1.ChartArea.View3d.Elevation = 30

’Setup some colors and borders


Chart2D1.Interior.BackgroundColor = RGB(170, 170, 170)

Olectra Chart OCX


Chart2D1.Interior.ForegroundColor = RGB(0, 0, 0)
Chart2D1.Border.Type = 2 ’oc2dBorder3DIn
Chart2D1.Border.Width = 5
Chart2D1.ChartArea.Border.Type = 1 ’oc2dBorder3DOut
Chart2D1.ChartArea.Border.Width = 3

’Allow users to bring up our Property Page


Chart2D1.AllowUserChanges = True

’Add 5 labels to the Chart


For x = 1 to 5
Chart2D1.ChartLabels.Add
Next

Figure 1 Sample Visual Basic script

Chapter 9 n Adding an Olectra Chart 2D Control to a Web Page 141


’Setup the Labels
For x = 1 to 5
Chart2D1.ChartLabels(x).Name = "Label" & x
Chart2D1.ChartLabels(x).AttachMethod = 2
’oc2dAttachDataIndex
Chart2D1.ChartLabels(x).AttachDataIndex.Series = x
Chart2D1.ChartLabels(x).AttachDataIndex.Point = 1
Chart2D1.ChartLabels(x).Font.Size = 10
Chart2D1.ChartLabels(x).Font.Bold = True
Chart2D1.ChartLabels(x).Border.Type = 3 ’oc2dBorderShadow
Chart2D1.ChartLabels(x).Border.Width = 2
Chart2D1.ChartLabels(x).Interior.BackgroundColor =
RGB(255, 235, 205)
Chart2D1.ChartLabels(x).IsConnected = True
Chart2D1.ChartLabels(x).Offset = 10
Next

’Set the text of each of the labels


Chart2D1.ChartLabels(1).Text = "North"
Chart2D1.ChartLabels(2).Text = "South East"
Chart2D1.ChartLabels(3).Text = "South West"
Chart2D1.ChartLabels(4).Text = "West"
Chart2D1.ChartLabels(5).Text = "East"

’Force the location of the Chart to give it more room


Chart2D1.ChartArea.PlotArea.Top.Value = 40
Chart2D1.ChartArea.PlotArea.Bottom.Value = 0

’Go back to normal Chart updates


Chart2D1.IsBatched = False
End Sub

-->
</SCRIPT>

Figure 2 Sample Visual Basic script (continued)


Olectra Chart OCX

Notes
n The CLSID (pronounced Class ID) specified above is for the 32-bit Olectra Chart 2D.
For information on adding a 3D control see Adding an Olectra Chart 3D Control to a
Web Page on page 245.
n Olectra Chart is safe for scripting, which means that it (or any of its methods) will not
write to the local storage when used within a secure Web browser. Olectra Chart will
also not execute any binary code (for example, a. virus) that is passed to it as data.
n The Codebase element in the above example points to where the .CAB file (which
contains all the files users must download to view the control) is located. For more
information on creating .CAB files, see Packaging the Control on page 144.
n If you are developing using 1.1 of Olectra Chart, and viewing a web page that contains
version 6.0 of the control, conflicts may arise. See Special Version Considerations on
page 143 for more information.

142 Part I n Using 2D Chart


Loading data from a URL

Using the LoadURL method, you can load data or a chart description file (.OC2 and
.OC3) directly from a URL instead of adding it programmatically. If you want to load an
entire chart, use the Chart2D object’s LoadURL method. If you just want to load data
into an existing chart, use the ChartData object’s LoadURL method. Both of these
methods have a single parameter, URLname, which is a string representing the URL where
the file you want to load is located.

The following two examples illustrate the different uses of the LoadURL method from
within an HTML file:
<SCRIPT LANGUAGE="VBScript">
Sub Window_OnLoad()
’Load an .OC2 file

Chart2D1.loadURL("http://www.apexsc.com/OlectraChart6/data/profit.oc2")

’ Load a .DAT file


Chart2D1.ChartGroups(1).Data.LoadURL("http://www.apexsc.com/OlectraChar
t6/data/1992.dat")
End Sub
</SCRIPT>

Special Version Considerations

If you have a registered version of Olectra Chart 1.1 on your computer, browsing to a web
site containing version 6.0 of the control may cause problems. If the <OBJECT> tag is set to
require Olectra Chart 6.0, the control will download and re-register itself as the current
control. For this reason it is highly recommended that you do not browse locations
containing version 6 of the control on your 1.1 development machine.

To restore Olectra Chart 1.1 as the version on your computer, do the following:
1. Unregister Olectra Chart 6.0. Internet Explorer caches all downloaded ActiveX con-
trol components within a directory called OCCACHE that exists directly under the
WINDOWS or WINNT root directories. In that directory, type at the command prompt:
Regsvr32 /u olch2x32.ocx

Olectra Chart OCX


2. Remove the files downloaded by version 6.0. If you wish to remove Olectra Chart
from your computer, you only need to delete the files in the OCCACHE directory that
correspond to the ones listed in the .INF file.
3. Register Olectra Chart 1.1. In the Windows/System32 directory, type at the command
prompt:
Regsvr32 olch2x32.ocx

Chapter 9 n Adding an Olectra Chart 2D Control to a Web Page 143


9.3 Creating a Licence Pack File
Once you have created the HTML page shell for Olectra Chart, you must create a license
pack file that the user’s browser uses to register the control on their computer. To do this,
use the lpk_tool program to create a license pack file for all the ActiveX controls on your
page:
1. Run lpk_tool (located in your ActiveX SDK’s \bin directory).
2. From the Available Controls list, select the Olectra Chart 2D and click the Add but-
ton.
3. Click the Save & Exit button. You will be prompted for a file name and location.

After creating the .LPK file, you must add the following lines in your HTML page, before
the <OBJECT> tag used to describe Olectra Chart. In this example, replace filename.lpk
with the name of your pack file:
<OBJECT CLASSID = "clsid:5220cb21-c88d-11cf-b347-00aa00a28331">
<PARAM NAME="LPKPath" VALUE="filename.lpk">
</OBJECT>

Notes
n You must have a registered version of Olectra Chart on your computer to successfully
generate a .LPK file.
n The reference to the resulting .LPK file that you create must be placed on your HTML
page before references to any of your ActiveX controls.
n If your .LPK was created with only Olectra Chart in it, it should be 878 bytes. If it is
smaller, the license pack file was not created properly.

9.4 Packaging the Control


There are three parts to create and copy the files required when downloading the ActiveX
control:
Olectra Chart OCX

n A: Creating an .INF file


n B: Creating a .CAB file
n C: Copying .LPK and .CAB files to the server

A: Creating the .INF file

In order for your browser to correctly load and run Olectra Chart you must create an .INF
file that lists all of the control’s dependencies. Create a text file with the suffix .INF that
lists all of the files needed for this component. For 32-bit Olectra Chart 2D, the files
needed are:
olch2x32.ocx
msvcrt.dll
mfc42.dll

144 Part I n Using 2D Chart


Here is the contents of an example .INF file called OLECTRA.INF:
[Add.Code]
olch2x32.ocx=olch2x32.ocx
mfc42.dll=mfc42.dll
msvcrt.dll=msvcrt.dll

[olch2x32.ocx]
File=thiscab
Clsid={92D71E93-25A8-11CF-A640-9986B64D9618}

[mfc42.dll]
File=mfc42.cab

[msvcrt.dll]
File=msvcrt40.cab

Notes
n Many users may already have the mfc42.dll and msvcrt.dll files available on their
computers from prior software installations, so this .INF file will instruct Internet
Explorer to download them only if necessary.
n To minimize download time, compress these files individually using cabarc.exe. For
more information, see the following section, Creating a CAB File.

B: Creating a .CAB file


1. Use the cabarc.exe program (found in the Cabinet SDK’s \bin directory) to create
.CAB files to combine and compress the files needed for downloading, minimizing
the download requirements for the ActiveX controls embedded within your HTML
page.

To create a CAB file that contains the Olectra Chart OCX, DLL and the .INF file,
type:
cabarc n olectra.cab olch2x32.ocx olectra.inf
2. Find the place in the HTML on your Web page where the Olectra Chart control is ref-
erenced. (There should be an <OBJECT> tag with a CLASSID that matches the 32-bit

Olectra Chart OCX


Olectra Chart 2D CLSID. Edit the HTML and add a Codebase element with the suit-
able web site URL and CAB file name.

For example:
<OBJECT ID="Chart2D" WIDTH=313 HEIGHT=225
CLASSID="CLSID:92D71E93-25A8-11CF-A640-9986B64D9618"
CODEBASE="http://www.yoursite.com/olectra.cab">
</OBJECT>

Chapter 9 n Adding an Olectra Chart 2D Control to a Web Page 145


A Sample HTML File

Here is a very simple .HTML file that displays a 2D chart control. In particular, note the
class IDs for the license pack file and the chart control:
<HTML>
<HEAD>

<meta http-equiv="Content-Type"

content="text/html; charset=iso-8859-1">

<TITLE>Home Page</TITLE>

</HEAD>
<OBJECT CLASSID="clsid:5220cb21-c88d-11cf-b347-00aa00a28331"

<PARAM NAME="LPKPath" value="olectra.lpk">

</OBJECT></p>
<p>
<OBJECT ID="Chart2D" WIDTH=313 HEIGHT=225

CLASSID="CLSID:92D71E93-25A8-11CF-A640-9986B64D9618"

CODEBASE="http://www.yoursite.com/olectra.cab">

</OBJECT>
</BODY>

</HTML>

C: Copying .LPK and .CAB files to the server

Once you have created the .LPK and .CAB files, copy them to the server where your web
page is. The .LPK file must be in the same directory as the HTML file that references it.
The .CAB file must be in the directory that is specified in the <OBJECT> tag. For
example, in the above HTML code, the file olectra.cab would go in the root directory of
the server where www.yoursite.com is located.
Olectra Chart OCX

9.5 Testing your Web Page


Once you have created your web page with the Olectra Chart ActiveX control embedded,
you should now run Internet Explorer on a machine that has never had Olectra Chart
installed on it. Navigate to the Web site where your page exists and have Internet Explorer
attempt to display it.

You may get a sequence of dialog boxes depending on the security level that your copy of
Internet Explorer is set to. You can change these settings by doing the following:
1. On the View menu, click Options. The Options dialog appears.
2. Click the Security tab.
3. Click the Safety Level button.

146 Part I n Using 2D Chart


4. The choices for Security Level are High, Medium, None. The default for Internet Ex-
plorer is High, so controls that have not been digitally signed will not be downloaded.
Olectra Chart 6.0 is signed.

Note
n Internet Explorer caches all downloaded ActiveX control components within a
directory called OCCACHE that exists directly under the WINDOWS or WINNT root
directories. If you wish to remove Olectra Chart from your test system, you only need
to delete the files in the OCCACHE directory that correspond to the ones listed in the
.INF file described in Packaging the Control on page 144.

Olectra Chart OCX

Chapter 9 n Adding an Olectra Chart 2D Control to a Web Page 147


Olectra Chart OCX

148 Part I n Using 2D Chart


Olectra Chart OCX
10
Chart Basics
Chart Terminology n Using the Property Editor
Interacting with the Chart n Choosing the Chart Type
3D Bar and 3D Surface Charts n Understanding Data Layout
Loading and Saving Charts and Data

Successful charting requires that you are familiar with basic chart processes and
vocabulary, specifically as they relate to the 3D Chart control. The following topics cover
basic information that anyone who uses 3D Chart should be familiar with.

Olectra Chart OCX

151
10.1 Chart Terminology
The following shows the terms used to describe chart elements.

10.2 Using the Property Editor


The 3D Chart Property Editor enables you to customize the properties of any chart.
Olectra Chart OCX

Immediate Feedback Model

As you edit properties, the changes are immediately applied to the chart and displayed.
This enables you to quickly see how a change affects the chart so that you can make
further changes without leaving the Property Editor.

To Display the Property Editor


n Click the right mouse button over any part of the chart and select “Properties...” from
the pop-up menu.

152 Part II n Using 3D Chart


To Edit Chart Properties
1. Select the tab that corresponds to the element of the chart that you want to edit.

Tabs contain one or more inner tabs that group related properties together. Some tabs
also contain a list that selects a specific object to edit.
2. If the tab contains a list on the left side, select the specific object to edit from that list.
3. Select the inner tab that corresponds to the kind of property you want to edit.
4. Click on a control and change the value of that property.

The change is immediately applied to the chart and displayed unless the IsBatched
property (located on the Control tab’s General inner tab) is set. When IsBatched is
set, click the Apply button to display property changes.
5. Make further changes to the same property or change other properties on this tab or
other tabs.

To Close the Property Editor


n Click the OK or Cancel button to close the Property Editor.

10.3 Interacting with the Chart


You can interact with the chart as it’s running to examine data more closely or visually
isolate a part of the chart. The interactions described here affect the chart displayed inside
the ChartArea; other chart elements like the header are not affected.

Special Notes
n The keyboard/mouse combinations that perform the different interactions can be
changed or removed by a programmer. The interactions described here may not be
enabled for your chart.

Rotation

Olectra Chart OCX


1. Hold down both mouse buttons (or middle button on a 3-button mouse)
2. To rotate freely, move mouse in the desired direction.
3. Or, to constrain rotation along an axis, press the “x”, “y”, “z”, or “e” key and move
mouse perpendicular to axis.

Translation
1. Press SHIFT, hold down both mouse buttons (or middle button on a 3-button mouse).
2. Move mouse to change the positioning of the chart inside the ChartArea.

Scaling
1. Press CTRL, hold down both mouse buttons (or middle button on a 3-button mouse).
2. Move mouse down to increase chart size, or up to decrease chart size.

Chapter 10 n Chart Basics 153


Zooming
1. Press CTRL, hold down left mouse button.
2. Drag mouse to select zoom area and release mouse button.

Reset to Automatic Scale and Position


n Press the “r” key to remove all scaling, translation, and zooming effects. Rotation is
not removed.

10.4 Choosing the Chart Type


The 3D Chart displays data as a 3D surface chart, a 3D bar chart, or a 3D scatter plot. Use
the ChartType property to specify whether to display data as a surface chart, bar chart, or
scatter plot. The ChartType property is located on the ChartGroup tab’s General inner
tab on the Property Editor.
Olectra Chart OCX

For more information on 3D Bar charts, see Special Bar Chart Properties on page 233.
For more information on 3D Scatter plots, see Special Scatter Plot Properties on page
233.

154 Part II n Using 3D Chart


10.5 3D Bar and 3D Surface Charts

Mesh Mesh
Surface Example Bar Example

Notes
n You can customize the top and bottom mesh color and other mesh properties.

Shaded Shaded
Surface Example Bar Example

Olectra Chart OCX

Notes
n You can customize the top and bottom surface color and other surface properties.

Chapter 10 n Chart Basics 155


Contours Contours
Surface Example Bar Example

Notes
n You can customize contour levels, ContourStyles, and other contour properties.

Zones Zones
Surface Example Bar Example
Olectra Chart OCX

Notes
n You can customize contour levels, ContourStyles, and other zoning properties.

156 Part II n Using 3D Chart


Mesh, Shaded Mesh, Shaded
Surface Example Bar Example

Notes
n You can customize the top and bottom mesh color and other mesh properties.
n You can customize the top and bottom surface color and other surface properties.

Mesh, Contours Mesh, Contours


Surface Example Bar Example

Olectra Chart OCX

Notes
n You can customize the top and bottom mesh color and other mesh properties.

Chapter 10 n Chart Basics 157


n You can customize contour levels, ContourStyles, and other contour properties.

Mesh, Zones Mesh, Zones


Surface Example Bar Example

Notes
n You can customize the top and bottom mesh color and other mesh properties.
n You can customize contour levels, ContourStyles, and other zoning properties.
Olectra Chart OCX

158 Part II n Using 3D Chart


Shaded, Contours Shaded, Contours
Surface Example Bar Example

Notes
n You can customize the top and bottom surface color and other surface properties.
n You can customize contour levels, ContourStyles, and other contour properties.

Shaded, Zones Shaded, Zones


Surface Example Bar Example

Olectra Chart OCX

Notes
n You can customize the top and bottom surface color and other surface properties.

Chapter 10 n Chart Basics 159


n You can customize contour levels, ContourStyles, and other zoning properties.

Contours, Zones Contours, Zones


Surface Example Bar Example

Notes
n You can customize contour levels, ContourStyles, and other contour and zoning
properties.

Mesh, Shaded, Zones Mesh, Shaded, Zones


Surface Example Bar Example
Olectra Chart OCX

Notes
n You can customize the top and bottom mesh color and other mesh properties.

160 Part II n Using 3D Chart


n You can customize the top and bottom surface color and other surface properties.
n You can customize contour levels, ContourStyles, and other zoning properties.

Mesh, Shaded, Contours Mesh, Shaded, Contours


Surface Example Bar Example

Notes
n You can customize the top and bottom mesh color and other mesh properties.
n You can customize the top and bottom surface color and other surface properties.
n You can customize contour levels, ContourStyles, and other contour properties.

Olectra Chart OCX

Chapter 10 n Chart Basics 161


Shaded, Contours, Zones Shaded, Contours, Zones
Surface Example Bar Example

Notes
n You can customize the top and bottom surface color and other surface properties.
n You can customize contour levels, ContourStyles, and other contour and zoning
properties.

Mesh, Contours, Zones Mesh, Contours, Zones


Surface Example Bar Example
Olectra Chart OCX

Notes
n You can customize the top and bottom mesh color and other mesh properties.

162 Part II n Using 3D Chart


n You can customize contour levels, ContourStyles, and other contour and zoning
properties.

Mesh, Shaded, Contours, Zones Mesh, Shaded, Contours, Zones


Surface Example Bar Example

Notes
n You can customize the top and bottom mesh color and other mesh properties.
n You can customize the top and bottom surface color and other surface properties.
n You can customize contour levels, ContourStyles, and other contour and zoning
properties.

No Chart Displayed
n No chart displays when all four properties are off.

Olectra Chart OCX


10.6 Understanding Data Layout
The 3D chart displays three-dimensional data. Each data point consists of an X/Y
Cartesian coordinate and a Z elevation value. It charts surfaces that are increasing in X and
Y and cannot chart surfaces that fold back in X or Y (such as a sphere).

The data must be supplied in one of three basic layouts, Grid, Irregular Grid, or Point.
Data can come from many different sources, such as data files or the results of
mathematical formulae. You can load and save data files, and customize the data itself,
using the Property Editor.

Chapter 10 n Chart Basics 163


Grid Layout

Use Grid layout when the X- coordinates of each point and the Y-coordinates of each point
are always the same distance apart. The following diagram illustrates the characteristics of
Grid layout.

Grid Data Layout

RowCount = 3
ColumnCount = 4

RowDelta = 1
ColumnDelta = 1

RowOrigin = -2
ColumnOrigin = -2

Column 1 Column 2 Column 3 Column 4 Z-Values


-12 -11.75 -11.25 -10.25 Row 1
-12 -11.7 -11.2 -10.25 Row 2
-12 -11.75 -11.25 -10.25 Row 3

The important characteristics of Grid layout are:


n The X/Y grid is defined by the number of rows and columns, the origins, and the
Olectra Chart OCX

single row and column delta value.


n The grid spacing for all rows is set by the RowDelta property. The grid spacing for all
columns is set by the ColumnDelta property.

Irregular Grid Layout

Use Irregular Grid layout when the X- coordinates of each point or the Y-coordinates of
each point are not the same distance apart. The following diagram illustrates the
characteristics of Irregular Grid layout.

164 Part II n Using 3D Chart


Irregular Grid Data Layout

RowCount = 4
ColumnCount = 3

ColumnDeltas

RowDeltas

RowOrigin = 0
ColumnOrigin = 0

Column 1 Column 2 Column 3 Z-Values


12.25 15.25 18.25 Row 1
12.5 15.5 18.5 Row 2
14 17 20 Row 3
14.5 17.5 20.5 Row 4

The important Irregular Grid layout characteristics are:


n The X/Y grid is defined by the number of rows and columns, the origins, and the
irregular grid spacing deltas.
n Each row and column has its own RowDelta/ColumnDelta value that sets the grid
spacing between that row/column and the previous one.

Olectra Chart OCX


Point Layout

Use Point Layout for scatter plots when you want to chart multiple series of points. The
following diagram illustrates the characteristics of Point layout.

Chapter 10 n Chart Basics 165


Point Data Layout

Series 1 = Purple

Series 2 = Red

Z=3

X=5

Y=1

X Y Z
Point 1 5 1 3
Series 1 Point 2 5 2 4
Point 3 4 3 2

X Y Z
Point 1 2 2 2
Series 2 1 3 3
Point 2

The important Point layout characteristics are:


n The points are grouped into one or more series.
Olectra Chart OCX

n Each individual point is specified by its X, Y, and Z Cartesian coordinates.

Holes in the data

Use the HoleValue property to set the data value that represents a hole in your data. When
the chart sees values in the data grid that are the same as the hole value it displays as a hole
in the chart.

To edit Grid and Irregular Grid data:


n Use the Layout, RowCount, and ColumnCount properties to set the format and size
of the data. Use the HoleValue, RowOrigin, ColumnOrigin, RowDelta,
ColumnDelta, and Value properties to define the data itself. These properties are also
located on the ChartGroup tab’s Data inner tab on the Property Editor. Use the
EnterData button to edit actual data points.

166 Part II n Using 3D Chart


To edit Point data:
n Use the Layout property to set the chart type. Use the NumSeries property to set the
number of series in the scatter plot, which creates a DataCoord Collection for each
series of data. Use the DataCoord Collection’s Add method to specify an x, y, and z
coordinate for each point in the series.

To load and save data files:


n Use the Load and Save buttons to load and save data files. These are located on the
ChartGroup tab’s Data inner tab on the Property Editor.

10.7 Loading and Saving Charts and Data


The two main components of any chart are the data it’s displaying and the properties that
control its appearance. You can save the current chart data and load new chart data from a
file. You can also load and save chart descriptions, which are settings for all of the chart
properties.

Olectra Chart includes sample chart descriptions and data files that you can use as
templates to build your own custom chart.

To Load and Save Data:


n Use the Load and Save buttons on the ChartGroup tab’s Data inner tab on the
Property Editor to load and save data. See Understanding Data Layout for information
on data layouts.

To Load and Save Chart Descriptions:


n Use the Load and Save buttons on the Control tab’s General inner tab on the
Property Editor to load and save chart descriptions.

Olectra Chart OCX

Chapter 10 n Chart Basics 167


Olectra Chart OCX

168 Part II n Using 3D Chart


11
Distributing Olectra Chart Applications
Distributing 32-bit OCX Applications

The following topics cover distributing applications created with the 32-bit
3D Olectra Chart control.

Olectra Chart OCX

169
11.1 Distributing 32-bit OCX Applications
You can freely distribute any applications that you create with Olectra Chart. An Olectra
Chart application needs its dynamic link libraries present on the system it is run on.

Distributable Files

When distributing 3D 32-bit OCX applications, you may only distribute the following file:
OLCH3X32.OCX

The following MFC and OLE support files must also be installed on the end-user’s system
for Olectra Chart OCX applications to work:
MFC42.DLL
MSVCRT.DLL
OLEPRO32.DLL
OLEAUT32.DLL

If OLEPRO32.DLL has not previously been installed, it must be registered before it can be
used. To register this DLL, follow the same steps used to register the Olectra Chart
Control. If this DLL is installed already, you can assume that it has been registered.

Distributing Olectra Chart in Visual Basic

In order to distribute Olectra Chart using VB 6, you must run the Package & Deployment
wizard (located in your VB directory\Wizards\PDWizard ) once to create a file vb6dep.ini.
For VB5, you must run the Setup wizard (located in your VB directory\Setupkit\kitfile32)
once to create a file vb5dep.ini. The following dependences must be added to this file so
you can distribute an application created with Olectra Chart:
[OLCH2X32.OCX]
Register=$(DLLSelfRegister)
Dest=$(WinSysPath)
Uses1=MFC42.DLL
Uses2=MSVCRT.DLL

[OLCH3X32.OCX]
Register=$(DLLSelfRegister)
Olectra Chart OCX

Dest=$(WinSysPath)
Uses1=MFC42.DLL
Uses2=MSVCRT.DLL

[MFC42.DLL]
Register=$(DLLSelfRegister)
Dest=$(WinSysPath)

[MSVCRT.DLL]
Dest=$(WinSysPath)

Note that the above file contains the dependencies for both the 2D and 3D Olectra Chart
controls.

Once you have added the above dependencies, run the Setup wizard and follow the
directions on each screen. On the Confirm Dependency screen, make sure you include the
OCX files.

170 Part II n Using 3D Chart


In VB 6, on the Included Files Screen, make sure the following files have been included:
OLCH2X32.OCX
OLCH3X32.OCX
MSVCRT.DLL
MFC42.DLL

In VB 5, on the File Summary screen, make sure the following files have been included:
OLCH2X32.OCX
OLCH3X32.OCX
MSVCRT.DLL
MFC42.DLL

End-user Online Help

If your applications allow the end-user to access the 3D Chart Property Editor, you should
also distribute the Property Editor’s end-user online help, contained in the following files:
OLCH3D-U.HLP
OLCH3D-U.CNT

If you have disabled end-user property editing, you do not need to distribute these files.

Registering the 3D Chart Control

Before the 3D Chart control can be used in an application, appropriate entries must be
added to the Microsoft Windows registration database.

To register the control for 32-bit applications, pass the complete path and filename of the
Olectra Chart OCX file, OLCH3X32.OCX, to the REGSVR32.EXE control registration
program.

Olectra Chart OCX

Chapter 11 n Distributing Olectra Chart Applications 171


Olectra Chart OCX

172 Part II n Using 3D Chart


12
Programming Considerations
Object Hierarchy n Programming with Objects
Programming In C++ n Programming in Delphi
Using Array Data in Delphi n Compatibility Issues
Upgrading Visual Basic 4.0 Projects from Olectra Chart 1.1

Controlling the chart in an application program is generally quite straightforward once you
are familiar with the object hierarchy. For most chart objects, the examples and overviews
in the Object Reference provide all the information needed to program them.

The following topics cover programming considerations for the 3D Chart.

Olectra Chart OCX

173
12.1 Object Hierarchy
The following are the high-level objects defined as children of the 3D Chart control:

For information on the object hierarchy for a specific chart object, go to the help page for
that object and press the Object Hierarchy button.
Olectra Chart OCX

12.2 Programming with Objects


When you create a 3D Chart control, a Chart3D object is created. This object, like other
Visual Basic objects, has properties defined for it. You can change the behavior of your
chart by changing these properties.

The Object Reference describes the Chart3D object, the sub-objects automatically created
when the Chart3D object is created, and the properties defined for each object. Properties
that are read-only are indicated as such in their object description.

174 Part II n Using 3D Chart


A Simple Example

The following statement turns off the chart’s double buffering feature by setting the
IsDoubleBuffered property of the Chart3D object to False:
Chart3D1.IsDoubleBuffered = False

By default, the first Chart3D object created in an application is named Chart3D1, the
second is named Chart3D2, and so on. This is standard Visual Basic behavior.

Navigating the Object Hierarchy

As with other Visual Basic objects, you can access a specific object by navigating its
object hierarchy. For example, the following code retrieves the background color of the
main body of the chart:
Dim BackColor As Long
BackColor = Chart3D1.ChartArea.Interior.BackgroundColor

Default Properties

If an object is referenced in a statement without a property being specified, the object’s


default property is assumed. For example, the default property for the Border object is the
Type property, which means that the following two statements are equivalent:
Chart3D1.ChartArea.Header.Border.Type = oc3dBorderShadow
Chart3D1.ChartArea.Header.Border = oc3dBorderShadow

Both of the above statements change the value of the Type property to
oc3dBorderShadow.

Using Collections

Many 3D Chart objects are organized into collections. For example, the chart axes are
organized into the Axes collection.

All collections are indexed by number, with 1 referring to the first element of the
collection, 2 the second, and so on. If the objects in a collection have a Name property, the
collection can also be indexed by object name. For example:

Olectra Chart OCX


Chart3D1.ChartArea.Axes("X").Max = 25.1

This statement accesses the axis named “X” (the X-axis), and sets the maximum value of
this axis to 25.1. Note that Visual Basic recognizes the default Item property of the
collection, whereas other environments may require an explicit reference to the Item
property:
Chart3D1.ChartArea.Axes.Item("X").Max = 25.1

Some 3D Chart collections are static, whereas others are dynamic. Dynamic collections
have Add and Remove methods defined. Elements cannot be added to or removed from
static collections.

For more details on the behavior of Visual Basic collections, refer to the Visual Basic
documentation.

Chapter 12 n Programming Considerations 175


Accessing Each of the Elements of a Collection

Visual Basic enables you to access each of the elements of a collection in turn using the
For Each statement. For example, the following code sets the vertical pixel offset (the
distance between the center of each chart label and its point of attachment) to 10:
For Each Label in Chart3D1.ChartLabels
Label.VerticalOffset = 10
Next

Each collection defines a Count property whose value is the current number of objects in
the collection. You can use Count to access some or all of the elements of a collection. For
example, the following is another way to set the vertical pixel offset for the chart labels:
Dim Counter As Integer
For Counter = 1 To Chart3D1.ChartLabels.Count
Chart3D1.ChartLabels(Counter).VerticalOffset = 10
Next

Calling Methods

To call a 3D Chart method, access the object with which it is associated. For example, the
following statement uses the DataCoordToCoord method, defined by the ChartGroups
collection, to convert the data coordinates (5.1, 10.2, 8.4) to their equivalent pixel
coordinates:
Chart3D1.ChartGroups(1).DataCoordToCoord 5.1, 10.2, 8.4, PixelX,
PixelY

Each method is described in the help page for its associated object. For example,
DataCoordToCoord is described in the ChartGroups collection help page.

12.3 Programming In C++


The 3D Chart can be used in the Visual C++ (version 5.0 or later) environment, which
creates programs written in the C++ programming language. The chart will not work
properly with earlier versions of Visual C++.
Olectra Chart OCX

Inserting the 3D Chart Control into an OLE Container Project

In the Visual C++ environment, a 3D Chart control behaves like any other OLE control,
which means that it can be incorporated into a container such as a dialog or an application
window.

To add the 3D Chart control to an OLE container project, use Component Gallery as
follows:
1. From the Insert menu, select Component. The Component Gallery dialog box ap-
pears.
2. Select the OLE Controls tab.
3. Select the 3D Chart control icon in the Component Gallery window.

176 Part II n Using 3D Chart


4. Click the Insert button. This displays a Confirm Classes dialog box, which lists the
3D Chart control classes.
5. Click the OK button to accept the class generated by Component Gallery.
6. Click the Close button to close Component Gallery.
7. At this point, the 3D Chart wrapper class, CChart3D, is added to your project. This
means that the 3D chart control can now be added to your application’s main dialog
box, as shown below.

Adding the 3D Chart Control to the Main Dialog Box

To add the 3D Chart control to your dialog template, perform the following steps:
1. Load the container project into Developer Studio.
2. In the Project Workspace window, click the ResourceView button.
3. Open the Dialog folder.
4. Double-click the main dialog box template.
5. Choose the 3D Chart control icon from the Controls toolbar.
6. Position the mouse in the dialog box, and click to position the 3D Chart control.
7. From the File menu, choose Save All.

Adding a Member Variable to a Project

Once the 3D Chart control has been added to the project and placed in the dialog box
container, you can access this control from other parts of your project. The easiest way to
do this is to create a member variable of the dialog class, CContainerDlg, of type
CChart3D (the 3D Chart wrapper class). To create a member variable, perform the
following steps:
1. Load the OLE container project.
2. Choose ClassWizard from the View menu.
3. Choose the Member Variables tab.

Olectra Chart OCX


4. From the Class Name list box, select the main dialog class (CContainerDlg).
5. From the ControlIDs list box, select the control ID of the embedded 3D Chart con-
trol.
6. Click the Add Variable button to display the Add Member Variable dialog box.
7. In the Member Variable edit box, enter a name.
8. Select Control from the Category list box.
9. Click OK to close the Add Member Variables dialog box.
10. Click OK to exit ClassWizard.

The member variable you have just added can now be used to access the embedded 3D
Chart control.

Chapter 12 n Programming Considerations 177


Programming the 3D Chart Control

At this point, you are ready to actually program the control. To do this, note the following:
n A wrapper class header file is defined for each 3D Chart object. Examples: the
wrapper class header file for the Chart3D object is named chart3d.cpp, and the
wrapper class header file for the Border object is named border.cpp.
n The wrapper class header file for an object defines two routines for each of its
properties: a routine that gets the current value of the property, and a routine that sets
the value of the property. For example, the chart3d.cpp file defines two routines for
the IsDoubleBuffered property of the Chart3D object: GetIsDoubleBuffered(),
which gets the current value of the IsDoubleBuffered property, and
SetIsDoubleBuffered(), which sets the value of the IsDoubleBuffered property.
n Methods defined for an object are included in the wrapper class header file for the
object.

Setting an Object Property

The following statement sets the background color of the chart area. The variable m_chart
contains an instance of a Chart3D object (the main 3D Chart object).
m_chart.GetChartArea().GetInterior().SetBackgroundColor(
RGB(247,206,151));

This statement navigates the 3D Chart object hierarchy by retrieving the values of
successive properties. First, the value of the ChartArea property is retrieved, which is a
ChartArea object. Then, this ChartArea object’s Interior property is retrieved, which is
an Interior object. Finally, the Interior object’s BackgroundColor property is set.

Using Collections

Many 3D Chart objects are organized into collections. For example, the chart axes are
organized into the Axes collection.

To access a particular element of a collection, specify the index which uniquely identifies
this element. For example, the following code changes the maximum value of the X axis
Olectra Chart OCX

to 25.1:
Caxis
axisX(m_chart.GetChartArea().GetAxes().GetItem(COleVariant("x")));
axisX.GetMax().SetValue(25.1);

Note that the index 1 refers to the first element of a collection.

Calling Methods

To call a 3D Chart method, access the object with which it is associated. For example, the
following statement uses the DataCoordToCoord method, defined by the ChartGroups
collection, to convert the data coordinates (5.1, 10.2, 14.3) to their equivalent pixel
coordinates:
long pixelx, pixely;
m_chart.GetChartGroups().GetItem(COleVariant(short(1)))
.DataCoordToCoord(5.1, 10.2, 14.3, &pixelx, &pixely);

178 Part II n Using 3D Chart


Each method is described in the help page for its associated object. For example,
DataCoordToCoord is described in the ChartGroups collection help page.

Demo Programs

Sample C++ programs, created using Visual C++, are included as part of the Olectra Chart
distribution. These sample programs are contained in the \CHART\3D\DEMOS\VC
directory.

12.4 Programming in Delphi


The 3D Chart can be used in the Delphi version 3.0 and later environment, which creates
programs written in the PASCAL programming language. The following are special
considerations that should be taken into account when programming with Olectra Chart.

Adding Olectra Chart 3D OCX to Delphi 4


1. Run Delphi.
2. On the Component menu, click Import ActiveX Control. The Import ActiveX dialog
appears.
3. In the list of controls select Olectra Chart 3D Control (Version 6.0).
4. Click the Install button. The Install dialog appears.
5. Select an existing package or create a new one for the control.
6. Click the OK button to install the control. The confirm dialog appears.
7. Click Yes to build and install the Control.

Adding the Olectra Chart 3D OCX to Delphi 3


1. Run Delphi.
2. On the Component menu, click Install. The Install Components dialog appears.

Olectra Chart OCX


3. Click the OCX button. The Import OLE Control dialog appears.
4. In the Import OLE Control dialog, select the Olectra 3D OCX and click OK. The In-
stall Components dialog appears.
5. Click OK. Delphi adds the Olectra Chart OCX to the OCX tab of the Components
toolbar.

12.5 Using Array Data in Delphi


In order to pass Array data to Olectra Chart from Delphi, you must use Delphi’s Variant-
type arrays. For more information on using Variant arrays in Delphi, refer to the "OLE

Chapter 12 n Programming Considerations 179


Automation Example" chapter of your Delphi User’s Guide. The following code shows
how to use Array data with Delphi:
procedure TForm1.Button1Click(Sender: TObject);
var
x1: Variant;
m,n: integer;
begin
// Create the variant array

x1 := VarArrayCreate([1,10000,1,4], varDouble);
// Set the chart to have 4 series of 10000 points

Chart3D1.ChartGroups.Item(1).ElevationData.RowCount := 10000;

Chart3D1.ChartGroups.Item(1).ElevationData.ColumnCount := 4;
// Place data into the array

{ ... code omitted ... }


// Transfer the data to the chart

Chart3D1.ChartGroups.Item(1).ElevationData.CopyZArrayIn( x1);
// Release the variant item

x1 := Unassigned;
end;

Due to the changes made when Borland introduced Delphi 3 and Delphi 4, there are a
number of coding changes that are required to use Olectra Chart. Below is the current list
of known changes that may be required:
1. The name of the file inserted into the code by the IDE on the uses line has changed
from OLCH2X32 to OlectraChart3D_TLB.
2. In order to use the Safe Array functions, you now have to declare the arrays for use
with these functions as type OleVariant instead of Variant.
3. Code located in the OnCreate() event that used to work fine in Delphi 2.01 will not
work in later versions. There are two work-arounds for this (Borland is currently
working on a Patch that should hopefully cure this problem):
Olectra Chart OCX

Solution A:

Around any code that deals with Olectra Chart, use the Chart3D1.IsBatched :=
True/False; statements to put the Chart in Batch mode.

Solution B:

Move the code to the OnActivate() event and use a flag to ensure that this code only
runs once.
4. Due to the stronger typing introduced in Delphi 3 and Delphi 4, there are five methods
in Olectra Chart that have been renamed automatically by Delphi. The following is the

180 Part II n Using 3D Chart


Conversion Log appearing at the top of a Delphi 3 PASCAL file created during the
OCX import process:

’Label’ is a reserved word. Label changed to Label_


’Type’ is a reserved word. IBorder.Type changed to Type_
’Unit’ is a reserved word. ITimeScale.Unit changed to Unit_
’Label’ is a reserved word. IValueLabel.Label changed to Label_
’String’ is a reserved word. Parameter ’String’ in
IStringCollection.Add changed to ’String_’

Note that although these changes still occur in Delphi 4, a Conversion Log is not
generated.
5. In order to access the font object associated with various objects in Olectra Chart, you
now have to access them using a Variant. Here is an example:
var
f: Variant;
begin
f := Chart3D1.Header.Font;
f.Name := ’Times New Roman’;
f.Size := 15;
f.Bold := True;
f := UnAssigned;
end;

6. When accessing the data object in Olectra, Delphi 2.01 lets you do it using either
round brackets () or square brackets []. In Delphi 3 you must use square brackets when
accessing the data object. Here is an example:
Chart3D1.ChartGroups.Item[1].Data.x[1, 1] := 1;
Chart3D1.ChartGroups.Item[1].Data.y[1, 1] := 5;

Note
n In the above examples, it also shows that the .Item[] reference also requires the use of
square brackets now, where in Delphi 2.01 it also allowed the use of round brackets ().

12.6 Compatibility Issues

Olectra Chart OCX


The following compatibility issues affect the behavior of the 3D Chart control in various
Windows environments.

Predefined Dash Styles used in Windows 95, and Windows 98

In the Windows 95 and Windows 98 environments, lines are drawn using the dash styles
predefined by Microsoft Windows. As a consequence, some 3D Chart dash styles are not
displayed exactly as specified. The following dash styles are affected:
n The short dash pattern (oc3dLineShortDash) is represented as a dash-dot pattern.
n The long-short-long dash pattern (oc3dLineLongShortLongDash) is represented as a
dash-dot-dot pattern.

Chapter 12 n Programming Considerations 181


Non-solid lines of thickness greater than 1 in Windows95, and Windows 98

In the Windows 95 and Windows 98 environments, any non solid lines of thickness greater
than 1 are rendered as lines with thickness 1.

12.7 Upgrading Visual Basic 4.0 Projects from Olectra Chart 1.1
For most development environments, upgrading your chart from version 1.1 of the OCX
to version 6.0 is as easy as loading the .OC3 file with into your environment with Olectra
Chart 6.0 installed. Saving the file will automatically update your project.

Projects created with Visual Basic 4.0 record the version of the OCX inside the .VBP file.
After you upgrade to Olectra Chart 6.0, your projects containing Olectra Chart 1.1 will not
load correctly. The log file will contain this message:
Class OlectraChart3D.Chart3D of control Chart was not a loaded control
class.

To Update your .VBP File:


1. Open the Visual Basic 4.0 project file (.VBP) in Notepad (or another text editor). You
will need to change the line reading:
Object={92D71E90-25A8-11CF-A640-9986B64D9618}#1.1#0; OLCH3X32.OCX
2. Replace the version number 1.1 with 6.0, as in the following:
Object={92D71E90-25A8-11CF-A640-9986B64D9618}#6.0#0; OLCH3X32.OCX
3. Save the .VBP file. Now the project will load correctly.

Note that this is only required if you are using Visual Basic 4.0. Visual Basic 5.0 (and
later) detects and correct this problem automatically.
Olectra Chart OCX

182 Part II n Using 3D Chart


13
Building a Chart
Creating Histogram Bar Charts n Annotating the Axes n Axis Labelling Programming Considerations
Setting Axis Bounds n Titling Axes n Customizing the PlotCube
Positioning the Chart n Modifying the 3D View n Adding and Formatting Grid Lines
Creating 4D Charts n Displaying 4D Data n Storing Chart Descriptions in Files
Printing Charts

Building a chart is quite easy. The chart can automatically set properties based on the data,
so axis numbering and data display usually don’t need much customization.

The following topics cover information on the various steps required to create a chart.

Olectra Chart OCX

183
13.1 Creating Histogram Bar Charts
3D bar charts typically display the values along an axis in a fixed format. You can display
one or more axes in a histogram format. Histograms may (but usually don’t) use an
irregular data layout. There is always one less bar because the row/column delta is used
for the width of each bar. You can display a bar chart in a histogram format along either
the X- or Y-axis.

To display a histogram:
1. Set the ChartType property to Bar. The ChartType property is located on the Chart-
Group tab's General inner tab on the Property Editor.
2. Use the bar RowFormat and ColumnFormat properties to set the display format of
the X- and Y-axes respectively. Both RowFormat and ColumnFormat can be either
fixed or histogram. These properties are located on the Bar tab’s General inner tab on
the Property Editor.
Olectra Chart OCX

13.2 Annotating the Axes


The annotation along each axis is an extremely important part of any chart. The 3D chart
can annotate any axis with numbers based on the data (Values) or with text you supply
that is displayed at axis coordinates (ValueLabels). The X- and Y-axes can also be
annotated with text for each point in the data (DataLabels).

Values Annotation

Values automatically generates numeric annotation based on the data itself. Values
annotation can be used for any axis.

184 Part II n Using 3D Chart


Use the axis AnnotationMethod property to specify Values annotation for an axis.
AnnotationMethod is located on the Axes tab’s General inner tab on the Property Editor.

ValueLabels Annotation

A very flexible type of annotation, ValueLabels displays text you define at a specific axis
coordinate. This is useful to label only specific coordinates, or to produce annotation in a
form that the chart does not provide. ValueLabels annotation can be used for any axis.

ValueLabels

Every label displayed on the axis is one ValueLabel. Each ValueLabel has a Value
property and a Label property.

Use the Value property to set the axis coordinate to display the label. Use the Label
property to specify the text to display. All ValueLabels properties are located on the Axes
tab’s ValueLabels inner tab on the Property Editor. Set AnnotationMethod to

Olectra Chart OCX


ValueLabels for an axis and use this tab to define the labels.

DataLabels Annotation (X- and Y-axes only)

DataLabels displays text you define at each point along the X- or Y-axes. DataLabels
annotation cannot be used for the Z-axis.

DataLabels are a collection of labels. The first label applies to the first point, the second
label applies to the second point, and so on.

Use the RowLabels and ColumnLabels ChartGroup properties to define and edit
DataLabels. These are located on the ChartGroup tab’s Labels inner tab on the Property
Editor. Set AnnotationMethod to DataLabels for an axis and use this tab to define the
labels.

Chapter 13 n Building a Chart 185


13.3 Axis Labelling Programming Considerations
There are three distinct ways to label axes when using the 3D Chart control:
n The axis can be automatically labelled based on the range of data.
n Surface lines or bar row/columns can be individually labelled.
n Labels can be placed at explicit locations along an axis.

The axis labelling method in use for a particular axis is specified by the
AnnotationMethod property. Valid values for this property are specified by the
annotation method constants.

If the AnnotationMethod property is set to oc3dAnnotateValues, Olectra Chart will


automatically annotate the axis based on the range of the data. This is most suitable for the
Z-axis, and for surface charts.

If the AnnotationMethod property is set to oc3dAnnotateDataLabels, Olectra Chart


uses a list of strings to annotate each grid line or bar. This labelling method can only be
used on the X- and Y-axes. For the X-axis, the labels are supplied by setting the
RowLabels property of the ChartGroup object for this chart. For example, the following
code specifies three data labels for each of the three rows of a chart:
With Chart3D1
’ assume three rows in chart
.ChartArea.Axis("X").AnnotationMethod = oc3dAnnotateDataLabels
With .ChartGroups(1).RowLabels
.Add "Row 1"
.Add "Row 2"
.Add "Row 3"
End With
End With

Similarly, labels for the Y-axis are supplied by the setting the ColumnLabels property of
the ChartGroup object.

If the AnnotationMethod property is set to oc3dAnnotateValueLabels, Olectra Chart


places labels at explicit locations along an axis. The ValueLabels property, which is a
ValueLabels collection, supplies this list of strings and their locations. For example, the
Olectra Chart OCX

following code sets chart labels at the locations 10, 20 and 30:
With Chart3D1.ChartArea.Axis("X")
.AnnotationMethod = oc3dAnnotateValueLabels
With .ValueLabels
.Add 10#, "Label 1"
.Add 20#, "Label 2"
.Add 30#, "Label 3"
End With
End With

186 Part II n Using 3D Chart


13.4 Setting Axis Bounds
The chart usually recalculates and redraws the axes whenever data changes. You can fix
the bounds of any axis so that it is not recalculated when data changes. For the X- and Y-
axes, you can also frame a portion of data by setting axis bounds inside the data bounds.

To set the axis minimum and maximum:

Use the Axes Min and Max properties to fix the minimum or maximum axis extent at a
particular value. Their IsDefault properties allow the chart to automatically determine
axis bounds based on the data bounds. These properties are located on the Axes tab’s
Scale inner tab on the Property Editor.

Z-axis Notes

The Z-axis minimum/maximum cannot be set inside the Z-range of the data. If you have
fixed an extent for the Z-axis and a subsequent data change puts the range outside of the
axis, the chart sets the Z-axis IsDefault property so that its extent is recalculated.

X- and Y-axis Notes

The X- and Y-axis minimum/maximum cannot be set to a location that does not coincide
with a line of data. The values are always adjusted upwards so they do coincide.

13.5 Titling Axes


Adding a title to an axis clarifies what is charted along that axis. An axis title can have
either a stroke or True Type font. You can add a title to any axis and specify the font.

Olectra Chart OCX


Axis Titles

To add an axis title:

Use the axis Title property to add a title to an axis. To remove the title, delete the text.

Chapter 13 n Building a Chart 187


Title font

Use the Stroke and Size CubeFont properties to specify a stroke font for the titles. Use the
TrueType property to specify a True Type font for the axes. All axes titles use the same
font. See Choosing Fonts for more information on using CubeFonts.

The Title, Stroke, TrueType and Size properties are located on the Axes tab’s Title inner
tab on the Property Editor.

13.6 Customizing the PlotCube


The PlotCube is the three-dimensional cube enclosing the charted data, the axes, and the
annotation. You can customize its shape and other appearance attributes.

Changing the PlotCube Shape

For many charts, the length of each axis is the same, so the PlotCube should appear
square. You can change the scale of the X or Y dimension to make the PlotCube appear
stretched or flattened. This can be used to make more densely packed data points easier to
examine in the chart.

Use the XScale property to scale the X dimension of the PlotCube and the YScale
property to scale the Y dimension. The value represents the percentage of the Z dimension
to scale. For example, setting XScale to 200 would make the X-axis appear double the
length of the Z-axis.

These properties are located on the PlotCube tab’s General inner tab on the Property
Editor.

Ceiling and Floor Projections

Contour lines and zone colors can be projected onto the PlotCube’s ceiling and floor. This
is useful when you’d like to focus the chart on the 3D surface shape but still provide
contour or zone information on the chart.
Olectra Chart OCX

Use the IsContoured and IsZoned Ceiling and Floor properties to project contour lines or
zone colors on the sides of the PlotCube. These properties have no effect on 3D charts or
bar charts. IsContoured and IsZoned are located on the PlotCube tab’s Ceiling and
Floor inner tabs on the Property Editor.

188 Part II n Using 3D Chart


13.7 Positioning the Chart
At run-time, the header, footer, legend, and chart area are, by default, positioned by
Olectra Chart. The default positioning for each of these objects depends on a large number
of factors, including:
n The window’s current width and height.
n The size of the legend, header and footer areas. These, in turn, depend on the text and
fonts being used.
n The positioning of areas which have been explicitly positioned by the user program.

Olectra Chart OCX


The 3D Chart control’s default positioning algorithms will size and position the header,
footer and legend areas first. The chart area will be sized and positioned to fit into the
largest remaining rectangular area.

To position an area manually, change the properties of its Location object. For example,
the following statement sets the Height property to change the height of the chart area:
Chart3D1.ChartArea.Location.Height.Value = 100

You can also change the following area attributes:


n The Width property specifies the area width.
n The Left property specifies the distance from the left edge of the area to the Y-axis.
n The Top property specifies the distance from the top of the area to the X-axis.

Chapter 13 n Building a Chart 189


13.8 Modifying the 3D View
When displaying a three-dimensional bar or surface chart on a two-dimensional screen,
the viewing angle determines the parts of the chart that are visible. To enable you to see
every part of the chart, you can customize the rotation of the chart and control the
perspective effect.

Controlling Perspective Effect

Use the Perspective View3D property to control the perspective effect displayed by the
chart. Small values exaggerate the effect and large values diminish it.

Rotating the 3D View

Use the XRotation, YRotation, and ZRotation properties to customize the rotation of the
chart. The values are degrees along an axis.

All View3D properties are located on the View3D tab’s General inner tab on the Property
Editor.

13.9 Adding and Formatting Grid Lines


Displaying a grid on a chart can make it easier to see the exact value of data points. For
each axis, you can add grid lines to one or both planes of the PlotCube.
Olectra Chart OCX

Grid lines are a property of an axis, drawn along and perpendicular to it. The grid is drawn
wherever annotation appears on the axis.

190 Part II n Using 3D Chart


Adding grid lines

Use the GridLines IsOnXYPlane property to add a grid to the XY-plane along the X- or
Y-axis.

Use the IsOnXZPlane property to add a grid to the XZ-plane along the X- or Z-axis.

Use the IsOnYZPlane property to add a grid to the YZ-plane along the Y- or Z-axis.

These properties are located on the Axes tab’s GridLines inner tab on the Property Editor.

Formatting grid lines

Use the GridStyle Pattern property to set the grid line drawing pattern, the Width
property to set the width, and the Color properties to set the line color. The valid patterns
are shown below:

None

Solid

LongDash

Dotted

ShortDash

LongShortLongDash

DashDot

These properties are located on the Axes tab’s GridStyle inner tab on the Property Editor.

Olectra Chart OCX

Chapter 13 n Building a Chart 191


13.10 Creating 4D Charts
A 4D chart uses color to display a fourth dimension of data on a 3D surface or bar chart.
The colors come from a second set of data that the chart uses for the zoning and
contouring colors. 4D charts are useful for visualizing two sets of identically-sized data in
one chart.

Creating a 4D Chart

Use the following steps and conditions to create a 4D chart:


1. Add the elevation data to the chart. See Understanding Data Layout for information
on adding data to a chart.
2. Set the IsShaded and IsZoned ChartGroup properties, located on the ChartGroup
tab’s General inner tab on the Property Editor.
3. Add the contour data to the chart. This data will be used to derive the zoning and con-
Olectra Chart OCX

touring colors for the fourth dimension of chart information. The contour data is locat-
ed on the ChartGroup tab’s Data inner tab on the Property Editor.

Notes for 4D Bar Charts

The elevation and contour data must have the same origin and the same number of rows
and columns. The row and column deltas must also be identical in both. If these conditions
are not met, a 4D chart is not displayed.
n When a set of contour data is added to a bar chart and the IsZoned ChartGroup
property is set, each bar is drawn with one color (determined by the zoned height of
the bar) instead of being drawn as separate colored segments.
n Contours are never drawn when contour data is added.

192 Part II n Using 3D Chart


13.11 Displaying 4D Data
3D Chart enables you to display four-dimensional data by representing the fourth
dimension as color.

To display four-dimensional data, do the following:


n Specify the first three dimensions of the data by setting the ElevationData property of
the ChartGroup object. (For details on how to define three-dimensional data, see
Working With Data.)
n Set the fourth dimension by setting the ContourData property of the ChartGroup
object.

For example, the following code sets the third and fourth coordinates of the point in the
second row and first column to 1.55 and 1.75 respectively:

Olectra Chart OCX


With Chart3D1.ChartGroups(1)
.ElevationData.Value(2, 1) = 1.55
.ContourData.Value(2, 1) = 1.75
End With

The ContourData property, like the ElevationData property, is of type Chart3DData.


For the 4D chart to display properly, the following properties of ContourData must be
set:
n The Layout property must be set to the same value as its ElevationData equivalent.
n The RowCount, ColumnCount, RowOrigin, ColumnOrigin, RowDelta and
ColumnDelta properties must be set to identical values in both ContourData and
ElevatedData.

If either of the above conditions are not met, the 4D chart will not be displayed.

Chapter 13 n Building a Chart 193


In bar charts, each bar is displayed as a single solid color according to the zoned height of
the bar.

In plots, the fourth dimension is displayed as zoning and contouring colors:


Olectra Chart OCX

194 Part II n Using 3D Chart


If any of the fourth-dimensional coordinates are missing (if any Value in the
ContourData is set to the value of the HoleValue property), the surface in the region of
the hole will be displayed as if the fourth dimension was not attached.

13.12 Storing Chart Descriptions in Files


To save a chart description in a file, access the Chart3D object and call the Save method:
Chart3D1.Save "C:\OLECTRA\CHART1.OC3"

To load a previously saved chart description from a file, call the Load method:
Chart3D1.Load "C:\OLECTRA\CHART1.OC3"

Both methods return True if the file operation was successful and False if an error
occurred.

Saving Chart Data

Chart data is normally stored with the other chart properties. If you don’t want the data
saved, set the IsSaved property in the Chart3DData object to False. If you want the chart
data saved to a file, set the FileName property to the name of the file. Saved data can be
loaded from this file using the Load method.

If the IsSaved property is set to True, data is saved with the chart, and the value of the
FileName property is ignored.

13.13 Printing Charts


The Chart3D object defines four methods which provide printing and drawing
capabilities:
n CopyToClipboard copies the chart to the clipboard.
n DrawToDC draws the chart on a specified device.

Olectra Chart OCX


n DrawToFile draws the chart and saves the drawing in a file.
n PrintChart prints the chart.

Each of these methods enables you to produce a copy of the chart in bitmap format,
metafile format, or enhanced metafile format.

For more details on these methods, refer to the Chart3D object help page.

Chapter 13 n Building a Chart 195


Olectra Chart OCX

196 Part II n Using 3D Chart


14
Working with Data
Data Overview n Grid and Irregular Grid Data
Point Data n Loading Data From a File
Charting Data Directly From Your Program n Copying Data n Double Buffering

The following topics explain how to plot, setup, copy and configure your data for use with
Olectra Chart.

Olectra Chart OCX

197
14.1 Data Overview
The 3D Chart control enables you to add or modify data at runtime.

Data Organization

Data in a chart is organized into chart groups. In 3D Chart, a chart group is represented by
a ChartGroup object. At present, only one chart group can be stored in a chart group
collection.

Within a chart group, the three-dimensional data to be displayed is assumed to come either
from a gridded surface, or from one or more series of points. This data is represented by
the ElevationData property, which is a Chart3DData object. The data displayed can be
in one of three formats:
n Regularly-gridded data, in which the X- and Y-gridlines are evenly spaced
n Irregularly-gridded data, in which the X- and Y-gridlines are not evenly spaced.
n Point data, in which the X, Y and Z coordinates can be specified without restrictions.

To set the data format, set the Layout property to the appropriate data layout constant.

Handling Missing Data

If the Value property for a data point is set to a special value known as the hole value, the
chart treats the data point as a missing value, and does not display it on the chart. This hole
value is specified by the HoleValue property of the Chart3DData object.

For example, the following code treats the point in the third row and first column as a
missing value:
With Chart3D1.ChartGroups(1).ElevationData
.HoleValue = 999.1
.Value(3, 1) = 999.1
End With

Batching Data Updates


Olectra Chart OCX

Normally, the displayed chart is updated whenever a Chart3DData object property is


changed. If you are changing or creating several data points, you can improve
performance by batching the changes. To do this, set the IsBatched property to True.

When IsBatched is set to True, the chart is not updated when a Chart3DData object
property is changed. Updating does not take place until IsBatched is reset to False.

14.2 Grid and Irregular Grid Data


For grid and irregular grid data, the Chart3DData object defines the following properties
which control the data to be displayed in the chart:
n The RowCount and ColumnCount properties define the number of rows and
columns of data.

198 Part II n Using 3D Chart


n The RowOrigin and ColumnOrigin properties specify the origins of the X-axis and
Y-axis respectively.
n RowDelta and ColumnDelta are indexed properties which specify the space between
neighboring rows and columns. For example, the following statement specifies a
distance of 2.5 between the first row and second row of the chart:
Chart3D1.ChartGroups(1).ElevationData.RowDelta(1) = 2.5

If the data is regularly-gridded, RowDelta and ColumnDelta each have only one value.
n The Value property specifies the Z-coordinate of a particular data point. This property
is indexed by row and column. For example, the statement
Zval = Chart3D1.ChartGroups(1).ElevationData.Value(1, 3)
assigns the Z-coordinate of the point in the first row and third column to Zval.

Changing Data Values

To change a data value displayed in the chart, all you need to do is set its Value property.
For example, the following statement changes the value of the point in the third row and
second column to 3.14159:
Chart3D1.ChartGroups(1).ElevationData.Value(3, 2) = 3.14159

Adding Rows and Columns

To add rows to a chart group, do the following:


n Set the RowCount property to the new number of rows.
n If the data is irregularly-gridded, set the RowDelta property for the space between a
new row and its predecessor.
n Set the Value property for each of the new points.

For example, the following code adds a fourth row of three points to a chart group:
With Chart3D1.ChartGroups(1).ElevationData
.RowCount = 4
’ set space between third row and fourth row
’ (not necessary if data is regularly-gridded)

Olectra Chart OCX


.RowDelta(3) = 1.0
.Value(4, 1) = 5.17
.Value(4, 2) = 5.84
.Value(4, 3) = 6.33
End With

New columns can be added in much the same way:


n Set the ColumnCount property to the new number of columns.
n If the data is irregularly-gridded, set the ColumnDelta property for the space between
a new column and its predecessor.
n Set the Value property for each of the new points.

Chapter 14 n Working with Data 199


Smoothing Data

The Smooth method passes a center-weighted averaging function over the chart grid,
resulting in a smoother-looking dataset. For example:
Chart3D1.ChartGroups(1).ElevationData.Smooth 0.7

The argument specifies the center weight, and must be between 0 and 1. This method is a
nine-point filter using all points adjacent to the center. Each new value is a weighted
average of the original value and its surrounding points. The weights of the surrounding
points are computed based on the value of the center weight and its distance from the
center point.

Creating a Shaded-Relief Map

The CreateShaded method creates a new Chart3DData object from an existing object,
filling it with a shaded-relief map of the original chart data, suitable for draping over the
original data as the data’s fourth dimension (as described in Displaying 4D Data on page
193.)

CreateShaded is passed the following five arguments:


n The sweep angle
n The rise angle (used along with the sweep angle to locate the light source)
n The scale, which determines the difference in units between the “ground” coordinates
in the XY-plane and those of the Z-values. (If the scale is set to 0, a default value will
be computed based on the average slope of the facets.)
n The base amount of ambient light (must be between 0 and 1)
n The brightness of the light (must be between 0 and 1)

Here is an example of code that calls CreateShaded:


Dim Shaded As Object
...
With Chart3D1.ChartGroups(1).ElevationData
Set Shaded = .CreateShaded 45#, 45#, 0, 0.25, 0.5
End With
Olectra Chart OCX

For a more detailed example, refer to the shader demo program.

Creating a Subset of a Chart

The CreateSubset method enables you to create a subset of an existing chart. This method
is passed the following seven arguments:
n The X- and Y-coordinates of the origin of the subset region.
n The X- and Y-coordinates of the endpoint of the subset region.
n The number of X-axis grid lines contained in the region.
n The number of Y-axis grid lines contained in the region.
n The spline interpolation method to use (this must be an interpolation constant)

200 Part II n Using 3D Chart


Here is code that calls CreateSubset:
Dim Subset As Object
...
With Chart3D1.ChartGroups(1).ElevationData
Set Subset = .CreateSubset 10.0, 12.5, 35.0, 27.5, 5, 4, _
oc3dInterpolateLinearSpline
End With

Drawing 4D Charts

3D Chart enables you to represent four-dimensional plots and bar charts using color as the
fourth dimension. For details, see Displaying 4D Data on page 193.

14.3 Point Data


The data for the point data format is accessed by series. The NumSeries property of the
Chart3DData object controls the number of series in the chart. The following example
sets the number of series to 3:
Chart3D1.ChartGroups(1).ElevationData.NumSeries = 3

An appropriate number of series will be generated whenever NumSeries is changed,


including removing series if NumSeries is decreased.

The PointSeries Collection

Individual series are accessed via the PointSeries collection of the Chart3DData object.
The PointSeries collection itself returns a DataCoordCollection of DataCoord objects,
which define the coordinates for the individual points in the series. The following methods
are defined for the DataCoordCollection:

Add(x, y, z) Adds a DataCoord object to the series with the


specified coordinates (x, y, and z are doubles).

Olectra Chart OCX


Remove(index) Removes a DataCoord object from the collection.

RemoveAll(index) Removes all DataCoord objects from the


collection.

The number of points in the series can be determined via the read-only Count property.

Examples

The following adds a point with coordinates (1, 3, 2) to the second series:
Chart3D1.ChartGroups(1).ElevationData.PointSeries(2).Add 1#, 3#, 2#

The following removes the third point in the first series:


Chart3D1.ChartGroups(1).ElevationData.PointSeries(1).Remove 3

Chapter 14 n Working with Data 201


The following assigns the number of points in the third series to x:
x = Chart3D1.ChartGroups(1).ElevationData.PointSeries(3).Count

Data Points

The coordinates of specific points are accessible via the properties of their respective
DataCoord object. To retrieve the DataCoord object for a coordinate, use the Item
method of the DataCoordCollection. The following code sets the coordinates of the third
point of the second series to (1, 3, 2):
With Chart3D1.ChartGroups(1).ElevationData.PointSeries.Item(3)
.X = 1
.Y = 3
.Z = 2
End With

Note that the Item method is the default method of the DataCoordCollection object, so it is
not necessary to specify the Item method when calling DataCoord methods. The following
sets the y-coordinate of the third point of the first series to 3:
Chart3D1.ChartGroups(1).ElevationData.PointSeries(1)(3).y = 3

14.4 Loading Data From a File


A common task in any Olectra Chart program is to load the chart data (called a dataset)
from a file into a format that the chart can use.

In order for Olectra Chart to allocate and load the data from a file, it must be in one of
three basic layouts, Grid, Irregular Grid, or Point. Use the Grid format for surface and bar
charts when the X-coordinates of each point and the Y-coordinates of each point are
always the same distance apart. Use the Irregular Grid format for surface and bar charts
when the X-coordinates of each point or the Y-coordinates of each point are not the same
distance apart. Use the Point format for multiple series of points in scatter plots.
Olectra Chart OCX

See Understanding Data Layout on page 163 for more information on Grid, Irregular
Grid, and Point layout.

The following examples illustrate the Grid, Irregular Grid, and Point file formats.

Grid File Format


! Grid has 50 by 30 points
! Holes have a value of 100.0
! Grid increases in X steps of 1.0 and Y steps of 2.0
! Origin of grid is at X = -20, Y = 50
GRID 50 30
100.0 1.0 2.0 -20.0 50.0
! 1500 data values follow, one for each grid point
49.875000 43.765625 38.500000 33.984375 30.12400
26.828125 24.000000 21.235610 48.877940 17.39770
. . .

202 Part II n Using 3D Chart


Line 5 indicates that the file format is Grid, and the file contains 50 by 30 data points. Line
6 indicates the hole value (100.0), the X and Y increments (1.0 and 2.0), and the
coordinates for the origin.

Lines beginning with a "!" are comments and are ignored by the control.

Irregular Grid Format


! Irregular grid has 10 by 5 points
! Holes have a value of 100.0
! Ten X values are given, and then five Y values
IRGRID 10 5
100.0
20 21.1 23.4 24.4 25.0 27.8 29.9 31.0 32.6 33.2
50.3 51.3 52.6 54.8 59.6
! 50 data points follow
23.34563 12.89239 11.99423 15.781212 18.81988
. . .

Line 4 indicates that the file is in the Irregular Grid format, and has 10 by 5 points. Line 5
shows the hole value (100.0). Line 6 contains the 10 X values, and line 7 contains the 5 Y
values.

Lines beginning with a "!" are comments and are ignored by the control.

Point File Format


! Point has 2 series.
! Holes have a value of 100.0
POINT 2
100.0
! The first series has 5 points
5
! X Y Z
5.65 6.24 1.78
7.41 7.26 4.21
5.45 5.44 1.43
0.97 9.66 3.41
3.86 1.42 0.20
! The second series has 3 points
3

Olectra Chart OCX


8.49 -1.28 8.76
8.14 0.42 6.06
7.17 -3.80 4.11

Line 3 indicates that the file Is in Point format, and has 2 series. Line 6 shows the hole
value (100.0). Line 8 indicates that the first series has 5 points. Lines 10–14 contain the X,
Y, and Z coordinates of the 5 points in the first series. Line 16 indicates that the second
series has 3 points, and the three following lines specify the coordinates of the 3 points.

Lines beginning with a "!" are comments and are ignored by the control.

Chapter 14 n Working with Data 203


Loading the Data

To allocate and load the data from a file, you can either use the Property Editor’s Load
button, which is located on the Data subtab of the ChartGroup tab, or do it
programmatically. Use the Chart3dData’s Load method to load data from a file:
’ Load the data from a file MMF95.DAT
Chart3d.ChartGroups(1).Data.Load MMF95.DAT

Loading Data From a URL

Instead of using the Load method to specify the location of a data file, you can specify a
URL where the chart can find the data. Olectra Chart provides two different methods to
load data from the Internet:
n Use the Chart3D Object’s LoadURL method to load a chart description file (.OC3).
n Use the Chart3DData Object’s LoadURL method to load a data file (.DAT) into an
existing chart.

In addition, if you want to set a URL location but do not want to load the data, use the
Chart3DData Object’s Datapath property. This property can be set at design time, and
used to initialize the chart data at run-time.

14.5 Charting Data Directly From Your Program


Often it may not be convenient to load chart data from a file. For example, if the data is
created from within the program using a mathematical calculation, it makes more sense to
read it into the chart directly instead of saving it to a file and then reading it again. Not
only can this method be quicker, it can also be quite easy to program.
Olectra Chart OCX

204 Part II n Using 3D Chart


The following example creates a 2-dimensional array, populates the array with data, and
then copies the contents of the array to the chart’s Z values:
’ Create the array
Dim x(1 To 10000, 1 To 4) As Double
Chart3D1.IsBatched = True

’ Set the number of rows and columns


Chart3D1.ChartGroups(1).ElevationData.RowCount = 10000
Chart3D1.ChartGroups(1).ElevationData.ColumnCount = 4

’ Populate the array


For m = 1 To 4
For n = 1 To 10000
Select Case m
Case 1, 3
x(n, m) = m * 5 * Rnd + Sqr(2 * m * m * n)
Case Else
x(n, m) = m * -5 * Rnd + Sqr(2 * m * n)
End Select
Next n
Next m

’ Copy the array to the chart


Chart3D1.ChartGroups(1).ElevationData.CopyZArrayIn x
Chart3D1.IsBatched = False

14.6 Copying Data


Before you can create a chart, you must provide it with data. Olectra provides users with 2
different methods that allow you to copy data arrays directly to and from the chart, making
it easy to quickly create chart data. Note: the methods defined in this section only apply to
Grid, and Irregular Grid data formats, and cannot be used with the Point data format.

The following copying data methods are defined by the Chart3DData Object:

CopyZArrayIn(array)

Olectra Chart OCX


Copies an array (array) to the Z values for a chart. array must be a two-dimensional array
of singles, doubles, longs or integers.

CopyZArrayOut(array)

Copies the Z values from the chart into an array. array must be a two-dimensional array of
singles, doubles, longs or integers.

Chapter 14 n Working with Data 205


The following example initializes an array, MyArray, populates it with data, and copies the
array to the chart using CopyZArrayIn:
’ Create the array
Dim MyArray(1 To 200, 1 To 4) As Double
Chart3D1.IsBatched = True

’ Set the number of rows and columns


Chart3D1.ChartGroups(1).ElevationData.RowCount = 200
Chart3D1.ChartGroups(1).ElevationData.ColumnCount = 4

’ Populate the array


For i = 1 To 4
For j = 1 To 200
Select Case x
Case 1, 3
x(i, j) = i * 5 * Rnd + Sqr(2 * j * j * i)
Case Else
x(i, j) = i * -5 * Rnd + Sqr(2 * j * i)
End Select
Next j
Next i

’ Copy the array to the chart


Chart3D1.ChartGroups(1).ElevationData.CopyZArrayIn MyArray
Chart3D1.IsBatched = False

14.7 Double Buffering


Double buffering is a graphics technique which will reduce the amount of flashing
perceived by a user when a chart changes. By default, double buffering is in effect. To turn
off double buffering for a Chart3D object, set its IsDoubleBuffered property to False.

When double buffering is turned on, every time the chart changes, it will:
n Allocate (if necessary) and clear an off-screen bitmap.
n Render the complete graph to the off-screen bitmap.
Olectra Chart OCX

When double buffering is turned off, the chart clears the screen image every time a chart is
changed (possibly causing a visual flash). Then, it renders the complete image to the
visible window (possibly allowing the user to see the chart being drawn piece by piece).

Turning off double buffering can improve the chart’s graphing performance and reduce its
memory requirements.

206 Part II n Using 3D Chart


15
Customizing Chart Elements
Adding Header and Footer Titles n Modifying the Surface Appearance
Formatting the Legend n Legend Labels Programming Considerations
Formatting the Mesh n Using Borders n Choosing Fonts
Setting Colors n Positioning Chart Elements n Form Resizing
Using ChartLabels n ChartLabels Programming Considerations
Using ContourStyles n Customizing ContourStyles n Adding Images to Chart Elements
Contour and Zone Projection n Customizing the Distribution Table
Distribution Table Programming Considerations n Special Bar Chart Properties
Special Scatter Plot Properties

When the chart data and axes are formatted properly, you can customize its elements to
make it clearer and professional-looking. The following topics cover tasks that customize
the appearance of a chart.

Olectra Chart OCX

207
15.1 Adding Header and Footer Titles
A chart can have two titles, called the header and footer. A title consists of one or more
lines of text with an optional border, both of which you can customize. You can also set
the text alignment, positioning, colors, and font used for the header or footer.

Title Text and Alignment

Use the Text title property to add, change, or remove text for a title. Text is located on the
Titles tab’s Label inner tab on the Property Editor. To enter multiple lines of text, press
Enter between each line.

Use the Adjust title property to specify whether to center, left-justify, or right-justify a
multi-line title. Adjust is located on the Titles tab’s General inner tab on the Property
Editor.

Title Positioning

Use the Left and Top location properties to customize the location of the title. When their
IsDefault properties are used, the header is centered over the ChartArea and the footer is
centered below the ChartArea. These properties are located on the Titles tab’s Location
inner tab on the Property Editor. See Positioning Chart Elements on page 219 for more
information.

Title Border

Use the Type and Width border properties to customize the title’s border. These properties
are located on the Titles tab’s Border inner tab on the Property Editor. See Using Borders
on page 214 for more information.

Title Colors

Use the interior properties to customize background and text colors of a title. These are
located on the Titles tab’s Interior inner tab on the Property Editor. See Setting Colors on
page 218 for more information.
Olectra Chart OCX

Title Font

Use the font properties to customize the font used for a title. These are located on the
Titles tab’s Font inner tab on the Property Editor. See Choosing Fonts on page 215 for
more information.

208 Part II n Using 3D Chart


15.2 Modifying the Surface Appearance
The shaded surface (drawn when the IsShaded ChartGroup property is used) has color
and appearance properties that you can customize. The zoning method (drawn when the
IsZoned ChartGroup property is used) can also be customized.

Surface Colors

Use the ShadedBottomColor and ShadedTopColor Elevation properties to set the


shading colors. These properties are located on the ChartGroup tab’s Elevation inner tab
on the Property Editor.

Making a 3D Surface Solid

Use the IsSolid Surface property to make a 3D surface appear solid. The chart draws a
“skirt” around the data to the minimum Z-value. IsSolid is located on the Surface tab’s
General inner tab on the Property Editor.

Olectra Chart OCX


Zoning Method

Use the ZoneMethod Contour property to specify how to determine each zone region.
Contour zoning uses the contour intervals for each zone region, while cell zoning uses the
rectangular block formed by the X/Y grid. Cell zoning produces a coarser-looking surface
but redraws significantly faster than contour zoning. ZoneMethod is located on the
ChartGroup tab’s General inner tab on the Property Editor.

Chapter 15 n Customizing Chart Elements 209


15.3 Formatting the Legend
The chart automatically generates a legend whenever contours or zones are drawn. When
using contours only, the legend shows the value represented by each contour line. When
using zones, the legend shows the value represented by each zone level. You can
customize the layout, positioning, border, colors and font used for the legend.

Legend Type and Orientation

Use the legend Type property to specify whether to draw the legend in a continuous or
stepped style. Continuous legends take less space on the screen than stepped. Type is
located on the Legend tab’s General inner tab on the Property Editor.
Olectra Chart OCX

Continuous Legend Stepped Legend

Use the legend Orientation property to lay out the legend horizontally or vertically, and
the IsReversed property to specify whether to display the SeriesLabels in reverse order.
These properties are located on the Legend tab’s General inner tab on the Property Editor.

210 Part II n Using 3D Chart


Legend Positioning

Use the legend Anchor property to specify where to position the legend relative to the
ChartArea. You can select from eight compass points around the ChartArea. Anchor is
located on the Legend tab’s General inner tab on the Property Editor.

Use the Left and Top location properties to finetune the positioning. When their IsDefault
properties are used, the chart automatically positions the legend. These properties are
located on the Legend tab’s Location inner tab on the Property Editor. See Positioning
Chart Elements on page 219 for more information.

Legend Title

Use the legend Text property to specify the legend title. The legend title appears centred at
the top of the legend. Text is located on the Legend tab’s Title inner tab on the Property
Editor.

Custom Legend Labels

Use the legend Labels property to define a set of custom legend labels used instead of the
automatically-generated numeric labels. When no labels exist, the chart displays the
automatic legend. The first label applies to the first contour level, and so on. Examine the
value of the Levels Contour property to determine the number of legend labels you need to
define. Labels is located on the Legend tab’s Labels inner tab on the Property Editor.

Legend Border

Use the Type and Width border properties to customize the title’s border. These properties
are located on the Legend tab’s Border inner tab on the Property Editor. See Using
Borders on page 214 for more information.

Legend Colors

Use the interior properties to customize background and text colors of the legend. These
are located on the Legend tab’s Interior inner tab on the Property Editor. See Setting

Olectra Chart OCX


Colors on page 218 for more information.

Legend Font

Use the font properties to customize the font used for the legend. These are located on the
Legend tab’s Font inner tab on the Property Editor. See Choosing Fonts on page 215 for
more information.

Chapter 15 n Customizing Chart Elements 211


15.4 Legend Labels Programming Considerations

Specifying Labels

To specify your own labels for a legend, access the Labels property of the Legend object
and call its Add method. For example, the following code creates a set of three legend
labels:
With Chart3D1.Legend.Labels
.Add "First"
.Add "Second"
.Add "Third"
End With

Legend Type

If the Legend object’s Type property is set to oc3dLegendTypeStepped, each legend


label you create is associated with a particular zone. If Type is set to
oc3dLegendTypeContinuous, each legend label is associated with the boundary between
two zones. The Type property is located on the Legend tab’s General inner tab on the
Property Editor.

Note that zones are numbered from the bottom up: the first zone label is associated with
the zone appearing at the bottom of the legend, and so on upwards.

Legend Label Filter

The Legend object’s LabelFilter property allows you to specify how many legend labels
to display. When LabelFilter is set to n, every nth label will be drawn.
Olectra Chart OCX

LegendFilter = 1 LegendFilter = 2 LegendFilter = 4

The LabelFilter property is located on the Legend tab’s Labels inner tab on the Property
Editor.

212 Part II n Using 3D Chart


Legend Distribution Range

When the Distribution Table specifies contour levels outside the span of the data, the
Legend object’s DistributionRange property controls whether they appear in the legend.
When DistributionRange is set to oc3dDistributionRangeData, only the range of
contour levels in the Distribution Table spanned by the data appear in the legend. When
DistributionRange is set to oc3dDistributionRangeAll all contour levels specified in the
Distribution Table appear in the legend. The DistributionRange property appears as
Range on the Property Editor, and is located on the Legend tab’s General inner tab.

15.5 Formatting the Mesh


The mesh (drawn when the IsMeshed ChartGroup property is used) has display, color, and
filtering properties that you can customize. Mesh filtering is particularly useful when
displaying a large amount of data in a small space.

Mesh Filtering

Use the ColumnMeshFilter and RowMeshFilter Surface properties to define how to


filter the display of mesh lines. The chart can automatically determine the best filter, or
you can specify a positive integer to use.
n When set to 0, the chart automatically determines the best filter based on the density
of the mesh. As the chart data increases or the size of the chart control decreases, the
chart performs more mesh filtering.
n When greater than 0, the chart provides fixed mesh filtering. Higher values cause
fewer mesh lines to be drawn. For example, a value of 5 filters the mesh so that every
fifth mesh line is drawn.

The ColumnMeshFilter and RowMeshFilter properties are located on the Surface tab’s
General inner tab on the Property Editor.

Olectra Chart OCX

Chapter 15 n Customizing Chart Elements 213


Mesh Display

Use the IsColumnMeshShowing and IsRowMeshShowing properties to display or hide


the mesh lines. These properties are located on the Surface tab’s General inner tab on the
Property Editor.

Mesh Transparency

Use the IsTransparent ChartGroup property to make the mesh transparent. The effect is
only visible when the chart is not shaded (controlled by the IsShaded property). When
transparent, everything behind the mesh shows through, including the walls and axes on
the PlotCube and other parts of the mesh. IsTransparent is located on the ChartGroup
tab’s General inner tab on the Property Editor.

Mesh Colors

Use the MeshBottomColor and MeshTopColor Elevation properties to set the mesh
colors. These properties are located on the ChartGroup tab’s Elevation inner tab on the
Property Editor.
Olectra Chart OCX

15.6 Using Borders


Adding a border to part of the chart can help highlight important information, or simply
make the chart look more attractive. You can customize the border type and width of the
following chart elements:
n Header and Footer titles
n Legend
n ChartArea
n the entire chart

The valid border types are shown below; you can also specify that no border is used.

214 Part II n Using 3D Chart


To change a border

Use the border Type property to set the type of border and the Width property to set its
thickness. These properties are located on the Border inner tab, found on the Control,
ChartArea, Titles, Legend, and ChartLabels tabs of the Property Editor.

15.7 Choosing Fonts

Olectra Chart OCX


A chart can have more impact when you customize the fonts used for different chart
elements. You may also want to change the font size to make an element better fit the
overall size of the chart. The chart uses two kinds of fonts: TrueType fonts and Cube Fonts
(special fonts that can be rotated in 3D space). The following table lists the type of font
used by each chart element:

Uses TrueType Font Uses TrueType or Cube Font


Header title Axis annotation
Footer title Axis title

Legend

Chapter 15 n Customizing Chart Elements 215


To change Header, Footer, or Legend fonts

Use the font properties to set the font, style, and size attributes. Font properties are located
on their own dialog on the Font inner tab, found on the Titles, Legend, and ChartLabels
tabs on the Property Editor. Click the button on the tab to display the dialog.

To choose TrueType or Cube Fonts

Use the Chart3D object’s UseTrueType property to specify whether to use TrueType
fonts for Axis annotation, Axis titles, and ChartLabels. If UseTrueType is True, TrueType
fonts are used. If UseTrueType is False, Cube fonts are used for Axis annotation and Axis
titles. When UseTrueType is False, which type of font a ChartLabel uses depends on how
it is attached to the chart. See Using ChartLabels on page 220 for more information.

To change Axis annotation, Axis title, or ChartLabel fonts

Use the CubeFont object’s TrueType property to specify the font, style, and size
attributes of TrueType fonts. Use the CubeFont object’s Stroke property to specify which
cube font to use and the Size property to set its height. Size is measured in thousandths of
the PlotCube length, for example, a value of 80 means the characters are 8% of the length
of the PlotCube height. The following shows the valid cube fonts:

RomanComplex RomanComplexSmall

RomanSimplex RomanTriplex RomanDuplex


Olectra Chart OCX

ItalicComplex ItalicComplexSmall ItalicTriplex

216 Part II n Using 3D Chart


GreekComplex GreekComplexSmall GreekSimplex

GothicEnglish GothicGerman GothicItalian

ScriptComplex ScriptSimplex CyrillicComplex

These properties are located on the Font inner tab of the ChartLabels tab, the Title inner
tab of the Axes tab, and the Font inner tab of the Axes tab on the Property Editor.

Notes
n Olectra Chart uses the container’s exposed Ambient font (if available) as its own
default font.
n The Color control in the font chooser dialog has no effect on the text color. To set the

Olectra Chart OCX


color of text, use the ForegroundColor property, located on the Interior inner tab of
that element.

Chapter 15 n Customizing Chart Elements 217


15.8 Setting Colors
Color can powerfully enhance a chart’s visual impact. You can customize colors using
color names, RGB values, or interactively using a color chooser. Each of the following
visual elements in the chart has a background and foreground color that you can
customize:
n the entire chart
n Header and Footer titles
n Legend
n ChartArea
n PlotCube (background only)
n each ChartLabel added to the chart

The mesh, contour lines, surface shading, and zone fills also have color properties you can
customize.

Specifying named colors

You can specify a color as one of over 200 recognized named colors. Choose common
colors like Blue or Orange, or more exotic colors like Chartreuse or HotPink. Most of
these colors look best on systems that can display 256 colors or more.

Choosing colors interactively

You can choose colors interactively using a color chooser dialog that works just like the
standard Windows Control Panel color chooser. Choose from Windows basic colors,
custom colors, or interactively with a full color spectrum.

Specifying RGB colors

Alternately, you can specify a color by its RGB components, useful for matching another
RGB color. RGB color values combine hexadecimal values for the red, green, and blue
components of a color. “00” is the smallest value a component can have; “ff” is the largest
Olectra Chart OCX

value. For example, “#ff00ff” specifies magenta (the maximum value of red and blue
combined with no green).

Using Automatic colors

The background and foreground of all elements except the chart itself can be “Automatic”.

When a background or foreground is automatic, the chart uses the color of the element
outside it for the background. For example, the header would have the background of the
chart itself when its background is set to Automatic.

To change a color

Use the BackgroundColor and ForegroundColor properties to set background and


foreground colors. These properties are located on the Interior inner tab, found on the
Control, Titles, Legend, ChartArea, PlotCube, and ChartLabels tabs of the Property

218 Part II n Using 3D Chart


Editor. RGB and named colors have their own controls. The button displays the interactive
color chooser dialog.

15.9 Positioning Chart Elements


Each of the main chart elements (header, footer, legend, ChartArea, and ChartLabels) has
properties that control its position and size. While the chart can automatically control
these properties, you can also customize the following:
n Positioning of any element except ChartLabels
n Size of the ChartArea only

When the chart controls positioning, it first allows space for the header, footer, and legend,
if they exist (size is determined by contents, border, and font). The ChartArea is sized and
positioned to fit into the largest remaining rectangular area. Positioning adjusts when other
chart properties change.

To change or view location

Use the Left location property to specify the number of pixels from the edge of the chart to
the left edge of the chart element. Use the Top location property to specify the number of
pixels from the edge of the chart to the top of the chart element. Left and Top have
IsDefault properties that allow the chart to automatically position the element.

These properties are located on the Location inner tab, found on the ChartArea, Titles,
Legend, and ChartLabels tabs of the Property Editor.

To change width and height (ChartArea only)

Use the Width and Height location properties to specify the width and height of the
ChartArea. These properties have IsDefault properties that allow the chart to
automatically size the ChartArea.

These properties are located and enabled on the ChartArea tab’s Location inner tab on

Olectra Chart OCX


the Property Editor.

Chapter 15 n Customizing Chart Elements 219


15.10 Form Resizing
Some applications permit the resizing of a Form object at runtime. This resizing is
enabled at design time by setting the form’s BorderStyle property to either 2 (Sizable) or 5
(Sizable ToolWindow).

To adjust the size of a Chart3D object when the Form object is resized, define a Resize
procedure for the form, and adjust the chart’s height and width to correspond to the form’s
height and width. Here is a sample Resize procedure:
Private Sub Form_Resize()
’ Match the graph to the size of the form.
If Width > 700 Then ’ Check the width of the window
’ This keeps a consistent border around the sides of the chart
Chart3D1.Width = Width - 700
Else
’ Sets the width to 0 because the window
’ is smaller than the size of the chart
Chart3D1.Width = 0
End If

If Height > 1360 Then ’ Check the height of the window


’ This keeps a consistent border around the
’ top and bottom of the chart
Chart3D1.Height = Height - 1360
Else
’ Sets the height to 0 because the window is smaller than
’ the size of the chart
Chart3D1.Height = 0
End If
End Sub

The height and width of both the form and the chart are measured in twips (1,440 twips
equals one inch). To convert twips to pixels, use the following code:
pixwidth = Chart3D1.Width / Screen.TwipsPerPixelX
pixheight = Chart3D1.Height / Screen.TwipsPerPixelY
Olectra Chart OCX

15.11 Using ChartLabels


A ChartLabel is an independent label that can be displayed inside or outside the PlotCube.
ChartLabels are useful when you want to highlight an important data point, but can also be
used generally to provide information on data or on the chart.

There is no limit to the number of ChartLabels a chart can contain. Each ChartLabel has
label, interior color, border, fonts, and attachment attributes that you can customize.

Attaching and Positioning ChartLabels

When you define a ChartLabel, you need to specify how and where to attach it to the chart.

The attachment method determines the basic appearance of the ChartLabel. The best
method depends on what you are using the ChartLabel for. The following illustrates and
describes the attachment methods:

220 Part II n Using 3D Chart


n Coordinates attaches outside the PlotCube and can appear anywhere on the chart.
You specify the number of pixels from the top-left corner of the chart to the center of
the ChartLabel. When attached this way, customizing the facing plane and cube font
has no effect.
n DataCoordinates attaches inside the PlotCube to any point in 3D space within the
data range. You specify the data X, Y, and Z coordinates. When attached this way,
customizing the border and font has no effect. Note that the chartlabels must fall
within the maximum and minimum data coordinates for the axes, otherwise the label
is not drawn.
n DataIndex attaches inside the PlotCube to a specific data point on the chart. You
specify the row and column indices. When attached this way, customizing the border
and font has no effect.

Use the AttachMethod ChartLabel property to set the attachment method, and the
AttachCoord, AttachDataCoord, or AttachDataIndex properties to set the attachment
point. These properties are located on their own dialog on the ChartLabels tab’s Attach

Olectra Chart OCX


inner tab on the Property Editor. Click the AttachMethod button to display the dialog.

Connecting Line and Offset

Use the IsConnected property to draw a line connecting the ChartLabel to its attachment
point. IsConnected is located on the ChartLabels tab’s General inner tab on the Property
Editor.

Use the HorizontalOffset and VerticalOffset properties to set the distance between the
ChartLabel and its attachment point. They have no effect when displaying a 3D surface or
bar chart. These properties are located on the ChartLabels tab’s Attach inner tab on the
Property Editor.

Chapter 15 n Customizing Chart Elements 221


ChartLabel Text and Alignment

Use the Text label property to set or change a ChartLabel’s text. Text is located on the
ChartLabels tab’s Label inner tab on the Property Editor. To enter multiple lines of text,
press Enter between each line.

Use the Adjust property to specify whether to center, left-justify, or right-justify a multi-
line ChartLabel. Adjust is located on the ChartLabels tab’s General inner tab on the
Property Editor.

ChartLabel 3D Plane

When displaying a 3D surface or bar chart, use the Plane property to set which plane to
face the ChartLabel. You can select either the XZ or YZ plane. Plane is located on the
ChartLabels tab’s General inner tab on the Property Editor.

ChartLabel Border

When attached by DataCoordinates or DataIndex, the border is a fixed thin line and
cannot be customized. When attached by Coordinates, you can use the Type and Width
border properties to customize the ChartLabel’s border. These properties are located on
the ChartLabels tab’s Border inner tab on the Property Editor. See Using Borders on
page 214 for more information.

ChartLabel Colors

Use the interior properties to customize background and text colors of a ChartLabel. These
are located on the ChartLabels tab’s Interior inner tab on the Property Editor. See Setting
Colors on page 218 for more information.

ChartLabel Fonts

A ChartLabel has both a TrueType font and a CubeFont property. When the Chart3D
object’s UseTrueType property is True, all ChartLabels use TrueType fonts. When the
Chart3D object’s UseTrueType property is False, if the ChartLabel is attached by
Olectra Chart OCX

DataCoordinates or DataIndex, it uses the Cube font; when attached by Coordinates, it


uses the TrueType font. The TrueType and Cube font properties are located on the
ChartLabels tab’s Font inner tab on the Property Editor. See Choosing Fonts on page 215
for more information.

222 Part II n Using 3D Chart


15.12 ChartLabels Programming Considerations
A ChartLabel object defines an independent rectangular region which can be attached to
a chart. The ChartLabels collection contains all of the chart labels defined for a particular
chart.

To create a ChartLabel object, call the Add method:


Dim label As Object
Set label = Chart3D1.ChartLabels.Add

The Remove method removes a ChartLabel from the collection:


Chart3D1.ChartLabels.Remove 1

Defining the ChartLabel

The ChartLabel object provides a number of properties that help you define and position
the chart label. The most important of these properties are the following:
n The Text property specifies the text to appear in the chart label, and is of type Label.
n The Plane property specifies the orientation of the chart label. The orientation is
specified as a plane constant.
n The IsConnected property is a Boolean which specifies whether a line is to be drawn
from the chart label to its attached location. If True, the line is drawn.

The following code sets the above properties:


With Chart3D1.ChartLabels(1)
.Text = "Here is my chart label"
.Plane = oc3dXZPlane
.IsConnected = True
End With

Attaching the ChartLabel

Chart labels can be attached to a chart in one of three ways:


n at a particular grid index

Olectra Chart OCX


n to a point in 3D space
n to pixel coordinates on the chart

To attach a chart label to a particular grid index, set the AttachMethod property to
oc3dTextAttachDataIndex, and then set the AttachDataIndex property to the index
values for that particular grid location. For example, the following attaches a chart label to
the point at the second row and third column:
With Chart3D1.ChartLabels(1)
.AttachMethod = oc3dTextAttachDataIndex
.AttachDataIndex.Row = 2
.AttachDataIndex.Column = 3
End With

To attach a chart label to a point in 3D space, set the AttachMethod property to


oc3dTextAttachDataCoord, and then set the AttachDataCoord property to the

Chapter 15 n Customizing Chart Elements 223


coordinates of the value. For example, the following attaches a chart label to the point
(1.1, 15.8, 4.3):
With Chart3D1.ChartLabels(1)
.AttachMethod = oc3dTextAttachDataCoord
.AttachDataCoord.X = 1.1
.AttachDataCoord.Y = 15.8
.AttachDataCoord.Z = 4.3
End With

To attach a chart label to pixel coordinates on the chart, set the AttachMethod property to
oc3dTextAttachCoord, and then set the AttachCoord property to the desired pixel
coordinates. For example, the following attaches a chart label to the pixel coordinates
(100, 100):
With Chart3D1.ChartLabels(1)
.AttachMethod = oc3dTextAttachCoord
.AttachCoord.X = 100
.AttachCoord.Y = 100
End With

The following is the object hierarchy for the ChartLabels collection and the properties
described above:

Chart3D

ChartLabel

AttachCoord
Coord Object

Attach DataCoord
DataCoord Object

AttachDataIndex
DataIndex Object
Olectra Chart OCX

Batching ChartLabel Changes

To improve efficiency, you can batch changes to a chart label. To do this, set the
IsBatched property to True before changing any chart label properties, and set IsBatched
to False once you have finished. This ensures that the chart will be updated only once,
instead of after each property change.

224 Part II n Using 3D Chart


15.13 Using ContourStyles
The attributes that define how contour lines and zoning colors look in the chart are called a
ContourStyle. The chart has a built-in set of 100 styles. A subset of these styles are used
for the chart display, based on the number of contour levels in the chart. You can load and
save sets of ContourStyles and customize individual styles.

Every ContourStyle has a FillStyle and a LineStyle. FillStyles are used for zoning colors.
LineStyles are used for contour lines. Most charts will not need to customize
ContourStyles. Situations where you will need to customize them include:
n When it is important in your chart to control the precise ContourStyle for any
particular level;
n When you need to display more than 100 levels; or
n When you want to uniquely identify contour lines. The built-in styles use the same
LineStyle for every ContourStyle.

Olectra Chart OCX


FillStyle

Use the Color properties to set the fill color for a ContourStyle. These properties are
located on the Styles tab’s FillStyle inner tab on the Property Editor.

Chapter 15 n Customizing Chart Elements 225


LineStyle

Use the Pattern property to set the line drawing pattern, the Width property to set its
width, and the Color properties to set the line color for a ContourStyle. The valid patterns
are shown below:

None
Solid

LongDash

Dotted

ShortDash

LongShortLongDash

DashDot

These properties are located on the Styles tab’s LineStyle inner tab on the Property Editor.

To Load and Save ContourStyles

Use the Load and Save buttons on the Styles tab’s General inner tab on the Property
Editor to load and save sets of ContourStyles. Olectra Chart includes sample contour
styles suitable for various kinds of charts.

To Reset ContourStyles

Use the ResetStyles button on the Styles tab’s General inner tab on the Property Editor to
return to the chart’s 100 built-in styles.
Olectra Chart OCX

226 Part II n Using 3D Chart


15.14 Customizing ContourStyles
By default, the chart defines an array of contour styles for each chart group. These contour
styles are specified as a ContourStyles collection of objects. The following is the object
hierarchy for the ContourStyles collection:

Chart3D Legend
Object
ChartGroups Collection

Contour

Styles
ContourStyles
collection

Each ContourStyle object in this collection defines two properties which specify the
appearance of a particular contour line or zone in a chart:
n The FillStyle property is a FillStyle object, and specifies the color of the zone
associated with this contour style.
n The LineStyle property is a LineStyle object, and specifies the width, color and
pattern of the contour line associated with this contour style. By default, each line is
one pixel wide and is a solid black line.

A total of 100 contour styles are defined by default. To add additional contour styles, use
the Add method.

Contour Styles and Distribution Levels

Note that the nth contour line or zone in a chart is normally not associated with the nth
contour style in the ContourStyles collection. The relationship between distribution levels
(contour lines/zones) and the ContourStyles collection is as follows: if nstyles contour

Olectra Chart OCX


styles are provided, and the number of distribution levels is nlevels, the index of the
contour style associated with the nth distribution level is the largest integer less than or
equal to the following:
(n * (nstyles - 1) / nlevels) + 1

For example, if 100 contour styles and 6 distribution levels are defined, the distribution
levels use the 1st, 21st, 41st, 60th, 80th and 100th elements of the ContourStyles
collection, respectively. (The number of distribution levels is specified by the NumLevels
property of the ContourLevels object.) Normally, you will not need to calculate the
contour style index yourself, as the CalcIndex method (described below) calculates it for
you.

To force a one-to-one matchup between contour styles and distribution levels, create an
array of contour styles with the same number of elements as there are distribution levels.
(If you have specified that zone regions are to be drawn, your array of contour styles must
contain one more element than the number of distribution levels. Zone regions are

Chapter 15 n Customizing Chart Elements 227


specified by setting the IsZoned property of the Contour object to True. The extra
contour style is used to specify the last zone’s fill color.)

Finding and Changing ContourStyles

To find the ContourStyle object associated with a particular contour line or zone, use the
CalcIndex method. For example, the following retrieves the ContourStyle object for the
third contour line:
Dim Index As Long
With Chart3D1.ChartGroups(1).Contour
Index = .Styles.CalcIndex(3)
End With

You can use this approach to change the attributes of individual zones or contour lines. For
example, to change the color for a particular zone, change the Color property of the
FillStyle object. The following statements change the first zone color to green:
Dim Index As Long
With Chart3D1.ChartGroups(1).Contour
Index = .Styles.CalcIndex(1)
.Styles(Index).FillStyle.Color = RGB(0, 128, 0)
End With

To change the line width, color and pattern for a contour line, change the Width, Color
and Pattern properties of the LineStyle object. For example, the following statements
change the second contour line to a dotted green line which is 5 pixels wide:
Dim Index As Long
With Chart3D1.ChartGroups(1).Contour
Index = .Styles.CalcIndex(2)
With .Styles(Index).LineStyle
.Width = 5
.Color = RGB(0, 128, 0)
.Pattern = oc3dLineDotted
End With
End With

The customized contour style table resulting from these changes can be saved into a file
using the Save method, and restored from a file using the Load method. This enables you
Olectra Chart OCX

to use the same contour styles in different charts.

To revert to the default contour style behavior, invoke the Reset method. All contour
styles will be reset to their default values.

228 Part II n Using 3D Chart


15.15 Adding Images to Chart Elements
You can add a Windows bitmap (.BMP) or Metafile (.WMF or .EMF) image to the
background of any 3D chart element. You can add separate images to the following chart
elements:
n Chart
n ChartArea
n ChartLabels
n Header, Footer and Title
n Legend

To Add an Image to a Chart Element:

Use the FileName property to specify the name and location of the image you want to
display. The image must be in either Windows bitmap or Metafile format. Use the
IsEmbedded property to include the specified image with the chart. If IsEmbedded is
true, the image will be included with your chart. If IsEmbedded is False, the chart will
look for the image file in the specified location.

To Set the Image Layout:

Use the Layout property to specify how the image is to be displayed. You can set Layout
to one of the following:
n Centered - places the image in the center of the chart element
n Fitted - resizes the image to fit as much of the chart element as possible, while
maintaining the image’s aspect ratio (so that the image remains in proportion)
n Stretched - resizes the image to fit the entire chart element area
n Stretch to Width - stretches the image horizontally to match the chart element width
n Stretch to Height - stretches the image vertically to match the chart element height
n Tiled - repeats the image to fill the entire chart element

Olectra Chart OCX


n Cropped Fit - resizes the image to fit the shorter of the two chart element dimensions
(either the height or the width), and crops the other dimension.

These properties are located on the Control, ChartArea, Legend, ChartLabels, and
Titles Image Tab.

Using Images as Labels

Use the HasMinimumSize property to use an image as a label. When HasMinimumSize


is enabled the text area in which the image appears will be sized according to the image
dimensions, so when a text area is empty, the image itself will appear as the label. When
HasMinimumSize is disabled, the text area will be sized according to the text. If
HasMinimumSize is enabled and the text is larger than the image, then the text
determines the size. HasMinimumSize applies to Titles and ChartLabels, and can be
found on their respective Image tabs.

Chapter 15 n Customizing Chart Elements 229


Notes
n Enhanced Metafiles are only supported under Windows 95/98 and Windows NT.
n If the background image type either a Metafile (.WMF) or Enhanced Metafile (.EMF)
format, the image will not draw when the chart is either copied to the clipboard or
copied to a file. To get around this limitation, it is recommended that you set your
background image to a Bitmap format when you want to copy your chart to the
printer, clipboard or file.
n When text areas containing background images are rotated, the image is not rotated
with the text area.
n You can only add images to ChartLabels that do not fall within the PlotCube.

15.16 Contour and Zone Projection


The contours and zones determined for the chart can be displayed on the ceiling or the
floor of the plot cube. To do this, set the IsContoured and/or the IsZoned property for the
ceiling or the floor.

For example, the following statement projects zones onto the ceiling of the plot cube:
Chart3D1.ChartArea.PlotCube.Ceiling.Projection.IsZoned = True

The following is the complete object hierarchy for contour and zone projection on the plot
cube ceiling or floor:

Is Chart3D

ChartArea

PlotCube
Olectra Chart OCX

Ceiling
IsContoured
Projection and IsZoned
properties

Floor
IsContoured
Projection and IsZoned
properties

The contour and zone settings used in these projections are set by the Contour object
defined for that chart group.

Contour and zone projection are ignored in two-dimensional charts and bar charts.

230 Part II n Using 3D Chart


15.17 Customizing the Distribution Table
The chart’s ContourLevels determine how many contour lines and zoning colors are used
in the chart, and the Z-values that mark each level. You can customize the number of
levels or the distribution table itself.

Overview

To generate contours and zones, the chart analyzes the data and based on the number of
levels specified, creates the following:
n A linear distribution table that contains the Z-value that marks each level.
n An assignment of ContourStyles from the chart’s 100 built-in styles. The chart
determines which styles to use by evenly distributing its 100 styles through the
number of levels.

Customizing the Number of Levels

Use the NumLevels ContourLevels property to set the number of contour levels to use.
This has no effect when the chart is using a custom distribution table. You can specify up
to 100 levels; the more levels you use, the finer the distribution table. NumLevels is
located (as Levels) on the Levels tab’s General inner tab on the Property Editor.

Creating a Custom Distribution Table

When a linear distribution table does not suit the needs of your chart, you can create or
load a custom table that sets the number of levels and the value used to mark each level.
Olectra Chart includes sample distribution table files that you can use as templates to build
a table that suits your chart.

Use the Load and Save buttons on the Levels tab’s General inner tab on the Property
Editor to load and save distribution tables.

Resetting to Linear Distribution Table

Olectra Chart OCX


Use the IsDefault ContourLevels property to use linear distribution. Any customized
levels are removed. IsDefault is located on the Levels tab’s General inner tab on the
Property Editor.

Chapter 15 n Customizing Chart Elements 231


15.18 Distribution Table Programming Considerations
In 3D Chart, the ContourLevels object controls the behavior of the distribution levels
used to create contour levels and zones for a chart. One ContourLevels object is defined
for each chart group. The following is the object hierarchy for the ContourLevels object:

Chart3D Legend
Object
ChartGroups Collection

Contour

Levels
ContourLevels Object

The NumLevels property of the ContourLevels object specifies the number of


distribution levels to use in the chart. Any number between 0 and 100 is valid. If 0 is
specified, no contour levels are drawn, and the entire chart is displayed as one zone.

By default, distribution levels are evenly spaced. To define your own distribution levels
and spacing, use the Add method to create them. For example, the following code defines
distribution levels at 1000, 2500 and 4200:
With Chart3D1.ChartGroups(1).Contour.Levels
.Add 1000#
.Add 2500#
.Add 4200#
End With

To remove a distribution level, use the Remove method:


Chart3D1.ChartGroups(1).Contour.Levels.Remove 1000#

A list of distribution levels can also be saved to a file using the Save method, and reloaded
from a file using the Load method.
Olectra Chart OCX

At any time, you can revert to evenly spaced distribution levels by setting the IsDefault
property to True. The number of distribution levels in the chart will not change when you
do this.

Distribution Levels and Contour Styles

3D Chart defines a contour style for each distribution level. This contour style specifies
the width, color and pattern of the contour line associated with this contour style, and the
color of the associated zone.

The ContourStyles collection defines the contour styles for a particular chart group. To
retrieve the contour style for a particular distribution level, use the CalcIndex method. For
example, the following retrieves the contour style for the third distribution level:
Dim Index As Long
With Chart3D1.ChartGroups(1).Contour
Index = .Styles.CalcIndex(3)
End With

232 Part II n Using 3D Chart


For more information on programming ContourStyles, see Customizing ContourStyles on
page 227.

15.19 Special Bar Chart Properties


In a 3D bar chart, each data point is displayed as a single bar drawn from the Z-value to
the origin. Spacing between adjacent bars is honored when using either grid or irregular
grid data layout. You can customize several properties unique to bar charts, including
origin, spacing, and colors.

Bar Z Origin

Use the axis Origin property to set the origin of the Z-axis. It is only used with bar charts.
Origin is located on the Axes tab’s General inner tab on the Property Editor.

Bar Spacing Width

Use the bar RowSpacing and ColumnSpacing properties to set the space used by each
bar. The value represents the percentage of available space, with valid values between 0
and 100. When 100, the bars touch one another. These properties are located on the
ChartGroup’s Bar inner tab on the Property Editor.

Bar Shading Colors

When a bar chart is shaded but not zoned, bars drawn above the Z-origin use the surface
top color and bars drawn below the Z-origin use the surface bottom color. You can
arbitrarily set the color of one bar or entire rows and columns of bars. To define colors that
appear in the legend, you need to create a 4D chart; see Creating 4D Charts on page 192
for more information.

Use the DataColor properties to define custom bar colors. Each color is defined by a row
index, a column index, and the color to use. To set a color for an entire row, specify 0 as
the column index. To set a color for an entire column, specify 0 as the row index.

Olectra Chart OCX


DataColor properties are located on the ChartGroup tab’s Bar Colors inner tab on the
Property Editor.

15.20 Special Scatter Plot Properties


A scatter plot consists of one or more series of individual points. You can specify whether
or not drop lines appear, and you can customize the appearance of the symbol and drop
lines for each series.

Adding Drop Lines

Use the Elevation object’s HasDropLines property to specify whether or not drop lines
appear between the plotted points and the origin. Each point in a scatter plot has a drop

Chapter 15 n Customizing Chart Elements 233


line that connects it to the Z plane. The HasDropLines property is located on the
ChartGroup tab’s Scatter inner tab on the Property Editor.

The following code specifies that drop lines appear:


Chart3D1.ChartGroups(1).Elevation.HasDropLines = True

Changing ChartStyles

The attributes that define how a series of data looks in the scatter plot are called a
ChartStyle. Each series has its own ChartStyle, which you can customize. The ChartStyle
object allows you to programmatically change the following properties of a series:
n The Line property, which defines the line style for the object. This specifies the color,
pattern and thickness of drop lines. This property is of type LineStyle.
n The Symbol property, which defines the symbol style for the object. This specifies the
color, size and shape of points. This property is of type SymbolStyle.
Olectra Chart OCX

The following sets the line pattern for the second series to a dotted line:
Chart3D1.ChartGroups(1).Styles(2).Line.Pattern = oc3dLineDotted

And the following statement sets the symbol style for the third series to an unfilled circle:
Chart3D1.ChartGroups(1).Styles(3).Symbol.Shape = oc3dShapeCircle

The Chart Styles Collection

The ChartStyles collection contains the ChartStyle objects defined for each series. The
following methods are defined for the ChartStyles collection:

Add(index) Add a new ChartStyle object to the collection

Remove(index) Remove a ChartStyle object from the collection

234 Part II n Using 3D Chart


Normally, you will not need to add or remove ChartStyle objects from the collection
yourself. If a ChartStyle object already exists when its corresponding series is created, the
previously created ChartStyle object is used to display the data in this series.

By looping through the ChartStyles collection, you can quickly change the behavior of all
of the lines or points in a chart. For example, the following code lightens all of the points
in a chart whenever the mouse is clicked:
Private Sub Chart3D1_Click()
Dim Style As Object
For Each Style in Chart3D1.ChartGroups(1).Styles
Style.Shape.Color = Style.Shape.Color + &H50505
Next Style
End Sub

Formatting Drop Lines

Use the Line Pattern property to set the line drawing pattern, the Width property to set its
width, and the Color properties to set the line color for a ChartStyle. The valid patterns are
shown below:

None

Solid

LongDash

Dotted

ShortDash

LongShortLongDash

DashDot

These properties are located on the ChartStyles tab’s LineStyle inner tab on the Property

Olectra Chart OCX


Editor.

Formatting Symbols

Use the Symbol Shape property to set the symbol type, the Size property to set its size,
and the Color properties to set the symbol color for a ChartStyle. The valid symbols are
shown below:

None Vertical Line

Dot Horizontal Line

Box Cross

Triangle Circle

Chapter 15 n Customizing Chart Elements 235


Diamond Square

Star Inverted Triangle

Diagonal Cross Open Triangle

Open Diamond Open Inverted Triangle

These properties are located on the ChartStyles tab’s SymbolStyle inner tab on the
Property Editor.
Olectra Chart OCX

236 Part II n Using 3D Chart


16
Programming User Interaction
Programming Actions n Returning Coordinate Values
Customizing the Property Editor

Olectra Chart allows you to interact with the user, reacting to specific mouse, menu and
keyboard actions. You can also determine which tabs from the Property Editor you want
users to see. The following topics cover the different types of user interaction.

Olectra Chart OCX

237
16.1 Programming Actions
A chart action is a user event that causes some interactive action to take place in the
control. There are three stages of user interaction defined in 3D Chart:
n Starting a user interaction
n Updating a user interaction
n Ending a user interaction

Chart actions are defined for each of these stages. The complete list of actions is specified
by the Action Constants.

Action Maps

An action map is a mapping of a mouse operation and/or key pressing to a chart action.
Each action map consists of three parts:
n The message (indicating what mouse operation or key pressing occurred)
n Any modifier flags
n The keycode (if the message is WM_KEYDOWN or WM_KEYUP)

The ActionMaps collection specifies the action maps currently defined for the 3D Chart
control.

Recognized Messages

The following messages are recognized:

WM_LBUTTONDBLCLK double-click left mouse button

WM_MBUTTONDBLCLK double-click both mouse buttons

WM_RBUTTONDBLCLK double-click right mouse button

WM_LBUTTONDOWN press left mouse button

WM_MBUTTONDOWN press both mouse buttons


Olectra Chart OCX

WM_RBUTTONDOWN press right mouse button

WM_LBUTTONUP release left mouse button

WM_MBUTTONUP release both mouse buttons


WM_RBUTTONUP release right mouse button

WM_MOUSEMOVE move mouse

WM_KEYDOWN press key

WM_KEYUP release key

These constants are defined in oc_api.txt, which is located in the \CHART\INCLUDE


directory.

238 Part II n Using 3D Chart


If you have a three-button mouse, holding down the middle mouse button is equivalent to
simultaneously holding down the left and right mouse buttons.

Modifier Flags

The following modifier flags are recognized:

MK_LBUTTON left mouse button

MK_MBUTTON both mouse buttons

MK_RBUTTON right mouse button


MK_ALT Alt key

MK_SHIFT Shift key

MK_CONTROL Ctrl key

These constants are defined in oc_api.txt, which is located in the \CHART\INCLUDE


directory.

Recognized Keycodes

Any valid VK_ value is treated as a recognized keycode. Note the following, however:
n Αll alphabetic characters are forced to upper case.
n MK_SHIFT must appear in the modifier if capitals are desired.
n The CapsLock key toggles the meaning of the MK_SHIFT modifier.

Determining Action Mappings

To determine which action is mapped to a particular Microsoft Windows message, use the
Item property, which is defined by the ActionMaps collection. For example, the
following statement returns the action performed when the left mouse button is clicked:
Dim LeftMouse As Object

Olectra Chart OCX


...
Set LeftMouse = Chart3D1.ActionMaps.Item WM_LBUTTONDOWN, 0, 0

An exception is generated if no action is mapped to a particular message.

Chapter 16 n Programming User Interaction 239


By default, the following action maps are defined:

WM_MBUTTONDOWN, MK_MBUTTON, 0 oc3dActionModifyStart (start rotation)

WM_MBUTTONDOWN, MK_MBUTTON+MK_SHIFT, 0 oc3dActionModifyStart (start


translation)

WM_MBUTTONDOWN, MK_MBUTTON+MK_CONTROL, oc3dActionModifyStart (start scaling)


0
WM_LBUTTONDOWN, MK_MBUTTON+MK_CONTROL, oc3dActionZoomStart (start zooming)
0
WM_KEYDOWN, MK_MBUTTON, ’X’ oc3dActionRotateXAxis (specify that
rotation is to be about the X-axis)

WM_KEYDOWN, MK_MBUTTON, ’Y’ oc3dActionRotateYAxis (specify that


rotation is to be about the Y-axis)

WM_KEYDOWN, MK_MBUTTON, ’Z’ oc3dActionRotateZAxis (specify that


rotation is to be about the Z-axis)

WM_KEYDOWN, MK_MBUTTON, ’E’ oc3dActionRotateEye (specify that


rotation is to be about the eye point)

WM_KEYDOWN, MK_MBUTTON, ’N’ oc3dActionRotateFree (specify


unconstrained rotation)

WM_MOUSEMOVE, MK_MBUTTON, 0 oc3dActionRotate

WM_MOUSEMOVE, MK_MBUTTON + MK_SHIFT, 0 oc3dActionTranslate

WM_MOUSEMOVE, MK_MBUTTON + MK_CONTROL, 0 oc3dActionScale

WM_MOUSEMOVE, MK_LBUTTON + MK_CONTROL, 0 oc3dActionZoomUpdate

WM_MBUTTONUP, 0, 0 oc3dActionModifyEnd (end rotation)

WM_MBUTTONUP, MK_SHIFT, 0 oc3dActionModifyEnd (end


translation)

WM_MBUTTONUP, MK_CONTROL, 0 oc3dActionModifyEnd (end scaling)

WM_LBUTTONUP, MK_CONTROL, 0 oc3dActionZoomEnd (end zooming)


Olectra Chart OCX

WM_KEYDOWN, 0, ’R’ oc3dActionReset

WM_RBUTTONDOWN, MK_MBUTTON,0 oc3dActionProperties (display


Property Editor)

WM_KEYDOWN, MK_LBUTTON, VK_ESCAPE oc3dActionZoomCancel


WM_KEYDOWN, MK_MBUTTON, VK_ESCAPE oc3dActionModifyCancel

Programming Action Mappings

To program an action mapping, use the Add method to add the new action mapping to the
collection.

240 Part II n Using 3D Chart


For example, the following tells 3D Chart to undo all scaling and translations when the left
mouse button is double-clicked:
Dim NewLeft As Object
...
With Chart3D1.ActionMaps
Set NewLeft = .Add WM_LBUTTONDBLCLK, 0, 0, oc3dActionReset
End With

All 3D Chart actions are can be customized: you can determine which Microsoft Windows
message will call a particular action, and decide on the appropriate steps to perform in
each case.

Removing Action Mappings

To remove an existing action mapping, use the Remove method to remove the action
mapping from the collection:
With Chart3D1.ActionMaps
.Remove WM_LBUTTONDBLCLK, 0, 0
End With

Note that Remove generates an exception if no action exists to be removed.

Calling an Action Directly

To call an action directly, call the CallAction method, which is defined by the Chart3D
object. This method is passed the action to be performed and the X- and Y- coordinates of
a window location.

For examples of code using CallAction, refer to the actions demo provided with your
Olectra Chart distribution.

Actions and Events

Each of the actions defined in the Action Constants maps to a 3D Chart event method. The
following mappings are defined:

Olectra Chart OCX


oc3dActionNone no event method called

oc3dActionModifyStart ModifyStart()
oc3dActionModifyEnd ModifyEnd()

oc3dActionModifyCancel ModifyEnd()

oc3dActionRotate View3DModify()

oc3dActionScale ViewportModify()

oc3dActionTranslate ViewportModify()
oc3dActionZoomStart ModifyStart()
oc3dActionZoomUpdate no event method called

oc3dActionZoomEnd ViewportModify(), ModifyEnd()

Chapter 16 n Programming User Interaction 241


oc3dActionZoomCancel ModifyEnd()

oc3dActionRotateXAxis no event method called

oc3dActionRotateYAxis no event method called


oc3dActionRotateZAxis no event method called

oc3dActionRotateEye no event method called


oc3dActionRotateFree no event method called

oc3dActionReset ModifyStart(),
ViewportModify(), ModifyEnd()
oc3dActionProperties property pages are displayed

The event methods are defined in the Event Reference section. Note that some actions
trigger multiple events.

16.2 Returning Coordinate Values


The ChartGroups collection provides methods which enable you to do the following:
n Determine the pixel coordinates of a given data point, or the closest point to a given
set of pixel coordinates.
n Convert from data coordinates to screen pixel coordinates and vice versa.
n Change the Z-value of a grid location.
n Determine the Z-value of any point on the surface.

Determining Coordinate Values

To determine the pixel coordinates of a given data point, call DataIndexToCoord. For
example, the following code obtains the pixel coordinates of the point in the second row
and third column:
Olectra Chart OCX

Dim PixelX As Long


Dim PixelY As Long
...
With Chart3D1.ChartGroups(1)
.DataIndexToCoord 2, 3, PixelX, PixelY
End With
’ PixelX and PixelY now contain the pixel coordinate value

242 Part II n Using 3D Chart


Converting Data Coordinates to Pixel Coordinates

To convert from data coordinates to screen pixel coordinates, call the


DataCoordToCoord method. For example, the following code obtains the pixel
coordinates corresponding to the data coordinates (5.1, 10.2, 8.4):
Dim PixelX As Long
Dim PixelY As Long
...
With Chart3D1.ChartGroups(1)
.DataCoordToCoord 5.1, 10.2, 8.4, PixelX, PixelY
End With
’ PixelX and PixelY now contain the pixel coordinate value

If the data coordinate is out of the visible range of the chart, both of the pixel X- and Y-
coordinates are set to -1.

Converting Pixel Coordinates to Data Coordinates

To convert from pixel coordinates to data coordinates, call CoordToDataCoord. For


example, the following converts the pixel coordinates (225, 92) to their equivalent data
coordinates:
Dim DataX As Double
Dim DataY As Double
Dim DataZ As Double
Dim Region As Integer
...
With Chart3D1.ChartGroups(1)
Region = CoordToDataCoord 225, 92, DataX, DataY, DataZ
End With
’ DataX, DataY and DataZ now contain the data coordinate value

CoordToDataCoord returns, as its return value, the region of the chart in which the pixel
coordinates are located. This region is represented as a region constant.

Picking Data Points

To determine the closest data point to a set of pixel coordinates, call CoordToDataIndex:

Olectra Chart OCX


Dim Row As Long
Dim Column As Long
Dim Distance As Long
Dim Region As Integer
...
With Chart3D1.ChartGroups(1)
Region = CoordToDataIndex 225, 92, Row, Column, Distance
End With

CoordToDataIndex returns the row and column of the closest data point, and also returns
the distance in pixels between the pixel coordinates and the point. CoordToDataIndex
returns, as its return value, the region of the chart in which the pixel coordinates are
located. This region is represented as a region constant. When the returned region is
oc3dRegionInLegend, the returned point value is also set to oc3dRegionInLegend, and
the returned series is the closest element in the legend.

Chapter 16 n Programming User Interaction 243


The DragZValue method enables you to change the Z-value of any point on the grid. For
example, the following changes the Z-value of the point in the second row and third
column to the pixel coordinates (225,92):
With Chart3D1.ChartGroups(1)
.DragZValue 2, 3, 225, 92
End With

The DragZValue method can be used to interactively drag a point to a new coordinate, as
in the surface demo program.

The SurfaceValue method enables you to determine the Z-value of any point on the chart
surface. For example, the following code determines the Z-value of the data coordinates
(106,84):
Dim Zvalue As Double
...
With Chart3D1.ChartGroups(1)
Zvalue = .SurfaceValue 106, 84
End With

Converting Visual Basic Coordinates

In Visual Basic, coordinate values are measured in twips (1,440 twips equals one inch).
The following code converts the height and width of a chart from twips to pixels:
pixwidth = Chart3D1.Width / Screen.TwipsPerPixelX
pixheight = Chart3D1.Height / Screen.TwipsPerPixelY

16.3 Customizing the Property Editor


Depending on the type of chart you create, you may want to allow users to view the entire
Property Editor, or only part of it. By hiding a Property Editor tab or subtab, you can
determine what chart components users can customize.

To Hide a Property Editor Tab


Olectra Chart OCX

Use the ShowChartEditorElement method to set the display state of the Property Editor
tab. The following example hides the Control tab and the Title subtab of the Axes tab:
Chart3d1.ShowChartEditorElement oc3dceeControl, False
Chart3d1.ShowChartEditorElement oc3dceeAxesTitle, False

To Display a Property Editor Tab Display State

Use the IsChartEditorElementVisible method to determine if the tab is currently hidden


or visible. The method returns True if the element is visible, and False otherwise. The
following example gets the display state for the Title subtab of the Axes tab, and shows the
tab if it is currently hidden:
If Chart3d1.IsChartEditorVisible (oc3dceeAxesTitle) = False then
Chart3d1.ShowChartEditorElement oc3dceeAxesTitle, True
EndIf

244 Part II n Using 3D Chart


17
Adding an Olectra Chart 3D Control to
a Web Page
Getting Started n Creating a Web Page
Creating a License Pack File n Packaging the Control
Testing your Web Page

You can add the Olectra Chart 3D control to a web page. Steps 1-5 provide detailed
information on the tools you need, how to insert the control, how to create the license pack
file, how to optimize the download process and what to look for when testing the web
page.

Olectra Chart OCX

245
17.1 Getting Started
Before you can add Olectra Chart to your web page, you will need the following tools:

Microsoft ActiveX SDK - Use this SDK to create the License Pack File (.LPK) that users
will download when viewing a web page containing an Olectra Chart ActiveX control.
You can download the ActiveX SDK from:
http://www.microsoft.com/msdownload/sbndownload/sbnaxsdk/sbnaxsdk.htm

For more information about the ActiveX SDK, go to:


http://www.microsoft.com/workshop/prog/sdk/?

Microsoft Cabinet SDK - Use this SDK to create the Cabinet file which stores all the
files to be downloaded. Creating a .CAB file helps to minimize the download time, and to
keep all downloaded files together. You can download the Cabinet SDK from:
http://www.microsoft.com/workshop/prog/cab

For more information about the CAB SDK, go to:


http://www.microsoft.com/workshop/prog/cab/overview.htm

17.2 Creating a Web Page


The first step in adding an ActiveX control to a web page is to create the HTML page, and
add the required code to insert, size and access the chart. The following three steps outline
how to do this:
1. Create the web page that you want to add Olectra Chart to.
2. Insert and size the ActiveX control. To do this, add an <OBJECT> tag to your HTML
code as follows:
<OBJECT ID="Chart3D1" WIDTH=473 HEIGHT=352
CLASSID="CLSID: 3D931501-4601-11CF-80B2-0020AF19EE14 "
CODEBASE="http://www.yoursite.com/olectra.cab">
</OBJECT>
Olectra Chart OCX

When this HTML code is processed, the browser checks to see if Olectra Chart is
registered on the computer where the page is being browsed from, and if not it will
download and register the control.

If you want to specify a version the control to check for, add the Version element. This will
avoid such problems as using new functionality with a prior version of the control. The
following example shows how to specify the control version to search for:
<OBJECT ID="Chart3D1" WIDTH=473 HEIGHT=352
CLASSID="CLSID:3D931501-4601-11CF-80B2-0020AF19EE14 "
CODEBASE="http://www.yoursite.com/olectra.cab#Version=5,0,0,0">
</OBJECT>

246 Part II n Using 3D Chart


3. To set properties, load data or access the chart, you must write VBScript code. For ex-
ample, the following code sets the header, footer, ChartType and adds some data:

<SCRIPT LANGUAGE="VBScript">
Sub Window_OnLoad()

’Do the basic setup of the chart.


Chart3D1.AllowUserChanges = False
Chart3D1.IsBatched = True
Chart3D1.Border.Type = 4 ’Plain
Chart3D1.Border.Width = 1
Chart3D1.Interior.BackGroundColor = RGB(&HFA, &HFA, &HD2)
Chart3D1.Interior.ForeGroundColor = RGB(0, 0, 0)

Chart3D1.ChartArea.Axes("X").MajorGrid.IsOnXYPlane = True
Chart3D1.ChartArea.Axes("X").MajorGrid.IsOnXZPlane = True
Chart3D1.ChartArea.Axes("Y").MajorGrid.IsOnXYPlane = True
Chart3D1.ChartArea.Axes("Y").MajorGrid.IsOnYZPlane = True
Chart3D1.ChartArea.Axes("Z").MajorGrid.IsOnXZPlane = True
Chart3D1.ChartArea.Axes("Z").MajorGrid.IsOnYZPlane = True

Chart3D1.ChartGroups(1).ChartType = 1 ’Bar
Chart3D1.ChartGroups(1).Elevation.IsMeshed = True
Chart3D1.ChartGroups(1).Elevation.IsShaded = True
Chart3D1.ChartGroups(1).Elevation.ShadedTopColor = RGB(&HFF, &HF8,_
&HDC)

Chart3D1.ChartGroups(1).ElevationData.RowCount = 3
Chart3D1.ChartGroups(1).ElevationData.ColumnCount = 4
Chart3D1.ChartGroups(1).ElevationData.Value(1, 1) = 1.32608
Chart3D1.ChartGroups(1).ElevationData.Value(1, 2) = 1.4186
Chart3D1.ChartGroups(1).ElevationData.Value(1, 3) = 1.49956
Chart3D1.ChartGroups(1).ElevationData.Value(1, 4) = 1.56597
Chart3D1.ChartGroups(1).ElevationData.Value(2, 1) = 1.34446
Chart3D1.ChartGroups(1).ElevationData.Value(2, 2) = 1.43709
Chart3D1.ChartGroups(1).ElevationData.Value(2, 3) = 1.5124
Chart3D1.ChartGroups(1).ElevationData.Value(2, 4) = 1.56768
Chart3D1.ChartGroups(1).ElevationData.Value(3, 1) = 1.35423
Chart3D1.ChartGroups(1).ElevationData.Value(3, 2) = 1.44188
Chart3D1.ChartGroups(1).ElevationData.Value(3, 3) = 1.50643

Olectra Chart OCX


Chart3D1.ChartGroups(1).ElevationData.Value(3, 4) = 1.54619
Chart3D1.ChartGroups(1).ElevationData.RowOrigin = 1
Chart3D1.ChartGroups(1).ElevationData.ColumnOrigin = 1

Chart3D1.ChartArea.PlotCube.XScale = 180
Chart3D1.ChartArea.PlotCube.YScale = 180
Chart3D1.ChartArea.PlotCube.Interior.BackGroundColor = RGB_
(&HD2, &HB4, &H8C)
End Sub
</SCRIPT>

Notes:
n The CLSID (pronounced Class ID) specified above is for the 32-bit Olectra Chart 3D.
For information on adding a 2D control, see Adding an Olectra Chart 2D Control to a
Web Page on page 139.

Chapter 17 n Adding an Olectra Chart 3D Control to a Web Page 247


n Olectra Chart is safe for scripting, which means that it (or any of its methods) will not
write to the local storage when used within a secure Web browser. Olectra Chart will
also not execute any binary code (for example, a. virus) that is passed to it as data.
n The Codebase element in the above example points to where the .CAB file (which
contains all the files users must download to view the control) is located. For more
information on creating .CAB files, see Optimizing the Download Process.
n If you are developing using 1.1 of Olectra Chart, and viewing a web page that contains
version 6.0 of the control, conflicts may arise. See Special Version Considerations on
page 248 for more information.

Loading data from a URL

Using the LoadURL method, you can load data or a chart description file (.OC3 and
.OC2) directly from a URL instead of adding it programmatically. If you want to load an
entire chart, use the Chart3D object’s LoadURL method. If you just want to load data
into an existing chart, use the ChartData object’s LoadURL method. Both of these
methods have a single parameter, URLname, which is a string representing the URL where
the file you want to load is located.

The following two examples illustrate the different uses of the LoadURL method from
within an HTML file:
<SCRIPT LANGUAGE="VBScript">

’ Load a chart description file


Chart3D1.LoadURL =
"http://www.apexsc.com/OlectraChart6/data/default.oc3"

’ Load data into a chart


Chart3D1.ChartGroups(1).Data.LoadURL =
"http://www.apexsc.com/OlectraChart6/data/default.dat"
</SCRIPT>

Special Version Considerations

If you have a registered version of Olectra Chart 1.1 on your computer, browsing to a web
Olectra Chart OCX

site containing version 6.0 of the control may cause problems. If the <OBJECT> tag is set to
require Olectra Chart 6.0, the control will download and re-register itself as the current
control. For this reason it is highly recommended that you do not browse locations
containing version 6 of the control on your 1.1 development machine.

To restore Olectra Chart 1.1 as the version on your computer, do the following:
1. Unregister Olectra Chart 6.0. Internet Explorer caches all downloaded ActiveX com-
ponents within a directory called OCCACHE that exists directly under the WIN-
DOWS or WINNT root directories. In that directory, type at the command prompt:
Regsvr32 /u olch3x32.ocx
2. Remove the files downloaded by version 6.0. If you wish to remove Olectra Chart
from your computer, you only need to delete the files in the OCCACHE directory that
correspond to the ones listed in the .INF file.

248 Part II n Using 3D Chart


3. Register Olectra Chart 1.1. In the Windows/System32 directory, type at the command
prompt:
Regsvr32 olch3x32.ocx

17.3 Creating a License Pack File


Once you have created the HTML page shell for Olectra Chart, you must create a license
pack file that the user’s browser uses to register the control on their computer. To do this,
use the lpk_tool program to create a license pack file for all the ActiveX controls on your
page:
1. Run lpk_tool (located in your ActiveX SDK’s \bin directory).
2. From the Available Controls list, select theOlectra Chart 3D and click the Add but-
ton.
3. Click the Save & Exit button. You will be prompted for a file name and location.

After creating the .LPK file, you must add the following lines in your HTML page, before
the <OBJECT> tag used to describe Olectra Chart. In this example, replace filename.lpk
with the name of your pack file:
<OBJECT CLASSID = "clsid: 5220cb21-c88d-11cf-b347-00aa00a28331">
<PARAM NAME="LPKPath" VALUE="filename.lpk">
</OBJECT>

Notes:
n You must have a registered version of Olectra Chart on your computer to successfully
generate a .LPK file.
n The reference to the resulting .LPK file that you create must be placed on your HTML
page before references to any of your ActiveX controls.
n If your .LPK was created with only Olectra Chart in it, it should be 878 bytes. If it is
smaller, the license pack file was not created properly.

Olectra Chart OCX


17.4 Packaging the Control
There are three parts to create and copy the files required when downloading the ActiveX
control:
n Creating an .INF file
n Creating a .CAB file
n Copying .LPK and .CAB files to the server

A: Creating the .INF file

In order for your browser to correctly load and run Olectra Chart you must create an .INF
file that lists all of the control’s dependencies. Create a text file with the suffix .INF that

Chapter 17 n Adding an Olectra Chart 3D Control to a Web Page 249


lists all of the files needed for this component. For 32-bit Olectra Chart 3D, the files
needed are:
olch3x32.ocx
msvcrt40.dll
mfc40.dll

Here is the contents of an example .INF file called OLECTRA.INF:


[Add.Code]
olch3x32.ocx=olch3x32.ocx
mfc40.dll=mfc40.dll
msvcrt40.dll=msvcrt40.dll

[olch3x32.ocx]
File=thiscab
Clsid={3D931501-4601-11CF-80B2-0020AF19EE14}

[mfc40.dll]
File=http://www.yoursite.com/yourdemo/mfc40.cab

[msvcrt40.dll]
File=http://www.yoursite.com/yourdemo/msvcrt40.cab

Notes:
n Italicized characters in the above example should be replaced with the URL where
these .CAB files will be located on your web server.
n Many users may already have the MFC40.DLL and MSVCRT40.DLL files available
on their computers from prior software installations, so this .INF file will instruct
Internet Explorer to download them only if necessary.

To minimize download time, compress these files individually using cabarc.exe. For more
information, see the following section, Creating a .CAB File.

B: Creating a .CAB file


1. Use the cabarc.exe program (found in the Cabinet SDK’s \bin directory) to create
.CAB files to combine and compress the files needed for downloading, minimizing
Olectra Chart OCX

the download requirements for the ActiveX controls embedded within your HTML
page.

To create a CAB file that contains the Olectra Chart OCX, DLL and the .INF file,
type:
cabarc n olectra.cab olch3x32.ocx olectra.inf
2. Find the place in the HTML on your Web page where the Olectra Chart control is ref-
erenced. (There should be an <OBJECT> tag with a CLASSID that matches the 32-bit
Olectra Chart 3D CLSID. Edit the HTML and add a Codebase element with the suit-
able web site URL and CAB file name.

For example:
<OBJECT ID="Chart3D" WIDTH=313 HEIGHT=225
CLASSID="CLSID: 3D931501-4601-11CF-80B2-0020AF19EE14"
CODEBASE="http://www.yoursite.com/olectra.cab">
</OBJECT>

250 Part II n Using 3D Chart


A Sample HTML File

Here is a very simple .HTML file that displays a 3D chart control. In particular, note the
class IDs for the license pack file and the chart control:
<HTML>

<HEAD>
<meta http-equiv="Content-Type"content="text/html; charset=iso-8859-1">
<TITLE>Home Page</TITLE>
</HEAD>

<OBJECT CLASSID="clsid: 5220cb21-c88d-11cf-b347-00aa00a28331"


<PARAM NAME="LPKPath" value="olectra.lpk">
</OBJECT></p>

<p>

<OBJECT ID="Chart3D" WIDTH=313 HEIGHT=225


CLASSID="CLSID: 3D931501-4601-11CF-80B2-0020AF19EE14"
CODEBASE="http://www.yoursite.com/olectra.cab">

</OBJECT>
</BODY>
</HTML>

C: Copying .LPK and .CAB files to the server

Once you have created the .LPK and .CAB files, copy them to the server where your web
page is. The .LPK file must be in the same directory as the HTML file that references it.
The .CAB file must be in the directory that is specified in the <OBJECT> tag. For example,
in the above HTML code, the file OLECTRA.CAB would go in the root directory of the
server where www.yoursite.com is located.

17.5 Testing your Web Page


Once you have created your web page with the Olectra Chart ActiveX control embedded,

Olectra Chart OCX


you should now run Internet Explorer on a machine that has never had Olectra Chart
installed on it. Navigate to the Web site where your page exists and have Internet Explorer
attempt to display it.

You may get a sequence of dialog boxes depending on the security level that your copy of
Internet Explorer is set to. You can change these settings by doing the following:
1. On the View menu, click Options. The Options dialog appears.
2. Click the Security tab.
3. Click the Safety Level button.
4. The choices for Security Level are High, Medium, None. The default for Internet Ex-
plorer is High, so controls that have not been digitally signed will not be downloaded.
Olectra Chart 6.0 is signed.

Chapter 17 n Adding an Olectra Chart 3D Control to a Web Page 251


Note:

Internet Explorer caches all downloaded ActiveX control components within a directory
called OCCACHE that exists directly under the WINDOWS or WINNT root directories.
If you wish to remove Olectra Chart from your test system, you only need to delete the
files in the OCCACHE directory that correspond to the ones listed in the .INF file
described in Packaging the Control on page 249.
Olectra Chart OCX

252 Part II n Using 3D Chart


Index
- format code 65 action maps 132
# format code 65 definition 240
$ format code 65 modifier flags 239
() format code 65 overview 238
+ format code 65 programming 134, 240
, (comma) format code 65 recognized keycodes 133, 239
.(period) format code 65 removing 135, 241
.CAB file, creating 145 actions
.CAB files 250 calling directly 241
/ format code 65 programming 132, 238
? format code 65 adding 208
0 format code 65 3D effect 120
100 percent stacking axis title 77
Bar charts 36 ChartLabel border 124
charts,creating 84 grid lines 82
32-bit applications, distributing 58, 170 gridlines 82
3D header and footer titles 106
chart, features summary 10 Markers 127
3D Bar charts rows and columns 199
spacing width 233 second Y-axis 79
special properties 233 aligning
3D Chart Control ChartLabels text 123
adding to Delphi 179 aligning title text 106
adding to the main dialog box 177 alignment
inserting into an OLE container project 176 ChartLabel text, changing 222
programming 178 Anchor ChartLabel property 123
3D data annotating
copying 205 axes 184
handling missing 198 axes with PointLabels 68
loading 204 annotation

Olectra Chart OCX


loading from a file 202 axis, positioning 73
overview 198 PointLabels 62
3D effect rotating axis 77
adding 120 TimeLabels 62
3D elevation ValueLabels 62
setting 120 Values 62
3D plane, ChartLabel 222 annotation method, choosing 63
3D surface, setting 209 AnnotationAngle property 44
3D view, modifying 190 AnnotationMethod TimeLabel property 70
4D Bar Charts, creating 192 applications, distributing 170
4D charts Area charts 20
creating 192 Array data
displaying data for 193 file format 95
layout 29
overview 92
A using in Delphi 52, 179
AttachMethod property 122, 223
Accounting format 64, 66 automatic margins, using 119
Action constants 135, 241 axes

253
annotating 63, 184 Bubble chart
annotating with TimeLabels 69 special properties 34
annotating with ValueLabels 68 Bubble charts
annotating with Values 63 choosing 28
logarithmic 78 hiding series 99
Numbering annoation method 63 minimum and maximum size 34
numbering precision 63
programming considerations 72
rotating 77
ticking increments 64
C
titling 77, 187 C++
axis adding 3D control to 177
adding a second Y- 79 adding Chart control to the main dialog 49
adding a title 187 adding member variable to a project 49
annotating with PointLabels 68 calling methods 51
annotating with TimeLables 69 calling methods in 178
annotation, changing 216 inserting control into an OLE container project 176
annotation, choosing font of 116 inserting the 2D Chart control 49
annotation, overview 62 programming 3D Chart Control 178
bounds, setting 187 programming in 49, 176
changing appearance of 80 setting an object property 50
changing orientation 114 CalcIndex method 227
DataMax property 76 CallAction method 241
DataMin property 76 calling methods 48
direction 74, 75 Candle charts
labelling programming considerations 186 choosing 22
Max property 76 creating complex 37
Min property 76 hiding series 99
rotating annotation 77 special properties 37
setting data bounds 76 ceiling projections 188
tick length, changing 80 centering, images 113
title, rotating 77 changing
title,adding 77 axis appearance 80
zoom 18 borders 115
AxisAllowNegative property 44 grid spacing 82
chart
adding borders to 115
Area, choosing 20
B axis zoom 18
Bar charts Bar, choosing 21
100 percent stacking 36 Bubble, choosing 28
Olectra Chart OCX

3D, creating 120 Candle, choosing 22


choosing 21 Candle, special properties 37
cluster width 35 creating subset of 200
creating 4D 192 descriptions, loading and saving 31
floating 35 Filled Radar, choosing 27
negative 37 graphics zoom 18
special properties 34 HiLo, choosing 23
Base TimeLabel property 70 introduction 10
batching moving 17, 18
chart updates 103 orientation 74
ChartLabel changes 127, 224 Pie, choosing 22
data updates 93, 198 Polar, choosing 25
binding external database to a chart 97 positioning 189
borders Radar, choosing 26
adding to titles 106 rotating 18, 153
changing 115, 215 scaling 17, 153
ChartLabel, changing 222 translating 153
legend 108 zooming 17, 154
overview 115 Chart control, packaging 144

254 Index
chart data ChartType property 20, 21, 22, 23, 24, 25, 26, 28
saving 88 CheckNewPoints fast update method 99
chart descriptions choosing
loading and saving 167 area charts 20
storing in files 88, 195 Bar charts 21
chart elements Bubble charts 28
adding images to 229 Candle charts 22
positioning 117, 219 chart type 19
Chart outlines ChartType 154
showing and hiding 114 Filled Radar charts 27
chart properties HiLo charts 23
editing 153 HiLoOpenClose charts 24
chart properties, editing 17 Pie charts 22
Chart Styles Collection 234 Plot charts 19
chart terminology 16 Polar charts 25
chart updates, batching 103 Radar charts 26
chart, interacting with 17 closing, Property Editor 17
Chart2DData object 35 CLSID 247
ChartArea ClusterOverlap property 34
adding borders to 115 ClusterWidth property 35
adding images to 113, 229 collections
changing appearance 114 accessing elements of 47
changing color of 116 using 47, 175
changing width and height 118, 219 using in C++ 50
ChartGroups, creating combination charts 85 color
charting data changing 117
directly from your program 96 colors
using Data Binding 97 changing ChartLabel 222
ChartLabel ChartLabel 124
adding borders to 115 overview 218
border 222 setting 116
cahnging color of 116 setting legend 108
colors, changing 222 specifying named 218
fonts, changing 222 title 106
fonts,choosing 116 ColumnCount property 198
plane, changing 222 ColumnDelta property 166, 199
text, changing 222 ColumnOrigin property 166, 199
ChartLabel fonts, changing 216 columns, adding 199
ChartLabels combination charts, creating using ChartGroups 85
adding a border 124 Complex Candle charts 37
adding images to 113, 229 continuous legends 210

Olectra Chart OCX


aligning text 123 contours
attaching 125, 223 bar ChartType 156
attaching and positioning 122, 220 surface ChartType 156
batching changes 127, 224 zones bar ChartType 160
connecting lines 123 zones surface ChartType 160
defining 223 ContourStyles
offset 123 customizing 227
programming 124 finding and changing 228
programming considerations 223 loading and saving 226
rotating 124 using 225
using 122 ContourStyles collection 227, 232
charts converting
drawing 4D 201 data coordinates 86
loading and saving 167 pixel coordinates to data coordinates 137
printing 89, 195 coordinate values, returning 242
ChartStyles coordinates
changing 108, 234 converting Visual Basic 88
ChartType returning 136
choosing 19, 154 Coordinates attachment method 221

Index 255
coordinates, converting data 86 General file format 95
coordinates, converting passed by reference 88 General layout 29
CoordToDataCoordObject method 88 Grid layout 164
CoordToDataIndexObject method 88 handling missing 94
copying handling missing, 3D 198
data 205 holes in 166
copying data 100 Irregular Grid layout 164
CopyToClipboard printing method 89, 195 loading 3D 204
CopyXVectorIn Chart2DData method 100 loading and saving 31, 167
CopyXVectorOut Chart2DData method 101 loading from a file 95, 202
CopyYArrayIn Chart2DData method 101 loading from a URL 96, 143, 204, 248
CopyYArrayOut Chart2DData method 101 loading second ChartGroup 86
CopyYVectorIn Chart2DData method 101 overview 92
CopyYVectorOut Chart2DData method 101 overview, 3D 198
CopyZArrayIn method 205 Point layout 165
CopyZArrayOut method 205 Point, overview 201
CreateShaded method 200 saving 88
CreateSubset method 200 smoothing 200
creating specifying series 97
.CAB file 250 understanding 163
4D charts 192 Data Binding
Plot charts 19 charting data using 97
stacking charts 83 data bounds, setting 76
Cube Font 215 data coordinates
Currency format 64, 66 converting 136
custom legend labels 211 converting to pixel coordinates 243
custom Values formatting data files, loading and saving 30
accounting format 66 data layout
Currency formatting 66 understanding 29
format codes 65 data points 202
Fraction format 66 picking 137, 243
Number format 67 DataCoordinates attachment method 221
Percentage format 67 DataCoordToCoord method. 243
Scientific Notation format 67 DataCoordToCoordObject method 88
using 64 DataIndex attachment method 221
customizing DataIndexToCoordObject method 88
ContourStyles 227 DataLabels annoation 185
origins 81 Delphi
Property Editor 138 adding 3D Chart Control to 179
CyrillicComplex stroke font 217 adding control to 51
programming in 51, 179
Olectra Chart OCX

using Array data 52


D using Array data in 179
Denominator property 67
data Depth View3D property 120
Array 29 displaying the Property Editor 17
Array, using in Delphi 52 distributable files 170
array, using in Delphi 179 distributing
batching 93 32-bit 58
batching updates 198 32-bit applications 170
changing 93 Distribution Levels 227
charting directly from a program 96 distribution range, legend 213
charting directly from your program 204 Distribution Table
charting using Data Binding 97 creating custom 231
converting coordinates 86 customizing 231
copying 100, 205 programming considerations 232
displaying 4D 193 resetting to linear 231
editing 30 double buffering 206
editing point 167 drawing 4D charts 201
fast update 94 DrawNewPoints fast update method 99

256 Index
DrawToDC printing method 89, 195 form resizing 220
DrawToFile printing method 89, 195 format codes
drop lines, adding to Scatter Plot 233 custom Values formatting 65
TimeLabels axis annotation 71
Format TimeLabel property 70
E formatting
creating special ranges for 66
Edit Chart Data dialog 30 formatting symbols 235
editing forms, resizing 121
chart properties 17, 153 Fraction format 64, 66
ElevationData property 198 Fraction Object 66
EncodingMethod property 34 full-range X-axis, Polar charts 43
Enhanced Metafiles 230
error offset, setting 48
ErrorOffset property 48
excluding a series 98
G
excluding series 85 General data
exploding Pie charts 41 file format 95
layout 29
overview 93
F GothicEnglish stroke font 217
GothicGerman stroke font 217
fast update 94 GothicItalian stroke font 217
Fast Update methods 99 graphics zoom, chart area 18
file format GreekComplex stroke font 217
Array data 95 GreekComplexSmall stroke font 217
General data 95 GreekSimplex stroke font 217
file formats Grid data
Grid data 202 file format 202
Irregular Grid 203 layout 164
Point data 203 overview 198
Filled Radar grid lines
choosing 27 adding 82, 191
FillStyle adding and formatting 190
ContourStyle 225 formatting 191
overview 108 horizontal 82
setting 108 vertical 82
filter, legend 212 grid spacing
Floating Bar charts 35 changing 82
floor projections 188 gridlines, adding 82
font

Olectra Chart OCX


changing 116
ChartLabel 124
title, setting 188
H
title,setting 106 half-range X-axis, Polar charts 43
fonts handling missing data 94
ChartLabel, changing 222 HasDropLines property 233
choosing 116, 215 HasMinimumSize property 229
Cube 215 header
TrueType 215 adding images to 113, 229
footer changing color of 116
adding a title 106 color, changing 218
adding borders to 115 fonts, changing 216
adding images to 113, 229 positioning 219
changing color of 116 header and footer titles 208
color, changing 218 headers
fonts, changing 216 adding a title 106
fonts,choosing 116 help support, see Getting Started booklet
positioning 219 hiding
footer, adding 208 chart outlines 114

Index 257
hiding a series 98 labelling axes, programming considerations 72
hiding series 85 Layout Chart2DData property 92
HiLo Charts Layout property 30
choosing 23 legend
HiLo charts adding borders to 115
hiding series 99 adding images to 113, 229
HiLoOpenClose charts border, setting 211
choosing 24 borders 108
hiding series 99 changing color of 116
open and close ticks 38 colors, setting 108, 211
special properties 38 custom labels 211
Histogram Bar charts, creating 184 distribution range 213
Hole property 30 filter, adding 212
holes in data 166 font, setting 211
HoleValue property 198 fonts, changing 216
horizontal grid lines 82 fonts,choosing 116
formatting 210
labels, programming considerations 212
I orientation, setting 210
positioning 107, 211, 219
image text and orientation 107
adding to chart elements 113, 229 title 108
setting layout 113, 229 title, setting 211
images using 107
HasMinimumSize property 229 Licence Pack file, creating 144
using as labels 114, 229 license pack file,creating 249
Immediate Feedback Model 16 LineStyle
Index, positining Markers by 128 ContourStyle 225
interacting with the chart 17 customizing Marker 128
introduction to 3D Chart overview 108
summary of features 10 setting 109, 226
introduction to Olectra Chart LineStyle object 227, 228
summary of features 9 loading
Irregular Grid data 3D data 204
file format 203 3D data from a file 202
overview 198 chart description files 31
Irregular Grid layout, data 164 charts and data 31
IsComplex property 37 ContourStyles 226
IsDoubleBuffered property 46, 50, 206 data from a file 95
IsEmbedded property 229 data from a URL 96, 143
IsHalfRange property 43 second ChartGroup data 86
Olectra Chart OCX

IsHorizontal ChartArea property 74 LoadURL method 96, 248


IsOpenCloseFullWidth property 38 location
IsReversed axis property 75 ChartLabel, changing 124
IsShaded ChartGroup property 209 logarithmic axes 78
IsShowingClose property 38 logical data sets 23, 24, 28
IsShowingOpen property 38
IsStacked property 19, 20, 25, 27
IsY2Axis100Percent property 36
IsYAxis100Percent property 36
M
IsZoned ChartGroup property 209 margins
ItalicComplex stroke font 216 setting 119
ItalicComplexSmall stroke font 216 using automatic 119
ItalicTriplex stroke font 216 Markers
adding 127
customizing LineStyle 128
L positioning 128
programming 128
LabelFilter property 212 maximum and minimum size, Bubble charts 34
LabelFormat axis property 64 MaximumSize property 34

258 Index
mesh about 46
bar ChartType 155 about 3D 174
colors, setting 214 navigating 47, 175
contours bar ChartType 157 objects
contours surface ChartType 157 default properties 47
contours, zones bar ChartType 162 programming with 46, 174
contours, zones surface ChartType 162 setting properties of in C++ 50
formatting 213 oc_api.txt 238, 239
shaded bar ChartType 157 oc3dActionModifyCancel 240
shaded surface ChartType 157 oc3dActionModifyEnd 240
shaded, contours bar ChartType 161 oc3dActionModifyStart 240
shaded, contours surface ChartType 161 oc3dActionProperties 240
shaded, contours, zones bar ChartType 163 oc3dActionReset 240
shaded, contours, zones Surface ChartType 163 oc3dActionRotate 240
shaded, zones bar ChartType 160 oc3dActionRotateEye 240
shaded, zones surface ChartType 160 oc3dActionRotateFree 240
surface ChartType 155 oc3dActionRotateXAxis 240
transparency 214 oc3dActionRotateYAxis 240
zones bar ChartType 158 oc3dActionScale 240
zones surface ChartType 158 oc3dActionTranslate 240
MeshBottomColor Elevation property 214 oc3dActionZoomCancel 240
MeshTopColor Elevation property 214 oc3dActionZoomEnd 240
messages oc3dActionZoomUpdate 240
action maps 132 OLEAUT32.DLL 58, 170
methods Olectra Chart
calling 48, 176 distributing 32-bit 58
calling in C++ 51, 178 features summary 9
MFC40.DLL 250 Olectra Chart 1.1, upgrading Visual Basic projects from 54
MFC42.DLL 58, 170 Olectra Chart 2D OCX
Microsoft ActiveX SDK 140, 246 adding to Delphi 51
MinimumSize property 34 OLECTRA.INF 250
missing data, handling 94, 198 OLEPRO32.DLL 58, 170
missing slices, Pie charts 41 OrderCurrencySignValue property 66
modifier flags 133 origin, setting in Polar charts 43
modifier flags, action maps 239 OriginBase property 43
MSVCRT.DLL 58, 170 OriginPlacement property 81
MSVCRT40.DLL 250 origins
customizing 81
placing 81
N Other slice, building 39
Other slice, changing style 41

Olectra Chart OCX


negative
Bar charts 37
negative Polar charts, creating 44
NegativeValueColor 66
P
Number format 64, 67 Percentage format 64, 67
Number Object 67 Percentage Object 67
Numbering annotation method 63 picking data points 137, 243
Numbering precision 63 Pie charts
NumLevels ContourLevels property 231 3D, creating 120
NumMethod axis property 63 choosing 22
NumPoints Chart2DData property 92 exploding 41
NumPoints property 30 MinSlices property 40
NumSeries Chart2DData property 92 missing slices 41, 42
NumSeries property 30 ordering 41
Other slice style 41
special properties 39
O StartAngle property 41
pixel coordinates, converting data coordinates to 136
object hierarchy pixel coordinates, converting to data coordinates 243

Index 259
pixel coordinates,converting to data coordinates 137 Property Editor
Plot charts closing 17
choosing 19 customizing 138, 244
plot data displaying 17, 152
overview 93 using 16, 152
PlotArea
adding images to 113
adjusting margins 118
changing background color 116
R
setting margin properties 17 Radar charts
PlotCube choosing 26
changing shape 188 radial grid lines 82
customizing 188 recognized keycodes, action maps 239
Point data registering the 2D chart control, 32-bit 59
editing 167 REGSVR32.EXE 59, 171
file format 203 removing
layout 165 action maps 135, 241
overview 201 returning coordinate values 136
PointDisplay property 42 RGB colors
PointLabels specifying 117
annotating axes with 68 RomanComplex stroke font 216
overview 62 RomanComplexSmall stroke font 216
PointLabels annotation 62 RomanDuplex stroke font 216
PointSeries collection 201 RomanSimplex stroke font 216
Polar charts RomanTriplex stroke font 216
AnnotationAngle property 44 rotating
AxisAllowNegative property 44 axes 77
choosing 25 axis annotation 77
OriginBase property 43 axis title 77
setting origin 43 chart 18, 153
special properties 42 ChartLabels 124
positioning RowCount property 198
axis annotation 73 RowDelta property 166, 199
ChartLabels 122, 220 RowOrigin property 166
legend 107 RowOrigin propety 199
Markers 128 rows
titles 106 adding 199
Precision axis property 63
PrintChart printing method 89, 195
printing S
charts 89, 195
Olectra Chart OCX

saving
methods 89
chart data 88
programming
chart description files 31
2D chart control in C++ 50
3D Chart Control 178 charts and data 31, 167
ContourStyles 226
action maps 134, 240
scaling
actions 132, 238
chart 153
C++ 49
ChartLabels 124 Scatter Plot
in C++ 176 drop lines, adding 233
special properties 233
in Delphi 179
Scientific format 64
Markers 128
programming considerations Scientific Notation format 67
axis labelling 72, 186 Scientific Object 67
ScriptComplex stroke font 217
ChartLabels 223
ScriptSimplex stroke font 217
Distribution Table 232
legend labels 212 series
projections, ceiling and floor 188 data, specifying 97
hiding and excluding 85, 98
properties
SeriesDisplay property 35
editing, chart 17

260 Index
setting text
axis and data bounds 76 legend 107
error offset 48 ThisPoint property 30
shaded ThisSeries property 30
bar ChartType 155 ThresholdMethod property 39
contours bar ChartType 159 ThresholdValue property 39
contours surface ChartType 159 tick length
contours, zones bar ChartType 162 changing 80
contours, zones surface ChartType 162 ticking increments, axes 64
surface ChartType 155 TickLength AxisStyle property 80
zones bar ChartType 159 ticks
zones surface ChartType 159 creating open and close 38
Shaded-Relief Map, creating 200 TickSpacing axis property 64
ShiftPoints fast update method 100 Time axis, using 73
showing, chart outlines 114 TimeLabels
slices, missing 41 annotating axes with 69
slices, missing pie 42 format codes 71
SliceStyle overview 62
overview 108 TimeLabels annotation 62
setting 110 TimeScale axis property 73
smoothing data 200 title
SortOrder property 41 adding images to 229
spacing, grid 82 titles 208
special adding a border 106
3D Bar chart properties 233 aligning text 106
Bar chart properties 34 border, setting 208
Bubble chart properties 34 colors, setting 208
Candle chart properties 37 font, setting 188, 208
HiLoOpenClose chart properties 38 header, adding 208
Pie chart properties 39 legend 108
Polar chart properties 42 positioning 106
Scatter Plot properties 233 positioning, setting 208
Stacking Bar chart properties 35 setting colors 106
special ranges for custom Values formatting 66 setting the font 106
stacking 20 text and alignment 208
Area charts 20 titling
Filled Radar charts 27 axes 187
Plot charts 19 titling axes 77
Stacking Bar charts translating, chart 153
3D, creating 120 TrueType font 215
special properties 35 choosing 216

Olectra Chart OCX


stacking charts
100 percent 84
creating 83
viewing as 100 percent 114
U
StartAngle property 41 understanding data layout 29
stepped legends 210 Unit TimeLabel property 70
support, see Getting Started booklet URL, loading data from 96, 143
surface UseTrueType property 216
colors,setting 209 using
making 3D 209 collections 47
modifying appearance of 209 Property Editor 16
SymbolStyle
overview 108
setting 110 V
Value, positioning Markers by 128
ValueFormat Object 64
T ValueFormat object 66
technical support, see Getting Started booklet ValueLabels

Index 261
annotating axes with 68
overview 62
ValueLabels annotation 62, 185
Values
custom formatting 64
Values annotation 62, 63, 184
Values Format dialog 64
Visual Basic 4.0 projects, upgrading from Olectra Chart 1.1
54, 182
Visual Basic coordinates, converting 137
Visual Basic, distributing Olectra Chart in 170

W
web page, creating 140

X
X-axis
full or half-range 43
PointLables annotation 62
TimeLabels 62
XValue property 30

Y
Y-axis
adding a second 79
YValue property 30

Z
Zone Projection 230
ZoneMethod Contour property 209
zones bar ChartType 156
zones surface ChartType 156
zooming, chart 154
Olectra Chart OCX

262 Index

Anda mungkin juga menyukai