guiGraphCreate (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

NX-400

Firmware version:

1.00.00


This function creates a new graph on the provided form.

Wrap = TRUE

Wrap = TRUE

 

Graphs can be used to visualize data, supporting both a bar graph and line graphs.

 

The total size of the graph depends on the x_scale and x_count parameters. If the product of these parameters are larger than the available area for the graph, the graph can be scrolled by clicking on the left and right thirds.

 

The entries can be set in two different ways.

It can be set using the index of the entry to update. This is suited to e.g. show historic data or data where each bar shows a specific reading.

Alternatively, data can be added to a buffer and then appended to the end of the graph when guiGraphScrollNext is called, dropping the oldest data if the graph is full. This is suited for showing the history of a reading, e.g. a temperature sensor.

 

 

Input:

Wrap = FALSE

Wrap = FALSE

form : SYSHANDLE

A handle to the form that the graph is created on.

 

x : SINT default 1

The horizontal location of the graph.

 

y : SINT default 1

The vertical location of the graph.

 

w : SINT default 1

The width of the graph.

 

h : SINT default 1

The height of the graph.

 

tag : DINT

The tag value to store.

 

y_min : INT default -100

The minimum value to show on the graph.

 

y_max : INT default 100

The maximum value to show on the graph.

 

x_scale : INT (1..25) default 5

The width of each entry in pixels. This is the width of the bar and the space until the next bar for bar graphs, and the distance from one point on the line graph to the next.

 

x_count : INT (1..240) default 20

The number of entries to store in the graph. This determines how many entries that can be added before the graph is full.

 

bars : INT (0,1) default 0

Set to 1 to show the bar graph, set to 0 to disable the bar graph.

 

lines : INT (0..4) default 0

Determines the number of line graphs to show.

 

wrap : BOOL default FALSE

Determines how the graph reacts when entries are appended when it is full.

Set to TRUE, the graph will wrap around when it is full, similar to how an oscilloscope works. It shows a vertical line just after the latest data.

Set to FALSE, the entry is added at the end and the graph is scrolled, dropping the first entry.

 

 

Output:

graph : SYSHANDLE

The handle to the new graph.

 

Returns: INT

0

- Success.

-1

- Interface is not open (see guiOpen).

-2

- Not enough memory / resources.

-3

- Invalid argument.

-5

- Unknown error

-10

- Invalid location or dimension.

-11

- The GUI API is not supported.

-12

- The location is already used.

 

Declaration:

FUNCTION guiGraphCreate : INT;
VAR_INPUT
  form    : SYSHANDLE;
  x       : SINT := 1;
  y       : SINT := 1;
  w       : SINT := 1;
  h       : SINT := 1;
  tag     : DINT;
  y_min   : INT := -100;
  y_max   : INT := 100;
  x_scale : INT := 5;
  x_count : INT := 20;
  bars    : INT := 0;
  lines   : INT := 0;  
  wrap    : BOOL := FALSE;
  graph   : ACCESS SYSHANDLE;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  rc     : INT;
  graph  : SYSHANDLE;
  form   : SYSHANDLE;
END_VAR;
 
BEGIN
  ...
  // Create a graph with space for 50 items, for showing values between -10 and 100.
  rc := guiGraphCreate(graph := graph, form:=form, x:=1, y:=1, w:=5, h:=6,
    y_min := -10, x_count := 50, bars := 1, lines := 4);
  ...
END;
END_PROGRAM;