FLTK 1.4.0
Loading...
Searching...
No Matches
Fl_Chart.H
Go to the documentation of this file.
1//
2// Fl_Chart widget header file for the Fast Light Tool Kit (FLTK).
3//
4// Copyright 1998-2023 by Bill Spitzak and others.
5//
6// This library is free software. Distribution and use rights are outlined in
7// the file "COPYING" which should have been included with this file. If this
8// file is missing or damaged, see the license at:
9//
10// https://www.fltk.org/COPYING.php
11//
12// Please see the following page on how to report bugs and issues:
13//
14// https://www.fltk.org/bugs.php
15//
16
21#ifndef Fl_Chart_H
22#define Fl_Chart_H
23
24#ifndef Fl_Widget_H
25#include "Fl_Widget.H"
26#endif
27
28// values for type()
29#define FL_BAR_CHART 0
30#define FL_HORBAR_CHART 1
31#define FL_LINE_CHART 2
32#define FL_FILL_CHART 3
33#define FL_SPIKE_CHART 4
34#define FL_PIE_CHART 5
35#define FL_SPECIALPIE_CHART 6
36
37#define FL_FILLED_CHART FL_FILL_CHART
38
39#define FL_CHART_MAX 128
40#define FL_CHART_LABEL_MAX 18
41
44 float val;
45 unsigned col;
47};
48
71class FL_EXPORT Fl_Chart : public Fl_Widget {
72 int numb;
73 int maxnumb;
74 int sizenumb;
75 FL_CHART_ENTRY *entries;
76 double min, max;
77 uchar autosize_;
78 Fl_Font textfont_;
79 Fl_Fontsize textsize_;
80 Fl_Color textcolor_;
81
82protected:
83 void draw() FL_OVERRIDE;
84
85 // (static) protected draw methods (STR 2022)
86 // these methods are documented in src/Fl_Chart.cxx
87
88 static void draw_barchart(int x, int y, int w, int h, int numb, FL_CHART_ENTRY entries[],
89 double min, double max, int autosize, int maxnumb, Fl_Color textcolor);
90
91 static void draw_horbarchart(int x, int y, int w, int h, int numb, FL_CHART_ENTRY entries[],
92 double min, double max, int autosize, int maxnumb,
93 Fl_Color textcolor);
94
95 static void draw_linechart(int type, int x, int y, int w, int h, int numb,
96 FL_CHART_ENTRY entries[], double min, double max, int autosize,
97 int maxnumb, Fl_Color textcolor);
98
99 static void draw_piechart(int x, int y, int w, int h, int numb, FL_CHART_ENTRY entries[],
100 int special, Fl_Color textcolor);
101
102public:
103 Fl_Chart(int X, int Y, int W, int H, const char *L = 0);
104
105 ~Fl_Chart();
106
107 void clear();
108
109 void add(double val, const char *str = 0, unsigned col = 0);
110
111 void insert(int ind, double val, const char *str = 0, unsigned col = 0);
112
113 void replace(int ind, double val, const char *str = 0, unsigned col = 0);
114
119 void bounds(double *a, double *b) const {
120 *a = min;
121 *b = max;
122 }
123
124 void bounds(double a, double b);
125
129 int size() const { return numb; }
130
138 void size(int W, int H) { Fl_Widget::size(W, H); }
139
143 int maxsize() const { return maxnumb; }
144
145 void maxsize(int m);
146
148 Fl_Font textfont() const { return textfont_; }
149
151 void textfont(Fl_Font s) { textfont_ = s; }
152
154 Fl_Fontsize textsize() const { return textsize_; }
155
157 void textsize(Fl_Fontsize s) { textsize_ = s; }
158
160 Fl_Color textcolor() const { return textcolor_; }
161
163 void textcolor(Fl_Color n) { textcolor_ = n; }
164
169 uchar autosize() const { return autosize_; }
170
175 void autosize(uchar n) { autosize_ = n; }
176};
177
178#endif
int Fl_Font
A font number is an index into the internal font table.
Definition Enumerations.H:1044
unsigned int Fl_Color
An FLTK color value; see also Colors
Definition Enumerations.H:1101
int Fl_Fontsize
Size of a font in pixels.
Definition Enumerations.H:1073
#define FL_CHART_LABEL_MAX
max label length for entry
Definition Fl_Chart.H:40
Fl_Widget and Fl_Label classes.
Fl_Chart displays simple charts.
Definition Fl_Chart.H:71
Fl_Color textcolor() const
Gets the chart's text color.
Definition Fl_Chart.H:160
int size() const
Returns the number of data values in the chart.
Definition Fl_Chart.H:129
void textfont(Fl_Font s)
Sets the chart's text font to s.
Definition Fl_Chart.H:151
void autosize(uchar n)
Sets whether the chart will automatically adjust the bounds of the chart.
Definition Fl_Chart.H:175
void size(int W, int H)
Sets the widget size (width, height).
Definition Fl_Chart.H:138
void bounds(double *a, double *b) const
Gets the lower and upper bounds of the chart values.
Definition Fl_Chart.H:119
void textsize(Fl_Fontsize s)
Sets the chart's text size to s.
Definition Fl_Chart.H:157
Fl_Font textfont() const
Gets the chart's text font.
Definition Fl_Chart.H:148
uchar autosize() const
Gets whether the chart will automatically adjust the bounds of the chart.
Definition Fl_Chart.H:169
int maxsize() const
Gets the maximum number of data values for a chart.
Definition Fl_Chart.H:143
void textcolor(Fl_Color n)
Sets the chart's text color to n.
Definition Fl_Chart.H:163
Fl_Fontsize textsize() const
Gets the chart's text size.
Definition Fl_Chart.H:154
Fl_Widget is the base class for all widgets in FLTK.
Definition Fl_Widget.H:104
virtual void draw()=0
Draws the widget.
void size(int W, int H)
Changes the size of the widget.
Definition Fl_Widget.H:410
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46
unsigned char uchar
unsigned char
Definition fl_types.h:30
For internal use only.
Definition Fl_Chart.H:43
float val
For internal use only.
Definition Fl_Chart.H:44
char str[FL_CHART_LABEL_MAX+1]
For internal use only.
Definition Fl_Chart.H:46
unsigned col
For internal use only.
Definition Fl_Chart.H:45