Synphonyte / leptos-struct-table

Easily create Leptos table components from structs
Apache License 2.0
164 stars 24 forks source link

Add support for polars #20

Open deanm0000 opened 8 months ago

deanm0000 commented 8 months ago

I think there's a really good synergy between display data tables and polars. Polars gives access to cloud data and to group by aggregations to only mention a few benefits.

Polars would be a good source especially for virtualized tables as they have lazy evaluation too.

maccesch commented 8 months ago

Oh this is an interesting one!

maccesch commented 8 months ago

How exactly would you want to use it though? It still would have to be downloaded from somewhere, right? At the moment the rows get downloaded and cached internally simply as a vec of struct instances.

deanm0000 commented 8 months ago

I'm thinking something like:

fn main() {
    mount_to_body(|| {
        let df = DataFrame::new(vec![
            Series::new("a",[1.0,2.0,3.0]),
            Series::new("b",[2.1,3.1,4.1]),
            Series::new("c",[0.0,1.2,2.2])
        ])
        .unwrap()

        view! {
            <table>
                <TableContent df />
            </table>
        }
    });
}

After looking at the paginated_rest_datasource, I think I can use the TableDataProvider to use a DataFrame. That said, I think polars would be a good synergy for if/when grouping is a feature that you'd support.

As a tangent, is there any way to have dynamically defined (not just types but the existence of) columns or can it only ever work with what's hard codes in a struct?

maccesch commented 8 months ago

I haven't tried to use it dynamically yet as this is not (yet?) the premise of this crate. But it could be possible if you implement TableDataProvideras well as TableRow manually without using the macro.

If get sth to work feel free to make a PR for a new example. Would be cool and could server as a basis for future development.

Grouping is certainly on the roadmap but probably not very soon.