I am using the MVC model, and I want to separate the data that generate the graph from its view. What I want to do is to put all the data from the graph in one file (the model) and just display it from another file (view), with a line or two of code.
For example with the following graph:
File 1 (model)
import plotly.express as px
long_df = px.data.medals_long()
fig = px.bar(long_df, x=“nation”, y=“count”, color=“medal”, title=“Long-Form Input”)
fig.show()
File 2 (view)
Something to call the graph from the file 1 to draw it, instead of having to put all the code in the file 2 to draw it.
Thank you.
Edit: Calling a function could be interesting, but in my view file there is the HTML/CSS, so If I simply call my_graph_function() which would include the code of the graph, the function won’t be included in the HTML/CSS and will just draw the graph without taking the HTML/CSS layout into account.