EasyGUI  Version v1.0
Graph

Graph which can display plots. More...

Data Structures

struct  gui_graph_data_t
 Graph data widget structure. More...
 
struct  gui_graph_t
 Graph widget structure. More...
 

Typedefs

typedef struct gui_graph_data * gui_graph_data_p
 

Enumerations

enum  gui_graph_color_t { GUI_GRAPH_COLOR_BG = 0x00, GUI_GRAPH_COLOR_FG = 0x01, GUI_GRAPH_COLOR_BORDER = 0x02, GUI_GRAPH_COLOR_GRID = 0x03 }
 Graph color list enumeration. More...
 
enum  gui_graph_border_t { GUI_GRAPH_BORDER_TOP = 0x00, GUI_GRAPH_BORDER_RIGHT = 0x01, GUI_GRAPH_BORDER_BOTTOM = 0x02, GUI_GRAPH_BORDER_LEFT = 0x03 }
 Graph border list enumeration. More...
 
enum  gui_graph_type_t { GUI_GRAPH_TYPE_YT = 0x00, GUI_GRAPH_TYPE_XY = 0x01 }
 Graph type enumeration. More...
 

Functions

gui_handle_p gui_graph_create (gui_id_t id, float x, float y, float width, float height, gui_handle_p parent, gui_widget_evt_fn evt_fn, uint16_t flags)
 Create new graph widget. More...
 
uint8_t gui_graph_setcolor (gui_handle_p h, gui_graph_color_t index, gui_color_t color)
 Set color to specific part of widget. More...
 
uint8_t gui_graph_setminx (gui_handle_p h, float v)
 Set minimal X value of plot. More...
 
uint8_t gui_graph_setmaxx (gui_handle_p h, float v)
 Set maximal X value of plot. More...
 
uint8_t gui_graph_setminy (gui_handle_p h, float v)
 Set minimal Y value of plot. More...
 
uint8_t gui_graph_setmaxy (gui_handle_p h, float v)
 Set maximal Y value of plot. More...
 
uint8_t gui_graph_setaxes (gui_handle_p h, float min_x, float max_x, float min_y, float max_y)
 Set all axes. More...
 
uint8_t gui_graph_zoomreset (gui_handle_p h)
 Reset zoom of widget. More...
 
uint8_t gui_graph_zoom (gui_handle_p h, float zoom, float x, float y)
 Zoom widget display data. More...
 
uint8_t gui_graph_attachdata (gui_handle_p h, gui_graph_data_p data)
 Attach new data object to graph widget. More...
 
uint8_t gui_graph_detachdata (gui_handle_p h, gui_graph_data_p data)
 Detach existing data object from graph widget. More...
 
gui_graph_data_p gui_graph_data_create (gui_id_t id, gui_graph_type_t type, size_t length)
 Creates data object according to specific type. More...
 
uint8_t gui_graph_data_addvalue (gui_graph_data_p data, int16_t x, int16_t y)
 Add new value to the end of data object. More...
 
uint8_t gui_graph_data_setcolor (gui_graph_data_p data, gui_color_t color)
 Set color for graph data. More...
 
gui_graph_data_p gui_graph_data_get_by_id (gui_handle_p graph_h, gui_id_t id)
 Get data collection with specific ID from graph. More...
 

Detailed Description

Graph which can display plots.

Graph widget to display plot lines of 2 different types, either XY or YT.

image_widget_graph.png
Graph widget with 2 data plots. Red is XY and green is YT

Example code for image above

Typedef Documentation

◆ gui_graph_data_p

typedef struct gui_graph_data* gui_graph_data_p

Graph data pointer

Enumeration Type Documentation

◆ gui_graph_border_t

Graph border list enumeration.

Enumerator
GUI_GRAPH_BORDER_TOP 

Border top index

GUI_GRAPH_BORDER_RIGHT 

Border right index

GUI_GRAPH_BORDER_BOTTOM 

Border bottom index

GUI_GRAPH_BORDER_LEFT 

Border left index

◆ gui_graph_color_t

Graph color list enumeration.

See also
gui_graph_setcolor
Enumerator
GUI_GRAPH_COLOR_BG 

Background color index

GUI_GRAPH_COLOR_FG 

Foreground color index (background of plotting area)

GUI_GRAPH_COLOR_BORDER 

Border color index

GUI_GRAPH_COLOR_GRID 

Grid color index

◆ gui_graph_type_t

Graph type enumeration.

Enumerator
GUI_GRAPH_TYPE_YT 

Data type is Y versus time

GUI_GRAPH_TYPE_XY 

Data type is Y versus X [Y(x)]

Function Documentation

◆ gui_graph_attachdata()

uint8_t gui_graph_attachdata ( gui_handle_p  h,
gui_graph_data_p  data 
)

Attach new data object to graph widget.

Parameters
[in,out]hGraph widget handle
[in]dataData object handle
Returns
1 on success, 0 otherwise

◆ gui_graph_create()

gui_handle_p gui_graph_create ( gui_id_t  id,
float  x,
float  y,
float  width,
float  height,
gui_handle_p  parent,
gui_widget_evt_fn  evt_fn,
uint16_t  flags 
)

