Skip to content
/ chart Public

A sweet program that draws live charts right in your terminal!

License

Notifications You must be signed in to change notification settings

cmtptr/chart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

==== SYNOPSIS ==================================================================
A neat little charting program that runs in the terminal.

It reads numeric values from <filename> (or in the absence of the <filename>
argument, or if <filename> is '-', stdin) and plots them on a chart that is
drawn directly in the terminal.

==== USAGE =====================================================================
Invoke chart with the syntax:

	chart [<option>...] [<filename>]

The input is to be formatted in lines of text as follows:

	[,]<number>[,<number>...]

Each line beginning with a number not prefixed by a comma is taken to represent
a new data point.  Each number prefixed by a comma (i.e., the first numbers in
lines which begin with commas and those numbers following other numbers on the
same line and delimited by commas) is taken to represent an update to the most
recent data point.

==== DEPENDENCIES ==============================================================
chart depends on curses.

==== INSTALLATION ==============================================================
To build chart, type:

	make

To install chart:

	make [DESTDIR=<path>] [PREFIX=<path>] install

If not specified, DESTDIR is "" and PREFIX is "/usr/local" by default.

==== LICENSE ===================================================================
See LICENSE.

==== EXAMPLES ==================================================================
Try the following BASH scripts:

	#!/bin/bash
	y=0
	while true; do
		for i in $(seq 1 4); do
			y=$((y + RANDOM % 9 - 4))
			if (( $y > 127 )); then
				y=127
			elif (( $y < -128 )); then
				y=-128
			fi
			if (( $i != 1 )); then
				echo -n ,
			fi
			echo $y
		done
		sleep 0.2
	done | ./chart -s ohlc -t '$RANDOM' "$@"

┌─── $RANDOM ───────────────────────────────────────────────────────────────┐
│                                                                 ┌┌┴┬      ┤16
│                                                              │ ┌┤┤ │┐┐    │
│                                                              ┴├┘    ├│┌┌┐┬┤-1
│                                                             ┌ ┘      └┘┤└││
│                                                            ┐┘             │
│                                                         ┌┼┬└              │
│                                                       │ ││                │
│                                                      ┌┴┬┘                 │
│                                                      ┘                    │
│                                                    ├┌                     │
│                                              │    │┘┘                     │
│                                              ┴┐  │┴                       │
│                                             ┌ │┐ ┴                        │
│ │                                          ├┤ └│┌                         │
│┐├┬┐                                     ┐ ┌┘   └┘                         │
│├┘│└┬     │            ┌          │┐┐ │┤┼└││                               │
│     ┬ ┐ ┌┴┐          ┌┘┐ ┤│┐   │┬┴├│┐┴└  ┼┘                               │
│      ┴└┴┤ └┬┬ │      ┘ ├┬└┴├┬┼┴┼│  └└                                     │
│             │┬├┬┐   ┌        │                                            │
│              │┘│├┤┌┌┘                                                     │
│                  └│┘                                                      │
│                   ┘                                                       ┤-88
└───────────────────────────────────────────────────────────────────────────┘


	#!/bin/bash
	t0=0
	five0=0
	while read one five1 fifteen _ </proc/loadavg; do
		t1=$(($(date +%s) / 450))
		if (( $t1 > $t0 )); then
			printf ",%s\n%s,%s\n" $five0 $fifteen $five1
			t0=$t1
		fi
		five0=$five1
		echo ,$one
		sleep 30
	done | exec chart -s ohlc -t loadavg

┌─── loadavg ──────────────────────────────────────────────────────────────┐
│                  │                                                       ┤1.44
│                  │                                                       │
│                  │                                                       │
│                  │                                                       │
│                  │                                                       │
│                  │                                                       │
│                  │                                                       │
│                  │                                                       │
│                  │                                                       │
│                  ││    │              │        │      │                  │
│                  ││    │              │        │      ││                 │
│                  │││   │              │  │   │ │      ││        │        │
│                │ │││   │              │  │   │ │      ││      │ │        │
│                │ │││   │  │       ││ ││  │ │ │ │      ││    │ │ │   │    │
│                │ │││   │ ││       ││ │││ │││ │││      ││    │││ │   ││  ┌┤0.42
│                ││├├│   │ │││      ││ │││││││││││     │├├││  ││││││  ││  ││
│                ││││┤│ │├│├│││     │││││││├│││├├│   │ │││││││││││├│││││ │││
│                │││┤├┤ ││││┼││     │├│├││││┼│││┤┤│ ││ │││┼│││├││├│┤││├├ │││
│                │├││││┐││┼┘│┼┤ │  │├│├│┤├┼┤│┼┼┤│├┤ │├│││┤│┤┼┼┤┼┼┤┤├┼┼┤┤┤│││
│ │   │   │      ├│┘ │├│┤┘│ ││├┤┼┤│││┤┤┤├┤│ │││ ││├┐┤┤┼┼┤││├│││││ │││││││┼┤│
│ ├│├├┼   │      │┤  ││├├ │   │├│├┼┼┘││││ │ │ │ │││├├││││ ││││ │   │││ │├│││
│─┘┴┘┘│───┴──────┘│    ││     ││ │││    │           │               │   │  ┤0
└──────────────────────────────────────────────────────────────────────────┘

About

A sweet program that draws live charts right in your terminal!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published