Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ Reexport = "1"
Statistics = "1"
Tables = "1"
julia = "1.6"
PrettyTables = "2"
PrettyTables = "2,3"
IteratorInterfaceExtensions = "1"
TableTraits = "1"
2 changes: 1 addition & 1 deletion src/TimeSeries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using DocStringExtensions: SIGNATURES
using RecipesBase
using Reexport
using Tables
using PrettyTables: pretty_table
using PrettyTables: PrettyTables, pretty_table

export TimeArray,
AbstractTimeSeries,
Expand Down
109 changes: 73 additions & 36 deletions src/timearray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -230,45 +230,82 @@ function Base.show(io::IO, ta::TimeArray)
return nothing
end
end
function Base.show(
io::IO,
::MIME"text/plain",
ta::TimeArray;
allrows=!get(io, :limit, false),
allcols=!get(io, :limit, false),
)
nrow = size(values(ta), 1)
ncol = size(values(ta), 2)

show(io, ta) # summary line

nrow == 0 && return nothing

println(io)

if allcols && allrows
crop = :none
elseif allcols
crop = :vertical
elseif allrows
crop = :horizontal
else
crop = :both
@static if pkgversion(PrettyTables).major == 2
# TODO: When PrettyTables v2 is more widely spread get rid off this and the compat
function Base.show(
io::IO,
::MIME"text/plain",
ta::TimeArray;
allrows=!get(io, :limit, false),
allcols=!get(io, :limit, false),
)
nrow = size(values(ta), 1)
ncol = size(values(ta), 2)

show(io, ta) # summary line

nrow == 0 && return nothing

println(io)

if allcols && allrows
crop = :none
elseif allcols
crop = :vertical
elseif allrows
crop = :horizontal
else
crop = :both
end

data = hcat(timestamp(ta), values(ta))
header = vcat("", string.(colnames(ta)))
return pretty_table(
io,
data;
header=header,
newline_at_end=false,
reserved_display_lines=2,
row_label_alignment=:r,
header_alignment=:l,
crop=crop,
vcrop_mode=:middle,
)
end

data = hcat(timestamp(ta), values(ta))
header = vcat("", string.(colnames(ta)))
return pretty_table(
io,
data;
header=header,
newline_at_end=false,
reserved_display_lines=2,
row_label_alignment=:r,
header_alignment=:l,
crop=crop,
vcrop_mode=:middle,
else
function Base.show(
io::IO,
::MIME"text/plain",
ta::TimeArray;
allrows=!get(io, :limit, false),
allcols=!get(io, :limit, false),
)
nrow = size(values(ta), 1)
ncol = size(values(ta), 2)

show(io, ta) # summary line

nrow == 0 && return nothing

println(io)

data = hcat(timestamp(ta), values(ta))
header = vcat("", string.(colnames(ta)))
return pretty_table(
io,
data;
column_labels=header,
new_line_at_end=false,
reserved_display_lines=2,
row_label_column_alignment=:r,
column_label_alignment=:l,
continuation_row_alignment=:c,
fit_table_in_display_horizontally=!allcols, # replaced crop keyword for v3 of PrettyTables
fit_table_in_display_vertically=!allrows, # replaced crop keyword for v3 of PrettyTables
vertical_crop_mode=:middle,
)
end
end

###### getindex #################
Expand Down
Loading