mirror of
https://github.com/tdulcet/Table-and-Graph-Libs.git
synced 2025-05-05 21:41:12 +08:00
Updated Travis CI and README.
This commit is contained in:
parent
4598d5f040
commit
f0e9e1f0c3
@ -7,6 +7,8 @@ matrix:
|
|||||||
dist: xenial
|
dist: xenial
|
||||||
- os: linux
|
- os: linux
|
||||||
dist: bionic
|
dist: bionic
|
||||||
|
- os: linux
|
||||||
|
dist: focal
|
||||||
install:
|
install:
|
||||||
- sudo apt-get -yqq update
|
- sudo apt-get -yqq update
|
||||||
- sudo apt-get -yqq install cppcheck
|
- sudo apt-get -yqq install cppcheck
|
||||||
|
48
README.md
48
README.md
@ -230,44 +230,38 @@ int main()
|
|||||||
|
|
||||||
#### Header row
|
#### Header row
|
||||||
|
|
||||||
Option: `headerrow`
|
Option: `headerrow`\
|
||||||
|
|
||||||
Default value: `false`
|
Default value: `false`
|
||||||
|
|
||||||
Header rows are bolded and centered.
|
Header rows are bolded and centered.
|
||||||
|
|
||||||
#### Header column
|
#### Header column
|
||||||
|
|
||||||
Option: `headercolumn`
|
Option: `headercolumn`\
|
||||||
|
|
||||||
Default value: `false`
|
Default value: `false`
|
||||||
|
|
||||||
Header columns are bolded and centered.
|
Header columns are bolded and centered.
|
||||||
|
|
||||||
#### Table border
|
#### Table border
|
||||||
|
|
||||||
Option: `tableborder`
|
Option: `tableborder`\
|
||||||
|
|
||||||
Default value: `true`
|
Default value: `true`
|
||||||
|
|
||||||
#### Cell border
|
#### Cell border
|
||||||
|
|
||||||
Option: `cellborder`
|
Option: `cellborder`\
|
||||||
|
|
||||||
Default value: `false`
|
Default value: `false`
|
||||||
|
|
||||||
Requires `tableborder` to be `true`.
|
Requires `tableborder` to be `true`.
|
||||||
|
|
||||||
#### Cell padding
|
#### Cell padding
|
||||||
|
|
||||||
Option: `padding`
|
Option: `padding`\
|
||||||
|
|
||||||
Default value: `1`
|
Default value: `1`
|
||||||
|
|
||||||
#### Alignment
|
#### Alignment
|
||||||
|
|
||||||
Option: `alignment`
|
Option: `alignment`\
|
||||||
|
|
||||||
Values:
|
Values:
|
||||||
|
|
||||||
* `left` (default)
|
* `left` (default)
|
||||||
@ -275,22 +269,19 @@ Values:
|
|||||||
|
|
||||||
#### bool to alpha
|
#### bool to alpha
|
||||||
|
|
||||||
Option: `boolalpha`
|
Option: `boolalpha`\
|
||||||
|
|
||||||
Default value: `false`
|
Default value: `false`
|
||||||
|
|
||||||
#### Title
|
#### Title
|
||||||
|
|
||||||
Option: `title`
|
Option: `title`\
|
||||||
|
|
||||||
Default value: `NULL`
|
Default value: `NULL`
|
||||||
|
|
||||||
The title 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).
|
The title 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).
|
||||||
|
|
||||||
#### Border style
|
#### Border style
|
||||||
|
|
||||||
Option: `style`
|
Option: `style`\
|
||||||
|
|
||||||
Values:
|
Values:
|
||||||
|
|
||||||
0. ASCII
|
0. ASCII
|
||||||
@ -442,38 +433,33 @@ int main()
|
|||||||
|
|
||||||
#### Border/Axis
|
#### Border/Axis
|
||||||
|
|
||||||
Option: `border`
|
Option: `border`\
|
||||||
|
|
||||||
Default value: `true`
|
Default value: `true`
|
||||||
|
|
||||||
#### Axis labels
|
#### Axis labels
|
||||||
|
|
||||||
Option: `axislabel`
|
Option: `axislabel`\
|
||||||
|
|
||||||
Default value: `true`
|
Default value: `true`
|
||||||
|
|
||||||
Requires `border` to be `true`.
|
Requires `border` to be `true`.
|
||||||
|
|
||||||
#### Axis units labels
|
#### Axis units labels
|
||||||
|
|
||||||
Option: `axisunitslabel`
|
Option: `axisunitslabel`\
|
||||||
|
|
||||||
Default value: `true`
|
Default value: `true`
|
||||||
|
|
||||||
Requires `border` and `axislabel` to be `true`.
|
Requires `border` and `axislabel` to be `true`.
|
||||||
|
|
||||||
#### Title
|
#### Title
|
||||||
|
|
||||||
Option: `title`
|
Option: `title`\
|
||||||
|
|
||||||
Default value: `NULL`
|
Default value: `NULL`
|
||||||
|
|
||||||
The title 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).
|
The title 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).
|
||||||
|
|
||||||
#### Axis/Border style
|
#### Axis/Border style
|
||||||
|
|
||||||
Option: `style`
|
Option: `style`\
|
||||||
|
|
||||||
Values:
|
Values:
|
||||||
|
|
||||||
0. ASCII
|
0. ASCII
|
||||||
@ -500,8 +486,7 @@ Values:
|
|||||||
|
|
||||||
#### Graph/Plot Color
|
#### Graph/Plot Color
|
||||||
|
|
||||||
Option: `color`
|
Option: `color`\
|
||||||
|
|
||||||
Values:
|
Values:
|
||||||
|
|
||||||
0. System default
|
0. System default
|
||||||
@ -544,6 +529,7 @@ Pull requests welcome! Ideas for contributions:
|
|||||||
|
|
||||||
* Add more options
|
* Add more options
|
||||||
* Add an option to print a border around graphs/plots
|
* Add an option to print a border around graphs/plots
|
||||||
|
* Add options to word wrap and truncate long text in table cells
|
||||||
* Add more examples
|
* Add more examples
|
||||||
* Improve the performance
|
* Improve the performance
|
||||||
* Handle newlines, tabs and formatted text in the tables
|
* Handle newlines, tabs and formatted text in the tables
|
||||||
@ -551,4 +537,6 @@ Pull requests welcome! Ideas for contributions:
|
|||||||
* Support more graph/plot colors
|
* Support more graph/plot colors
|
||||||
* Support combining colors when functions cross
|
* Support combining colors when functions cross
|
||||||
* Support plotting multiple arrays of different sizes
|
* Support plotting multiple arrays of different sizes
|
||||||
|
* 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.)
|
* Port to other languages (C, Java, Rust, etc.)
|
||||||
|
45
graphs.hpp
45
graphs.hpp
@ -22,7 +22,7 @@ const char *const styles[][11] = {
|
|||||||
{"━", "┃", "┏", "┳", "┓", "┣", "╋", "┫", "┗", "┻", "┛"}, //Heavy
|
{"━", "┃", "┏", "┳", "┓", "┣", "╋", "┫", "┗", "┻", "┛"}, //Heavy
|
||||||
{"═", "║", "╔", "╦", "╗", "╠", "╬", "╣", "╚", "╩", "╝"}, //Double
|
{"═", "║", "╔", "╦", "╗", "╠", "╬", "╣", "╚", "╩", "╝"}, //Double
|
||||||
{"╌", "╎", "┌", "┬", "┐", "├", "┼", "┤", "└", "┴", "┘"}, //Light Dashed
|
{"╌", "╎", "┌", "┬", "┐", "├", "┼", "┤", "└", "┴", "┘"}, //Light Dashed
|
||||||
{"╍", "╏", "┏", "┳", "┓", "┣", "╋", "┫", "┗", "┻", "┛"} //Heavy Dashed
|
{"╍", "╏", "┏", "┳", "┓", "┣", "╋", "┫", "┗", "┻", "┛"} //Heavy Dashed
|
||||||
};
|
};
|
||||||
// {" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "}};//No border
|
// {" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "}};//No border
|
||||||
|
|
||||||
@ -181,35 +181,38 @@ size_t outputlabel(const long double label, ostringstream &strm)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!output and fmod(label, M_PI) == 0)
|
if (abs(label) >= DBL_EPSILON)
|
||||||
{
|
{
|
||||||
const char symbol[] = "π";
|
if (!output and fmod(label, M_PI) == 0)
|
||||||
|
{
|
||||||
|
const char symbol[] = "π";
|
||||||
|
|
||||||
intpart = label / M_PI;
|
intpart = label / M_PI;
|
||||||
|
|
||||||
if (intpart == -1)
|
if (intpart == -1)
|
||||||
strm << "-";
|
strm << "-";
|
||||||
else if (intpart != 1)
|
else if (intpart != 1)
|
||||||
strm << intpart;
|
strm << intpart;
|
||||||
|
|
||||||
strm << symbol;
|
strm << symbol;
|
||||||
|
|
||||||
output = true;
|
output = true;
|
||||||
}
|
}
|
||||||
else if (!output and fmod(label, M_E) == 0)
|
else if (!output and fmod(label, M_E) == 0)
|
||||||
{
|
{
|
||||||
const char symbol[] = "e";
|
const char symbol[] = "e";
|
||||||
|
|
||||||
intpart = label / M_E;
|
intpart = label / M_E;
|
||||||
|
|
||||||
if (intpart == -1)
|
if (intpart == -1)
|
||||||
strm << "-";
|
strm << "-";
|
||||||
else if (intpart != 1)
|
else if (intpart != 1)
|
||||||
strm << intpart;
|
strm << intpart;
|
||||||
|
|
||||||
strm << symbol;
|
strm << symbol;
|
||||||
|
|
||||||
output = true;
|
output = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!output)
|
if (!output)
|
||||||
|
@ -19,7 +19,7 @@ const char *const styles[][11] = {
|
|||||||
{"━", "┃", "┏", "┳", "┓", "┣", "╋", "┫", "┗", "┻", "┛"}, //Heavy
|
{"━", "┃", "┏", "┳", "┓", "┣", "╋", "┫", "┗", "┻", "┛"}, //Heavy
|
||||||
{"═", "║", "╔", "╦", "╗", "╠", "╬", "╣", "╚", "╩", "╝"}, //Double
|
{"═", "║", "╔", "╦", "╗", "╠", "╬", "╣", "╚", "╩", "╝"}, //Double
|
||||||
{"╌", "╎", "┌", "┬", "┐", "├", "┼", "┤", "└", "┴", "┘"}, //Light Dashed
|
{"╌", "╎", "┌", "┬", "┐", "├", "┼", "┤", "└", "┴", "┘"}, //Light Dashed
|
||||||
{"╍", "╏", "┏", "┳", "┓", "┣", "╋", "┫", "┗", "┻", "┛"} //Heavy Dashed
|
{"╍", "╏", "┏", "┳", "┓", "┣", "╋", "┫", "┗", "┻", "┛"} //Heavy Dashed
|
||||||
};
|
};
|
||||||
// {" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "}};//No border
|
// {" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "}};//No border
|
||||||
|
|
||||||
@ -433,8 +433,7 @@ int table(const long double xmin, const long double xmax, const long double xscl
|
|||||||
const char *const aheaderrow[] = {"x", "y"};
|
const char *const aheaderrow[] = {"x", "y"};
|
||||||
// const char* const aheaderrow[] = {"", "x", "y"};
|
// const char* const aheaderrow[] = {"", "x", "y"};
|
||||||
|
|
||||||
char **headerrow = NULL;
|
char **headerrow = new char *[columns];
|
||||||
headerrow = new char *[columns];
|
|
||||||
|
|
||||||
for (unsigned int j = 0; j < columns; ++j)
|
for (unsigned int j = 0; j < columns; ++j)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user