Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bars ¶
type Bars []Bar
func (Bars) MaxLabelWidth ¶
MaxLabelWidth returns the max length of the Label from a list of Bars
type ChartOption ¶
type ChartOption interface { HorizontalOption SparklineOption // contains filtered or unexported methods }
func WithMaxVal ¶
func WithMaxVal(m float64) ChartOption
WithMaxVal sets the max value bars will be made relative to. By default, the bar with the highest value will take up the full width and all other bars will be sized relative to it. However, for charts where an absolute max value is desired, such as a percentage, you can use this option to make all bars sized relative to a specific value (i.e. 100.0 for % bars)
func WithMaxWidth ¶
func WithMaxWidth(w int) ChartOption
WithMaxWidth sets the maximum character width of the chart
type Horizontal ¶
Horizontal is a horizontal bar chart
func NewHorizontal ¶
func NewHorizontal(values Bars, options ...HorizontalOption) *Horizontal
NewHorizontal returns a new horizontal bar chart. By default, it will produce a set of bars that look like:
a: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 50
b: ▇▇▇▇▇▇▇▇▇ 25
c: ▇▇▇ 15
d: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 78
type HorizontalOption ¶
type HorizontalOption interface {
// contains filtered or unexported methods
}
HorizontalOption is an option for a horizontal bar graph
func WithBarChars ¶
func WithBarChars(s string) HorizontalOption
WithBarChars sets the characters to use in the bar
func WithLabelSeparator ¶
func WithLabelSeparator(s string) HorizontalOption
WithLabelSeparator sets the separator to use between the label and bar
func WithValueFormatter ¶
func WithValueFormatter(f func(Bar) string) HorizontalOption
WithValueFormatter sets a formatter function for displaying the value after the bar
type Sparkline ¶
func NewSparkline ¶
func NewSparkline(bars Bars, options ...SparklineOption) *Sparkline
NewSparkline creates a Sparkline chart from a set of bars
type SparklineOption ¶
type SparklineOption interface {
// contains filtered or unexported methods
}
SparklineOption is an option for a sparkline