Skip to content

Chart support #146

@dantownsend

Description

@dantownsend

I'm putting this here as a placeholder to collect thoughts. I don't think it's an immediate priority, but would be cool.

We support form creation using FormConfig. We might be able to add something similar called ChartConfig. It would initially just be for very simple chart types, like bar, line, and pie.

Here's an example:

async def get_data():
    movies = await Movie.select(
        Movie.director.name.as_alias("director"),
        Count(Movie.id)
    ).group_by(
        Movie.director
    )
    # Flatten the response so it's a list of lists like [['George Lucas', 3], ...]
    return [[i['director'], i['count']] for i in movies]

director_chart = ChartConfig(title='Movie count', type=Bar(source=get_data))

create_admin(charts=[director_chart])

There would be a new section in the sidebar:

Screenshot 2022-01-27 at 14 24 09

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions