Documentation
¶
Overview ¶
Package chart draws a sheet's charts: as text for any terminal (block elements for bars, braille for lines, half blocks for pies), and the plot area as an image for terminals with kitty graphics. Both share one layout, so axis labels, category labels and the legend stay terminal text around the image, in the terminal's own font.
Index ¶
- Constants
- func Delete(id int, wrap func(string) string) string
- func Image(t sheet.ChartType, d sheet.ChartData, w, h int, o Options, pal Palette) *image.RGBA
- func Placeholder(row, col int) string
- func Query() string
- func Transmit(id int, img *image.RGBA, cols, rows int, wrap func(string) string) string
- type Cell
- type Grid
- type Options
- type Palette
- type Role
Constants ¶
const Colors = 6
Colors is how many series colors there are; later series reuse them.
const QueryID = 31
Query is the probe for kitty graphics support: terminals that have it answer with an OK for image QueryID; others stay silent.
Variables ¶
This section is empty.
Functions ¶
func Image ¶
Image draws the plot area of the chart Draw lays out with the same arguments, cw by ch pixels per cell, on a transparent background. It returns nil when there's nothing to plot.
func Placeholder ¶
Placeholder returns the text of the cell at row, col of an image's placement. The foreground color must name the image: the 256-color index of its id.
Types ¶
type Cell ¶
type Cell struct {
Text string // one grapheme; "" continues a wide one to the left
Fg Role
Bg Role // only the pie's half blocks set a background
}
Cell is one terminal cell of a drawn chart.
type Grid ¶
type Grid struct {
W, H int
Cells []Cell
// Plot is the area an image covers, in cells. It is empty when the
// chart has nothing to plot.
Plot image.Rectangle
}
Grid is a drawn chart, W by H cells.
type Options ¶
type Options struct {
// Image leaves the plot area blank, for an image drawn by Image.
Image bool
// CellW and CellH are the size of a terminal cell in pixels; they set
// a pie's proportions. Zero means the usual 1:2.
CellW, CellH int
}
Options control drawing.
type Palette ¶
Palette holds the colors an image draws with: the terminal's colors for the series roles, so the image matches the text legend, and a faint color for gridlines.