FastUI icon indicating copy to clipboard operation
FastUI copied to clipboard

Chart component

Open Dejiah opened this issue 1 year ago • 10 comments

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?

Dejiah avatar Dec 05 '23 19:12 Dejiah

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

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

bobcolner avatar Dec 06 '23 02:12 bobcolner

also vega and mosaic should be simple to embed

jgunstone avatar Dec 07 '23 11:12 jgunstone

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.

samuelcolvin avatar Dec 08 '23 12:12 samuelcolvin

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:

  • the chart types are more expansive with echarts, especially around tree based options which seem to be missing in vega-lite/altair.
  • It looks like there is an event model that could somehow map nicely onto fastui.

AaronNHart avatar Jan 08 '24 17:01 AaronNHart

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

samuelcolvin avatar Feb 09 '24 07:02 samuelcolvin

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...

jgunstone avatar Feb 12 '24 15:02 jgunstone

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?

cjlala avatar Mar 05 '24 06:03 cjlala

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

tim-x-y-z avatar Mar 06 '24 10:03 tim-x-y-z

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

gaby avatar Jul 16 '24 03:07 gaby

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.

tim-x-y-z avatar Jul 16 '24 08:07 tim-x-y-z