Links
Comment on page

BarChart

The bar chart printer can be used to show data in relation to each other

Basic Usage

positiveBars := pterm.Bars{
pterm.Bar{
Label: "Bar 1",
Value: 5,
},
pterm.Bar{
Label: "Bar 2",
Value: 3,
},
pterm.Bar{
Label: "Longer Label",
Value: 7,
},
}
pterm.Info.Println("Chart example with positive only values (bars use 100% of chart area)")
pterm.DefaultBarChart.WithBars(positiveBars).Render()
pterm.DefaultBarChart.WithHorizontal().WithBars(positiveBars).Render()

Options

Name
Type
Description
Root
TreeNode
The structured tree
TreeStyle
*Style
Style of the tree
TextStyle
*Style
Style of the text
TopRightCornerString
string
Top right corner string
TopRightDownString
string
Top right down string
HorizontalString
string
Horizontal string
VerticalString
string
Vertical string
RightDownLeftString
string
Right down left string
Indent
int
Space between levels
Writer
io.Writer
Sets a custom writer

Using Options

Methods

This printer implements the RenderablePrinter interface.
Method
Description
Render()
Prints to the terminal or uses the specified Writer
Srender()
Returns the rendered string

Full Specification

pkg.go.dev contains the full specification for this printer and more technical descriptions.