Create beautiful Javascript charts with minimal code
Project description
Create beautiful Javascript charts with minimal code. Python port of Chartkick
Supports Google Charts and Highcharts
Works with Django, Flask/Jinja2 and with most browsers (including IE 6)
Usage
Load charkick from a template:
{% load chartkick %}
And draw charts:
{% line_chart data %} {% pie_chart data with height='400px' %} {% column_chart data with min=400 max=1000 %}
data is a context variable passed to the template:
def view(request): data = {'Strawberry': 23, 'Apple': 21, 'Grape': 13, 'Blueberry': 44, 'Banana': 22} return render(request, 'template.html', {'data': data})
To draw users join chart:
def view(request): qs = User.objects.values('join_date').order_by('-join_date') data = qs.annotate(count=Count('join_date')) data = dict(map(lambda x: (x['join_date'], x['count']), data)) return render(request, 'template.html', {'data': data})
Installation
Install chartkick:
$ pip install chartkick
Django: Add chartkick to INSTALLED_APPS and STATICFILES_DIRS:
INSTALLED_APPS = ( 'chartkick', ) import chartkick STATICFILES_DIRS = ( chartkick.js(), )
Flask: Add chartkick to jinja_env and static_folder:
app = Flask(__name__, static_folder=chartkick.js(), static_url_path='/static') app.jinja_env.add_extension("chartkick.ext.charts")
Load JS scripts:
Google Charts
<script src="http://www.google.com/jsapi"></script> <script src="static/chartkick.js"></script>
Highcharts
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script src="http://code.highcharts.com/highcharts.js"></script> <script src="static/chartkick.js"></script>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
chartkick-0.2.0.tar.gz
(7.9 kB
view details)
File details
Details for the file chartkick-0.2.0.tar.gz
.
File metadata
- Download URL: chartkick-0.2.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d988c3c8bd4845cbbb0742dc2bb6599f107596a51096dbb49a8dbdb2577adbdd |
|
MD5 | 30bb165fb8ea751a2533763699ce5bdf |
|
BLAKE2b-256 | 28e4210e54c84d743ed8b8e92140cea62f69d5a5c35d5a2ca05efa60872ea0bc |