-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
Print X-Axis values #28
Comments
I second this, I'd absolutely love to be able to use X axis too. |
@guptarohit @medzernik Any updates on this issue? I need to have time values in the X-Axis. |
It's been a long while, but I remember going with my own date input. This is the code I used to sort of make it work with dates. I used this output in Discord and made sure the dates fit on various iOS devices as well as on the desktop: package covid_slovakia
import (
"github.com/guptarohit/asciigraph"
)
// PrintLineASCII Prints the actual chart, gets the data as well as the labelstring to put in.
func PrintLineASCII(data []float64, dateStringStart, dateStringEnd string) string {
graphLabel := NormalizeXAxis(dateStringStart, dateStringEnd)
var chart string
// The length 22 is the magical number for correct formatting on iPhones (tested on iPhone 11 Pro and iPhone SE 2020)
// that's why we wrap it around when it's bigger than that. Height is 15
chart = asciigraph.Plot(data, asciigraph.Width(22), asciigraph.Height(15), asciigraph.Caption(graphLabel))
return chart
}
// NormalizeXAxis Inserts the X axis-like line at least, since there is no X axis...
func NormalizeXAxis(startDate, endDate string) string {
return "―――――――――――――――――――――\n\t" + startDate + " <-> " + endDate
}
// GetGraphReadyForDiscordPrint Simplifies the printout for reuse
func GetGraphReadyForDiscordPrint(input string) string {
return "**\n```go\n" + input + "```"
} |
Thanks for the help @medzernik , I need to try this out, I am building a CLI app to plot my laptop's battery usage in the terminal. I am trying to visualize my battery level and cycle count with the help of the graph. https://github.com/neymarsabin/batterarch I will try this implementation, but may write my own graph library if I need some other graphs. |
Hi there, pretty awesome lib!
How complex would it be to add an option to print the x-axis in addition to the y-axis?
I want to use your library in my fan2go project to print fan curve data to console, and it would be very helpful for users to see the x-axis values (0-255).
Thx!
The text was updated successfully, but these errors were encountered: