{"id":13393610,"url":"https://github.com/guptarohit/asciigraph","last_synced_at":"2025-05-12T13:27:39.520Z","repository":{"id":37752889,"uuid":"137647094","full_name":"guptarohit/asciigraph","owner":"guptarohit","description":"Go package to make lightweight ASCII line graph ╭┈╯ in command line apps with no other dependencies.","archived":false,"fork":false,"pushed_at":"2024-10-26T07:43:10.000Z","size":144,"stargazers_count":2808,"open_issues_count":11,"forks_count":103,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-04-23T17:04:45.500Z","etag":null,"topics":["ascii-chart","asciigraph","chart","charting-library","cli","command-line","command-line-tool","go","golang","golang-library","graph","line-chart","plot","terminal","utility"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/guptarohit/asciigraph","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guptarohit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"guptarohit","patreon":"rohitgupta","ko_fi":"rohitgupta","custom":["https://www.buymeacoffee.com/rohitgupta"]}},"created_at":"2018-06-17T10:37:16.000Z","updated_at":"2025-04-23T07:43:44.000Z","dependencies_parsed_at":"2024-01-03T00:56:31.057Z","dependency_job_id":"b6f79c40-41e0-45e1-988b-bdf9a0788e4b","html_url":"https://github.com/guptarohit/asciigraph","commit_stats":{"total_commits":97,"total_committers":15,"mean_commits":6.466666666666667,"dds":0.6701030927835052,"last_synced_commit":"956e426471c5749a21f9fd47388d9be18d79c626"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guptarohit%2Fasciigraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guptarohit%2Fasciigraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guptarohit%2Fasciigraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guptarohit%2Fasciigraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guptarohit","download_url":"https://codeload.github.com/guptarohit/asciigraph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253747184,"owners_count":21957710,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ascii-chart","asciigraph","chart","charting-library","cli","command-line","command-line-tool","go","golang","golang-library","graph","line-chart","plot","terminal","utility"],"created_at":"2024-07-30T17:00:56.917Z","updated_at":"2025-05-12T13:27:39.493Z","avatar_url":"https://github.com/guptarohit.png","language":"Go","funding_links":["https://github.com/sponsors/guptarohit","https://patreon.com/rohitgupta","https://ko-fi.com/rohitgupta","https://www.buymeacoffee.com/rohitgupta"],"categories":["Misc","开源类库","Go","Command Line","Open source library","命令行","Tools","高级控制台UI","Members","Build Automation","Repositories","高级控制台UI`用于构建控制台应用程序和控制台用户界面的库.`"],"sub_categories":["命令行","Advanced Console UIs","Command Line","高级控制台用户界面","标准 CLI"],"readme":"# asciigraph\n\n[![Build status][]][1] [![Go Report Card][]][2] [![Coverage Status][]][3] [![GoDoc][]][4] [![License][]][5] [![Mentioned in Awesome Go][]][6]\n\nGo package to make lightweight ASCII line graphs ╭┈╯.\n\n![image][]\n\n## Installation\n```bash\ngo get -u github.com/guptarohit/asciigraph@latest\n```\n\n## Usage\n\n### Basic graph\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/guptarohit/asciigraph\"\n)\n\nfunc main() {\n    data := []float64{3, 4, 9, 6, 2, 4, 5, 8, 5, 10, 2, 7, 2, 5, 6}\n    graph := asciigraph.Plot(data)\n\n    fmt.Println(graph)\n}\n```\n\nRunning this example would render the following graph:\n```bash\n  10.00 ┤        ╭╮\n   9.00 ┤ ╭╮     ││\n   8.00 ┤ ││   ╭╮││\n   7.00 ┤ ││   ││││╭╮\n   6.00 ┤ │╰╮  ││││││ ╭\n   5.00 ┤ │ │ ╭╯╰╯│││╭╯\n   4.00 ┤╭╯ │╭╯   ││││\n   3.00 ┼╯  ││    ││││\n   2.00 ┤   ╰╯    ╰╯╰╯\n```\n\n### Multiple Series\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/guptarohit/asciigraph\"\n)\n\nfunc main() {\n\tdata := [][]float64{{0, 1, 2, 3, 3, 3, 2, 0}, {5, 4, 2, 1, 4, 6, 6}}\n\tgraph := asciigraph.PlotMany(data)\n\n\tfmt.Println(graph)\n}\n```\n\nRunning this example would render the following graph:\n```bash\n 6.00 ┤    ╭─\n 5.00 ┼╮   │\n 4.00 ┤╰╮ ╭╯\n 3.00 ┤ │╭│─╮\n 2.00 ┤ ╰╮│ ╰╮\n 1.00 ┤╭╯╰╯  │\n 0.00 ┼╯     ╰\n```\n\n### Colored graphs\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/guptarohit/asciigraph\"\n)\n\nfunc main() {\n\tdata := make([][]float64, 4)\n\n\tfor i := 0; i \u003c 4; i++ {\n\t\tfor x := -20; x \u003c= 20; x++ {\n\t\t\tv := math.NaN()\n\t\t\tif r := 20 - i; x \u003e= -r \u0026\u0026 x \u003c= r {\n\t\t\t\tv = math.Sqrt(math.Pow(float64(r), 2)-math.Pow(float64(x), 2)) / 2\n\t\t\t}\n\t\t\tdata[i] = append(data[i], v)\n\t\t}\n\t}\n\tgraph := asciigraph.PlotMany(data, asciigraph.Precision(0), asciigraph.SeriesColors(\n\t\tasciigraph.Red,\n\t\tasciigraph.Yellow,\n\t\tasciigraph.Green,\n\t\tasciigraph.Blue,\n\t))\n\n\tfmt.Println(graph)\n}\n```\n\nRunning this example would render the following graph:\n\n![colored_graph_image][]\n\n### Legends for colored graphs\n\nThe graph can include legends for each series, making it easier to interpret.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/guptarohit/asciigraph\"\n\t\"math\"\n)\n\nfunc main() {\n\tdata := make([][]float64, 3)\n\tfor i := 0; i \u003c 3; i++ {\n\t\tfor x := -12; x \u003c= 12; x++ {\n\t\t\tv := math.NaN()\n\t\t\tif r := 12 - i; x \u003e= -r \u0026\u0026 x \u003c= r {\n\t\t\t\tv = math.Sqrt(math.Pow(float64(r), 2)-math.Pow(float64(x), 2)) / 2\n\t\t\t}\n\t\t\tdata[i] = append(data[i], v)\n\t\t}\n\t}\n\tgraph := asciigraph.PlotMany(data,\n\t\tasciigraph.Precision(0),\n\t\tasciigraph.SeriesColors(asciigraph.Red, asciigraph.Green, asciigraph.Blue),\n\t\tasciigraph.SeriesLegends(\"Red\", \"Green\", \"Blue\"),\n\t\tasciigraph.Caption(\"Series with legends\"))\n\tfmt.Println(graph)\n}\n```\nRunning this example would render the following graph:\n\n![graph_with_legends_image][]\n\n\n## CLI Installation\n\nThis package also brings a small utility for command line usage.\n\nAssuming `$GOPATH/bin` is in your `$PATH`, install CLI with following command:\n```bash\ngo install github.com/guptarohit/asciigraph/cmd/asciigraph@latest\n```\n\nor pull Docker image:\n```bash\ndocker pull ghcr.io/guptarohit/asciigraph:latest\n```\n\nor download binaries from the [releases][] page.\n\n\n## CLI Usage\n\n```bash                                                                                                                ✘ 0|125  16:19:23\n\u003e asciigraph --help\nUsage of asciigraph:\n  asciigraph [options]\nOptions:\n  -ac axis color\n    \ty-axis color of the plot\n  -b buffer\n    \tdata points buffer when realtime graph enabled, default equal to `width`\n  -c caption\n    \tcaption for the graph\n  -cc caption color\n    \tcaption color of the plot\n  -d delimiter\n    \tdata delimiter for splitting data points in the input stream (default \",\")\n  -f fps\n    \tset fps to control how frequently graph to be rendered when realtime graph enabled (default 24)\n  -h height\n    \theight in text rows, 0 for auto-scaling\n  -lb lower bound\n    \tlower bound set the minimum value for the vertical axis (ignored if series contains lower values) (default +Inf)\n  -lc label color\n    \ty-axis label color of the plot\n  -o offset\n    \toffset in columns, for the label (default 3)\n  -p precision\n    \tprecision of data point labels along the y-axis (default 2)\n  -r realtime\n    \tenables realtime graph for data stream\n  -sc series colors\n    \tcomma-separated series colors corresponding to each series\n  -sl series legends\n    \tcomma-separated series legends corresponding to each series\n  -sn number of series\n    \tnumber of series (columns) in the input data (default 1)\n  -ub upper bound\n    \tupper bound set the maximum value for the vertical axis (ignored if series contains larger values) (default -Inf)\n  -w width\n    \twidth in columns, 0 for auto-scaling\nasciigraph expects data points from stdin. Invalid values are logged to stderr.\n```\n\n\nFeed it data points via stdin:\n```bash\nseq 1 72 | asciigraph -h 10 -c \"plot data from stdin\"\n```\n\nor use Docker image:\n```bash\nseq 1 72 | docker run -i --rm ghcr.io/guptarohit/asciigraph -h 10 -c \"plot data from stdin\"\n```\n\nOutput:\n\n```bash\n 72.00 ┤                                                                  ╭────\n 64.90 ┤                                                           ╭──────╯\n 57.80 ┤                                                    ╭──────╯\n 50.70 ┤                                             ╭──────╯\n 43.60 ┤                                      ╭──────╯\n 36.50 ┤                              ╭───────╯\n 29.40 ┤                       ╭──────╯\n 22.30 ┤                ╭──────╯\n 15.20 ┤         ╭──────╯\n  8.10 ┤  ╭──────╯\n  1.00 ┼──╯\n                                  plot data from stdin\n```\n\n\nExample of **real-time graph** for data points stream via stdin:\n\n\u003ca href=\"https://asciinema.org/a/382383\" target=\"_blank\"\u003e\u003cimg width=\"500\" alt=\"Realtime graph for data points via stdin (google ping) using asciigraph\" src=\"https://asciinema.org/a/382383.svg\" /\u003e\u003c/a\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003ecommand for above graph\u003c/summary\u003e\n\n```sh\nping -i.2 google.com | grep -oP '(?\u003c=time=).*(?=ms)' --line-buffered | asciigraph -r -h 10 -w 40 -c \"realtime plot data (google ping in ms) from stdin\"\n```\n\u003c/details\u003e\n\n\nExample of **multi-series real-time graph** for data points stream via stdin:\n\n\u003ca href=\"https://asciinema.org/a/649906\" target=\"_blank\"\u003e\u003cimg width=\"500\" alt=\"Ping latency comparison: Google (Blue) vs. DuckDuckGo (Red) with asciigraph\" src=\"https://asciinema.org/a/649906.svg\" /\u003e\u003c/a\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003ecommand for above graph\u003c/summary\u003e\n\n```sh\n{unbuffer paste -d, \u003c(ping -i 0.4 google.com | sed -u -n -E 's/.*time=(.*)ms.*/\\1/p') \u003c(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\"\n```\n\u003c/details\u003e\n\n\n## Acknowledgement\n\nThis package started as golang port of [asciichart][].\n\n\n## Contributing\n\nFeel free to make a pull request! :octocat:\n\n\n[Build status]: https://github.com/guptarohit/asciigraph/actions/workflows/test.yml/badge.svg\n[1]: https://github.com/guptarohit/asciigraph/actions/workflows/test.yml\n[Go Report Card]: https://goreportcard.com/badge/github.com/guptarohit/asciigraph\n[2]: https://goreportcard.com/report/github.com/guptarohit/asciigraph\n[Coverage Status]: https://coveralls.io/repos/github/guptarohit/asciigraph/badge.svg?branch=master\n[3]: https://coveralls.io/github/guptarohit/asciigraph?branch=master\n[GoDoc]: https://godoc.org/github.com/guptarohit/asciigraph?status.svg\n[4]: https://godoc.org/github.com/guptarohit/asciigraph\n[License]: https://img.shields.io/badge/licence-BSD-blue.svg\n[5]: https://github.com/guptarohit/asciigraph/blob/master/LICENSE\n[Mentioned in Awesome Go]: https://awesome.re/mentioned-badge-flat.svg\n[6]: https://github.com/avelino/awesome-go#advanced-console-uis\n[image]: https://user-images.githubusercontent.com/7895001/41509956-b1b2b3d0-7279-11e8-9d19-d7dea17d5e44.png\n[colored_graph_image]: https://user-images.githubusercontent.com/7895001/166443444-40ad8113-2c0f-46d7-9c75-1cf08435ce15.png\n[releases]: https://github.com/guptarohit/asciigraph/releases\n[asciichart]: https://github.com/kroitor/asciichart\n[graph_with_legends_image]: https://github.com/guptarohit/asciigraph/assets/7895001/4066ee95-55ca-42a4-8a03-e73ce20df5d3\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguptarohit%2Fasciigraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguptarohit%2Fasciigraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguptarohit%2Fasciigraph/lists"}