Tables

Term.Tables.TableType
Table

A Table renderable.

Examples


t = 1:3
data = hcat(t, rand(Int8, length(t)))
Table(data)

┌───────────┬───────────┐
│  Column1  │  Column2  │
├───────────┼───────────┤
│     1     │    -95    │
├───────────┼───────────┤
│     2     │    -85    │
├───────────┼───────────┤
│     3     │    115    │
└───────────┴───────────┘
source
Term.Tables.TableMethod

Table(data::AbstractDict; kwargs...)

Construct Table from a Dict. The Dict's keys make up the table header if none is assigned.

source
Term.Tables.TableMethod
Table(
    tb::TablesPkg.AbstractColumns;
    box::Symbol = :SQUARE,
    style::String = "default",
    hpad::Union{Vector,Int} = 2,
    vpad::Union{Vector,Int} = 0,
    vertical_justify::Symbol = :center,
    show_header::Bool = true,
    header::Union{Nothing,Vector,Tuple} = nothing,
    header_style::Union{String,Vector,Tuple} = "default",
    header_justify::Union{Nothing,Symbol,Vector,Tuple} = nothing,
    columns_style::Union{String,Vector,Tuple} = "default",
    columns_justify::Union{Symbol,Vector,Tuple} = :center,
    columns_widths::Union{Nothing,Int,Vector} = nothing,
    footer::Union{Function,Nothing,Vector,Tuple} = nothing,
    footer_style::Union{String,Vector,Tuple} = "default",
    footer_justify::Union{Nothing,Symbol,Vector,Tuple} = :center,
    compact::Bool = false,
)

Generic constructor for a Table renderable.

Tip

Arguments such as header_style, columns_style and footer_style can either be passed a single value, which will be applied to all columns, or a vector of values, which will be applied to each column.

source
Term.Tables.TableMethod
Table(data::Union{AbstractVector, AbstractMatrix}; kwargs...)

Construct Table from Vector and Matrix

source
Term.Tables.assert_table_argumentsMethod
assert_table_arguments

Check that arguments passed to Table match the Table's shape. Single arguments are fine, but when a vector is passed it should have the appropriate size.

source
Term.Tables.calc_columns_widthsMethod
columns_widths

Get the width of each column in a Table.

If user passed a columns_widths argument use that, otherwise compute the width of each column based on the size of its contents including the header and footer.

source
Term.Tables.cellMethod
cell(x::AbstractString, hor_pad::Int, h::Int, w::Int, justify::Symbol, style::String, vertical_justify::Symbol)

Create a Table's row's cell from a string - apply styling and vertical/horizontal justification.

source
Term.Tables.cellMethod
cell(x::AbstractString, hor_pad::Int, h::Int, w::Int, justify::Symbol, style::String, vertical_justify::Symbol)

Create a Table's row's cell from a renderable - apply styling and vertical/horizontal justification.

source
Term.Tables.make_row_cellsMethod
make_row_cells(
    entries::Union{Tuple, Vector}, 
    style::Vector{String}, 
    justify::Vector{Symbol},
    widths::Vector{Int},
    height::Int, 
    vertical_justify::Symbol,
)

Create a row's cell from a vector of 'entries' (renderables or strings).

source
Term.Tables.table_rowMethod
function table_row(
    cells::Vector,
    widths::Vector,
    box::Symbol,
    top_level::Symbol,
    mid_level::Symbol,
    bottom_level::Symbol,
    box_style::String,
    row_height::Int;
    compact = false,
)

Create a single row of a Table renderable.

Each row is made up of an upper, mid and bottom section. The upper and bottom sections are created by rows of the Box type. The mid section is made up of the row's cells and dividing lines.

Arguments

  • cells: vector of cells content. Of length equal to the number of columns
  • widths: vector of width of each cell.
  • box: name of the Box used to construct the cell's lines
  • top/mid/bottom_level: name of the Box level to be used for construction
  • box_style: styling to be applied to box
  • row_height: height of the row
  • compact: if true avoids adding a top layer to the row
source