Documentation ¶
Overview ¶
Package dchart - make charts in the deck format
Package dchart generates deck markup for bar, line, dot, and volume 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 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 "#". A third column specifies an annotation.
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 value 2017-04-01 25.1619 2017-05-01 32.1801
The command line options are:
-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 bars (default true) -hbar horizontal chart layout (default false) -scatter show scatter chart (default false) -wbar show "word" bar chart (default false) -line show line chart (default false) -dot show dot plot (default false) -lego show lego chart (default false) -bowtie show bowtie chart (default false) -fan show fanchart (default false) -grid show gridlines on the y axis (default false) -val show values (default true) -rline show a regression line (default false) -frame show a frame outlining the chart (default false) -datacond conditional colors (low,high,color) -pct show percentages with values (default false) -valpos value position (t=top, b=bottom, m=middle) (default "t") -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 spokes on the radial chart (default false) -yaxis show a y axis (default true) -yrange define the y axis range (min,max,step) -fulldeck generate full 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) -x x location of the donut chart (default 50) -y y location of the donut chart (default 50) -psize diameter of the donut (default 30) -pwidth width of the donut or proportional map (default 3) -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") -vcolor value color (default "rgb(127,0,0)") -lcolor axis label color (default "rgb(75,75,75)") -rlcolor regression line color (default "rgb(127,0,0)") -framecolor frame color (default "rgb(127,0,0)") -volop volume opacity (default 50) -datafmt data format for values (default "%.1f") -note show annotation (default true)
Index ¶
- Constants
- func Parsebounds(s string) (float64, float64, float64, float64)
- type Attributes
- type ChartData
- type Flags
- type Measures
- type Settings
- func (s *Settings) GenerateChart(deck *generate.Deck, r io.ReadCloser)
- func (s *Settings) Hchart(deck *generate.Deck, r io.ReadCloser)
- func (s *Settings) Pchart(deck *generate.Deck, r io.ReadCloser)
- func (s *Settings) Slopechart(deck *generate.Deck, r io.ReadCloser)
- func (s *Settings) Vchart(deck *generate.Deck, r io.ReadCloser)
- func (s *Settings) Wbchart(deck *generate.Deck, r io.ReadCloser)
- func (s *Settings) Write(w io.Writer, r io.ReadCloser)
Constants ¶
const ( // Titlecolor is the color of the title string Titlecolor = "black" // Dotlinecolor is the dotted line color Dotlinecolor = "lightgray" // Defaultfmt is the default number format Defaultfmt = "%.1f" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attributes ¶
type Attributes struct { BackgroundColor, DataColor, FrameColor, LabelColor, RegressionLineColor, ValueColor, ChartTitle, CSVCols, DataCondition, DataFmt, HLine, NoteLocation, ValuePosition, YAxisR string }
Attributes define chart attributes
type ChartData ¶
type ChartData struct {
// contains filtered or unexported fields
}
ChartData defines the name,value pairs
func CSVdata ¶
CSVdata reads CSV structured name,value pairs, with optional comments, returning a slice with the data, allong with min, max and title
type Flags ¶
type Flags struct { DataMinimum, FullDeck, ReadCSV, ShowAxis, ShowBar, ShowBowtie, ShowDonut, ShowDot, ShowFan, ShowFrame, ShowGrid, ShowHBar, ShowLine, ShowLego, ShowNote, ShowPercentage, ShowPGrid, ShowPMap, ShowRadial, ShowRegressionLine, ShowScatter, ShowSlope, ShowSpokes, ShowTitle, ShowValues, ShowVolume, ShowWBar, ShowXLast, ShowXstagger, SolidPMap bool }
Flags define chart on/off switches
type Measures ¶
type Measures struct { CanvasWidth, CanvasHeight, TextSize, Left, Right, Top, Bottom, LineSpacing, BarWidth, LineWidth, PSize, PWidth, UserMin, UserMax, VolumeOpacity, XLabelRotation float64 Boundary string XLabelInterval, PMapLength int }
Measures define chart measures
type Settings ¶
type Settings struct { Flags Attributes Measures }
Settings is a collection of all chart settings
func NewChart ¶
NewChart initializes the settings required to make a chart chartType may be one of: "line", "slope", "bar", "wbar", "hbar", "volume, "scatter", "donut", "pmap", "pgrid", "lego", "radial", "bowtie", "fan"
func NewFullChart ¶
NewFullChart initializes the settings required to make a chart that includes the enclosing deck markup
func (*Settings) GenerateChart ¶
func (s *Settings) GenerateChart(deck *generate.Deck, r io.ReadCloser)
GenerateChart makes charts according to the orientation: horizontal bar or line, bar, dot, or donut volume charts
func (*Settings) Hchart ¶
func (s *Settings) Hchart(deck *generate.Deck, r io.ReadCloser)
Hchart makes horizontal bar charts using input from a Reader
func (*Settings) Pchart ¶
func (s *Settings) Pchart(deck *generate.Deck, r io.ReadCloser)
Pchart draws proportional data, either a pmap, pgrid, radial or donut using input from a Reader
func (*Settings) Slopechart ¶
func (s *Settings) Slopechart(deck *generate.Deck, r io.ReadCloser)
Slopechart draws a slope chart
func (*Settings) Vchart ¶
func (s *Settings) Vchart(deck *generate.Deck, r io.ReadCloser)
Vchart makes charts using input from a Reader the types of charts are bar (column), dot, line, and volume