All Projects → ajstarks → dchart

ajstarks / dchart

Licence: other
dchart makes charts using deck markup

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects
awk
318 projects
shell
77523 projects

Projects that are alternatives of or similar to dchart

Presenta Lib
A javascript library to build expressive web presentations in seconds.
Stars: ✭ 614 (+2690.91%)
Mutual labels:  deck
Kittik
Create slides in TypeScript and present them in the terminal using ASCII only!
Stars: ✭ 147 (+568.18%)
Mutual labels:  deck
Keynote-Helper
一份帮助你做 Keynote 的 Keynote。
Stars: ✭ 101 (+359.09%)
Mutual labels:  deck
Stream Deck Api
API to interact with the Elgato Stream Deck controller
Stars: ✭ 36 (+63.64%)
Mutual labels:  deck
Mdx Deck
♠️ React MDX-based presentation decks
Stars: ✭ 10,487 (+47568.18%)
Mutual labels:  deck
Marp
The entrance repository of Markdown presentation ecosystem
Stars: ✭ 3,378 (+15254.55%)
Mutual labels:  deck
Code Surfer
Rad code slides <🏄/>
Stars: ✭ 5,477 (+24795.45%)
Mutual labels:  deck
dekk
👁 A presentation tool written in react.js
Stars: ✭ 33 (+50%)
Mutual labels:  deck
Slidehub
SlideHub is an Open Source Slide Sharing Application for Azure / AWS
Stars: ✭ 120 (+445.45%)
Mutual labels:  deck
Vis Academy
A set of tutorials on how our frameworks make effective data visualization applications.
Stars: ✭ 254 (+1054.55%)
Mutual labels:  deck
Mtgdesktopcompanion
Cards manager for magic the gathering
Stars: ✭ 44 (+100%)
Mutual labels:  deck
Lpic 1 Anki Flashcards
Deck of Anki flashcards for the LPIC-1 (Linux System Administrator) exams 101 and 102 of the Linux Professional Institute (LPI).
Stars: ✭ 90 (+309.09%)
Mutual labels:  deck
Marp Core
The core of Marp converter
Stars: ✭ 224 (+918.18%)
Mutual labels:  deck
Deck
🗂 Kanban-style project & personal management tool for Nextcloud, similar to Trello
Stars: ✭ 675 (+2968.18%)
Mutual labels:  deck
deck
DECK is a powerful and high performant local web development studio unlike any other.
Stars: ✭ 1,414 (+6327.27%)
Mutual labels:  deck
Marp Cli
A CLI interface for Marp and Marpit based converters
Stars: ✭ 606 (+2654.55%)
Mutual labels:  deck
Presa
🎞 Make stylish presentations in React, powered by styled-components
Stars: ✭ 169 (+668.18%)
Mutual labels:  deck
Yu-Gi-Oh-Deck-Downloader
Chrome Extension that downloading Yu-Gi-Oh decks from ocg.xpg.jp for Automatic Dueling System (遊戯王ADS) like YGOPro or DevPro.
Stars: ✭ 60 (+172.73%)
Mutual labels:  deck
Advisor
A Hearthstone Deck Tracker plugin which tries to guess the opponent's deck while playing and shows it's supposed cards.
Stars: ✭ 16 (-27.27%)
Mutual labels:  deck
Deck Of Cards
Deck of Cards (old version)
Stars: ✭ 2,684 (+12100%)
Mutual labels:  deck

dchart - charts for deck

The dchart package generates deck markup for various chart types, reading from an io.ReadCloser and writing to an io.Writer. The chart types and attributes defined by manipulating settings.

API

NewChart(chartype string, top, bottom, left, right float64) => settings
settings.[thing] = ...
settings.GenerateChart(deck *generate.Deck, io.ReadCloser)

Chart Data		[]ChartData
Chart Settings	Settings

Read CSV or TSV 	Getdata(r io.ReadCloser, readcsv bool, cols string) ([]ChartData,float64,float64,string)
Read TSV 			TSVdata(r io.ReadCloser) ([]ChartData, float64, float64, string)
Read CSV 			CSVdata(r io.ReadCloser, csvcols string) ([]ChartData, float64, float64, string)
Defne a Chart 		NewChart(chartType string, top, bottom, left, right float64) Settings
Define Standalone 	NewFullChart(chartType string, top, bottom, left, right float64) Settings
Make Chart 			(s *Settings) GenerateChart(deck *generate.Deck, r io.ReadCloser)
Write the Chart 	(s *Settings) Write(w io.Writer, r io.ReadCloser)

Example Client

