Path: blob/main/doc/explanation/api/examples/stocks_declarative.md
2014 views
Stock Explorer - Declarative API
Before launching into the application code we will first declare some components of the app that will be shared, including the title of the app, a set of stock tickers, a function to return a dataframe given the stock ticker
and the rolling mean window_size
, and another function to return a plot given those same inputs:
This example demonstrates how APIs in Panel differ, to see the same app implemented using a different API visit:
The declarative API expresses the app entirely as a single Parameterized
class with parameters to declare the inputs, rather than explicit widgets. The parameters are independent of any GUI code, which can be important for maintaining large codebases, with parameters and functionality defined separately from any GUI or panel code. Once again the depends
decorator is used to express the dependencies, but in this case the dependencies are expressed as strings referencing class parameters, not parameters of widgets. The parameters and the plot
method can then be laid out independently, with Panel used only for this very last step.