Create new graph widget.

Parameters
[in]idWidget unique ID to use for identity for callback processing
[in]xWidget X position relative to parent widget
[in]yWidget Y position relative to parent widget
[in]widthWidget width in units of pixels
[in]heightWidget height in units of pixels
[in]parentParent widget handle. Set to NULL to use current active parent widget
[in]evt_fnCustom widget callback function. Set to NULL to use default callback
[in]flagsflags for create procedure
Returns
Widget handle on success, NULL otherwise

◆ gui_graph_data_addvalue()

uint8_t gui_graph_data_addvalue ( gui_graph_data_p  data,
int16_t  x,
int16_t  y 
)

Add new value to the end of data object.

Parameters
[in]dataData object handle
[in]xX position for point. Used only in case data type is GUI_GRAPH_TYPE_XY, otherwise it is ignored
[in]yY position for point. Always used no matter of data type
Returns
1 on success, 0 otherwise

◆ gui_graph_data_create()

gui_graph_data_p gui_graph_data_create ( gui_id_t  id,
gui_graph_type_t  type,
size_t  length 
)

Creates data object according to specific type.

Note
Data type used in graph widget is 2-byte (short int)
When
  • GUI_GRAPH_TYPE_XY is used, 2 * length * sizeof(short int) of bytes is allocated for X and Y value
Parameters
[in]idGraph data ID
[in]typeType of data. According to selected type different allocation size will occur
[in]lengthNumber of points on plot.
Returns
Graph data handle on success, NULL otherwise

◆ gui_graph_data_get_by_id()

gui_graph_data_p gui_graph_data_get_by_id ( gui_handle_p  graph_h,
gui_id_t  id 
)

Get data collection with specific ID from graph.

Parameters
[in]graph_hGraph widget handle
[in]idData collection ID
Returns
Data collection handle

◆ gui_graph_data_setcolor()

uint8_t gui_graph_data_setcolor ( gui_graph_data_p  data,
gui_color_t  color 
)

Set color for graph data.

Parameters
[in,out]dataGraph data handle
[in]colorNew color for data
Returns
1 on success, 0 otherwise

◆ gui_graph_detachdata()

uint8_t gui_graph_detachdata ( gui_handle_p  h,
gui_graph_data_p  data 
)

Detach existing data object from graph widget.

Parameters
[in,out]hGraph widget handle
[in]dataData object handle
Returns
1 on success, 0 otherwise

◆ gui_graph_setaxes()

uint8_t gui_graph_setaxes ( gui_handle_p  h,
float  min_x,
float  max_x,
float  min_y,
float  max_y 
)

Set all axes.

Parameters
[in]hWidget handle
[in]min_x,max_x,min_y,max_yNew coordinate maximum values
Returns
1 on success, 0 otherwise

◆ gui_graph_setcolor()

uint8_t gui_graph_setcolor ( gui_handle_p  h,
gui_graph_color_t  index,
gui_color_t  color 
)

Set color to specific part of widget.

Parameters
[in]hWidget handle
[in]indexColor index
[in]colorColor value
Returns
1 on success, 0 otherwise

◆ gui_graph_setmaxx()

uint8_t gui_graph_setmaxx ( gui_handle_p  h,
float  v 
)

Set maximal X value of plot.

Parameters
[in]hWidget handle
[in]vNew maximal X value
Returns
1 on success, 0 otherwise

◆ gui_graph_setmaxy()

uint8_t gui_graph_setmaxy ( gui_handle_p  h,
float  v 
)

Set maximal Y value of plot.

Parameters
[in]hWidget handle
[in]vNew maximal Y value
Returns
1 on success, 0 otherwise

◆ gui_graph_setminx()

uint8_t gui_graph_setminx ( gui_handle_p  h,
float  v 
)

Set minimal X value of plot.

Parameters
[in]hWidget handle
[in]vNew minimal X value
Returns
1 on success, 0 otherwise

◆ gui_graph_setminy()

uint8_t gui_graph_setminy ( gui_handle_p  h,
float  v 
)

Set minimal Y value of plot.

Parameters
[in]hWidget handle
[in]vNew minimal Y value
Returns
1 on success, 0 otherwise

◆ gui_graph_zoom()

uint8_t gui_graph_zoom ( gui_handle_p  h,
float  zoom,
float  x,
float  y 
)

Zoom widget display data.

Parameters
[in]hWidget handle
[in]zoomZoom coeficient. Use 2.0f to double zoom, use 0.5f to unzoom 2 times, etc.
[in]xX coordinate on plot where zoom focus will apply. Valid value between 0 and 1 relative to width area. Use 0.5f to zoom into center area
[in]yY coordinate on plot where zoom focus will apply. Valid value between 0 and 1 relative to height area. Use 0.5f to zoom into center area
Returns
1 on success, 0 otherwise

◆ gui_graph_zoomreset()

uint8_t gui_graph_zoomreset ( gui_handle_p  h)

Reset zoom of widget.

Parameters
[in]hWidget handle
Returns
1 on success, 0 otherwise