package main
import (
	"fmt"
	"os"
	"github.com/ajstarks/dchart"
	"github.com/ajstarks/deck/generate"
)
func main() {
	chart := dchart.NewFullChart("bar", 0, 0, 0, 0)
	chart.ShowTitle = true
	chart.XLabelInterval = 2
	deck := generate.NewSlides(os.Stdout, 0, 0)
	deck.StartDeck()
	for _, f := range os.Args[1:] {
		r, err := os.Open(f)
		if err != nil {
			fmt.Fprintf(os.Stderr, "%v\n", err)
			continue
		}
		chart.GenerateChart(deck, r)
	}
	deck.EndDeck()
}

creates this chart.

example output

Command line client

cmd/dchart is the command line tool for dchart. It generates deck markup for bar, line, scatter, dot, volume, donut, proportional and fan charts, reading data from the standard input or specified files. Unless specified otherwise, each input source generates a slide in the deck.

The input data format a tab-separated or CSV formatted list of label,data pairs where label is an arbitrary string, and data is intepreted as a floating point value.

A line beginning with "#" is parsed as a title, with the title text beginning after the "#". If a third column is present, it serves as an annotation. label strings with \n characters denote multi-line labels.

Here is an example input data file:

# GOOG Stock Volume (Millions of Shares)
2017-01-01	33.1916
2017-02-01	25.6825
2017-03-01	33.8351	Peak
2017-04-01	25.1619
2017-05-01	32.1801

Example CSV file:

#,GOOG Stock Volume (Millions of Shares)
2017-01-01,33.1916
2017-02-01,25.6825
2017-03-01,33.8351,Peak
2017-04-01,25.1619
2017-05-01,32.1801

Typically dchart generates input for deck clients like pdfdeck, or pdi (a shell script for pdfdeck which reads deck markup on the standard input and produces PDF on the standard output).

$ dchart foo.d bar.d baz.d > fbb.xml && pdfdeck fbb.xml && open fbb.pdf
$ dchart -min=0 -max=700 -datafmt %0.2f -line -bar=f -vol -dot [A-Z]*.d | pdi > allvol.pdf
$ ls -lS | awk 'BEGIN {print "# File Size"} NR > 1 {print $NF "\t" $5}' | dchart -hbar | pdi > fs.pdf

Defaults

With no options, dchart makes a bar graph, showing data values and every data label.

Placement

The plot is positioned and scaled on the deck canvas with the -top, -bottom, -left, and -right flags. These flag values represent percentages on the deck canvas.

Chart types and elements

The -bar, -hbar, -line, -dot, -scatter, -vol, -pgrid, -pmap,-donut, and -radial. flags specify the chart types.

The -grid, -title, -val, and -yaxis flags control the visibility of plot components.

Command line options

-dmim        data minimum (default false, min=0)
-min         set the minimum value
-max         set the maximum value
-csv         read CSV files (default false)
-csvcol      specify the columns to use for label,value

-bar         show bar chart (default true)
-wbar        show "word" bar chart (default false)
-hbar        horizontal chart layout (default false)
-scatter     show a scatter chart (default false)
-dot         show dot plot (default false)
-lego        show lego chart (default false)
-bowtie      show bowtie chart (default false)
-fan         show fan chart (default false)
-line        show line chart (default false)
-slope       show a slope chart (default false)
-frame       show a frame outlining the chart (default false)
-datacond    conditional coloring (low,high,color)
-rline       show regression line (default false)
-vol         show volume plot (default false)
-pgrid       show a proportional grid (default false)
-pmap        show proportional map (default false)
-donut       show a donut chart (default false)
-radial      show a radial chart (default false)
-spokes      show a radial chart with spokes (default false)

-grid        show gridlines on the y axis (default false)
-val         show values (default true)
-pct         show percentages with values (default false)
-valpos      value position (t=top, b=bottom, m=middle) (default "t")
-yaxis       show a y axis (default true)
-yrange      specify the y axis labels (min,max,step)
-fulldeck    generate full deck markup (default true)
-title       show title (default true)
-chartitle   specify the title (overiding title in the data)
-hline       horizontal line with optional label (value,label)
-noteloc     note location (c-center, r-right, l-left, default c)

-top         top of the plot (default 80)
-bottom      bottom of the plot (default 30)
-left        left margin (default 20)
-right       right margin (default 80)

-psize       diameter of the donut (default 30)
-pwidth      width of the donut or proportional map (default 3 time textsize)
-solidpmap   use solid colors for pmaps
-barwidth    barwidth (default computed from the number of data points)
-linewidth   linewidth for line charts (default 0.2)
-ls          linespacing (default 2.4)
-textsize    text size (default 1.5)
-xlabel      x axis label interval (default 1, 0 to supress all labels)
-xlabrot     x axis label rotation (default 0, no rotation)
-xstagger    stagger x axis labels
-xlast       show the last x label
-color       data color (default "lightsteelblue")
-framecolor  frame color (default "rgb(127,0,0)")
-rlcolor     regression line color (default "rgb(127,0,0)")
-vcolor      value color (default "rgb(127,0,0)")
-lcolor      axis label color (default "rgb(75,75,75)")
-volop       volume opacity (default 50)
-datafmt     data format for values (default "%.1f")
-note        show annotations (default true)

