GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
gp_widget_graph.h
Go to the documentation of this file.
1//SPDX-License-Identifier: LGPL-2.0-or-later
2
3/*
4
5 Copyright (c) 2014-2024 Cyril Hrubis <metan@ucw.cz>
6
7 */
8
25#ifndef GP_WIDGET_GRAPH_H
26#define GP_WIDGET_GRAPH_H
27
28#include <utils/gp_cbuffer.h>
31
57
62
68 double x;
70 double y;
71};
72
73struct gp_widget_graph {
74 gp_widget_size min_w;
75 gp_widget_size min_h;
76
77 const char *x_label;
78 const char *y_label;
79
80 long min_y_fixed:1;
81 long max_y_fixed:1;
82
83 /* Graph scaling window */
84 double min_x;
85 double max_x;
86 double min_y;
87 double max_y;
88
89 /* Graph data */
90 enum gp_widget_graph_style graph_style;
91 enum gp_widgets_color color;
92 gp_cbuffer data_idx;
93 struct gp_widget_graph_point *data;
94};
95
108 const char *x_label, const char *y_label,
109 size_t max_data_points);
110
121void gp_widget_graph_point_add(gp_widget *self, double x, double y);
122
130
140void gp_widget_graph_yrange_set(gp_widget *self, double min_y, double max_y);
141
150void gp_widget_graph_ymin_set(gp_widget *self, double min_y);
151
160void gp_widget_graph_ymax_set(gp_widget *self, double max_y);
161
170
178
179#endif /* GP_WIDGET_GRAPH_H */
Circular buffer indexing and iterators.
gp_widget_graph_style
A graph drawing style.
@ GP_WIDGET_GRAPH_LINE
Points connected by line.
@ GP_WIDGET_GRAPH_POINT
Point graph.
@ GP_WIDGET_GRAPH_FILL
Area below graph is filled.
@ GP_WIDGET_GRAPH_STYLE_MAX
Maximal number of styles.
gp_widget * gp_widget_graph_new(gp_widget_size min_w, gp_widget_size min_h, const char *x_label, const char *y_label, size_t max_data_points)
Allocates and initializes a new graph widget.
void gp_widget_graph_point_add(gp_widget *self, double x, double y)
Adds a graph point.
const char * gp_widget_graph_style_names[GP_WIDGET_GRAPH_STYLE_MAX]
A graph style names.
void gp_widget_graph_style_set(gp_widget *self, enum gp_widget_graph_style style)
Sets a graph style.
void gp_widget_graph_yrange_clear(gp_widget *self)
Clears graph y range.
void gp_widget_graph_ymin_set(gp_widget *self, double min_y)
Sets graph y minimum.
void gp_widget_graph_color_set(gp_widget *self, enum gp_widgets_color color)
Sets graph color.
void gp_widget_graph_yrange_set(gp_widget *self, double min_y, double max_y)
Sets graph y range.
void gp_widget_graph_ymax_set(gp_widget *self, double max_y)
Sets graph y maximum.
A widget size units.
Common widget types.
gp_widgets_color
Widget theme colors.
A circular buffer indexes.
Definition gp_cbuffer.h:19
double y
An y value.
double x
An x value.
A compound size.
A widget base.
Definition gp_widget.h:28