### Install asciigraph library Source: https://github.com/guptarohit/asciigraph/blob/master/README.md Command to install the asciigraph Go package using the go get tool. ```bash go get -u github.com/guptarohit/asciigraph@latest ``` -------------------------------- ### Install CLI utility Source: https://github.com/guptarohit/asciigraph/blob/master/README.md Provides methods to install the asciigraph CLI utility via Go or Docker. ```bash go install github.com/guptarohit/asciigraph/cmd/asciigraph@latest ``` ```bash docker pull ghcr.io/guptarohit/asciigraph:latest ``` -------------------------------- ### Asciigraph CLI with Multiple Options Example Source: https://context7.com/guptarohit/asciigraph/llms.txt Demonstrates the usage of asciigraph CLI with various options to create a system metrics graph. It sets height, width, number of series, delimiters, colors, legends, caption, Y-axis bounds, and X-axis limits. ```bash cat data.csv | asciigraph -h 15 -w 80 -sn 3 -d "," -sc "red,green,blue" -sl "CPU,Memory,Disk" -c "System Metrics" -cc yellow -p 1 -lb 0 -ub 100 -xmin 0 -xmax 60 -xt 7 ``` -------------------------------- ### Running Asciigraph with Docker Source: https://github.com/guptarohit/asciigraph/blob/master/README.md Demonstrates how to use the asciigraph Docker image to plot data from stdin. This is useful for environments where installing the CLI tool directly is not feasible. ```bash seq 1 72 | docker run -i --rm ghcr.io/guptarohit/asciigraph -h 10 -c "plot data from stdin" -xmin 0 -xmax 40 -xt 5 ``` -------------------------------- ### Use Asciigraph CLI Source: https://context7.com/guptarohit/asciigraph/llms.txt Provides examples of using the command-line interface to pipe data into the tool for real-time terminal graphing. ```bash go install github.com/guptarohit/asciigraph/cmd/asciigraph@latest seq 1 30 | asciigraph -h 10 -c "Linear Growth" seq 1 50 | asciigraph -h 8 -xmin 0 -xmax 50 -xt 6 -c "Progress" echo -e "1,5\n2,4\n3,3\n4,2\n5,1" | asciigraph -sn 2 -sc "red,blue" -sl "Series A,Series B" -h 6 ``` -------------------------------- ### Asciigraph CLI Help and Basic Usage Source: https://github.com/guptarohit/asciigraph/blob/master/README.md Displays the help message for the asciigraph CLI, outlining available options for customizing graph appearance and behavior. It also shows a basic example of how to pipe data from a sequence command to asciigraph for plotting. ```bash > asciigraph --help Usage of asciigraph: asciigraph [options] Options: -ac axis color y-axis color of the plot -b buffer data points buffer when realtime graph enabled, default equal to `width` -c caption caption for the graph -cc caption color caption color of the plot -d delimiter data delimiter for splitting data points in the input stream (default ",") -f fps set fps to control how frequently graph to be rendered when realtime graph enabled (default 24) -h height height in text rows, 0 for auto-scaling -lb lower bound lower bound set the minimum value for the vertical axis (ignored if series contains lower values) (default +Inf) -lc label color y-axis label color of the plot -o offset offset in columns, for the label (default 3) -p precision precision of data point labels along the y-axis (default 2) -r realtime enables realtime graph for data stream -sc series colors comma-separated series colors corresponding to each series -sl series legends comma-separated series legends corresponding to each series -sn number of series number of series (columns) in the input data (default 1) -ub upper bound upper bound set the maximum value for the vertical axis (ignored if series contains larger values) (default -Inf) -w width width in columns, 0 for auto-scaling -xmax value x-axis maximum value (default NaN) -xmin value x-axis minimum value (default NaN) -xt tick count x-axis tick count (default 5, minimum 2) asciigraph expects data points from stdin. Invalid values are logged to stderr. ``` ```bash seq 1 72 | asciigraph -h 10 -c "plot data from stdin" -xmin 0 -xmax 40 -xt 5 ``` -------------------------------- ### Multi-Series Real-time Graph with Customization Source: https://github.com/guptarohit/asciigraph/blob/master/README.md Illustrates creating a multi-series real-time graph by combining data streams from multiple sources (e.g., pinging different domains). This example uses shell process substitution and pipes to feed two data series to asciigraph, specifying colors, legends, and dimensions. ```sh {unbuffer paste -d, <(ping -i 0.4 google.com | sed -u -n -E 's/.*time=(.*)ms.*/\1/p') <(ping -i 0.4 duckduckgo.com | sed -u -n -E 's/.*time=(.*)ms.*/\1/p') } | asciigraph -r -h 15 -w 60 -sn 2 -sc "blue,red" -c "Ping Latency Comparison" -sl "Google, DuckDuckGo" ``` -------------------------------- ### Create a basic ASCII line graph Source: https://github.com/guptarohit/asciigraph/blob/master/README.md Demonstrates how to plot a single series of float64 data points into an ASCII graph. ```go package main import ( "fmt" "github.com/guptarohit/asciigraph" ) func main() { data := []float64{3, 4, 9, 6, 2, 4, 5, 8, 5, 10, 2, 7, 2, 5, 6} graph := asciigraph.Plot(data) fmt.Println(graph) } ``` -------------------------------- ### Apply Styling with Caption and Colors Source: https://context7.com/guptarohit/asciigraph/llms.txt Demonstrates applying ANSI colors to graph elements and adding captions to provide context to the visualization. ```go package main import ( "fmt" "github.com/guptarohit/asciigraph" ) func main() { data := []float64{3, 4, 9, 6, 2, 4, 5, 8, 5, 10} graph := asciigraph.Plot(data, asciigraph.Height(6), asciigraph.Caption("Server Response Times (ms)"), asciigraph.CaptionColor(asciigraph.Yellow), asciigraph.AxisColor(asciigraph.DarkGray), asciigraph.LabelColor(asciigraph.Cyan), asciigraph.SeriesColors(asciigraph.Green), ) fmt.Println(graph) } ``` -------------------------------- ### Real-time Graph from Stdin Data Stream Source: https://github.com/guptarohit/asciigraph/blob/master/README.md Shows how to generate a real-time graph by piping data from a continuous stream, such as network ping results, to asciigraph. The `-r` flag enables real-time mode, and options control graph dimensions and captions. ```sh ping -i.2 google.com | grep -oP '(?<=time=).*(?=ms)' --line-buffered | asciigraph -r -h 10 -w 40 -c "realtime plot data (google ping in ms) from stdin" ``` -------------------------------- ### Multi-series Real-time Graph with Different Colors Source: https://context7.com/guptarohit/asciigraph/llms.txt Creates a real-time graph displaying network latency for both Google and Cloudflare simultaneously. It uses different colors (green for Google, red for Cloudflare) and legends for each series. ```bash paste -d, <(ping -i 0.4 google.com | sed -u -n 's/.*time=\(.*\)ms.*/\1/p') <(ping -i 0.4 cloudflare.com | sed -u -n 's/.*time=\(.*\)ms.*/\1/p') | asciigraph -r -h 12 -w 50 -sn 2 -sc "green,red" -sl "Google,Cloudflare" ``` -------------------------------- ### Render colored graphs Source: https://github.com/guptarohit/asciigraph/blob/master/README.md Creates a multi-series graph with assigned colors for each series. ```go package main import ( "fmt" "github.com/guptarohit/asciigraph" "math" ) func main() { data := make([][]float64, 4) for i := 0; i < 4; i++ { for x := -20; x <= 20; x++ { v := math.NaN() if r := 20 - i; x >= -r && x <= r { v = math.Sqrt(math.Pow(float64(r), 2)-math.Pow(float64(x), 2)) / 2 } data[i] = append(data[i], v) } } graph := asciigraph.PlotMany(data, asciigraph.Precision(0), asciigraph.SeriesColors( asciigraph.Red, asciigraph.Yellow, asciigraph.Green, asciigraph.Blue, )) fmt.Println(graph) } ``` -------------------------------- ### Customize Series Characters with SeriesChars Source: https://context7.com/guptarohit/asciigraph/llms.txt Demonstrates how to use CreateCharSet for uniform characters or the CharSet struct for fine-grained control over plot symbols. ```go package main import ( "fmt" "math" "github.com/guptarohit/asciigraph" ) func main() { data1 := make([]float64, 30) data2 := make([]float64, 30) for i := range data1 { data1[i] = math.Sin(float64(i)*0.2)*5 + 10 data2[i] = math.Cos(float64(i)*0.2)*3 + 10 } graph := asciigraph.PlotMany( [][]float64{data1, data2}, asciigraph.Height(10), asciigraph.SeriesChars( asciigraph.CreateCharSet("*"), asciigraph.CreateCharSet("#"), ), asciigraph.SeriesColors(asciigraph.Red, asciigraph.Green), asciigraph.SeriesLegends("Stars (*)", "Hashes (#)"), ) fmt.Println(graph) asciiSet := asciigraph.CharSet{ Horizontal: "-", VerticalLine: "|", ArcDownRight: "/", ArcDownLeft: "\\", ArcUpRight: "\\", ArcUpLeft: "/", EndCap: "-", StartCap: "-", } graphASCII := asciigraph.Plot(data1[:15], asciigraph.Height(6), asciigraph.SeriesChars(asciiSet), asciigraph.Caption("ASCII-only output"), ) fmt.Println(graphASCII) } ``` -------------------------------- ### Real-time Network Latency Monitoring with Asciigraph Source: https://context7.com/guptarohit/asciigraph/llms.txt Monitors network latency by pinging a host every 0.5 seconds and displays the results in real-time using asciigraph. It extracts the time in milliseconds from the ping output and visualizes it. ```bash ping -i 0.5 google.com | grep -oP '(?<=time=).*(?=ms)' --line-buffered | asciigraph -r -h 10 -w 60 -c "Ping Latency (ms)" ``` -------------------------------- ### Add X-axis support Source: https://github.com/guptarohit/asciigraph/blob/master/README.md Configures an X-axis with a defined range and tick count for better data context. ```go package main import ( "fmt" "github.com/guptarohit/asciigraph" ) func main() { data := []float64{3, 4, 9, 6, 2, 4, 5, 8, 5, 10, 2, 7, 2, 5, 6} graph := asciigraph.Plot(data, asciigraph.XAxisRange(0, 14), asciigraph.XAxisTickCount(3), ) fmt.Println(graph) } ``` -------------------------------- ### Plot multiple data series Source: https://github.com/guptarohit/asciigraph/blob/master/README.md Shows how to plot multiple series of data on the same graph using PlotMany. ```go package main import ( "fmt" "github.com/guptarohit/asciigraph" ) func main() { data := [][]float64{{0, 1, 2, 3, 3, 3, 2, 0}, {5, 4, 2, 1, 4, 6, 6}} graph := asciigraph.PlotMany(data) fmt.Println(graph) } ``` -------------------------------- ### Set Axis Bounds with LowerBound and UpperBound Source: https://context7.com/guptarohit/asciigraph/llms.txt Shows how to enforce specific vertical axis ranges, ensuring the graph displays a fixed scale regardless of the input data range. ```go package main import ( "fmt" "github.com/guptarohit/asciigraph" ) func main() { data := []float64{5, 7, 3, 8, 6, 4, 9, 5} graph := asciigraph.Plot(data, asciigraph.Height(10), asciigraph.LowerBound(0), asciigraph.UpperBound(10), asciigraph.Caption("Fixed 0-10 range"), ) fmt.Println(graph) } ``` -------------------------------- ### Configure X-Axis Range and Ticks Source: https://context7.com/guptarohit/asciigraph/llms.txt The XAxisRange and XAxisTickCount options enable a labeled X-axis. XAxisRange defines the domain [min, max], while XAxisTickCount determines the number of tick marks displayed. ```go package main import ( "fmt" "github.com/guptarohit/asciigraph" ) func main() { data := []float64{3, 4, 9, 6, 2, 4, 5, 8, 5, 10, 2, 7, 2, 5, 6} graph := asciigraph.Plot(data, asciigraph.XAxisRange(0, 14), asciigraph.XAxisTickCount(5), ) fmt.Println(graph) } ``` -------------------------------- ### Add legends to colored graphs Source: https://github.com/guptarohit/asciigraph/blob/master/README.md Includes legends and a caption for multi-series colored graphs to improve readability. ```go package main import ( "fmt" "github.com/guptarohit/asciigraph" "math" ) func main() { data := make([][]float64, 3) for i := 0; i < 3; i++ { for x := -12; x <= 12; x++ { v := math.NaN() if r := 12 - i; x >= -r && x <= r { v = math.Sqrt(math.Pow(float64(r), 2)-math.Pow(float64(x), 2)) / 2 } data[i] = append(data[i], v) } } graph := asciigraph.PlotMany(data, asciigraph.Precision(0), asciigraph.SeriesColors(asciigraph.Red, asciigraph.Green, asciigraph.Blue), asciigraph.SeriesLegends("Red", "Green", "Blue"), asciigraph.Caption("Series with legends")) fmt.Println(graph) } ``` -------------------------------- ### Format Labels with Precision and Offset Source: https://context7.com/guptarohit/asciigraph/llms.txt Configures the decimal precision of Y-axis labels and the left margin width to accommodate label text. ```go package main import ( "fmt" "github.com/guptarohit/asciigraph" ) func main() { data := []float64{0.0012, 0.0045, 0.0023, 0.0067, 0.0034} graph := asciigraph.Plot(data, asciigraph.Height(5), asciigraph.Precision(4), asciigraph.Offset(5), asciigraph.Caption("High precision"), ) fmt.Println(graph) } ``` -------------------------------- ### Configure Graph Height in Go Source: https://context7.com/guptarohit/asciigraph/llms.txt The Height option controls the vertical size of the graph in text rows. Setting a positive integer forces the graph to fit within that height, while 0 enables auto-scaling based on data range. ```go package main import ( "fmt" "math" "github.com/guptarohit/asciigraph" ) func main() { data := make([]float64, 60) for i := range data { data[i] = 15 * math.Sin(float64(i)*((math.Pi*2)/30.0)) } graph := asciigraph.Plot(data, asciigraph.Height(10)) fmt.Println(graph) } ``` -------------------------------- ### Plot - Render Single Series Graph Source: https://context7.com/guptarohit/asciigraph/llms.txt Renders an ASCII line graph from a single slice of float64 values with optional customizations. ```APIDOC ## Plot(data []float64, options ...Option) string ### Description Renders an ASCII line graph from a single slice of float64 values. It accepts variadic options to customize height, width, precision, caption, colors, and axis formatting. ### Parameters #### Request Body - **data** ([]float64) - Required - A slice of numerical values to plot. - **options** (...Option) - Optional - Functional options for customization (e.g., Height, Width, Caption). ### Response - **Returns** (string) - The rendered ASCII graph string. ``` -------------------------------- ### Custom Plot Character with Asciigraph Source: https://context7.com/guptarohit/asciigraph/llms.txt Generates a sequence of numbers from 1 to 20 and visualizes them using asciigraph with a custom plot character '*'. ```bash seq 1 20 | asciigraph -h 8 -x "*" ``` -------------------------------- ### Plot Single Series Graph in Go Source: https://context7.com/guptarohit/asciigraph/llms.txt The Plot function renders an ASCII line graph from a single slice of float64 values. It supports customization via functional options like Height, Width, and Caption. ```go package main import ( "fmt" "github.com/guptarohit/asciigraph" ) func main() { data := []float64{3, 4, 9, 6, 2, 4, 5, 8, 5, 10, 2, 7, 2, 5, 6} graph := asciigraph.Plot(data, asciigraph.Height(8), asciigraph.Width(40), asciigraph.Caption("Sample Data"), ) fmt.Println(graph) } ``` -------------------------------- ### PlotMany - Render Multiple Series Graph Source: https://context7.com/guptarohit/asciigraph/llms.txt Renders ASCII line graphs with multiple data series overlaid on the same plot. ```APIDOC ## PlotMany(series [][]float64, options ...Option) string ### Description Renders ASCII line graphs with multiple data series overlaid on the same plot. Each series can have its own color, legend, and character set. ### Parameters #### Request Body - **series** ([][]float64) - Required - A slice of slices containing numerical data for each series. - **options** (...Option) - Optional - Functional options including SeriesColors and SeriesLegends. ### Response - **Returns** (string) - The rendered multi-series ASCII graph string. ``` -------------------------------- ### Set Graph Width with Interpolation Source: https://context7.com/guptarohit/asciigraph/llms.txt The Width option defines the horizontal dimension of the graph in columns. If the specified width differs from the data length, the library automatically interpolates the data points to fit. ```go package main import ( "fmt" "github.com/guptarohit/asciigraph" ) func main() { data := []float64{1, 5, 10, 8, 3, 7, 2, 9, 4, 6} graph := asciigraph.Plot(data, asciigraph.Width(30), asciigraph.Height(5), ) fmt.Println(graph) } ``` -------------------------------- ### Plot Multiple Series Graph in Go Source: https://context7.com/guptarohit/asciigraph/llms.txt The PlotMany function allows overlaying multiple data series on a single plot. It supports individual series colors, legends, and automatic padding for series of different lengths. ```go package main import ( "fmt" "github.com/guptarohit/asciigraph" ) func main() { series1 := []float64{0, 1, 2, 3, 3, 3, 2, 0} series2 := []float64{5, 4, 2, 1, 4, 6, 6} graph := asciigraph.PlotMany( [][]float64{series1, series2}, asciigraph.Height(6), asciigraph.SeriesColors(asciigraph.Blue, asciigraph.Red), asciigraph.SeriesLegends("Series A", "Series B"), asciigraph.Caption("Multi-series comparison"), ) fmt.Println(graph) } ``` -------------------------------- ### Height - Set Graph Height Source: https://context7.com/guptarohit/asciigraph/llms.txt Configures the vertical dimension of the graph in text rows. ```APIDOC ## Height(h int) Option ### Description Sets the graph's vertical dimension in text rows. If set to 0 or omitted, the height auto-scales based on the data range. ### Parameters #### Request Body - **h** (int) - Required - The number of rows for the graph height. ### Response - **Returns** (Option) - A functional option to be passed to Plot or PlotMany. ``` -------------------------------- ### Format Y-axis values Source: https://github.com/guptarohit/asciigraph/blob/master/README.md Customizes the Y-axis labels using YAxisValueFormatter to display human-readable units like GiB. ```go package main import ( "fmt" "github.com/guptarohit/asciigraph" ) func main() { data := []float64{ 30 * 1024 * 1024 * 1024, 70 * 1024 * 1024 * 1024, 2 * 1024 * 1024 * 1024, } graph := asciigraph.Plot(data, asciigraph.Height(5), asciigraph.Width(45), asciigraph.YAxisValueFormatter(func(v float64) string { return fmt.Sprintf("%.2f GiB", v/1024/1024/1024) }), ) fmt.Println(graph) } ``` -------------------------------- ### Apply ANSI Colors to Series Source: https://context7.com/guptarohit/asciigraph/llms.txt The SeriesColors option allows assigning specific ANSI colors to different data series. The library supports over 140 named colors, making it easy to distinguish between multiple lines in a single plot. ```go package main import ( "fmt" "math" "github.com/guptarohit/asciigraph" ) func main() { data1 := make([]float64, 40) data2 := make([]float64, 40) for i := range data1 { data1[i] = 10 * math.Sin(float64(i)*0.2) data2[i] = 10 * math.Cos(float64(i)*0.2) } graph := asciigraph.PlotMany( [][]float64{data1, data2}, asciigraph.Height(8), asciigraph.SeriesColors(asciigraph.Red, asciigraph.Blue), asciigraph.SeriesLegends("Sine", "Cosine"), asciigraph.Caption("Trigonometric Functions"), ) fmt.Println(graph) } ``` -------------------------------- ### Customize Y-Axis Labels Source: https://context7.com/guptarohit/asciigraph/llms.txt The YAxisValueFormatter option allows developers to provide a custom function to format Y-axis labels. This is useful for converting raw data values into human-readable formats like units or percentages. ```go package main import ( "fmt" "github.com/guptarohit/asciigraph" ) func main() { data := []float64{ 30 * 1024 * 1024 * 1024, 70 * 1024 * 1024 * 1024, 45 * 1024 * 1024 * 1024, 2 * 1024 * 1024 * 1024, } graph := asciigraph.Plot(data, asciigraph.Height(5), asciigraph.Width(40), asciigraph.YAxisValueFormatter(func(v float64) string { return fmt.Sprintf("%.1f GiB", v/1024/1024/1024) }), ) fmt.Println(graph) } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.