{"id":13700930,"url":"https://github.com/marianogappa/chart","last_synced_at":"2025-04-05T03:08:55.342Z","repository":{"id":64301631,"uuid":"66135810","full_name":"marianogappa/chart","owner":"marianogappa","description":"Quick \u0026 smart charting for STDIN","archived":false,"fork":false,"pushed_at":"2023-04-10T03:59:55.000Z","size":1881,"stargazers_count":545,"open_issues_count":9,"forks_count":27,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-02-14T22:32:50.797Z","etag":null,"topics":["chart","charting-library","chartjs","graphs"],"latest_commit_sha":null,"homepage":"https://marianogappa.github.io/chart/","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/marianogappa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-08-20T08:04:36.000Z","updated_at":"2024-01-04T16:07:01.000Z","dependencies_parsed_at":"2023-01-15T09:30:49.821Z","dependency_job_id":"1582e25b-f8bc-4cfb-9acc-d5ae9d835ab5","html_url":"https://github.com/marianogappa/chart","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marianogappa%2Fchart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marianogappa%2Fchart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marianogappa%2Fchart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marianogappa%2Fchart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marianogappa","download_url":"https://codeload.github.com/marianogappa/chart/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247280270,"owners_count":20912967,"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":["chart","charting-library","chartjs","graphs"],"created_at":"2024-08-02T20:01:09.267Z","updated_at":"2025-04-05T03:08:55.319Z","avatar_url":"https://github.com/marianogappa.png","language":"Go","funding_links":[],"categories":["Go","CLI Utilities"],"sub_categories":[],"readme":"# chart [![Build Status](https://img.shields.io/travis/marianogappa/chart.svg)](https://travis-ci.org/marianogappa/chart) [![Coverage Status](https://coveralls.io/repos/github/MarianoGappa/chart/badge.svg?branch=master)](https://coveralls.io/github/MarianoGappa/chart?branch=master) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/marianogappa/chart/master/LICENSE) [![Go Report Card](https://goreportcard.com/badge/github.com/marianogappa/chart?style=flat-square)](https://goreportcard.com/report/github.com/marianogappa/chart)\n\nQuick \u0026 smart charting for STDIN\n\n[Blogpost](https://movio.co/en/blog/improving-with-sql-and-charts/)\n\n![Chart example use](img/chart.gif?v=1)\n\n## Learn by example!\n\n[Cheatsheet](https://marianogappa.github.io/chart/)\n\n## Syntax\n\n```\nchart [options]\n```\n\n- `pie`: render a pie chart\n- `bar`: render a bar chart\n- `line`: render a line chart\n- `scatter`: render a scatter plot chart\n- `log`: use logarithmic scale (bar chart only)\n- `legacy-color`: use legacy colors\n- `gradient`: use color gradients\n- `' '|';'|','|'\\t'`: this character separates columns on each line (\\t = default)\n- `-t|--title`: title for the chart\n- `-x`: label for the x axis\n- `-y`: label for the y axis\n- `--date-format`: Sets the date format, according to [https://golang.org/src/time/format.go](https://golang.org/src/time/format.go)\n- `--debug`: Use to make sure to double-check the chart is showing what you expect.\n- `-h|--help`: Show help\n- `--zero-based`: Makes y-axis begin at zero\n\n## Installation\n\n```\ngo install github.com/marianogappa/chart@latest\n```\n\nor get the latest binary for your OS in the [Releases section](https://github.com/marianogappa/chart/v4/releases).\n\n## Example use cases\n\n- Pie chart of your most used terminal commands\n```\nhistory | awk '{print $2}' | chart\n```\n\n![Pie chart of your most used terminal commands](img/pie.png?v=1)\n\n- Bar chart of today's currency value against USD, in logarithmic scale\n```\ncurl -s http://api.fixer.io/latest?base=USD | jq -r \".rates | to_entries| \\\n    map(\\\"\\(.key)\\t\\(.value|tostring)\\\")|.[]\" | chart bar log -t \"Currency value against USD\"\n```\n\n![Bar chart of today's currency value against USD, in logarithmic scale](img/bar-log.png?v=1)\n\n- Bar chart of a Github user's lines of code per language (requires setting up an Access Token)\n```\nUSER=???\nACCESS_TOKEN=???\ncurl -u $USER:$ACCESS_TOKEN -s \"https://api.github.com/user/repos\" | \\\n    jq -r 'map(.languages_url) | .[]' | xargs curl -s -u $USER:$ACCESS_TOKEN | \\\n    jq -r '. as $in| keys[] | [.+ \" \"]+[$in[.] | tostring] | add' | \\\n    awk '{arr[$1]+=$2} END {for (i in arr) {print i,arr[i]}}' | \\\n    awk '{print $2 \"\\t\" $1}' | sort -nr | chart bar\n```\n\n![Bar chart of a Github user's lines of code per language (requires setting up an Access Token)](img/bar.png?v=1)\n\n- Line chart of the stargazers of this repo over time up to Jan 2017 (received some attention after the publication of [this](https://movio.co/blog/migrate-Scala-to-Go/) blogpost)\n```\ncurl -s \"https://api.github.com/repos/marianogappa/chart/stargazers?page=1\u0026per_page=100\" \\\n-H\"Accept: application/vnd.github.v3.star+json\" | \\\njq --raw-output 'map(.starred_at) | .[]' | awk '{print NR \"\\t\" $0}' | \\\nchart line --date-format 2006-01-02T15:04:05Z\n```\n\n![Line chart of Github stargazers of this repo over time](img/line.png?v-1)\n\n## Charting MySQL output\n\n`chart` works great with [sql](https://github.com/MarianoGappa/sql), or with any `mysql -Nsre '...'` query.\n\n## I don't trust the chart is correct\n\nMe neither. Add `--debug` to double-check (e.g. some rows could be being ignored due to parse failures, separator could be incorrect, column types could be inferred wrongly).\n\n```\n$ cat /tmp/c | ./chart bar --debug\nLines read  3\nLine format inferred    ff\nLines used  3\nFloat column count  2\nString column count 0\nDate/Time column count  0\nChart type  bar\nScale type  linear\nSeparator   [tab]\n```\n\n## Details\n\n- `chart` infers STDIN format by analysing line format on each line (doesn't infer separator though; defaults to `\\t`) and computing the winner format.\n- it uses the awesome [ChartJS](http://www.chartjs.org/) library to plot the charts.\n- when input data is string-only, `chart` infers a \"word frequency pie chart\" use case.\n- should work on Linux/Mac/Windows thanks to [open-golang](https://github.com/skratchdot/open-golang).\n\n## Known issues\n\n- Javascript's floating point messes up y-axis https://github.com/marianogappa/chart/v4/issues/15\n- No histogram support (ChartJS doesn't provide it) https://github.com/marianogappa/chart/v4/issues/22\n\n## Contribute\n\nPRs are greatly appreciated and are currently [being merged](https://github.com/marianogappa/chart/v4/pull/3).\nIf you have a use case that is not supported by `chart`, [I'd love to hear about it](https://github.com/marianogappa/chart/v4/issues), but if it's too complex I'd recommend you to try [gnuplot](http://www.gnuplot.info/).\n\n### Development\n\n- Requires Go version \u003e= 1.11 with module support for building and testing.\n\n- Requires [Goreleaser](https://goreleaser.com) for building and publishing releases.\n\n- See [Makefile](./Makefile) for build and test commands.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarianogappa%2Fchart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarianogappa%2Fchart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarianogappa%2Fchart/lists"}