chart

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2016 License: MIT Imports: 16 Imported by: 0

README

chart Build Status Coverage Status GitHub license

Quick & smart charting for STDIN

Learn by example!

Cheatsheet

Syntax

chart [pie|bar|line|scatter|log|' '|';'|','|'\t'|-t %title%|--title %title%|-x %x_label%|-y %y_label%]
  • pie: render a pie chart
  • bar: render a bar chart
  • line: render a line chart
  • scatter: render a scatter plot chart
  • log: use logarithmmic scale (bar chart only)
  • ' '|';'|','|'\t': this character separates columns on each line (\t = default)
  • -t|--title: title for the chart
  • -x: label for the x axis
  • -y: label for the y axis

Installation

go get -u github.com/MarianoGappa/chart

or get the latest binary for your OS in the Releases section.

Example use cases

  • Pie chart of your most used terminal commands
history | awk '{print $2}' | chart

Pie chart of your most used terminal commands

  • Bar chart of today's currency value against USD, in logarithmic scale
curl -s http://api.fixer.io/latest?base=USD | jq -r ".rates | to_entries| \
    map(\"\(.key)\t\(.value|tostring)\")|.[]" | chart bar log -t "Currency value against USD"

Bar chart of today's currency value against USD, in logarithmic scale

  • Bar chart of a Github user's lines of code per language (requires setting up an Access Token)
USER=???
ACCESS_TOKEN=???
curl -u $USER:$ACCESS_TOKEN -s "https://api.github.com/user/repos" | \
    jq -r 'map(.languages_url) | .[]' | xargs curl -s -u $USER:$ACCESS_TOKEN | \
    jq -r '. as $in| keys[] | [.+ " "]+[$in[.] | tostring] | add' | \
    awk '{arr[$1]+=$2} END {for (i in arr) {print i,arr[i]}}' | \
    awk '{print $2 "\t" $1}' | sort -nr | chart bar

Bar chart of a Github user's lines of code per language (requires setting up an Access Token)

Charting MySQL output

chart works great with sql, or with any mysql -Nsre '...' query.

Details

  • chart is still experimental.
  • it infers STDIN format by analysing line format on each line (doesn't infer separator though; defaults to \t and accepts user overrides) and computing the winner format.
  • it uses the awesome ChartJS library to plot the charts.
  • when input data is string-only, chart infers a "word frequency pie chart" use case.
  • should work on Linux/Mac/Windows thanks to open-golang.

Contribute

Please.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL