Skip to content

Commit

Permalink
Merge pull request #11 from JuliaComputing/sp/defaultheight
Browse files Browse the repository at this point in the history
better default height
  • Loading branch information
pfitzseb authored Feb 27, 2019
2 parents 37075d3 + 0ab6fa5 commit 1ad7739
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/TableView.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,21 @@ end
to_css_size(s::AbstractString) = s
to_css_size(s::Real) = "$(s)px"

function showtable(table; dark = false, height = 500, width = "100%")
function showtable(table; dark = false, height = :auto, width = "100%")
if !Tables.istable(typeof(table))
throw(ArgumentError("Argument is not a table."))
end

tablelength = Base.IteratorSize(table) == Base.HasLength() ? length(Tables.rows(table)) : nothing

if height === :auto
height = 500
if tablelength !== nothing
# header + footer height ≈ 40px, 28px per row
height = min(40 + tablelength*28, height)
end
end

rows = Tables.rows(table)
schema = Tables.schema(table)
if schema === nothing
Expand Down

0 comments on commit 1ad7739

Please sign in to comment.