2021-09-14 18:03:02 +08:00
[](https://travis-ci.com/tdulcet/Tables-and-Graphs)
2023-05-01 21:25:17 +08:00
[](https://github.com/tdulcet/Table-and-Graph-Libs/actions)
2019-01-04 17:29:55 +08:00
2023-05-11 22:03:53 +08:00
# Table and Graph Libraries
2019-01-04 17:29:55 +08:00
2022-02-01 23:20:23 +08:00
Console Table and Graph/Plot Libraries
2019-01-04 17:29:55 +08:00
Copyright © 2018 Teal Dulcet
2019-01-05 18:24:50 +08:00
These header only libraries use [box-drawing ](https://en.wikipedia.org/wiki/Box-drawing_character#Unicode ), [Braille ](https://en.wikipedia.org/wiki/Braille_Patterns ), [fraction ](https://en.wikipedia.org/wiki/Number_Forms ) and other Unicode characters and [terminal colors and formatting ](https://misc.flogisoft.com/bash/tip_colors_and_formatting ) to output tables and graphs/plots to the console. All the tables and graphs are created with a single (one) function call and they do not require any special data structures.
2019-01-04 17:29:55 +08:00
2022-07-14 16:33:38 +08:00
See the [python ](python ) directory for Python ports of the libraries.
2021-09-14 18:03:02 +08:00
❤️ Please visit [tealdulcet.com ](https://www.tealdulcet.com/ ) to support these libraries and my other software development.
2019-01-04 17:29:55 +08:00
2023-03-13 22:29:43 +08:00
## Table of Contents
* [Tables ](#tables )
* [Usage ](#usage )
* [Options ](#options )
* [Graphs/Plots ](#graphsplots )
* [Usage ](#usage-1 )
* [Options ](#options-1 )
* [Contributing ](#contributing )
2019-01-04 17:29:55 +08:00
## Tables
### Usage
2023-03-10 18:07:00 +08:00
Requires support for C++14. See the [tables.hpp ](tables.hpp ) file for full usage information.
2022-07-14 16:33:38 +08:00
2019-01-04 17:29:55 +08:00
Complete versions of all of the examples below and more can be found in the [tables.cpp ](tables.cpp ) file.
2022-07-14 16:33:38 +08:00
Compile with:
2023-03-10 21:15:01 +08:00
* GCC: `g++ -std=c++14 -Wall -g -O3 tables.cpp -o tables`
* Clang: `clang++ -std=c++14 -Wall -g -O3 tables.cpp -o tables`
2022-07-14 16:33:38 +08:00
Run with: `./tables`
2019-01-04 17:29:55 +08:00
#### Output char array as table
2022-07-14 16:33:38 +08:00
##### C style char array
2019-01-04 17:29:55 +08:00
```cpp
#include "tables.hpp"
using namespace std;
int main()
{
size_t rows = 5;
size_t columns = 5;
char ** *array;
// Allocate and set array
2022-07-14 16:33:38 +08:00
2022-07-14 16:44:17 +08:00
tables::options aoptions;
2019-01-04 17:29:55 +08:00
aoptions.headerrow = true;
aoptions.headercolumn = true;
2022-07-14 16:44:17 +08:00
tables::array(rows, columns, array, nullptr, nullptr, aoptions);
2019-01-04 17:29:55 +08:00
// Deallocate array
2022-07-14 16:33:38 +08:00
return 0;
}
```
##### C++ string array
```cpp
#include "tables.hpp"
using namespace std;
int main()
{
size_t rows = 5;
size_t columns = 5;
vector< vector < string > > array(rows, vector< string > (columns));
// Set array
string *headerrow = nullptr;
string *headercolumn = nullptr;
2022-07-14 16:44:17 +08:00
tables::options aoptions;
2022-07-14 16:33:38 +08:00
aoptions.headerrow = true;
aoptions.headercolumn = true;
2022-07-14 16:44:17 +08:00
tables::array(array, headerrow, headercolumn, aoptions);
2022-07-14 16:33:38 +08:00
2019-01-04 17:29:55 +08:00
return 0;
}
```
Table cells can contain [Unicode characters ](https://en.wikipedia.org/wiki/List_of_Unicode_characters ), but not newlines and tabs.

#### Output array as table with separate header row and column
2022-07-14 16:33:38 +08:00
##### C style char array
2019-01-04 17:29:55 +08:00
```cpp
#include "tables.hpp"
using namespace std;
int main()
{
size_t rows = 4;
size_t columns = 4;
2022-07-14 16:33:38 +08:00
2019-01-04 17:29:55 +08:00
const char* headerrow[] = {"Header row/column 1", "Header row 2", "Header row 3", "Header row 4", "Header row 5"};
const char* headercolumn[] = {"Header column 2", "Header column 3", "Header column 4", "Header column 5"};
char ** *array;
// Allocate and set array
2022-07-14 16:33:38 +08:00
2022-07-14 16:44:17 +08:00
tables::options aoptions;
2019-01-04 17:29:55 +08:00
aoptions.headerrow = true;
aoptions.headercolumn = true;
2022-07-14 16:44:17 +08:00
tables::array(rows, columns, array, headerrow, headercolumn, aoptions);
2019-01-04 17:29:55 +08:00
// Deallocate array
2022-07-14 16:33:38 +08:00
return 0;
}
```
##### C++ string array
```cpp
#include "tables.hpp"
using namespace std;
int main()
{
size_t rows = 5;
size_t columns = 5;
string headerrow[] = {"Header row/column 1", "Header row 2", "Header row 3", "Header row 4", "Header row 5"};
string headercolumn[] = {"Header column 2", "Header column 3", "Header column 4", "Header column 5"};
vector< vector < string > > array(rows, vector< string > (columns));
// Set array
2022-07-14 16:44:17 +08:00
tables::options aoptions;
2022-07-14 16:33:38 +08:00
aoptions.headerrow = true;
aoptions.headercolumn = true;
// or with C++20:
2022-07-14 16:44:17 +08:00
// tables::options aoptions{.headerrow = true, .headercolumn = true};
2022-07-14 16:33:38 +08:00
2022-07-14 16:44:17 +08:00
tables::array(array, headerrow, headercolumn, aoptions);
2022-07-14 16:33:38 +08:00
2019-01-04 17:29:55 +08:00
return 0;
}
```
Output same as example above.
#### Output array as table
2022-07-14 16:33:38 +08:00
##### C style pointer
2019-01-04 17:29:55 +08:00
```cpp
#include "tables.hpp"
using namespace std;
int main()
{
size_t rows = 5;
size_t columns = 5;
double **array; // array can be any data type
// Allocate and set array
2022-07-14 16:44:17 +08:00
tables::array(rows, columns, array);
2019-01-04 17:29:55 +08:00
// Deallocate array
2022-07-14 16:33:38 +08:00
return 0;
}
```
##### C++ array/vector
```cpp
#include "tables.hpp"
using namespace std;
int main()
{
size_t rows = 5;
size_t columns = 5;
vector< vector < double > > array(rows, vector< double > (columns)); // array can be any data type
// Set array
2022-07-14 16:44:17 +08:00
tables::array(array);
2022-07-14 16:33:38 +08:00
2019-01-04 17:29:55 +08:00
return 0;
}
```

#### Output sorted array as table
2022-07-14 16:33:38 +08:00
##### C style pointer
2019-01-04 17:29:55 +08:00
```cpp
#include <algorithm>
#include "tables.hpp"
using namespace std;
int dimensions; // Number of columns
int sortdimension; // Column to sort by
template < typename T >
2022-07-14 16:33:38 +08:00
bool compare(const T & a, const T & b)
2019-01-04 17:29:55 +08:00
{
if (a[sortdimension] == b[sortdimension])
for (int i = 0; i < dimensions ; + + i )
if (sortdimension != i and a[i] != b[i])
return a[i] < b [ i ] ;
return a[sortdimension] < b [ sortdimension ] ;
}
int main()
{
size_t rows = 5;
size_t columns = 5;
int **array; // array can be any data type
// Allocate and set array
2022-07-14 16:33:38 +08:00
2019-01-04 17:29:55 +08:00
dimensions = columns;
sortdimension = 0;
2022-07-14 16:33:38 +08:00
sort(array, array + rows, compare< int * > );
2022-07-14 16:44:17 +08:00
tables::array(rows, columns, array);
2019-01-04 17:29:55 +08:00
// Deallocate array
2022-07-14 16:33:38 +08:00
return 0;
}
```
##### C++ array/vector
```cpp
#include <algorithm>
#include "tables.hpp"
using namespace std;
int sortdimension; // Column to sort by
template < typename T >
bool compare(const T & a, const T & b)
{
if (a[sortdimension] == b[sortdimension])
2023-03-10 18:07:00 +08:00
for (int i = 0; i < tables::size ( a ) ; + + i )
2022-07-14 16:33:38 +08:00
if (sortdimension != i and a[i] != b[i])
return a[i] < b [ i ] ;
return a[sortdimension] < b [ sortdimension ] ;
}
int main()
{
size_t rows = 5;
size_t columns = 5;
vector< vector < int > > array(rows, vector< int > (columns)); // array can be any data type
// Set array
sortdimension = 0;
sort(array.begin(), array.end(), compare< vector < int > >);
2022-07-14 16:44:17 +08:00
tables::array(array);
2022-07-14 16:33:38 +08:00
2019-01-04 17:29:55 +08:00
return 0;
}
```

#### Output single function as table
2022-07-14 16:33:38 +08:00
##### C style function pointer
2019-01-04 17:29:55 +08:00
```cpp
#include "tables.hpp"
using namespace std;
double afunction(double x)
{
return x + 1;
}
int main()
{
double xmin = -10;
double xmax = 10;
2023-03-10 21:15:01 +08:00
double xstep = 0.5;
2022-07-14 16:33:38 +08:00
2022-07-14 16:44:17 +08:00
tables::options aoptions;
2019-01-04 17:29:55 +08:00
aoptions.headerrow = true;
2022-07-14 16:33:38 +08:00
2023-03-10 21:15:01 +08:00
tables::function(xmin, xmax, xstep, afunction, aoptions);
2022-07-14 16:33:38 +08:00
return 0;
}
```
##### C++ lambda function
```cpp
#include "tables.hpp"
using namespace std;
int main()
{
double xmin = -10;
double xmax = 10;
2023-03-10 21:15:01 +08:00
double xstep = 0.5;
2022-07-14 16:33:38 +08:00
function< double ( double ) > afunction = [](auto x)
{ return x + 1; };
2022-07-14 16:44:17 +08:00
tables::options aoptions;
2022-07-14 16:33:38 +08:00
aoptions.headerrow = true;
2023-03-10 21:15:01 +08:00
tables::function(xmin, xmax, xstep, afunction, aoptions);
2022-07-14 16:33:38 +08:00
2019-01-04 17:29:55 +08:00
return 0;
}
```

#### Output multiple functions as table
2022-07-14 16:33:38 +08:00
##### C style function pointer
2019-01-04 17:29:55 +08:00
```cpp
#include <cmath>
#include "tables.hpp"
using namespace std;
double function1(double x)
{
return 2 * x;
}
double function2(double x)
{
return pow(x, 2);
}
int main()
{
double xmin = -10;
double xmax = 10;
2023-03-10 21:15:01 +08:00
double xstep = 0.5;
2022-07-14 16:33:38 +08:00
2019-01-04 17:29:55 +08:00
size_t numfunctions = 2;
2022-07-14 16:33:38 +08:00
2019-01-04 17:29:55 +08:00
// Function parameter and return value can be any data type, as long as they are the same
2022-07-14 16:33:38 +08:00
function< double ( double ) > functions[] = {function1, function2};
2022-07-14 16:44:17 +08:00
tables::options aoptions;
2019-01-04 17:29:55 +08:00
aoptions.headerrow = true;
2022-07-14 16:33:38 +08:00
2023-03-10 21:15:01 +08:00
tables::functions(xmin, xmax, xstep, numfunctions, functions, aoptions);
2022-07-14 16:33:38 +08:00
return 0;
}
```
##### C++ lambda function
```cpp
#include <cmath>
#include "tables.hpp"
using namespace std;
int main()
{
double xmin = -10;
double xmax = 10;
2023-03-10 21:15:01 +08:00
double xstep = 0.5;
2022-07-14 16:33:38 +08:00
size_t numfunctions = 2;
// Function parameter and return value can be any data type, as long as they are the same
function< double ( double ) > functions[] = {[](auto x)
{ return 2 * x; },
[](auto x)
{ return pow(x, 2); }};
2022-07-14 16:44:17 +08:00
tables::options aoptions;
2022-07-14 16:33:38 +08:00
aoptions.headerrow = true;
2023-03-10 21:15:01 +08:00
tables::functions(xmin, xmax, xstep, numfunctions, functions, aoptions);
2022-07-14 16:33:38 +08:00
2019-01-04 17:29:55 +08:00
return 0;
}
```

### Options
#### Header row
2020-08-18 20:42:12 +08:00
Option: `headerrow` \
2019-01-04 17:29:55 +08:00
Default value: `false`
2021-09-14 18:03:02 +08:00
Header rows are bolded, centered and have a border.
2019-01-04 17:29:55 +08:00
#### Header column
2020-08-18 20:42:12 +08:00
Option: `headercolumn` \
2019-01-04 17:29:55 +08:00
Default value: `false`
2021-09-14 18:03:02 +08:00
Header columns are bolded, centered and have a border.
2019-01-04 17:29:55 +08:00
#### Table border
2020-08-18 20:42:12 +08:00
Option: `tableborder` \
2019-01-04 17:29:55 +08:00
Default value: `true`
#### Cell border
2020-08-18 20:42:12 +08:00
Option: `cellborder` \
2019-01-04 17:29:55 +08:00
Default value: `false`
#### Cell padding
2020-08-18 20:42:12 +08:00
Option: `padding` \
2019-01-04 17:29:55 +08:00
Default value: `1`
#### Alignment
2020-08-18 20:42:12 +08:00
Option: `alignment` \
2019-01-04 17:29:55 +08:00
Values:
2023-03-10 21:15:01 +08:00
* `nullptr`
2019-01-04 17:29:55 +08:00
* `left` (default)
* `right`
2023-03-10 21:15:01 +08:00
* `internal` (integer and floating-point types only)
2019-01-04 17:29:55 +08:00
#### bool to alpha
2020-08-18 20:42:12 +08:00
Option: `boolalpha` \
2019-01-04 17:29:55 +08:00
Default value: `false`
#### Title
2020-08-18 20:42:12 +08:00
Option: `title` \
2022-07-14 16:33:38 +08:00
Default value: `nullptr`
2019-01-04 17:29:55 +08:00
2023-03-13 22:29:43 +08:00
The title is output at the top of the table. It is word wrapped based on the current width of the terminal, using [this ](https://gist.github.com/tdulcet/819821ca69501822ad3f84a060c640a0 ) solution. Handles newlines, tabs and [Unicode characters ](https://en.wikipedia.org/wiki/List_of_Unicode_characters ).
2019-01-04 17:29:55 +08:00
#### Border style
2020-08-18 20:42:12 +08:00
Option: `style` \
2019-01-04 17:29:55 +08:00
Values:
2023-03-10 21:15:01 +08:00
0. `style_ASCII` : ASCII
2019-01-04 17:29:55 +08:00

2023-03-10 21:15:01 +08:00
1. `style_basic` : Basic
2019-01-04 17:29:55 +08:00

2023-03-10 21:15:01 +08:00
2. `style_light` : Light (default)
2019-01-04 17:29:55 +08:00

2023-03-10 21:15:01 +08:00
3. `style_heavy` : Heavy
2019-01-04 17:29:55 +08:00

2023-03-10 21:15:01 +08:00
4. `style_double` : Double
2019-01-04 17:29:55 +08:00

2023-03-10 21:15:01 +08:00
5. `style_light_dashed` : Light Dashed
2019-01-04 17:29:55 +08:00

2023-03-10 21:15:01 +08:00
6. `style_heavy_dashed` : Heavy Dashed
2019-01-04 17:29:55 +08:00

2023-03-10 21:15:01 +08:00
#### Check size
Option: `check` \
Default value: `true`
Check that the width of the table is not greater then the width of the terminal.
2019-01-04 17:29:55 +08:00
### Other C++ Console Tables Libraries
2019-01-05 18:24:50 +08:00
* [C++ Text Table ](https://github.com/haarcuba/cpp-text-table ) (must specify every cell individually in their data structure, limited options, no Unicode support, no header row or column support)
* [Cpp Console Table ](https://github.com/Oradle/CppConsoleTable ) (must specify every cell individually in their data structure, no Unicode support, no header row or column support)
* [ConsoleTable ](https://github.com/766F6964/ConsoleTable ) (requires C++11, must specify entire row at once in their data structure, no header column support)
2019-01-04 17:29:55 +08:00
## Graphs/Plots
### Usage
2023-03-10 18:07:00 +08:00
Requires support for C++14. See the [graphs.hpp ](graphs.hpp ) file for full usage information.
2022-07-14 16:33:38 +08:00
2019-01-04 17:29:55 +08:00
Complete versions of all of the examples below and more can be found in the [graphs.cpp ](graphs.cpp ) file.
2022-07-14 16:33:38 +08:00
Compile with:
2023-03-10 21:15:01 +08:00
* GCC: `g++ -std=c++14 -Wall -g -O3 graphs.cpp -o graphs`
* Clang: `clang++ -std=c++14 -Wall -g -O3 graphs.cpp -o graphs`
2019-01-04 17:29:55 +08:00
2022-07-14 16:33:38 +08:00
Run with: `./graphs`
2019-01-04 17:29:55 +08:00
If `height` is `0` , it will be set to the current height of the terminal (number of rows times four). If `width` is `0` , it will be set to the current width of the terminal (number of columns times two).
2022-07-14 16:33:38 +08:00
#### Output single array as plot
##### C style pointer
2019-01-04 17:29:55 +08:00
```cpp
#include "graphs.hpp"
using namespace std;
int main()
{
size_t height = 160;
size_t width = 160;
long double xmin = -20;
long double xmax = 20;
long double ymin = -20;
long double ymax = 20;
size_t rows = 10;
double **array; // array can be any data type, but must have exactly two columns
// Allocate and set array
2022-07-14 16:44:17 +08:00
graphs::array(height, width, xmin, xmax, ymin, ymax, rows, array);
2019-01-04 17:29:55 +08:00
// Deallocate array
2022-07-14 16:33:38 +08:00
return 0;
}
```
##### C++ array/vector
```cpp
#include "graphs.hpp"
using namespace std;
int main()
{
size_t height = 160;
size_t width = 160;
long double xmin = -20;
long double xmax = 20;
long double ymin = -20;
long double ymax = 20;
size_t rows = 10;
vector< vector < double > > array(rows, vector< double > (2)); // array can be any data type, but must have exactly two columns
// Set array
2022-07-14 16:44:17 +08:00
graphs::array(height, width, xmin, xmax, ymin, ymax, array);
2022-07-14 16:33:38 +08:00
2019-01-04 17:29:55 +08:00
return 0;
}
```
If `xmin` and `xmax` are both `0` , they will be set to the respective minimum and maximum values of x in the array. If `ymin` and `ymax` are both `0` , they will be set to the respective minimum and maximum values of y in the array.

2022-07-14 16:44:17 +08:00
Use `graphs::arrays()` to plot multiple arrays, which can be of different sizes.
2022-07-14 16:33:38 +08:00
2019-01-04 17:29:55 +08:00
#### Output single function as graph
2022-07-14 16:33:38 +08:00
##### C style function pointer
2019-01-04 17:29:55 +08:00
```cpp
#include "graphs.hpp"
using namespace std;
double afunction(double x)
{
return x + 1;
}
int main()
{
size_t height = 160;
size_t width = 160;
long double xmin = -20;
long double xmax = 20;
long double ymin = -20;
long double ymax = 20;
2022-07-14 16:44:17 +08:00
graphs::function(height, width, xmin, xmax, ymin, ymax, afunction);
2022-07-14 16:33:38 +08:00
return 0;
}
```
##### C++ lambda function
```cpp
#include "graphs.hpp"
using namespace std;
int main()
{
size_t height = 160;
size_t width = 160;
long double xmin = -20;
long double xmax = 20;
long double ymin = -20;
long double ymax = 20;
function< double ( double ) > afunction = [](auto x)
{ return x + 1; };
2022-07-14 16:44:17 +08:00
graphs::function(height, width, xmin, xmax, ymin, ymax, afunction);
2022-07-14 16:33:38 +08:00
2019-01-04 17:29:55 +08:00
return 0;
}
```

#### Output multiple functions as graph
2022-07-14 16:33:38 +08:00
##### C style function pointer
2019-01-04 17:29:55 +08:00
```cpp
#include "graphs.hpp"
using namespace std;
double function1(double x)
{
return 2 * x;
}
double function2(double x)
{
return pow(x, 2);
}
int main()
{
size_t height = 160;
size_t width = 160;
long double xmin = -20;
long double xmax = 20;
long double ymin = -20;
long double ymax = 20;
2022-07-14 16:33:38 +08:00
2019-01-04 17:29:55 +08:00
size_t numfunctions = 2;
2022-07-14 16:33:38 +08:00
2019-01-04 17:29:55 +08:00
// Function parameter and return value can be any data type, as long as they are the same
2022-07-14 16:33:38 +08:00
function< double ( double ) > functions[] = {function1, function2};
2022-07-14 16:44:17 +08:00
graphs::functions(height, width, xmin, xmax, ymin, ymax, numfunctions, functions);
2022-07-14 16:33:38 +08:00
return 0;
}
```
##### C++ lambda function
```cpp
#include "graphs.hpp"
using namespace std;
int main()
{
size_t height = 160;
size_t width = 160;
long double xmin = -20;
long double xmax = 20;
long double ymin = -20;
long double ymax = 20;
size_t numfunctions = 2;
// Function parameter and return value can be any data type, as long as they are the same
function< double ( double ) > functions[] = {[](auto x)
{ return 2 * x; },
[](auto x)
{ return pow(x, 2); }};
2022-07-14 16:44:17 +08:00
graphs::functions(height, width, xmin, xmax, ymin, ymax, numfunctions, functions);
2019-01-04 17:29:55 +08:00
return 0;
}
```

### Options
2023-03-13 22:29:43 +08:00
#### Border
2019-01-04 17:29:55 +08:00
2020-08-18 20:42:12 +08:00
Option: `border` \
2023-03-13 22:29:43 +08:00
Default value: `false`
#### Axis
Option: `axis` \
2019-01-04 17:29:55 +08:00
Default value: `true`
#### Axis labels
2020-08-18 20:42:12 +08:00
Option: `axislabel` \
2019-01-04 17:29:55 +08:00
Default value: `true`
2023-03-13 22:29:43 +08:00
Requires `axis` to be `true` .
2023-05-11 22:03:53 +08:00
#### Axis tick marks
2023-03-13 22:29:43 +08:00
Option: `axistick` \
Default value: `true`
2023-05-11 22:03:53 +08:00
Requires `axis` to be `true` .
2019-01-04 17:29:55 +08:00
#### Axis units labels
2020-08-18 20:42:12 +08:00
Option: `axisunitslabel` \
2019-01-04 17:29:55 +08:00
Default value: `true`
2023-05-11 22:03:53 +08:00
Requires `axis` and `axistick` to be `true` .
#### X-axis units format
Option: `xunits` \
Values:
1. `units_number` : Locale number format
2. `units_scale_none` : Locale number format with full precision
3. `units_scale_SI` : Auto-scale to the SI standard
4. `units_scale_IEC` : Auto-scale to the IEC standard
5. `units_scale_IEC_I` : Auto-scale to the IEC standard
6. `units_fracts` : Locale number format, but convert fractions and mathematical constants to Unicode characters (default)
6. `units_percent` : Percentage format
7. `units_date` : Locale date format
8. `units_time` : Locale time format
9. `units_monetary` : Locale monetary/currency format
Formats 2-5 are similar to the respective `--to` options with the [numfmt ](https://www.gnu.org/software/coreutils/manual/html_node/numfmt-invocation.html ) command from GNU Coreutils, but with [more precision ](https://github.com/tdulcet/Numbers-Tool#comparison-of---to-option ).
#### Y-axis units format
Option: `yunits` \
Values: Same as above.
2019-01-04 17:29:55 +08:00
#### Title
2020-08-18 20:42:12 +08:00
Option: `title` \
2022-07-14 16:33:38 +08:00
Default value: `nullptr`
2019-01-04 17:29:55 +08:00
2023-03-13 22:29:43 +08:00
The title is output at the top of the graph. It is word wrapped based on the current width of the terminal, using [this ](https://gist.github.com/tdulcet/819821ca69501822ad3f84a060c640a0 ) solution. Handles newlines, tabs and [Unicode characters ](https://en.wikipedia.org/wiki/List_of_Unicode_characters ).
2019-01-04 17:29:55 +08:00
#### Axis/Border style
2020-08-18 20:42:12 +08:00
Option: `style` \
2019-01-04 17:29:55 +08:00
Values:
2023-03-10 21:15:01 +08:00
0. `style_ASCII` : ASCII
2019-01-04 17:29:55 +08:00

2023-03-10 21:15:01 +08:00
1. `style_basic` : Basic
2019-01-04 17:29:55 +08:00

2023-03-10 21:15:01 +08:00
2. `style_light` : Light (default)
2019-01-04 17:29:55 +08:00

2023-03-10 21:15:01 +08:00
3. `style_heavy` : Heavy
2019-01-04 17:29:55 +08:00

2023-03-10 21:15:01 +08:00
4. `style_double` : Double
2019-01-04 17:29:55 +08:00

2023-03-10 21:15:01 +08:00
5. `style_light_dashed` : Light Dashed
2019-01-04 17:29:55 +08:00

2023-03-10 21:15:01 +08:00
6. `style_heavy_dashed` : Heavy Dashed
2019-01-04 17:29:55 +08:00

#### Graph/Plot Color
2020-08-18 20:42:12 +08:00
Option: `color` \
2019-01-04 17:29:55 +08:00
Values:
2023-03-10 21:15:01 +08:00
0. `color_default` : System default
1. `color_black` : Black
2. `color_red` : Red (default)
3. `color_green` : Green
4. `color_yellow` : Yellow
5. `color_blue` : Blue
2023-03-13 22:29:43 +08:00
6. `color_magenta` : Magenta
7. `color_cyan` : Cyan
8. `color_light_gray` : Light Gray
9. `color_dark_gray` : Dark Gray
10. `color_light_red` : Light Red
11. `color_light_green` : Light Green
12. `color_light_yellow` : Light Yellow
13. `color_light_blue` : Light Blue
14. `color_light_magenta` : Light Magenta
15. `color_light_cyan` : Light Cyan
16. `color_white` : White
2019-01-04 17:29:55 +08:00
See [here ](https://misc.flogisoft.com/bash/tip_colors_and_formatting#foreground_text ) for examples of the colors.
2023-03-13 22:29:43 +08:00
Only used when plotting a single array and when graphing a single function. When plotting multiple arrays or graphing multiple functions, colors 2 - 16 are used inorder. The system default color is used where the plots cross.
2019-01-04 17:29:55 +08:00
##### Plot

##### Graph

2023-03-10 21:15:01 +08:00
#### Check size
Option: `check` \
Default value: `true`
Check that the width and height of the graph are not greater then the respective width and height of the terminal.
2019-01-04 17:29:55 +08:00
### Other C++ Console Graphs/Plots Libraries
* [C++ terminal plotting library ](https://github.com/fbbdev/plot ) (requires C++14, based on [UnicodePlots.jl ](https://github.com/Evizero/UnicodePlots.jl ), no documentation and very difficult to use, although supports animations)
## Contributing
Pull requests welcome! Ideas for contributions:
2022-02-01 23:20:23 +08:00
Both:
2019-01-04 17:29:55 +08:00
* Add more options
2020-08-18 20:42:12 +08:00
* Add options to word wrap and truncate long text in table cells
2022-02-01 23:20:23 +08:00
* Add option to center text in table cells
2019-01-04 17:29:55 +08:00
* Add more examples
2023-03-13 22:29:43 +08:00
* Update screenshots of existing examples
2019-01-04 17:29:55 +08:00
* Improve the performance
2022-02-01 23:20:23 +08:00
* Handle newlines and tabs in the tables
2019-01-04 17:29:55 +08:00
* Handle formatted text in the table and graph/plot titles
* Support more graph/plot colors
2023-03-13 22:29:43 +08:00
* Support 256 and 24-bit color
* Support combining/blending colors when functions cross
2020-08-18 20:42:12 +08:00
* Update the `-t, --table` options of column command from [util-linux ](https://en.wikipedia.org/wiki/Util-linux ) to use the Table library
* Create a new CLI tool that uses the Graph library
2019-01-04 17:29:55 +08:00
* Port to other languages (C, Java, Rust, etc.)
2022-02-01 23:20:23 +08:00
C++:
2022-07-14 16:33:38 +08:00
* Support tables with the `wchar_t` , `char16_t` and `char32_t` C data types and the `wstring` , `u16string` and `u32string` C++ data types.