-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Made Termgraph an API/Module and some new features #75
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Has this been merged? I'm very keen to use it as an imort module! |
Thanks @AdityaTaggar05 for the great contributions! 👍 |
Any way to change the numbers to integers instead of float, it seems to be the default type. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have made termgraph an API/module to use in other scripts and would like it to be merged with the base repository.
I have kept the structure very simple and anyone can easily extend upon it and add other types of charts to the module. Some other features have also been added.
I have made some changes in termgraph.py itself and the API/module code can be found in module.py (I know I am really bad at naming things)
Issues Handled: #27, #39, #47
Features Added:
API/Module:
Colors
It houses all the colours that can be used in termgraph
Args
The Args class is basically the same thing as passing args through the command line. You can pass args as keyword arguments or use update_args on an Args instance. Args are directly passed into Chart.
Data
The Data class merges the data, labels and categories all in one. I wasn't able to add normal_data to it as well cause the normalize function required 'width' parameter for which we needed the access to the args but they are only accessible by Chart.
So the only resolution was passing the args to data as well which didn't seem like a good idea. So took the normalize function and put it in Chart class. You can also visualize the data by just printing it or by using the str() function on it. It also has a property called dims (I was inspired by NumPy for this) which may or may not be helpful but I added it for future use.
Chart
The Chart class takes in the data and the args. It is drawn by using the draw() method. It is an abstract-ish class and has nothing special in it except for the _normalize() method which is the same as before and _print_header() method which prints the title and category names.
Horizontal Chart
It is derived off of the Chart class and the main reason for deriving the new chart off of this is that it contains the print_row function. I did so because no other chart required access to the function except for the ones which are horizontal.
I was only able to implement Bar Chart due to time limitations and my exams approaching and some other reasons.
Below is the example code for usage (it can also be found in example.py)