Omnis Graphs: Using The Graph2 Component
Omnis Graphs: Using The Graph2 Component
TigerLogic Corporation
November 2007
The software this document describes is furnished under a license agreement. The software may be
used or copied only in accordance with the terms of the agreement. Names of persons, corporations, or
products used in the tutorials and examples of this manual are fictitious. No part of this publication may
be reproduced, transmitted, stored in a retrieval system or translated into any language in any form by
any means without the written permission of TigerLogic.
© TigerLogic Corporation, and its licensors 1992-2008. All rights reserved.
Portions © Copyright Microsoft Corporation.
Regular expressions Copyright (c) 1986,1993,1995 University of Toronto.
© 1999-2007 The Apache Software Foundation. All rights reserved.
This product includes software developed by the Apache Software Foundation
(http://www.apache.org/).
OMNIS® and Omnis Studio® are registered trademarks of TigerLogic Corporation.
Microsoft, MS, MS-DOS, Visual Basic, Windows, Windows 95, Win32, Win32s are registered
trademarks, and Windows NT, Visual C++ are trademarks of Microsoft Corporation in the US and other
countries.
SAP, R/3, mySAP, mySAP.com, xApps, xApp, and other SAP products and services mentioned herein
as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and
in several other countries all over the world.
IBM, DB2, and INFORMIX are registered trademarks of International Business Machines Corporation.
ICU is Copyright © 1995-2003 International Business Machines Corporation and others.
UNIX is a registered trademark in the US and other countries exclusively licensed by X/Open Company
Ltd.
Sun, Sun Microsystems, the Sun Logo, Solaris, Java, and Catalyst are trademarks or registered
trademarks of Sun Microsystems Inc.
J2SE is Copyright (c) 2003 Sun Microsystems Inc under a licence agreement to be found at:
http://java.sun.com/j2se/1.4.2/docs/relnotes/license.html
MySQL is a registered trademark of MySQL AB in the United States, the European Union and other
countries (www.mysql.com).
ORACLE is a registered trademark and SQL*NET is a trademark of Oracle Corporation.
SYBASE, Net-Library, Open Client, DB-Library and CT-Library are registered trademarks of Sybase
Inc.
Acrobat is a trademark of Adobe Systems, Inc.
Apple, the Apple logo, AppleTalk, and Macintosh are registered trademarks and MacOS, Power
Macintosh and PowerPC are trademarks of Apple Computer, Inc.
HP-UX is a trademark of Hewlett Packard.
OSF/Motif is a trademark of the Open Software Foundation.
CodeWarrior is a trademark of Metrowerks, Inc.
This software is based in part on ChartDirector, copyright Advanced Software Engineering
(www.advsofteng.com).
This software is based in part on the work of the Independent JPEG Group.
This software is based in part of the work of the FreeType Team.
Other products mentioned are trademarks or registered trademarks of their corporations.
Table of Contents
Table of Contents
OMNIS GRAPHS .................................................................6
CHART TYPES ..........................................................................6
XY Charts............................................................................6
Pie Charts...........................................................................8
Polar Charts .......................................................................9
Meter Charts.....................................................................10
The Graph2 Example Library...........................................10
COMMON GRAPH PROPERTIES ...............................................11
Setting the major and minor type .....................................13
COMMON GRAPH METHODS ..................................................14
XY CHARTS ..........................................................................16
XY chart properties...........................................................16
XY chart methods..............................................................17
List data structure for XY charts.......................................18
Data presentation in XY charts.........................................24
PIE CHARTS ...........................................................................26
Pie chart properties ..........................................................26
Pie chart methods .............................................................27
List data structure for Pie charts......................................27
POLAR CHARTS .....................................................................29
Polar chart properties ......................................................29
Polar chart methods .........................................................30
List data structure for Polar charts ..................................30
METER CHARTS .....................................................................33
Meter chart properties......................................................33
Meter chart methods.........................................................34
List data structure for Meter charts..................................34
Adding Pointers ................................................................35
Adding Rings ....................................................................37
GRAPH LAYERS AND THE PRELAYOUT EVENT .......................38
Adding layers to charts.....................................................38
GRAPH CLICKS AND DRILLDOWN ..........................................40
CHANGING THE COLOR OF GRAPH ELEMENTS........................41
ADDING COLORED ZONES .....................................................42
PARAMETER SUBSTITUTION AND FORMATTING .....................42
Parameters for Pie charts.................................................43
Parameters for all XY Chart Layers .................................43
Additional Parameters for HLOC and CandleStick Layers45
Additional Parameters for Box Whisker Layers ...............45
3
Table of Contents
5
Omnis Graphs
Omnis Graphs
You can create many different types of chart in Omnis using the Graph component (called
Graph2) and display them in your windows, remote forms, or reports. The data and
appearance of a chart is based on the data stored in an Omnis list variable. The different
chart types require a different list data structure to represent their data points. The Graph2
component supports four main types of chart, XY charts, Pie charts, Polar charts and Meter
charts, each of which has a number of subtypes (except Pie). The major and minor types of
the graph are specified as properties of the graph window object (found under External
Components in the Component Store) and the associated list variable is specified in the
$dataname property of the object.
Chart Types
XY Charts
XY charts can be one of several different minor types or subtypes.
Bar charts
Bar charts represent individual amounts, or
compare individual amounts; you can
change the graph orientation to show
horizontal bars. There are several subtypes
which you can select, including Line,
Scatter, Area, and Box whisker.
6
Chart Types
Line charts
Line charts emphasize the rate of change
rather than individual amounts.
Scatter charts
Scatter charts show the relationship of
different groups of numerical data, and plot
the data as xy coordinates.
Area charts
Area charts emphasize the amount or
magnitude of change rather than the rate of
change.
7
Omnis Graphs
High/Low/Open/Close charts
High/Low/Open/Close (HLOC) charts are
used to represent financial data; this type
uses four data items to represent each
element.
Candlestick charts
Candlestick charts are used to represent
financial data; this type uses four data
items to represent each element.
Pie Charts
The data in a pie chart is represented as
sections, or slices of a pie. There are no
minor types for this chart type, but pies have
numerous visual effects.
8
Chart Types
Polar Charts
Polar charts represent data points on a radial axis with the values represented as the distance
from the center; four minor types are available.
9
Omnis Graphs
Meter Charts
Numeric amounts or measurements can be shown as a meter or gauge; angular (or dial) or
linear styles are available.
10
Common Graph Properties
11
Omnis Graphs
The following common properties are found under the Custom tab in the Property Manager
for all graph types.
12
Common Graph Properties
13
Omnis Graphs
14
Common Graph Methods
The following method is available for the non-visual graph object, that is, object variables
based on the Graph2 object.
15
Omnis Graphs
XY Charts
The XY chart type has several subtypes, which all share the following properties and
methods.
XY chart properties
Property Name Data Type Description
$datacombine Constant The combine method of the data for Bar, Area, and
Line graphs, a constant: kG2dataSide,
kG2dataStack, kG2dataOverlay,
kG2dataPercentage; these constants can also be
used in the $addarealayer(), $addbarlayer(), and
$addlinelayer() XY chart methods
$3ddepth Integer Specifies the depth of a 3d XY chart; the default is
–1 but can be set to a positive integer value to
specify a custom depth which is useful for 3d line
and area graphs with multiple series
$hgridcolor RGB Color The horizontal grid color
$minorxytype Constant The minor type of a kG2xy graph; can be one of the
following: kG2xyBar, kG2xyLine, kG2xyScatter,
kG2xyArea, kG2xyBoxWhisker, kG2xyHLOC,
kG2xyCandleStick
$offsetheight Integer The additional offset height of the graph
$subtitle Character The subtitle of the graph
$swapxy Boolean if true the X & Y axis are swapped
$xaxisontop Character if true the X axis is to be displayed on the top
$xaxiswidth Integer Width of the X axis in pixels
$y2axistitle Character Y2 axis title
$yaxisonright Character if true the Y axis is to be displayed on the right
$yaxiswidth Integer Width of the Y axis in pixels
$layereffect Constant The effect for all layers, a constant:
kG2effectNone, kG2effectGlass,
kG2effectSoftLight
$layereffectalign Constant The alignment or direction for the effect for all
layers, as set by $layereffect; a constant:
kG2alignTop, kG2alignBottom, kG2alignLeft,
kG2alignCenter, kG2alignRight
16
XY Charts
XY chart methods
All the following methods can only be executed during the evPreLayout event; see below
for details.
17
Omnis Graphs
Note you can use the Omnis 4GL commands to build the list data for the graph, either from
an Omnis database, a SQL database, or on-the-fly, such as the following:
Set current list listGraph
Define list {(Name,Sales,Expenses)}
Add line to list {('Andy',85000,20000)}
Add line to list {('Sam',80000,15000)}
Add line to list {('Lisa',92000,34000)}
Add line to list {('Harry',45000,15000)}
18
XY Charts
Line/Area Charts
The line and area chart in their data representation are very similar to the bar chart. So given
the following data:
; define vars listGraph (List), colList (List), Name (Char), and use
built-in #vars
Do listGraph.$define(Name,#1,#2,#3,#4,#5,#6,#7,#8,
#9,#10,#11,#12,#13,#14,#15,#16,#17,#18,#19,#20)
Do listGraph.$add('Andy',30,28,40,55,75,68,
54,60,50,62,75,65,75,91,60,55,53,35,50,66,56,48,52,65,62)
Do listGraph.$add('Liza',48,52,65,62,30,68,54,60,
50,28,40,55,75,62,75,65,75,35,50,66,56,91,60,55,53)
; now build the column headings list
Do colList.$define(#1,#2,#3,#4,#5,#6,#7,#8,#9,#10,#11,#12,
#13,#14,#15,#16,#17,#18,#19,#20)
Do colList.$add(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)
Note the use of the colList list in the portion of code, which can be assigned to the
$columnheadings property of the graph field, overriding the normal x-axis variable names.
You should set the $majortype and minor type properties ($minorxytype or
$minorpolartype) of the graph to specify its type and subtype. The above method will
display the following line or area graph:
19
Omnis Graphs
Scatter Charts
Each individual row in the chart list data represents a new plot (or series). The X & Y plot
positions are then represented in two columns. Additional columns represent the other
groups, so given the following data:
Do listGraph.$define(Name,#1,#2,#3,#4)
Do listGraph.$add('Pt1',10,130,5,100)
Do listGraph.$add('Pt2',15,150,12,95)
Do listGraph.$add('Pt3',6,80,8,105)
Do listGraph.$add('Pt4',12,110,7,82)
Do listGraph.$add('Pt5',10.5,125,10.5,99)
There are two groups of five series which will result in the following chart:
Note that the symbols used to represent each series are in the order of square, diamond,
triangle, right-triangle, left-triangle, inverted triangle, circle, cross, and cross #2.
20
XY Charts
Gantt Charts
You can create Gantt charts using a Box Whisker chart and setting the $swapxy property to
kTrue so the bars are displayed horizontally. For Gantt charts you only need to provide two
groups of data in your list. The example Graph2 library contains a simple Gantt chart, as
follows:
21
Omnis Graphs
The following method is executed in the $construct() of the Gantt chart window:
; define inst vars: iGraphList (List), Name (Char)
Do iGraphList.$define(Name,#1,#2)
Do method $addline ('Market Research',2004,8,16,14)
Do method $addline ('Define Specifications',2004,8,30,14)
Do method $addline ('Overall Architecture',2004,9,13,14)
Do method $addline ('Project Planning',2004,9,20,14)
Do method $addline ('Detail Design',2004,9,27,14)
Do method $addline ('Software Development',2004,10,4,35)
Do method $addline ('Test Plan',2004,10,25,14)
Do method $addline ('Testing and QA',2004,11,1,21)
Do method $addline ('User documentation',2004,11,8,14)
The $addline() class method is:
; Params: p1 (Char) p2-p5 (Long Int)
; Local var: chartdate (Date time D m y)
Calculate Name as p1
Calculate chartdate as dat(con(p2,"-",p3,"-",p4),"Y-M-D")
Calculate #1 as $cinst.$objs.ganttChart.$convdate(chartdate)
Calculate chartdate as dadd(kDay,p5,chartdate)
Calculate #2 as $cinst.$objs.ganttChart.$convdate(chartdate)
Add line to list
You can use the $convdate() method to convert a date/time variable to an integer equivalent
which can be used in graph data.
22
XY Charts
Candlestick Charts
The candlestick chart is very similar to the HLOC chart and the list data is formatted in the
same way. The difference in the graphical representation is that the area between the
opening and closing price is shown as a filled rectangle; in the following example a black
rectangle indicates that the closing price was lower than the opening price (a bad day). Both
examples of the HLOC and Candlestick charts used the same data.
23
Omnis Graphs
Trend Chart
A trend chart allows you to view and compare data values over a given period or within a
group. The first column in the data list contains the name of item and the second column
onwards contains the data values for the item. A trend chart will contain one line for each
row of data in the list.
; iColList is a List var assigned to $columnheadings of the graph
object
Do lReturnList.$define(
lName,#1,#2,#3,#4,#5,#6,#7,#8,#9,#10,
#11,#12,#13,#14,#15,#16,#17,#18,#19,#20)
Do lReturnList.$add(
0,50,55,47,34,42,49,63,62,73,59,
56,50,64,60,67,67,58,59,73,77)
Do iColList.$define(
#1,#2,#3,#4,#5,#6,#7,#8,#9,#10,
#11,#12,#13,#14,#15,#16,#17,#18,#19,#20)
Do iColList.$add(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)
24
XY Charts
$datacombine = kG2dataSide: The data sets are $datacombine = kG2dataStack: The data sets
shown as individual bars side-by-side (the default are combined by stacking up the bar segments,
for XY bar charts) therefore showing individual amounts in relation
to the total amount for the data group
These different combine types can also be used when adding data layers to a graph using the
$addarealayer(), $addbarlayer(), or $addlinelayer() XY chart methods; see the Graph
Layers section.
25
Omnis Graphs
Pie Charts
Pie charts have the following properties and methods, in addition to the Common graph
properties and methods.
26
Pie Charts
Note that some ‘actions’ on a pie chart are controlled by setting a particular property, such
as $tilt; see the previous section for pie chart properties. Note also that you cannot add
layers to a pie chart using methods, such as those used on XY and Polar charts.
Pie charts have several properties that allow you to alter the appearance of the chart, such as
$tilt and $rotate. These can be used together with a set of sliders to create a dynamic
representation of the user’s data. See the Graph2 example in the Welcome screen when
Omnis starts up (click the New Users button on the main Omnis toolbar) – the Graph2
example application shows many effects for Pie charts.
27
Omnis Graphs
The code behind the slider can change the appropriate property in the pie chart, such as the
following, which allows the user to change the tilt of the pie chart:
; $event method for Tilt slider
; $min and $max of slider component are set to 0 and 100
On evNewValue
Calculate $cinst.$objs.GR.$tilt as pNewVal
The following code for a slider component allows the user to change the rotation of the
chart.
; $event method for Rotate slider
; $min and $max of slider component are set to 0 and 360
On evNewValue
Calculate $cinst.$objs.GR.$rotate as pNewVal
In addition, the $slicemove(iDistance, iSlice) method lets you move or ‘slice out’ one of the
slices in the pie chart. For example, the Slice move slider in the above window has the
following method:
; $event method for Slice-move slider
; $min and $max of slider component are set to 0 and 50
On evNewValue
Do $cinst.$objs.GR.$slicemove(pNewVal,’0,2’) ;; items 1 and 3
Using a combination of properties you can create some good effects for Pie charts. The
following pie chart uses $sidelayout set to kTrue, a custom $labelformat, and $slicemove is
set to slice out the first and the third slices in the chart.
28
Polar Charts
Polar Charts
The Polar chart has the following properties and methods, in addition to the Common graph
properties and methods.
29
Omnis Graphs
* See appropriate chart section for the format of the data in pList. In addition, see
$datacombine for details of the various data combine types available.
30
Polar Charts
31
Omnis Graphs
32
Meter Charts
Meter Charts
You can create Linear or Angular (radial) meter charts, and change their appearance using a
range of properties and methods. Meter charts have the following properties and methods,
in addition to the common graph properties and methods.
33
Omnis Graphs
34
Meter Charts
The example library uses the above data to create the following chart:
Note that this and the next meter chart has colored zones defined on the scale; these are
described on the Adding Colored Zones section.
When the minor type is set to kG2meterLinear, the following method:
Do iGraphList.$add(75.35)
Do iGraphList.$add(0)
Do iGraphList.$add(100)
Do iGraphList.$add(10)
Can be used to build the following linear chart:
Adding Pointers
The standard meter chart represents a single data point, which is shown using the default
pointer, but you can add one or more additional pointers to a chart to show other data. You
can add extra pointers to a meter chart (angular or linear) using the $addpointer() method,
which must be executed during the evPreLayout event for the graph object; see the Graph
Layers section for information about evPreLayout.
! $addpointer(nValue, iColor [,nPointertype])
adds a pointer to an angular or linear meter chart with the specified value and color;
this must be done during the evPreLayout event; the pointer type is a number in the
range 0-5, as follows:
35
Omnis Graphs
The different pointer styles are shown in the following linear chart:
36
Meter Charts
Adding Rings
A ring is the region in an Angular chart between two concentric circles. You can add rings
to an Angular chart using the $addring() method, which is useful for adding circular borders
and backgrounds to a meter; this must be done during the evPreLayout event.
! $addring(iStartradius, iEndradius, iFillcolor)
adds a colored ring to an angular meter with the specified start and end radius in pixels
The difference between the start and end radius is, in effect, the width or thickness of the
ring in pixels. If you use a start radius of zero, the ring will be drawn starting from the
center of the chart face and, depending on the value of the end radius, will draw a circle on
the chart with the given radius.
The example library demonstrates adding a ring to a radial meter chart, and uses the
following method, which is added to the $event() method for the graph window object:
On evPreLayout
Do $cinst.$objs.meterGraph.$addring(
173-abs(iBackgroundRaised),
174-abs(iBackgroundRaised),
$cinst.$objs.ringColor.$contents)
; etc...
Which produces the following chart; note the ring has been changed to red using the color
picker:
In the example library, the start and end radius settings for the $addring() method take
account of the raised background, since when the background is raised or inset by any
amount, the radius of the meter dial is reduced by the same amount. The color for the ring is
37
Omnis Graphs
taken from the color picker, which is returned in the value of the $contents property of the
color picker button.
A ring must be added to a meter chart during the evPreLayout event, which is triggered
following a $dispose() method for the graph object. For example, the method for the color
picker in the example library is as follows:
On evClick
Do $cinst.$objs.meterGraph.$dispose()
This causes the $event() method for the graph window object to be called and the
evPreLayout event is triggered, which in this case runs the method to add the ring.
38
Graph Layers and the Prelayout Event
For example, in the case of the High/Low/Open/Close charts, it is quite common in financial
applications to draw a line between the open and close points. This can be achieved by
adding a line layer during the evPreLayout event using the $addlinelayer() method, as
follows:
; $event() method for graph window object
; define var: lineLayer (List)
On evPreLayout
Do lineLayer.$define(Name,#1,#2,#3)
Do lineLayer.$add('',1950,1991,2026) ;; Closing prices
Do $cinst.$objs.GraphObj.$addlinelayer(lineLayer, kG2dataOverlay)
Refer to the appropriate layers section for the exact format of the list. The above method
will result in the following graph:
When using an object variable based on the Graph2 component you can use the
$prelayout() method in the object to add layers in the same way as described above.
Caution: A word of warning, evPreLayout events occur during the construction of a graph
image which typically happens during the drawing of the graph control. This can make
debugging the graph object’s $event() method potentially troublesome.
39
Omnis Graphs
For example, using the following method behind the $event() method of the graph object:
; the $event() for the graph object
On evGraphClick
OK message
{Graph Click =
// Item Number [pItem] (Name = [pItemname])
// Set Number [pSet] (Name = [pSetname])}
And clicking on the first item in the second set or group of the following graph
40
Changing the Color of Graph elements
41
Omnis Graphs
42
Parameter Substitution and Formatting
Here is an example method that changes the $labelformat property in a pie chart.
Calculate $cinst.$objs.GROBJ.$labelformat as con("{label}
${value}K",chr(10),"({percent}%)")
Pie chart with default labels Same pie chart with modified labels
For fields that are numbers, dates, or times, the Graph component supports a special syntax
in parameter substitution to allow formatting of these values. Please refer to the Number
Formatting and Date/Time Formatting sections below for details.
The following tables describe the fields available for various chart objects.
43
Omnis Graphs
because a stacked bar is composed of multiple data sets. It does not belong to any particular
data set and hence does not have a data set name.
Parameter Description
x The x value of the data point.
xLabel The bottom x-axis label of the data point.
x2Label The top x-axis label of the data point.
value The value of the data point.
accValue The accumulative value of the data point. This is useful for stacked
charts, such as stacked bar chart and stacked area chart.
totalValue The total value of all data points. This is useful for stacked charts, such
as stacked bar chart and stacked area chart.
percent The percentage of the data point based on the total value of all data
points.
accPercent The accumulated percentage of the data point based on the total value
of all data points. This is useful for stacked charts, such as stacked bar
chart and stacked area chart.
dataSet The data set number to which the data point belongs. The first data set
is 1, the second is 2, and so on.
dataSetName The name of the data set to which the data point belongs.
dataItem The data point number within the data set. The first data point is 1, the
second is 2, and so on.
dataGroup The data group number to which the data point belongs. The first data
group is 1, the second is 2, and so on.
dataGroupName The name of the data group to which the data point belongs.
layerId The layer number to which the data point belongs. The first layer is 1,
the second is 2, and so on.
44
Parameter Substitution and Formatting
Parameter Description
high The high value of the data representation.
low The low value of the data representation.
open The open value of the data representation.
close The close value of the data representation.
Parameter Description
top The value of the top edge of the box-whisker symbol.
bottom The value of the bottom edge of the box-whisker symbol.
max The value of the maximum mark of the box-whisker symbol.
min The value of the minimum mark of the box-whisker symbol.
med The value of the median mark of the box-whisker symbol.
Parameter Description
slope The slope of the trend line.
intercept The y-intercept of the trend line.
corr The correlation coefficient in linear regression analysis.
stderr The standard error in linear regression analysis.
45
Omnis Graphs
The following method sets the label for the data points in a polar chart.
Do $cinst.$objs.GROBJ.$getmainlayer() Returns lLayer
Do lLayer.$setdatalabelformat("({value},{angle})")
Number Formatting
For parameters that are numbers, the Graph component supports a number of formatting
options in parameter substitution.
For example, if you want a numeric field (value) to have a precision of two digits to the
right of the decimal point, use ',' (comma) as the thousand separator, and use '.' (dot) as the
decimal point, and you may use (value|2,.). The number 123456.789 will therefore be
displayed as 123,456.79.
46
Parameter Substitution and Formatting
For numbers, the formatting options are specified using the following syntax:
([param]|[a][b][c][d])
where:
Parameter Description
[param] The name of the parameter
[a] An integer specifying the number of digits to the right of the decimal
point. The default is automatic. To use the default, simply skip this
parameter.
[b] The thousand separator. Should be a non-alphanumeric character (not
0-9, A-Z, a-z). Use '~' for no thousand separater.
[c] The decimal point character.
[d] The negative sign character. Use '~' for no negative sign character.
You may skip the trailing formatting options if they are needed. For example, (value|2)
means formatting the value with two digits to the right, where the thousand separator,
decimal point character, and negative sign character are all using the default settings of the
chart.
Date/Time Formatting
For parameters that are dates & times, the formatting options can be specified using the
following syntax:
([param]|[datetime_format_string])
where [datetime_format_string] must start with an alphabetic character (A-Z or a-z), and
may contain any characters except ')'. Certain characters are substituted according to the
following table:
Parameter Description
yyyy Year in 4 digits (e.g. 2005)
yyy Year showing only the least significant 3 digits (e.g. 007 for the year 2007)
yy Year showing only the least significant 2 digits (e.g. 07 for the year 2007)
y Year showing only the least significant 1 digit (e.g. 7 for the year 2007)
mmm Month formatted as its name. The default is to use the first 3 characters of the
English month name (Jan, Feb, Mar ...).
mm Month formatted as 2 digits from 01 - 12, with leading zero if necessary.
m Month formatted using the minimum number of digits from 1 - 12.
dd Day of month formatted as 2 digits from 01 - 31, with leading zero if
47
Omnis Graphs
Parameter Description
necessary.
d Day of month formatted using the minimum number of digits from 1 - 31.
w The name of the day of week. The default is to use the first 3 characters of the
English day of week name (Sun, Mon, Tue ...).
hh The hour of day formatted as 2 digits, adding leading zero if necessary. The 2
digits will be 00 - 23 if the 'a' option (see below) is not specified, otherwise it
will be 00 - 12.
h The hour of day formatted using the minimum number of digits. The digits
will be 0 - 23 if the 'a' option (see below) is not specified, otherwise it will be
0 - 12.
nn The minute formatted as 2 digits from 00 - 59, adding leading zero if
necessary.
n The minute formatted using the minimum number of digits from 00 - 59.
ss The second formatted as 2 digits from 00 - 59, adding leading zero if
necessary.
s The second formatted using the minimum number of digits from 00 - 59.
a Display either 'am' or 'pm', depending on whether the time is in the morning
or afternoon.
48
Parameter Substitution and Formatting
In general, all tags in CDML are enclosed by <* and *>. Attributes within the tags
determine the styles of the text following the tags within the same block. If you want to
include <* in text without being interpreted as CDML tags, use <<* as the escape sequence.
The following font style attributes can be used:
! font
The font file name.
! size
The font size.
! width
The font width. This attribute is used to set the font width and height to different
values. If the width and height are the same, use the size attribute.
! height
The font height. This attribute is used to set the font width and height to different
values. If the width and height are the same, use the size attribute.
! color
The text color in hex format.
! underline
The line width of the line used to underline the following characters. Set to 0 to disable
underline.
Embedding Images
You can embed images in text using the <*img*> tag and the following syntax:
<*img=my_image_file.png*>
You can use the $imagesearchpath property (on the Preference tab) to specify the folder
where the Graph component will search for images (on Mac OS X the property uses a
standard HFS colon-separated pathname). If you leave the property blank (the default), the
component sets the search path to the icons folder in the Studio tree, which means your
image file must be located in this folder. Having set the image search path you can use the
image file name only in the <*img*> tag. For example, the line:
; set $imagesearchpath to C:\Program Files\RainingData\OS43\images
Calculate $cinst.$objs.GR.$labelformat as con(
"{label} ${value}K",chr(10),
"({percent}%)",chr(10),"<*img= sun_bullet.gif*>")
embeds the image file sun_bullet.gif which is located in the Omnis\images folder.
49
Omnis Graphs
Labels
You can override the default fonts for the main title and labels in a graph by setting the
$titlefont and $labelfont properties (found under the Custom tab in the Property Manager).
You can specify any true type font (TTF) or True type collection (TTC) that is located in
the Fonts folder in the main Omnis folder. If a folder called ‘Fonts’ does not exist you can
create one with this name. If you add fonts to this folder, you have to restart Omnis before
the fonts become available in Omnis.
The default value is set to “(DEFAULT)” which means the default font for your system will
be used (e.g. Times Roman under Windows). You can adjust the height or size of the main
graph title by setting the $titlefontheight property.
50
Using Graphs in Reports
The following method is contained in the $construct() method of the report class, therefore
the method is executed when the report is instantiated, and the graph object is created and
transferred to the picture variable before the report is printed. The $snapshot() method is
used to capture the graph image and returns it to the picture variable.
51
Omnis Graphs
52
Using Graphs in the Web client
The Graph2 example library contains a Remote form example, showing all the main chart
types. In this case, the remote form uses an object class based on the Graph2 component
and uses $snapshot() to transfer the graph image to a picture field in the remote form.
53
Omnis Graphs
54
Using Graphs in the Web client
The mouse co-ordinates are returned in pMouseX and pMouseY in the evClick event. The
$findobject() method uses the mouse co-ordinates to get the setno, itemno, setname, and
itemname which contain information about the graph object clicked on. Clicking on the first
bar in the second group of the above chart produces this data:
setno = 2, itemno = 1, setname = Expenses, itemname = Andy
You can use the item and set number/name information to drilldown into the data by
reformatting the list data and redrawing the graph in the remote form.
Note that the Set number and name are not valid for pie charts.
55
Index
Index
$addarealayer(), 17, 30 Angular charts, 33
$addbarlayer(), 17 Area charts, 7, 19
$addboxwhiskerlayer(), 17 Bar charts, 6, 7, 18
$addcandlesticklayer(), 17 Box whisker charts, 7, 21
$addhloclayer(), 17 Candlestick charts, 8, 23
$addlinelayer(), 17, 30, 39 CDML, 48
$addmark(), 14 Chart types, 6
$addpointer(), 34, 35 ChartDirector, 6, 48
$addring(), 34, 37 Color palettes, 41
$addscatterlayer(), 17 Colors
$addsplinearealayer(), 30 Changing graph elements, 41
$addsplinelinelayer(), 30 Date formatting, 47
$addtext(), 14, 50 Drilldown, 40
$addtrendlayer(), 17 Web client, 54
$addzone(), 14, 42 evPreLayout, 38
$columnheadings, 19 Gantt charts, 21
$convdate(), 14, 22 Graph layers, 38
$datacombine, 16, 24 Graph methods
$dataname Common, 14
Graph field, 18 Graph properties
Graphs, 11 Common, 11
$dispose(), 14 Graph2 component, 6
$findobject(), 14, 54 Graphs
$formatvalue(), 14, 50 Web client, 53
$getcolors(), 14, 41 HLOC charts, 8, 22
$getmainlayer(), 15 Images
$getradialaxis(), 30 Embedding images, 49
$getxaxis(), 17 kG2meter, 13
$getyaxis(), 17 kG2pie, 13
$imagesearchpath, 49 kG2polar, 13
$majortype, 11, 13 kG2xy, 13
$minormetertype, 11 Labels, 50
$minorpolartype, 11, 29 Layers, 38
$minortype, 13 Line charts, 19
$minorxytype, 11, 16 Linear charts
$prelayout(), 15, 39 Meter charts, 33
$redraw() Major type, 13
Graphs, 15 Meter charts, 33
$setcolors(), 15, 41 Methods, 34
$setlinearscale(), 15 Properties, 33
$setlogscale(), 15 Meters, 10
$slicemove(), 27 Minor type, 13
$snapshot(), 15, 51, 53 Number formatting, 46
$swapxy, 21 Parameters
56
Index
57