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

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

'Greys'

If set to Greys and will be used for cmap value in plots.

STATIC_FOLDER

'plots'

Default static folder.

BAR_HEIGHT

50

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.

License

Flask-Plots is free software you can redistribute it and/or modify it under the terms of the MIT License. For more information, you can see the LICENSE file for details.