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-2023 Cyril Hrubis <metan@ucw.cz>
6
7 */
8
14#ifndef GP_WIDGET_GRAPH_H
15#define GP_WIDGET_GRAPH_H
16
17#include <utils/gp_cbuffer.h>
18#include <widgets/gp_widget_types.h>
19#include <widgets/gp_widget_size_units.h>
20
34
39
44 double x, y;
45};
46
47struct gp_widget_graph {
48 gp_widget_size min_w;
49 gp_widget_size min_h;
50
51 const char *x_label;
52 const char *y_label;
53
54 long min_y_fixed:1;
55 long max_y_fixed:1;
56
57 /* Graph scaling window */
58 double min_x;
59 double max_x;
60 double min_y;
61 double max_y;
62
63 /* Graph data */
64 enum gp_widget_graph_style graph_style;
65 enum gp_widgets_color color;
66 gp_cbuffer data_idx;
67 struct gp_widget_graph_point *data;
68};
69
70gp_widget *gp_widget_graph_new(gp_widget_size min_w, gp_widget_size min_h,
71 const char *x_label, const char *y_label,
72 size_t max_data_points);
73
84void gp_widget_graph_point_add(gp_widget *self, double x, double y);
85
92void gp_widget_graph_style_set(gp_widget *self, enum gp_widget_graph_style style);
93
103void gp_widget_graph_yrange_set(gp_widget *self, double min_y, double max_y);
104
113void gp_widget_graph_ymin_set(gp_widget *self, double min_y);
114
123void gp_widget_graph_ymax_set(gp_widget *self, double max_y);
124
132void gp_widget_graph_yrange_clear(gp_widget *self);
133
140void gp_widget_graph_color_set(gp_widget *self, enum gp_widgets_color color);
141
142#endif /* GP_WIDGET_GRAPH_H */
Circular buffer indexing and iterators.
gp_widget_graph_style
A graph drawing style.
@ GP_WIDGET_GRAPH_LINE
@ GP_WIDGET_GRAPH_POINT
@ GP_WIDGET_GRAPH_FILL
@ GP_WIDGET_GRAPH_STYLE_MAX
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 circular buffer indexes.
Definition gp_cbuffer.h:19