MyNixOS website logo
Description

Command-line utility to draw charts from input data easily.

Please see the README on GitHub at https://github.com/portnov/chart-cli#readme

chart-cli README

This repo provides a chart command-line utility. chart is aimed to generate basic 2D charts from command line easily.

The chart utility is not aimed to give full control over generated charts, or to generate all possible types of charts - you may anytime do that by use of gnuplot or Chart package. This utility, instead, gives you a very quick way of generating some most useful types of charts.

Usage example:

$ cat > input.txt
X	Y1	Y2
1	1	3
2	4	6
3	7	4
4	5	8
6	3	2
^D

$ chart --header -o lines.png input.txt

Result:

lines.png

Supported chart types for now are:

  • Line charts (the default one)
  • Bar charts (clustered and stacked)
  • Area charts
  • Point charts

Other chart types may be added later.

Supported output formats are:

  • PNG (the default one)
  • SVG
  • PS (PostScript)
  • PDF

Output file format is automatically detected by specified output file name. If output file name is not specified explicitly, chart.png will be used.

Expected input format

Input data are expected to be provided as a series of lines; each line may represent either one point to plot, or several points at the same X coordinate.

The first line may optionally represent names of the columns.

Other lines should consist of several numbers. Numbers are separated with a delimiter. Default delimiter is TAB characater; you may specify another with -d command line option.

If only one number per line is provided, then these numbers will be used as Y values; for X values, line numbers (starting with 1) will be used.

If more than one number per line is provided, then for most chart types (except for bar charts) the first column will be used as X values, and other will be used as Y values.

In the first column, date/time values may be provided instead of numbers (to be used as values along X axis). Supported date/time formats are:

  • DD.MM.YYYY
  • YYYY/MM/DD
  • `12 September 2012'
  • today, tomorrow, yesterday
  • `in 2 days', '3 weeks ago'
  • `last monday', 'next friday'
  • last month' (1th of this month), next year' (1th of January of next year)

(thanks to dates package).

Command-line interface

I'll put it here for quick reference; more actual information is always accessible with chart --help:

Usage: chart [-o|--output OUTPUT.png] [COMMAND] [-1|--header]
             [-d|--delimiter CHAR] [-i|--index] [-t|--title TITLE]
             [-w|--width WIDTH] [-h|--height HEIGHT] [-b|--background COLOR]
             [-f|--foreground COLOR] [-L|--legend ON|OFF] [INPUT.txt]
  Make a chart

Available options:
  -o,--output OUTPUT.png   write output to OUTPUT.png
  -1,--header              first line contains column headers
  -d,--delimiter CHAR      specify fields delimiter ('\t' by default)
  -i,--index               if enabled, treat input data as if there was an
                           additional first column, containing line numbers,
                           starting from 1
  -t,--title TITLE         set chart title to TITLE
  -w,--width WIDTH         specify chart width, in pixels (default: 800)
  -h,--height HEIGHT       specify chart height, in pixels (default: 600)
  -b,--background COLOR    specify background color name (see SVG 1.1 spec)
  -f,--foreground COLOR    specify foreround color name (see SVG 1.1 spec)
  -L,--legend ON|OFF       enable or disable the legend (default: True)
  -h,--help                Show this help text

Available commands:
  line                     Make a line chart
  area                     Make an area chart
  points                   Make a points chart
  bar                      Make a bar chart

Installation

Install it by stack:

$ sudo apt-get install stack
$ git clone https://github.com/portnov/chart-cli.git
$ cd chart-cli/
$ stack install
Metadata

Version

0.1.0.0

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows