Graph class

The Graph class gives you access to graphs in T/HIS. More...

The T/HIS JavaScript API provides many class constants, properties and methods. For Arup to be able to extend and enhance the API in the future any constant, property or method names beginning with a lowercase or uppercase letter are reserved.
If you need to add your own properties or methods to one of the existing classes then to avoid any potential future conflict you should ensure that the name begins with either an underscore (_) or a dollar sign ($) or the name is prefixed with your own unique identifier.
For example if company 'ABC' need to add a property called 'example' then to avoid any potential future conflict use one of:

Class functions

Member functions

Graph constants

Name Description
Graph.AXIS_LINEAR Linear axis type
Graph.AXIS_LOG Logarithmic axis type
Graph.FONT_COURIER_BOLD Courier bold font
Graph.FONT_COURIER_MEDIUM Courier medium font
Graph.FONT_DEFAULT Takes the font defined in the preference file
Graph.FONT_HELVETICA_BOLD Helvetical bold font
Graph.FONT_HELVETICA_MEDIUM Helvetical medium font
Graph.FONT_SIZE_10 10 point font size
Graph.FONT_SIZE_12 12 point font size
Graph.FONT_SIZE_14 14 point font size
Graph.FONT_SIZE_18 18 point font size
Graph.FONT_SIZE_24 24 point font size
Graph.FONT_SIZE_8 8 point font size
Graph.FONT_SIZE_AUTO Font size would be automatically adjusted based on the graph area
Graph.FONT_TIMES_BOLD Times New Roman bold font
Graph.FONT_TIMES_MEDIUM Times New Roman medium font
Graph.GRID_OFF Turn off the grid.
Graph.GRID_ON Turn on the grid.
Graph.LEGEND_1_COLUMN Curve labels will be displayed in a single column in the legend
Graph.LEGEND_2_COLUMN Curve labels will be displayed in two columns in the legend
Graph.LEGEND_AUTO Automatic legend layout (see Legend)
Graph.LEGEND_COLUMN_LIST Column list legend layout (see Legend)
Graph.LEGEND_FLOATING Floating legend layout (see Legend)
Graph.LEGEND_OFF Off legend layout (see Legend)
Graph.NO Flag for no.
Graph.OFF Flag to turn off.
Graph.ON Flag to turn on.
Graph.PREFIX_AUTO Automatically add prefix to the curve label in the legend (see Legend)
Graph.PREFIX_DIR Directory name of the model will be used as the curve label prefix in the legend (see Legend)
Graph.PREFIX_MODEL_NUMBER Model number will be used as the curve label prefix in the legend (see Legend)
Graph.PREFIX_OFF Turn off the curve label prefix in the legend (see Legend)
Graph.PREFIX_ON Add prefix to the curve label in the legend (see Legend)
Graph.PREFIX_THF Root name of the THF file will be used as the curve label prefix in the legend (see Legend)
Graph.PREFIX_USER_DEFINED A user defined prefix will be used as the curve label prefix in the legend (see Legend)
Graph.YES Flag for yes.

Graph properties

