Updated READMEs and screenshots.

This commit is contained in:
Teal Dulcet 2023-09-01 05:54:13 -07:00
parent 4b613fb9eb
commit 1ba69c803d
38 changed files with 65 additions and 14 deletions

View File

@ -11,14 +11,27 @@ These header only libraries use [box-drawing](https://en.wikipedia.org/wiki/Box-
See the [python](python) directory for Python ports of the libraries.
For command-line tools using these respective libraries, see the [Tables and Graphs CLI](https://github.com/tdulcet/Tables-and-Graphs-CLI).
❤️ Please visit [tealdulcet.com](https://www.tealdulcet.com/) to support these libraries and my other software development.
## Table of Contents
* [Tables](#tables)
* [Usage](#usage)
* [Output char array as table](#output-char-array-as-table)
* [Output array as table with separate header row and column](#output-array-as-table-with-separate-header-row-and-column)
* [Output array as table](#output-array-as-table)
* [Output sorted array as table](#output-sorted-array-as-table)
* [Output single function as table](#output-single-function-as-table)
* [Output multiple functions as table](#output-multiple-functions-as-table)
* [Options](#options)
* [Graphs/Plots](#graphsplots)
* [Usage](#usage-1)
* [Output array as histogram](#output-array-as-histogram)
* [Output single array as plot](#output-single-array-as-plot)
* [Output multiple arrays as plot](#output-single-array-as-plot)
* [Output single function as graph](#output-single-function-as-graph)
* [Output multiple functions as graph](#output-multiple-functions-as-graph)
* [Options](#options-1)
* [Contributing](#contributing)
@ -34,6 +47,8 @@ Compile with:
* GCC: `g++ -std=c++14 -Wall -g -O3 tables.cpp -o tables`
* Clang: `clang++ -std=c++14 -Wall -g -O3 tables.cpp -o tables`
Other compilers should work as well, but are not (yet) tested.
Run with: `./tables`
#### Output char array as table
@ -95,7 +110,7 @@ int main()
}
```
Table cells can contain [Unicode characters](https://en.wikipedia.org/wiki/List_of_Unicode_characters), but not newlines and tabs.
Table cells can contain [Unicode characters](https://en.wikipedia.org/wiki/List_of_Unicode_characters) and formatted text with [ANSI escape sequences](https://en.wikipedia.org/wiki/ANSI_escape_code), but not newlines and tabs.
![](images/char%20array%20to%20table.png)
@ -501,6 +516,7 @@ Values:
4. `style_double`: Double
![](images/double%20table.png)
5. `style_arc`: Light Arc
![](images/light%20arc%20table.png)
6. `style_light_dashed`: Light Dashed
![](images/light%20dashed%20table.png)
7. `style_heavy_dashed`: Heavy Dashed
@ -531,6 +547,8 @@ Compile with:
* GCC: `g++ -std=c++14 -Wall -g -O3 graphs.cpp -o graphs`
* Clang: `clang++ -std=c++14 -Wall -g -O3 graphs.cpp -o graphs`
Other compilers should work as well, but are not (yet) tested.
Run with: `./graphs`
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).
@ -599,6 +617,8 @@ int main()
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 resulting histogram.
![](images/array%20to%20histogram.png)
#### Output single array as plot
##### C style pointer
@ -860,7 +880,9 @@ Option: `type`\
Values:
1. `type_braille`: Braille (default)
![](images/type%20braille%20graph.png)
2. `type_block`: Block
![](images/type%20block%20graph.png)
The Braille type has the highest resolution of 2×4 pixels per character, while the block type uses 2×2. This option is only used for plots and graphs. Histograms use 1×8 pixels per character.
@ -870,8 +892,11 @@ Option: `mark`\
Values:
1. `mark_dot`: Dot (default)
![](images/mark%20dot%20graph.png)
2. `mark_plus`: Plus
![](images/mark%20plus%20graph.png)
3. `mark_square`: Square
![](images/mark%20square%20graph.png)
The dot mark type uses a single pixel per mark, the plus uses five pixels and the square uses eight pixels. This option is only used for plots and graphs.
@ -898,6 +923,7 @@ Values:
4. `style_double`: Double
![](images/double%20graph.png)
5. `style_arc`: Light Arc
![](images/light%20arc%20graph.png)
6. `style_light_dashed`: Light Dashed
![](images/light%20dashed%20graph.png)
7. `style_heavy_dashed`: Heavy Dashed
@ -926,9 +952,9 @@ Values:
15. `color_light_cyan`: Light Cyan
16. `color_white`: White
See [here](https://misc.flogisoft.com/bash/tip_colors_and_formatting#foreground_text) for examples of the colors.
See here for [examples of the colors](https://misc.flogisoft.com/bash/tip_colors_and_formatting#foreground_text).
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.
This option is 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.
##### Plot
@ -958,7 +984,6 @@ Both:
* Add options to word wrap and truncate long text in table cells
* Add option to center text in table cells
* Add more examples
* Update screenshots of existing examples
* Improve the performance
* Handle newlines and tabs in the tables
* Handle formatted text in the table and graph/plot titles
@ -966,8 +991,8 @@ Both:
* Support 256 and 24-bit color
* Support combining/blending colors when functions cross
* 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
* Port to other languages (C, Java, Rust, etc.)
C++:
* Update the CI to test with more compilers
* Support tables with the `wchar_t`, `char16_t` and `char32_t` C data types and the `wstring`, `u16string` and `u32string` C++ data types.

View File

@ -8,6 +8,7 @@
#include <array>
#include <vector>
#include <random>
#include "graphs.hpp"
using namespace std;

View File

@ -271,7 +271,7 @@ namespace graphs
// Adapted from: https://github.com/coreutils/coreutils/blob/master/src/numfmt.c
void outputunit(long double number, const units_type scale, ostringstream &strm)
{
unsigned int x = 0;
unsigned x = 0;
long double val = number;
if (val >= -LDBL_MAX and val <= LDBL_MAX)
{
@ -309,7 +309,7 @@ namespace graphs
break;
}
unsigned int power = 0;
unsigned power = 0;
if (number >= -LDBL_MAX and number <= LDBL_MAX)
{
while (abs(number) >= scale_base)
@ -329,7 +329,7 @@ namespace graphs
strm << setprecision(LDBL_DIG) << number;
string str = strm.str();
const unsigned int length = 5 + (number < 0 ? 1 : 0);
const unsigned length = 5 + (number < 0 ? 1 : 0);
if (str.length() > length)
{
const int prec = anumber < 10 ? 3 : anumber < 100 ? 2
@ -856,7 +856,7 @@ namespace graphs
vector<vector<unsigned short>> aaarray(width, vector<unsigned short>(height, 0));
const unsigned int acolor = color + 1;
const unsigned acolor = color + 1;
for (size_t x = 0; x < graphs::size(histogram); ++x)
{

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 17 KiB

BIN
images/light arc graph.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
images/light arc table.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 17 KiB

BIN
images/mark dot graph.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
images/mark plus graph.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 18 KiB

BIN
images/type block graph.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -1,9 +1,24 @@
## Table of Contents
* [Tables](#tables)
* [Usage](#usage)
* [Output str array as table](#output-str-array-as-table)
* [Output array as table with separate header row and column](#output-array-as-table-with-separate-header-row-and-column)
* [Output array as table](#output-array-as-table)
* [Output sorted array as table](#output-sorted-array-as-table)
* [Output single function as table](#output-single-function-as-table)
* [Output lambda function as table](#output-lambda-function-as-table)
* [Output multiple functions as table](#output-multiple-functions-as-table)
* [Output multiple lambda functions as table](#output-multiple-lambda-functions-as-table)
* [Options](#options)
* [Graphs/Plots](#graphsplots)
* [Usage](#usage-1)
* [Output array as histogram](#output-array-as-histogram)
* [Output single array as plot](#output-single-array-as-plot)
* [Output multiple arrays as plot](#output-single-array-as-plot)
* [Output single function as graph](#output-single-function-as-graph)
* [Output lambda function as graph](#output-lambda-function-as-graph)
* [Output multiple functions as graph](#output-multiple-functions-as-graph)
* [Output multiple lambda functions as graph](#output-multiple-lambda-functions-as-graph)
* [Options](#options-1)
## Tables
@ -32,7 +47,7 @@ import tables
tables.array(array, headerrow=True, headercolumn=True)
```
Table cells can contain [Unicode characters](https://en.wikipedia.org/wiki/List_of_Unicode_characters), but not newlines and tabs.
Table cells can contain [Unicode characters](https://en.wikipedia.org/wiki/List_of_Unicode_characters) and formatted text with [ANSI escape sequences](https://en.wikipedia.org/wiki/ANSI_escape_code), but not newlines and tabs.
![](../images/char%20array%20to%20table.png)
@ -215,6 +230,7 @@ Values:
4. `style_types.double`: Double
![](../images/double%20table.png)
5. `style_types.arc`: Light Arc
![](../images/light%20arc%20table.png)
6. `style_types.light_dashed`: Light Dashed
![](../images/light%20dashed%20table.png)
7. `style_types.heavy_dashed`: Heavy Dashed
@ -265,6 +281,8 @@ graphs.histogram(height, width, xmin, xmax, ymin, ymax, array)
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 resulting histogram.
![](../images/array%20to%20histogram.png)
#### Output single array as plot
```py
@ -440,7 +458,9 @@ Option: `type`\
Values:
1. `type_types.braille`: Braille (default)
![](../images/type%20braille%20graph.png)
2. `type_types.block`: Block
![](../images/type%20block%20graph.png)
The Braille type has the highest resolution of 2×4 pixels per character, while the block type uses 2×2. This option is only used for plots and graphs. Histograms use 1×8 pixels per character.
@ -450,8 +470,11 @@ Option: `mark`\
Values:
1. `mark_types.dot`: Dot (default)
![](../images/mark%20dot%20graph.png)
2. `mark_types.plus`: Plus
![](../images/mark%20plus%20graph.png)
3. `mark_types.square`: Square
![](../images/mark%20square%20graph.png)
The dot mark type uses a single pixel per mark, the plus uses five pixels and the square uses eight pixels. This option is only used for plots and graphs.
@ -478,6 +501,7 @@ Values:
4. `style_types.double`: Double
![](../images/double%20graph.png)
5. `style_types.arc`: Light Arc
![](../images/light%20arc%20graph.png)
6. `style_types.light_dashed`: Light Dashed
![](../images/light%20dashed%20graph.png)
7. `style_types.heavy_dashed`: Heavy Dashed
@ -506,9 +530,9 @@ Values:
15. `color_types.light_cyan`: Light Cyan
16. `color_types.white`: White
See [here](https://misc.flogisoft.com/bash/tip_colors_and_formatting#foreground_text) for examples of the colors.
See here for [examples of the colors](https://misc.flogisoft.com/bash/tip_colors_and_formatting#foreground_text).
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.
This option is 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.
##### Plot

View File

@ -9,6 +9,7 @@
#include <algorithm>
#include <array>
#include <vector>
#include "tables.hpp"
using namespace std;

View File

@ -52,7 +52,7 @@ namespace tables
bool headercolumn = false;
bool tableborder = true;
bool cellborder = false;
unsigned int padding = 1;
unsigned padding = 1;
ios_base &(*alignment)(ios_base &) = left;
bool boolalpha = false;
const char *title = nullptr;
@ -177,7 +177,7 @@ namespace tables
const bool headercolumn = aoptions.headercolumn;
const bool tableborder = aoptions.tableborder;
const bool cellborder = aoptions.cellborder;
const unsigned int padding = aoptions.padding;
const unsigned padding = aoptions.padding;
const char *const title = aoptions.title;
const style_type style = aoptions.style;