Examples

Using this data in AAPL.d

# AAPL Volume
2017-01-01	563.122
2017-02-01	574.969
2017-03-01	561.628
2017-04-01	373.304
2017-05-01	653.755
2017-06-01	684.178
2017-07-01	421.992
2017-08-01	661.069
2017-09-01	679.879
2017-10-01	504.291
2017-11-01	600.663
2017-12-01	417.354

here are some variations.

$ dchart AAPL.d

no-args

$ dchart -yrange=0,700,50 AAPL.d

yrange

$ dchart -xlabel=2 -left 30 -right 70 -top 70 -bottom 40 -yaxis=f AAPL.d

pos

$ dchart -color gray AAPL.d

bar-gray

$ dchart -grid AAPL.d # add a y axis grid

bar-grid

$ dchart -grid -barwidth=1 AAPL.d # adjust the bar width

barwidth

$ dchart -bar=f -dot AAPL.d # no bars, dot plot

dot

$ dchart -bar=f -vol AAPL.d # no bars, volume plot

vol

$ dchart -datafmt %0.2f -bar=f -dot -line AAPL.d

dot-line

$ dchart -bar=f -line AAPL.d # line chart

connect

$ dchart -bar=f -line -yaxis=f -val=f AAPL.d # only show line and x axis

connect-no-axis-no-val

$ dchart -scatter -val=f -bar=f -yaxis=f AAPL.d

scatter

$ dchart -bar=f -line -vol -dot AAPL.d # combine line, volume, and dot

vol-dot

$ dchart -bar=f -line -vol -dot -yaxis=f AAPL.d # as above, removing the y-axis

vol-dot-no-axis

$ dchart -bar=f -line -vol -dot -grid AAPL.d

connect-dot-vol-val-grid

$ dchart -hbar AAPL.d

hlayout

$ sort -k2 -nr pdf.d | dchart -left 20 -hbar

sorted-bar

Using this data in browser.d

# Browser Market Share Dec 2016-Dec 2017
Chrome	53.72
Safari	14.47
Other	9.36
UC	8.28
Firefox	6.23
IE	3.99
Opera	3.9

here are views of proportional data:

$ dchart -wbar browser.d

wbar

$ dchart -donut -color=std -pwidth=5 browser.d

donut

$ dchart -pmap -pwidth=5 -textsize=1 browser.d

pmap

Using this data in incar.d:

# US Incarceration Rate
White	39	antiquewhite
Hispanic	19	burlywood
Black	40	sienna
Other	2	gray

the note field may be used to specify the color

pgrid

$ dchart -ls 3 -val=f -pgrid incar.d

Here is the lego chart variation:

lego

$ dchart -left 30 -top 80 -lego -textsize 4 

Using this data in slope.d

# Test Slope Graphs
one     20      First
two     80

three   0       Second
four    0

five    100     Third
six     0

seven   0       Fourth
eight   100

nine    50      Fifth
ten     50

eleven  100     Sixth
twelve  100

slope

$ dchart -slope -left=10 -right=30 -top=80 -bottom=60 slope.d

Using this data in count.d:

# Count Of Things
One	10	red
Two	20	green
Three	30	blue
Four	40	purple
Five	50	yellow
Six	60	black
Seven	70	brown
Eight	80	silver
Nine	90	orange
Ten	100	pink

$ dchart -psize=10 -pwidth=40 -left=50 -top=50 -radial -textsize=3 data/incr.d|pdf -pagesize 800,800

radial

Using this data:

# Clockwise
twelve	12	red
one	1	green
two	2	blue
three	3	purple
four	4	maroon
five	5	black
six	6	brown
seven	7	silver
eight	8	orange
nine	9	pink
ten	10
eleven	11

$ dchart -psize=10 -pwidth=40 -left=50 -top=50 -radial -textsize=3 -spokes data/clock.d|pdf -pagesize 800,800

spoke

Using this data:

# Occupations of African-Americans and Whites (2019)
Management	31.8	crimson
Service	23.8	gold
Sales	22.4	steelblue
Construction	5.7	tan
Production	16.3	rgb(101,67,33)
Management	41.4	crimson
Service	15.9	gold
Sales	21.3	steelblue
Construction	10.1	tan
Production	11.3	rgb(101,67,33)

$ dchart -val -psize=20 -top=60 -bowtie occupation.d

bowtie

$ dchart 0val -psize=20 -top=60 -fan occupation.d

fan

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].