Basic Usage¶
Installation¶
$ pip install flask-plots
Initialization¶
To get started, the first step is to import and load the extension
from flask import Flask
from flask_plots import Plots
app = Flask(__name__)
plots = Plots(app)
# do something with app...
with create_app()
factory
from flask import Flask
from flask_plots import Plots
plots = Plots()
def create_app():
app = Flask(__name__)
plots.init_app(app)
return app
app = create_app()
# do something with app...
Tutorial¶
You can see Tutorial: How to embed in a web application server?.
Sample Application¶
If you want to have a look at a small sample application, try browsing it on github.
Configurations¶
Configuration Variable |
Default Value |
Description |
---|---|---|
PLOTS_CMAP |
|
If set to |
STATIC_FOLDER |
|
Default static folder. |
BAR_HEIGHT |
|
Default bar height |
Macros¶
Macro |
Templates Path |
Description |
---|---|---|
render_img() |
plots/utils.html |
Render a img HTML tag. |
How to use this macro? It’s quite simple, just import them from the corresponding path and call them like this macro:
{% from 'plots/utils.html' import render_img %}
{{ render_img(data, alt_img='my-image') }}
Go to the Use Macros page to see the detailed usage for this macros.