Skip to main content

flask-dataview

Build Status

Dynamic data visualizations for flask. This Extension makes it easy to show large data in a flask application. At the moment it only supports timeseries data and shows it in a line graph that can be dynamically zoomed and created. Performance is really good because only the data that the user has selected is send and rendered.

Warning: This is a very (limited) premature version!

Used Libs:

  • jquery
  • bootstrap (for styling)
  • echarts

Installation

pip install flask-dataview

Example Charts

App:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import pendulum
import random

from flask import Flask, render_template
from flask_dataview import FlaskDataViews, RangeTimeSeries


e = FlaskDataViews()
app = Flask(__name__, template_folder=".")
e.init_app(app)


class MySeries(RangeTimeSeries):
    def get_range(self):
        d1 = pendulum.now("utc").subtract(days=300)
        d2 = pendulum.now("utc")
        return (d1, d2)

    def get_data_range(self, dt_from, dt_to):
        out = []
        cur = dt_from.replace(microsecond=0)
        while cur < dt_to:
            val = ((cur.int_timestamp / 3600) % 24) + random.random() * 10
            out.append((cur.isoformat(), val))
            cur = cur.add(minutes=10)
        return out

@app.route('/', methods=['POST', 'GET'])
def home():
    data = [MySeries("temp"), MySeries("act"), MySeries("ph", active=False)]

    mychart = e.basechart("myid1", "My Chart", series=data)
    if mychart.is_post_request():
        return mychart.data()
    return render_template("template.html", chart=mychart)

Template HTML

{{ jquery_cdn }}
{{ echarts_cdn }}
{{ dataview_javascript }}
{{ bootstrap_cdn }}

<h1>Demo Charts</h1>

<div id="mydivid" style="height: 400px;"></div>
{{ chart.render("mydivid") }}

The subclass of RangeTimeSeries should implement get_range to return the full range of the data (minimum timestamp to maximum timestamp). The method get_data_range should return the data in the selected timerange in tuples of isoformat timestamps and float values.

Development Build / Upload

python setup.py sdist
twine upload dist/*

Metadata

Release files for flask-dataview 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flask-dataview 0.3.3
File Size Uploaded Provenance Actions
flask-dataview-0.3.3.tar.gz 282.9 kB Without provenance Details for flask-dataview-0.3.3.tar.gz

Release files / flask-dataview-0.3.3.tar.gz

Download URL flask-dataview-0.3.3.tar.gz
Size 282.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e180bcbcc479aca7d6510bf16f754b7a50dcc3d356a9ba2e20e49299f6e8f264
BLAKE2b-256 checksum
How to use checksums
6f6a075c3350b00d6c899e23e92b50ce5012cc80840d6f8271f853e63c617214
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.2

Security for flask-dataview 0.3.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page