{"id":13475329,"url":"https://github.com/NimbleMarkets/ntcharts","last_synced_at":"2025-03-26T23:30:45.143Z","repository":{"id":230254067,"uuid":"765822855","full_name":"NimbleMarkets/ntcharts","owner":"NimbleMarkets","description":"Nimble Terminal Charts for the Golang BubbleTea framework and your TUIs","archived":false,"fork":false,"pushed_at":"2025-01-08T20:57:27.000Z","size":3840,"stargazers_count":379,"open_issues_count":4,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-19T20:12:37.254Z","etag":null,"topics":["bubbletea","charting","go","golang","graph","plot","tui"],"latest_commit_sha":null,"homepage":"https://nimble.markets","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NimbleMarkets.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2024-03-01T17:28:26.000Z","updated_at":"2025-03-18T14:49:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"2de0064a-4d23-439f-8fbf-56c74c8ce932","html_url":"https://github.com/NimbleMarkets/ntcharts","commit_stats":null,"previous_names":["nimblemarkets/ntcharts"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NimbleMarkets%2Fntcharts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NimbleMarkets%2Fntcharts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NimbleMarkets%2Fntcharts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NimbleMarkets%2Fntcharts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NimbleMarkets","download_url":"https://codeload.github.com/NimbleMarkets/ntcharts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245753845,"owners_count":20666822,"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":["bubbletea","charting","go","golang","graph","plot","tui"],"created_at":"2024-07-31T16:01:19.452Z","updated_at":"2025-03-26T23:30:45.126Z","avatar_url":"https://github.com/NimbleMarkets.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# ntcharts - Nimble Terminal Charts\n\n\u003cp\u003e\n    \u003ca href=\"https://github.com/NimbleMarkets/ntcharts/tags\"\u003e\u003cimg src=\"https://img.shields.io/github/tag/NimbleMarkets/ntcharts.svg\" alt=\"Latest Release\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://pkg.go.dev/github.com/NimbleMarkets/ntcharts?tab=doc\"\u003e\u003cimg src=\"https://godoc.org/github.com/golang/gddo?status.svg\" alt=\"GoDoc\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/NimbleMarkets/ntcharts/blob/main/CODE_OF_CONDUCT.md\"\u003e\u003cimg src=\"https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg\"  alt=\"Code Of Conduct\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n`ntcharts` is a Golang Terminal Charting library for the Bubble Tea Framework and other TUIs.\n\nWe supply many chart types within the glory of your terminal!  \n\n| Type | Description |\n| :-------- | :----- |\n| [Canvas](./examples/README.md#canvas) | A 2D grid to plot arbitrary runes, with [LipGloss](https://github.com/charmbracelet/lipgloss) for styling and [BubbleZone](https://github.com/lrstanley/bubblezone) for mousing.  It is the foundation for all the following charts. |\n| [Bar Chart](./examples/README.md#bar-chart) | Displays values as either horizontal rows or vertical columns. |\n| [Heat Map](./examples/README.md#heatmap) | Displays (x,y) values on a color-mapped heatmap. |\n| [Line Chart](./examples/README.md#lines) | Displays (X,Y) data points onto a 2D grid in various types of charts. |\n| [OHLC/Candle Chart](./examples/README.md#candlesticks) | Displays Open, High, Low, Close values as candlesticks. |\n| [Scatter Chart](./examples/README.md#scatter) | Plots abitrary runes onto (X,Y) coordinates. |\n| [Streamline Chart](./examples/README.md#streaming) | Displays a continuous a line moving across the Canvas from the right side to the left side. |\n| [Time Series Chart](./examples/README.md#time-series) | Displays lines with values on the Y axis and time values on the X axis. |\n| [Waveline Chart](./examples/README.md#wave-line) | A line chart that connects points in a wave pattern. |\n| [Sparkline](./examples/README.md#sparkline) | A small, simple visual of data chart for quick understanding. |\n\n## Quickstart Tutorial\n\nThis [tutorial](./examples/quickstart/README.md) creates a simple [Time Series Chart](./examples/README.md#time-series) with two data sets utilizing the Bubble Tea framework, Lip Gloss for styling and BubbleZone for mouse support.\n\n\u003ca href=\"./examples/quickstart/README.md\" alt=\"quickstart readme\"\u003e\u003cimg src=\"examples/quickstart/demo.gif\" alt=\"quickstart gif\" width='300'/\u003e\u003c/a\u003e\n\n## Usage\n\nSee the [`examples` folder](./examples/README.md) for code samples and visuals of each type.\n\n#### Canvas\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/NimbleMarkets/ntcharts/canvas\"\n    \"github.com/charmbracelet/lipgloss\"\n)\n\nfunc main() {\n    c := canvas.New(5, 2)\n    c.SetLinesWithStyle(\n        []string{\"hello\", \"world\"},\n        lipgloss.NewStyle().Foreground(lipgloss.Color(\"6\"))) // cyan\n\n    fmt.Println(c.View())\n}\n```\n\nThis example produces the following canvas with Lip Gloss foreground color:\n\n\u003cimg src=\"examples/usage/canvas.png\" alt=\"canvas png\" width='50'/\u003e\n\n#### Bar Chart\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/NimbleMarkets/ntcharts/barchart\"\n    \"github.com/charmbracelet/lipgloss\"\n)\n\nfunc main() {\n    d1 := barchart.BarData{\n        Label: \"A\",\n        Values: []barchart.BarValue{\n            {\"Item1\", 21.2, lipgloss.NewStyle().Foreground(lipgloss.Color(\"10\"))}}, // green\n    }\n    d2 := barchart.BarData{\n        Label: \"B\",\n        Values: []barchart.BarValue{\n            {\"Item1\", 15.2, lipgloss.NewStyle().Foreground(lipgloss.Color(\"9\"))}}, // red\n    }\n\n    bc := barchart.New(11, 10)\n    bc.PushAll([]barchart.BarData{d1, d2})\n    bc.Draw()\n\n    fmt.Println(bc.View())\n}\n```\n\nThis example produces the following bar chart with green and red bars:\n\n\u003cimg src=\"examples/usage/barchart.png\" alt=\"barchart png\" width='80'/\u003e\n\n#### Streamline Chart\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/NimbleMarkets/ntcharts/linechart/streamlinechart\"\n)\n\nfunc main() {\n    slc := streamlinechart.New(13, 10)\n    for _, v := range []float64{4, 6, 8, 10, 8, 6, 4, 2, 0, 2, 4} {\n        slc.Push(v)\n    }\n    slc.Draw()\n\n    fmt.Println(slc.View())\n}\n```\n\nThis example produces the following streamline chart:\n```\n  │  ╭╮      \n 8│  ││      \n  │ ╭╯╰╮     \n 6│ │  │     \n  │╭╯  ╰╮    \n 4├╯    ╰╮  ╭\n  │      │  │\n 2│      ╰╮╭╯\n  │       ││ \n 0│       ╰╯ \n```\n\n#### Time Series Chart\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"time\"\n    \"github.com/NimbleMarkets/ntcharts/linechart/timeserieslinechart\"\n)\n\nfunc main() {\n    tslc := timeserieslinechart.New(41, 10)\n    for i, v := range []float64{0, 4, 8, 10, 8, 4, 0, -4, -8, -10, -8, -4, 0} {\n        date := time.Now().Add(time.Hour * time.Duration(24*i))\n        tslc.Push(timeserieslinechart.TimePoint{date, v})\n    }\n    tslc.DrawBraille()\n\n    fmt.Println(tslc.View())\n}\n```\n\nThis example produces the following time series chart using braille runes starting with today's date:\n```\n 10│      ⣀⠤⠒⠉⠒⠤⡀                        \n   │    ⡠⠊      ⠈⠢⡀                      \n  5│  ⡠⠊          ⠈⠢⡀                    \n   │⡠⠊              ⠈⠑⢄                 ⢀\n  0│                   ⠑⡄              ⡔⠁\n   │                    ⠈⠢⡀          ⡠⠊  \n -5│                      ⠈⠢⡀      ⡠⠊    \n   │                        ⠈⠑⠢⢄⡠⠔⠊      \n-10└─────────────────────────────────────\n   '24 03/27   03/31   04/03   04/05     \n```\n\n#### Waveline Chart\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/NimbleMarkets/ntcharts/canvas\"\n    \"github.com/NimbleMarkets/ntcharts/linechart/wavelinechart\"\n)\n\nfunc main() {\n    wlc := wavelinechart.New(12, 10, wavelinechart.WithYRange(-3, 3))\n    wlc.Plot(canvas.Float64Point{1.0, 2.0})\n    wlc.Plot(canvas.Float64Point{3.0, -2.0})\n    wlc.Plot(canvas.Float64Point{5.0, 2.0})\n    wlc.Plot(canvas.Float64Point{7.0, -2.0})\n    wlc.Plot(canvas.Float64Point{9.0, 2.0})\n    wlc.Draw()\n\n    fmt.Println(wlc.View())\n}\n```\n\nThis example produces the following waveline chart:\n```\n 3│         \n  │╭╮  ╭╮  ╭\n 2│││  ││  │\n  │││  ││  │\n 0├╯╰╮╭╯╰╮╭╯\n  │  ││  ││ \n-2│  ││  ││ \n  │  ╰╯  ╰╯ \n-3└─────────\n  0 2 4 6    \n```\n\n#### Sparkline\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/NimbleMarkets/ntcharts/sparkline\"\n)\n\nfunc main() {\n    sl := sparkline.New(10, 5)\n    sl.PushAll([]float64{7.81, 3.82, 8.39, 2.06, 4.19, 4.34, 6.83, 2.51, 9.21, 1.3})\n    sl.Draw()\n\n    fmt.Println(sl.View())\n}\n```\n\nThis example produces the following sparkline:\n\n\u003cimg src=\"examples/usage/sparkline.png\" alt=\"sparkline png\" width='100'/\u003e\n\n#### Heat Map\n\nHeat Maps map values to colors on a 2D grid.  The following example creates a heatmap of the function `sin(sqrt(x^2 + y^2))`.   There are more examples in the [`examples` README](./examples/README.md#heatmap).\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\n\t\"github.com/NimbleMarkets/ntcharts/heatmap\"\n)\n\nfunc main() {\n\thm := heatmap.New(20, 20, heatmap.WithValueRange(0, 1))\n\thm.SetXYRange(-1, 1, -1, 1)\n\tfor x := float64(-1); x \u003c 1.0; x += 1.0 / float64(hm.GraphWidth()) {\n\t\tfor y := float64(-1); y \u003c 1.0; y += 1.0 / float64(hm.GraphHeight()) {\n\t\t\tval := math.Sin(math.Sqrt(x*x + y*y))\n\t\t\thm.Push(heatmap.NewHeatPoint(x, y, val))\n\t\t}\n\t}\n\thm.Draw()\n\tfmt.Println(hm.View())\n}\n```\n\nThis example [(source)](./examples/heatmap/simple/main.go) produces the following heatmap:\n\n\u003cimg src=\"examples/usage/heatmap.png\" alt=\"simple heatmap png\" width='100'/\u003e\n\n## Open Collaboration\n\nWe welcome contributions and feedback.  Please adhere to our [Code of Conduct](./CODE_OF_CONDUCT.md) when engaging our community.\n\n * [GitHub Issues](https://github.com/NimbleMarkets/ntcharts/issues)\n * [GitHub Pull Requests](https://github.com/NimbleMarkets/ntcharts/pulls)\n\n## Acknowledgements\n\nThanks to [Charm.sh](https://charm.sh) for making the command line glamorous and sharing [Bubble Tea](https://github.com/charmbracelet/bubbletea) and [Lip Gloss](https://github.com/charmbracelet/lipgloss) and more.  Thanks to [BubbleZone](https://github.com/lrstanley/bubblezone) for bringing the mouse support :mouse:.\n\nThanks also to [asciigraph](https://github.com/guptarohit/asciigraph), [ratatui](https://docs.rs/ratatui/latest/ratatui/index.html), and [termdash](https://github.com/mum4k/termdash) for inspiration.\n\n## License\n\nReleased under the [MIT License](https://en.wikipedia.org/wiki/MIT_License), see [LICENSE.txt](./LICENSE.txt).\n\nCopyright (c) 2024 [Neomantra Corp](https://www.neomantra.com).   \n\n----\nMade with :heart: and :fire: by the team behind [Nimble.Markets](https://nimble.markets).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNimbleMarkets%2Fntcharts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNimbleMarkets%2Fntcharts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNimbleMarkets%2Fntcharts/lists"}