feelpp / antora-ui

https://feelpp.github.io/antora-ui/
Mozilla Public License 2.0
0 stars 2 forks source link

Dynamic generation of a Plotly diagram from Python code #18

Closed prudhomm closed 1 year ago

ggrossetie commented 1 year ago

My proposal is to use an Asciidoctor extension to process Python source block that includes an exec option and a target attribute.

[source%exec,python,target=result1]
----
import plotly.express as px

fig = px.line(x=["a","b","c"], y=[1,3,2], title="sample figure")
fig.show()
----

[#result1]
--
--

If the result should always be displayed after the source block, we can remove the target attribute.

[source%exec,python]
----
import plotly.express as px

fig = px.line(x=["a","b","c"], y=[1,3,2], title="sample figure")
fig.show()
----

// the result will be displayed here
ggrossetie commented 1 year ago

image

ggrossetie commented 1 year ago

Do you want to create a dedicated repository for Asciidoctor extensions? Alternatively, I can create this extension in https://github.com/feelpp/book.feelpp.org/tree/develop/lib

ggrossetie commented 1 year ago

In the example above, I'm using pd.read_csv with a remote URL rather than acsv=fpp.download("github:{repo:feelpp,path:toolboxes/fluid/cases/moving_body/gravity/cylinder_under_gravity/curve_comparison.csv}", worldComm=app.worldCommPtr())[0] in order to reduce the number of dependencies needed to generate a Plotly chart.

prudhomm commented 1 year ago

Regarding extension i am fine with a specific repository @ggrossetie

prudhomm commented 1 year ago

It all seems very good otherwise