pydantic / FastUI

Build better UIs faster.
https://fastui-demo.onrender.com
MIT License
7.91k stars 302 forks source link

Chart component #75

Open Dejiah opened 7 months ago

Dejiah commented 7 months ago

Hi,

I think it would be great if we had a chart component (e.g. think 2D bar charts or scatter plots).

Guess the mechanism of supplying data in the backend could be similar as it is implemented for the Table component. For frontend implementation I think we could leverage something like Chart.js to do the charting work itself for us.

Not sure if this use case is common enough such that it would fit into FastUI itself or whether this should rather be considered a custom component and be separate from the package.

Any thoughts?

bobcolner commented 7 months ago

This would be a great feature. These libs are very feature complete:

https://plotly.com/graphing-libraries/ https://bokeh.org/

jgunstone commented 7 months ago

also vega and mosaic should be simple to embed

samuelcolvin commented 7 months ago

I think the simple solution is to return a vega JSON object perhaps from altair and render that in the frontend.

I think long term this is an idea that I'm really interested in, and I'd like to try to do something more powerful, particularly WRT interaction etc.

AaronNHart commented 6 months ago

Also worth considering may be echarts, which has a json format and an (auto-gen) pydantic model in ezcharts.

From my limited perspective, there are 2 possible advantages:

samuelcolvin commented 5 months ago

ye, I agree echarts is probably the best way to go.

jgunstone commented 5 months ago

I've been using quarto recently which is great - with it you can build a website from pandoc-markdown.

they recently added a feature to support observablejs code blocks. this allows you to create interactive elements within an otherwise static website. could be of interest as an approach...

cjlala commented 4 months ago

Hi guys, aftering reading the above comments, I still have no idea how to add a chart in the fastui. Can someone show me a piece of codes?

tim-habitat commented 4 months ago

I made an initial proposal for this here: https://github.com/pydantic/FastUI/pull/201 using recharts

gaby commented 1 week ago

@tim-habitat Just noticed your PR is kind of stale, has there been any changes? This feature would be huge for FastUI

tim-habitat commented 1 week ago

No nothing changed my side and would be happy to freshen up, though i suspect the team at pydantic might want to implement it in a different way based on the comments above. This to me is why i would love to have a discussion about plugins / making it easier to extend components: https://github.com/pydantic/FastUI/issues/262 in that case i would be happy to implement a few graphs etc. and people could easily use that package, without it living in the core fastui leaving space for the team to do as they see fit in the future.