Name Type Description
active constant If the graph is active or inactive. Can take Graph.YES or Graph.NO
add_x_units constant shows x-axis units. It can take either Graph.ON or Graph.OFF
add_y2_units constant shows second y-axis units. It can take either Graph.ON or Graph.OFF
add_y_units constant shows y-axis units. It can take either Graph.ON or Graph.OFF
auto_title string Turn on to set graph title automatically and turn off to define the graph title manually using the property Graph.title. Can take either Graph.ON or Graph.OFF
auto_xlabel constant Turn on to set label for the x-axis automatically and turn off to define the label for the x-axis manually using the property xlabel. Can take either Graph.ON or Graph.OFF
auto_xmax constant Can take either Graph.ON or Graph.OFF. Graph.ON will set the maximum value for the y-axis range automatically and Graph.OFF will use the property xmax value as the maximum value for the x-axis range
auto_xmin constant Can take either Graph.ON or Graph.OFF. Graph.ON will set the minimum value for the x-axis range automatically and Graph.OFF will use the property xmin value as the minimum value for the x-axis range
auto_y2label constant Turn on to set label for the second y-axis automatically and turn off to define the label for the second y-axis manually using the property y2label. Can take either Graph.ON or Graph.OFF
auto_y2max constant Can take either Graph.ON or Graph.OFF. Graph.ON will set the maximum value for the second y-axis range automatically and Graph.OFF will use the property y2max value as the maximum value for the second y-axis range
auto_y2min constant Can take either Graph.ON or Graph.OFF. Graph.ON will set the minimum value for the second y-axis range automatically and Graph.OFF will use the property y2min value as the minimum value for the second y-axis range
auto_ylabel constant Turn on to set label for the y-axis automatically and turn off to define the label for the y-axis manually using the property ylabel. Can take either Graph.ON or Graph.OFF
auto_ymax constant Can take either Graph.ON or Graph.OFF. Graph.ON will set the maximum value for the y-axis range automatically and Graph.OFF will use the property ymax value as the maximum value for the y-axis range
auto_ymin constant Can take either Graph.ON or Graph.OFF. Graph.ON will set the minimum value for the y-axis range automatically and Graph.OFF will use the property ymin value as the minimum value for the y-axis range
background_colour Colour Graph background colour
foreground_colour Colour Graph foreground colour
grid constant To turn on/off the grid. Can take Graph.GRID_ON or Graph.GRID_OFF
id (read only) integer Graph ID
legend_background_colour Colour Background colour for the legend area
legend_background_trans integer Transparancy of the legend area. The value should lie between 0 and 100
legend_font constant Font for the curve labels in the legend. Can take either Graph.FONT_DEFAULT, Graph.FONT_HELVETICA_MEDIUM, Graph.FONT_HELVETICA_BOLD, Graph.FONT_TIMES_MEDIUM, Graph.FONT_TIMES_BOLD, Graph.FONT_COURIER_MEDIUM or Graph.FONT_COURIER_BOLD
legend_font_colour Colour Font colour for the curve labels in the legend
legend_font_size constant Font size for the curve labels in the legend. Can take either Graph.FONT_SIZE_AUTO, Graph.FONT_SIZE_8, Graph.FONT_SIZE_10, Graph.FONT_SIZE_12, Graph.FONT_SIZE_14, Graph.FONT_SIZE_18 or Graph.FONT_SIZE_24
legend_layout constant Defines the legend layout type. Can take Graph.LEGEND_COLUMN_LIST, Graph.LEGEND_AUTO, Graph.LEGEND_OFF or Graph.LEGEND_FLOATING
legend_prefix_format constant Format of the prefix that is being included in the curve label of the legend. Can take either Graph.PREFIX_MODEL_NUMBER, Graph.DIR, Graph.PREFIX_THF or Graph.PREFIX_USER_DEFINED
legend_show_prefix constant Include the prefix in the curve label of the legend. Can take either Graph.PREFIX_AUTO, Graph.PREFIX_ON or Graph.PREFIX_OFF
legend_show_user_lines constant Visibility of user lines when Graph.LEGEND_COLUMN_LIST is selected for legend layout. Can take either Graph.ON or Graph.OFF
legend_user_line_1 string User defined line 1 from the legend area
legend_user_line_1_size constant Font size for the user defined line 1. Can take either Graph.FONT_SIZE_AUTO, Graph.FONT_SIZE_8, Graph.FONT_SIZE_10, Graph.FONT_SIZE_12, Graph.FONT_SIZE_14, Graph.FONT_SIZE_18 or Graph.FONT_SIZE_24
legend_user_line_2 string User defined line 2 from the legend area
legend_user_line_2_size constant Font size for the user defined line 2. Can take either Graph.FONT_SIZE_AUTO, Graph.FONT_SIZE_8, Graph.FONT_SIZE_10, Graph.FONT_SIZE_12, Graph.FONT_SIZE_14, Graph.FONT_SIZE_18 or Graph.FONT_SIZE_24
legend_user_line_3 string User defined line 3 from the legend area
legend_user_line_3_size constant Font size for the user defined line 3. Can take either Graph.FONT_SIZE_AUTO, Graph.FONT_SIZE_8, Graph.FONT_SIZE_10, Graph.FONT_SIZE_12, Graph.FONT_SIZE_14, Graph.FONT_SIZE_18 or Graph.FONT_SIZE_24
legend_user_line_4 string User defined line 4 from the legend area
legend_user_line_4_size constant Font size for the user defined line 4. Can take either Graph.FONT_SIZE_AUTO, Graph.FONT_SIZE_8, Graph.FONT_SIZE_10, Graph.FONT_SIZE_12, Graph.FONT_SIZE_14, Graph.FONT_SIZE_18 or Graph.FONT_SIZE_24
legend_user_line_5 string User defined line 6 from the legend area
legend_user_line_5_size constant Font size for the user defined line 5. Can take either Graph.FONT_SIZE_AUTO, Graph.FONT_SIZE_8, Graph.FONT_SIZE_10, Graph.FONT_SIZE_12, Graph.FONT_SIZE_14, Graph.FONT_SIZE_18 or Graph.FONT_SIZE_24
legend_user_line_6 string User defined line 6 from the legend area
legend_user_line_6_size constant Font size for the user defined line 6. Can take either Graph.FONT_SIZE_AUTO, Graph.FONT_SIZE_8, Graph.FONT_SIZE_10, Graph.FONT_SIZE_12, Graph.FONT_SIZE_14, Graph.FONT_SIZE_18 or Graph.FONT_SIZE_24
legend_user_lines_colour Colour Font colour for the user defined lines in the legend
legend_user_lines_font constant Font for the user defined lines in the legend. Can take either Graph.FONT_DEFAULT, Graph.FONT_HELVETICA_MEDIUM, Graph.FONT_HELVETICA_BOLD, Graph.FONT_TIMES_MEDIUM, Graph.FONT_TIMES_BOLD, Graph.FONT_COURIER_MEDIUM or Graph.FONT_COURIER_BOLD
num_legend_columns constant Number of columns of curve labels in legends. Can take Graph.LEGEND_1_COLUMN, Graph.LEGEND_2_COLUMN or Graph.LEGEND_3_COLUMN
show_title string Shows graph title. Can take either Graph.ON or Graph.OFF
show_xlabel constant Shows graph x-axis label. Can take either Graph.ON or Graph.OFF
show_y2axis constant Shows graph second y-axis. Can take either Graph.ON or Graph.OFF. (Note, Curve property y_axis must be set to Curve.Y2_AXIS for the curve to be plotted on the second y-axis.)
show_y2label constant Shows graph second y-axis label. Can take either Graph.ON or Graph.OFF
show_ylabel constant Shows graph y-axis label. Can take either Graph.ON or Graph.OFF
title string Graph title
x_axis_type constant Defines x-axis type i.e. linear or logarithmic. Can take either Graph.AXIS_LINEAR or Graph.AXIS_LOG
x_unit_colour Colour Colour of the x-axis units
x_unit_decimals integer Defines the number decimals in the x-axis units.
x_unit_font constant Font for the x-axis units. Can take either Graph.FONT_DEFAULT, Graph.FONT_HELVETICA_MEDIUM, Graph.FONT_HELVETICA_BOLD, Graph.FONT_TIMES_MEDIUM, Graph.FONT_TIMES_BOLD, Graph.FONT_COURIER_MEDIUM or Graph.FONT_COURIER_BOLD
x_unit_format constant Defines the format for the x-axis units. Can take either Graph.AXIS_UNITS_AUTO, Graph.AXIS_UNITS_SCIENTIFIC or Graph.AXIS_UNITS_GENERAL
x_unit_size constant Font size for the x-axis units. Can take either Graph.FONT_SIZE_AUTO, Graph.FONT_SIZE_8, Graph.FONT_SIZE_10, Graph.FONT_SIZE_12, Graph.FONT_SIZE_14, Graph.FONT_SIZE_18 or Graph.FONT_SIZE_24
xlabel string Label for x-axis
xlabel_colour Colour Colour of the x-axis label
xlabel_font constant Font for the x-axis label. Can take either Graph.FONT_DEFAULT, Graph.FONT_HELVETICA_MEDIUM, Graph.FONT_HELVETICA_BOLD, Graph.FONT_TIMES_MEDIUM, Graph.FONT_TIMES_BOLD, Graph.FONT_COURIER_MEDIUM or Graph.FONT_COURIER_BOLD
xlabel_size constant Font size for the x-axis label. Can take either Graph.FONT_SIZE_AUTO, Graph.FONT_SIZE_8, Graph.FONT_SIZE_10, Graph.FONT_SIZE_12, Graph.FONT_SIZE_14, Graph.FONT_SIZE_18 or Graph.FONT_SIZE_24
xmax real Maximum value of x-axis range
xmin real Minimum value of the x-axis range
y2_axis_type constant Defines second y-axis type i.e. linear or logarithmic. Can take either Graph.AXIS_LINEAR or Graph.AXIS_LOG
y2_unit_colour Colour Colour of the second y-axis units
y2_unit_decimals integer Defines the number decimals in the second y-axis units.
y2_unit_font constant Font for the second y-axis label. Can take either Graph.FONT_DEFAULT, Graph.FONT_HELVETICA_MEDIUM, Graph.FONT_HELVETICA_BOLD, Graph.FONT_TIMES_MEDIUM, Graph.FONT_TIMES_BOLD, Graph.FONT_COURIER_MEDIUM or Graph.FONT_COURIER_BOLD
y2_unit_format constant Defines the format for the second y-axis units. Can take either Graph.AXIS_UNITS_AUTO, Graph.AXIS_UNITS_SCIENTIFIC or Graph.AXIS_UNITS_GENERAL
y2_unit_size constant Font size for the second y-axis units. Can take either Graph.FONT_SIZE_AUTO, Graph.FONT_SIZE_8, Graph.FONT_SIZE_10, Graph.FONT_SIZE_12, Graph.FONT_SIZE_14, Graph.FONT_SIZE_18 or Graph.FONT_SIZE_24
y2label string Label for second y-axis
y2label_colour Colour Colour of the second y-axis label
y2label_font constant Font for the second y-axis label. Can take either Graph.FONT_DEFAULT, Graph.FONT_HELVETICA_MEDIUM, Graph.FONT_HELVETICA_BOLD, Graph.FONT_TIMES_MEDIUM, Graph.FONT_TIMES_BOLD, Graph.FONT_COURIER_MEDIUM or Graph.FONT_COURIER_BOLD
y2label_size constant Font size for the second y-axis label. Can take either Graph.FONT_SIZE_AUTO, Graph.FONT_SIZE_8, Graph.FONT_SIZE_10, Graph.FONT_SIZE_12, Graph.FONT_SIZE_14, Graph.FONT_SIZE_18 or Graph.FONT_SIZE_24
y2max real Maximum value of the second y-axis range
y2min real Minimum value of the second y-axis range
y_axis_type constant Defines y-axis type i.e. linear or logarithmic. Can take either Graph.AXIS_LINEAR or Graph.AXIS_LOG
y_unit_colour Colour Colour of the y-axis units
y_unit_decimals integer The number decimals in the y-axis units.
y_unit_font constant Font for the y-axis units. Can take either Graph.FONT_DEFAULT, Graph.FONT_HELVETICA_MEDIUM, Graph.FONT_HELVETICA_BOLD, Graph.FONT_TIMES_MEDIUM, Graph.FONT_TIMES_BOLD, Graph.FONT_COURIER_MEDIUM or Graph.FONT_COURIER_BOLD
y_unit_format constant Defines the format for the y-axis units. Can take either Graph.AXIS_UNITS_AUTO, Graph.AXIS_UNITS_SCIENTIFIC or Graph.AXIS_UNITS_GENERAL
y_unit_size constant Font size for the y-axis units. Can take either Graph.FONT_SIZE_AUTO, Graph.FONT_SIZE_8, Graph.FONT_SIZE_10, Graph.FONT_SIZE_12, Graph.FONT_SIZE_14, Graph.FONT_SIZE_18 or Graph.FONT_SIZE_24
ylabel string Label for y-axis
ylabel_colour Colour Colour of the y-axis label
ylabel_font constant Font for the y-axis label. Can take either Graph.FONT_DEFAULT, Graph.FONT_HELVETICA_MEDIUM, Graph.FONT_HELVETICA_BOLD, Graph.FONT_TIMES_MEDIUM, Graph.FONT_TIMES_BOLD, Graph.FONT_COURIER_MEDIUM or Graph.FONT_COURIER_BOLD
ylabel_size constant Font size for the y-axis label. Can take either Graph.FONT_SIZE_AUTO, Graph.FONT_SIZE_8, Graph.FONT_SIZE_10, Graph.FONT_SIZE_12, Graph.FONT_SIZE_14, Graph.FONT_SIZE_18 or Graph.FONT_SIZE_24
ymax real Maximum value of y-axis range
ymin real Minimum value of the y-axis range

