diff --git a/README.md b/README.md index b3c66bb..af90dfb 100644 --- a/README.md +++ b/README.md @@ -1 +1,21 @@ # FloatingTableView + +View your datasets in a new window. Ideal for terminal-based data cleaning workflows. + +FloatingTableView.jl leverages Julia Computing's [TableView.jl](https://github.com/JuliaComputing/TableView.jl) and [Blink.jl](https://github.com/JuliaGizmos/Blink.jl) to view any [Tables.jl](https://github.com/JuliaData/Tables.jl) compatible data source in an Electron-based window. + +The function exports a single, one-argument function + +``` +julia> using DataFrames, FloatingTableView + +julia> df = DataFrame(rand(100, 100)); + +julia> browse(df) +``` + +Because TableView.jl uses lazy-loading of data, FloatingTableView can handle very large datasets with no performance penalty. However, because it uses an Electron-based window via Blink.jl, there is a non-trivial "time to first browse" startup time. Repeated calls to `browse` will be fast. + +Similar packages: [BrowseTables.jl](https://github.com/tpapp/BrowseTables.jl). Opens tables in a browser instead of an electron window, which may offer slightly improved performance for small datasets. However columns are not re-sizeable. Due the lazy-loading FloatingTableView will offer much better performance for large datasets. + + diff --git a/src/FloatingTableView.jl b/src/FloatingTableView.jl index 265ea5a..0fa13b8 100644 --- a/src/FloatingTableView.jl +++ b/src/FloatingTableView.jl @@ -2,8 +2,10 @@ module FloatingTableView using Blink, TableView -export browse +export browse, showtable +# Method for keeping current window active borrowed +# from Plots.jl mutable struct CurrentWin nullablewin::Union{Blink.Window, Nothing} end @@ -24,13 +26,45 @@ end current(win::Blink.Window) = (CURRENT_WIN.nullablewin = win) -function browse(df) +""" + browse(t; kwargs) + +Browse data source in a new Blink window using +Tables.jl's `showtable` function. + +# Arguments + +- `t`, a Tables.jl-compatible data source, + for example a `DataFrame` or a `NamedTuple` + of `Vector`s +- `kwargs`, keyword arguments passed to the + `showtable` command from TableView.jl to + control the details of the new data viewer. + See [`showtable`](@ref) for details. + +# Examples + +```julia +julia> t = (a = rand(10), b = rand(10)) + +julia> browse(t) +``` + +```julia +julia> t = rand(100, 100) + +julia> browse(t, dark = true) +``` + +See also: [`showtable`](@ref) +""" +function browse(df; kwargs...) if iswinnull() || !active(current()) w = Blink.Window() current(w) - body!(current(), showtable(df)) + body!(current(), showtable(df; kwargs...)) else - body!(current(), showtable(df)) + body!(current(), showtable(df; kwargs...)) end return nothing