Open markusressel opened 3 years ago
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.
@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 + "```"
}
@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!