Detailed Description

The Graph class contains information on the number of graphs. See the documentation below for more details.

Constructor

new Graph(index (optional)[integer])

Description

Create a new Graph.

Arguments

  • index (optional) (integer)

    Graph index to copy initial display and axis settings from (optional). If not defined then the display and axis settings will be copied from those defined in the preference file.

    Returns

    Graph object

    Return type

    Graph

    Example

    To create a new graph and copy all of the setting from graph 2

    var l = new Graph(2);

    Details of functions

    AddCurveID(Curve ID[integer], redraw (optional)[boolean])

    Description

    Adds a curve to the graph.

    Arguments

  • Curve ID (integer)

    ID of the curve to add.

  • redraw (optional) (boolean)

    If this argument is false then the graph will not be redrawn after the curve is added. This is to be used if a large number of curves are to be added to a graph, so as to avoid the same curves being drawn multiple times. No argument or true will trigger a redraw after the curve is added.

    Returns

    Returns true if the curve is successfully added to the graph else it would return false

    Return type

    Boolean

    Example

    To add a curve with id (n) to the graph (g):

    g.AddCurveID(n);


    AddCurveID(Curve ID[integer], No redraw (optional)[integer])   [deprecated]

    This function is deprecated in version 22.0. It is only provided to keep old scripts working. We strongly advise against using it in new scripts. Support may be removed in future versions.

    Description

    Adds a curve to the graph.

    Arguments

  • Curve ID (integer)

    ID of the curve to add.

  • No redraw (optional) (integer)

    If this argument is 1 then the graph will not be redrawn after the curve is added. This is to be used if a large number of curves are to be added to a graph, so as to avoid the same curves being drawn multiple times. No argument or 0 will trigger a redraw after the curve is added.

    Returns

    Returns true if the curve is successfully added to the graph else it would return false

    Return type

    Boolean

    Example

    To add a curve with id (n) to the graph (g):

    g.AddCurveID(n);


    AddToPage(Page number[integer])

    Description

    Adds the graph to the page.

    Arguments

  • Page number (integer)

    Page number for which to add the graph to.

    Returns

    Returns true if the graph is successfully added to the page else it would return false

    Return type

    Boolean

    Example

    To add a graph (g) to page id (n):

    g.AddToPage(n);


    Delete()

    Description

    Deletes the graph

    Arguments

    No arguments

    Returns

    No return value

    Example

    Deletes the graph (g)

    g.Delete();


    DeleteFromID(ID[integer]) [static]

    Description

    Deletes a graph

    Arguments

  • ID (integer)

    ID of graph to delete

    Returns

    No return value

    Example

    To delete the graph n

    Graph.DeleteFromID(n);

    Maximum number of graphs in T/HIS is 32


    GetAllCurveIDs()

    Description

    Returns the IDs of the curves present in the graph in an array.

    Arguments

    No arguments

    Returns

    Array of curve IDs

    Return type

    array

    Example

    To get the array of all the curve ids present in a graph (g):

    var num = g.GetAllCurveIDs();


    GetAllPageIDs()

    Description

    Returns all the pages containing the graph.

    Arguments

    No arguments

    Returns

    Array of page IDs

    Return type

    array

    Example

    To get the list of all page ids containing the graph (g):

    var pages_ids = g.GetAllPageIDs();


    GetFromID(ID[integer]) [static]

    Description

    Returns the graph object for a given graph id.

    Arguments

  • ID (integer)

    ID of graph to return the graph for

    Returns

    Graph object or NULL if graph does not exists

    Return type

    Graph

    Example

    To get the graph n

    var num = Graph.GetFromID(n);

    Maximum number of graphs in T/HIS is 32


    GetNumCurves()

    Description

    Returns number curves present in the graph.

    Arguments

    No arguments

    Returns

    Number of curves present in the graph.

    Return type

    Number

    Example

    To find number of curves in a graph (g):

    var num = g.GetNumCurves();


    Lock(Lock type[integer])

    Description

    Locks the blanking status of either blanked curves, unblanked curves or all curves on the graph.

    Arguments

  • Lock type (integer)

    No argument or 0 to lock blanked curves, -1 to unlock blanked curves, -2 to unfreeze all visible curves

    Returns

    No return value

    Example

    To lock all blanked curves on graph g:

    g.Lock();


    RemoveCurveID(ID[integer])

    Description

    Removes a curve from the graph.

    Arguments

  • ID (integer)

    ID of the curve to be removed

    Returns

    Returns true if the curve is successfully removed from the graph else it would return false

    Return type

    Boolean

    Example

    To remove a curve with id (n) from the graph (g):

    g.RemoveCurveID(n);


    RemoveFromPage(ID[integer])

    Description

    Removes the graph from a page.

    Arguments

  • ID (integer)

    ID of the page from which the graph is to be removed

    Returns

    Returns true if the graph is successfully removed from the page else it would return false

    Return type

    Boolean

    Example

    To remove the graph (g) from page with id (n):

    g.RemoveFromPage(n);


    Total() [static]

    Description

    Returns the total number of graphs.

    Arguments

    No arguments

    Returns

    integer

    Return type

    Number

    Example

    To find how many graphs there are in T/HIS:

    var num = Graph.Total();