metasoarous / oz

Data visualizations in Clojure and ClojureScript using Vega and Vega-lite
Eclipse Public License 1.0
825 stars 74 forks source link

Visualize data in a table? #49

Open didibus opened 5 years ago

didibus commented 5 years ago

Maybe I'm being dumb, but is there a way to render the data in a simple data, column/row with header, that I can sort, filter, search on, etc. ?

Or can this only do charts?

metasoarous commented 5 years ago

Hi @didibus. Thanks for asking.

You can absolutely do a simple table with the hiccup syntax. However, fancy stuff like sorting, filtering and searching does not come out of the box; You'd have to code that stuff up yourself using the Reagent API. I could see a case being made for having a pre-configured table component with some of these features though.

metasoarous commented 5 years ago

Some rough example code for generating some hiccup rendering as a static table:

(let [data-keys (-> data first keys)]
  (oz/view!
    [:table
     [:tr (for [k data-keys] [:th (name k)])]
     (for [x data]
       [:tr (for [k data-keys] [:tr (get x k)])])]))
didibus commented 5 years ago

Ah I see, I guess I would have thought since Vega has all these nice interactive charts, they'd come with a nice interactive table as well.

metasoarous commented 5 years ago

I'm going to go ahead and reopen this, because I do think there's room for a table component of some sort. I may not get to it right away, but it's worth keeping around as a reminder.

Thanks again.

keesterbrugge commented 5 years ago

It might be interesting to look at datatables since it offers sort, search and column filter.

R already gets a lot of mileage out of datatables: rstudio uses datatables within knitr, shiny and its built-in data explorer looks very similar.

A number of cases where this would be useful:

I often browse through (generated) datasets in rstudio using the built-in data explorer, so having this would be great! Being able to filter and sort in a widget gives a better interactive experience than changing a dataset and then reprinting it.

cheers

keesterbrugge commented 5 years ago

Now that think more about it, it would be cool if the table editor and row selection functionality of datatables can be exposed as signals that can be listened to. This would provide additional means of interaction.

metasoarous commented 5 years ago

Hey @keesterbrugge. Thanks for your thoughts on this.

I fully agree that a feature rich table helper (like datatables) would be great. I don't know that I want to use re-frame-datatables itself, as I don't want to assume re-frame (if someone has a re-frame app after all they can just include re-frame-datables themselves). But I think a standalone reagent component and hiccup/markdown helper with all the core features would be great. I'd be somewhat inclined to just whip it up from scratch over using datatables as a dependency, but I could potentially be talked out of that stance.

Thanks again!

metasoarous commented 2 years ago

Update here:

There is now a oz/data-table cljs component, and you can oz/view! a document with a [:data-table ...] entry, and it will render with this component. However, static output is still not currently supported, but should be added before we closed this issue.

Thanks