# GuiGraphCtrl

A control that plots one or more curves in a chart.

## Graph

```
float
```

Ratio of where to place the center coordinate of the graph on the Y axis. 0.5=middle height of control.

```
LinearColorF
```

plotColor [6]

Color to use for the plotting curves in the graph.

plotType [6]

Charting type of the plotting curves.

```
string
```

plotVariable [6]

Name of the variable to automatically plot on the curves. If empty, auto-plotting is disabled for the respective curve.

```
int
```

plotInterval [6]

Interval between auto-plots of plotVariable for the respective curve (in milliseconds).

## Public Functions

```
void
```

addAutoPlot(int plotId, string variable, int updateFrequency)

Sets up the given plotting curve to automatically plot the value of the *variable* with a frequency of *updateFrequency*.

```
void
```

addDatum(int plotId, float value)

Add a data point to the plot's curve.

```
float
```

getDatum(int plotId, int index)

Get a data point on the given plotting curve.

```
void
```

matchScale(int plotID1, int plotID2, ... )

Set the scale of all specified plots to the maximum scale among them.

```
void
```

removeAutoPlot(int plotId)

Stop automatic variable plotting for the given curve.

```
void
```

setGraphType(int plotId, GuiGraphType graphType)

Change the charting type of the given plotting curve.

## Detailed Description

A control that plots one or more curves in a chart.

Up to 6 individual curves can be plotted in the graph. Each plotted curve can have its own display style including its own charting style (plotType) and color (plotColor).

The data points on each curve can be added in one of two ways:

Manually by calling addDatum(). This causes new data points to be added to the left end of the plotting curve.

Automatically by letting the graph plot the values of a variable over time. This is achieved by calling addAutoPlot and specifying the variable and update frequency.

// Create a graph that plots a red polyline graph of the FPS counter in a 1 second (1000 milliseconds) interval. new GuiGraphCtrl( FPSGraph ) { plotType[ 0 ] = "PolyLine"; plotColor[ 0 ] = "1 0 0"; plotVariable[ 0 ] = "fps::real"; plotInterval[ 0 ] = 1000; };

note:Each curve has a maximum number of 200 data points it can have at any one time. Adding more data points to a curve will cause older data points to be removed.

## Graph

float centerY

Ratio of where to place the center coordinate of the graph on the Y axis. 0.5=middle height of control.

This allows to account for graphs that have only positive or only negative data points, for example.

LinearColorF plotColor [6]

Color to use for the plotting curves in the graph.

GuiGraphType plotType [6]

Charting type of the plotting curves.

string plotVariable [6]

Name of the variable to automatically plot on the curves. If empty, auto-plotting is disabled for the respective curve.

int plotInterval [6]

Interval between auto-plots of plotVariable for the respective curve (in milliseconds).

## Public Functions

addAutoPlot(int plotId, string variable, int updateFrequency)

Sets up the given plotting curve to automatically plot the value of the *variable* with a frequency of *updateFrequency*.

**Parameters:**

plotId | Index of the plotting curve. Must be 0<=plotId<6. |

variable | Name of the global variable. |

updateFrequency | Frequency with which to add new data points to the plotting curve (in milliseconds). // Plot FPS counter at 1 second intervals. %graph.addAutoPlot( 0, "fps::real", 1000 ); |

addDatum(int plotId, float value)

Add a data point to the plot's curve.

**Parameters:**

plotId | Index of the plotting curve to which to add the data point. Must be 0<=plotId<6. |

value | Value of the data point to add to the curve. |

note:Data values are added to the

leftend of the plotting curve.

note:A maximum number of 200 data points can be added to any single plotting curve at any one time. If this limit is exceeded, data points on the right end of the curve are culled.

getDatum(int plotId, int index)

Get a data point on the given plotting curve.

**Parameters:**

plotId | Index of the plotting curve from which to fetch the data point. Must be 0<=plotId<6. |

index | Index of the data point on the curve. |

The value of the data point or -1 if *plotId* or *index* are out of range.

matchScale(int plotID1, int plotID2, ... )

Set the scale of all specified plots to the maximum scale among them.

**Parameters:**

plotID1 | Index of plotting curve. |

plotID2 | Index of plotting curve. |

removeAutoPlot(int plotId)

Stop automatic variable plotting for the given curve.

**Parameters:**

plotId | Index of the plotting curve. Must be 0<=plotId<6. |

setGraphType(int plotId, GuiGraphType graphType)

Change the charting type of the given plotting curve.

**Parameters:**

plotId | Index of the plotting curve. Must be 0<=plotId<6. |

graphType | Charting type to use for the curve. |

note:Instead of calling this method, you can directly assign to plotType.