Skip to main content

Create beautiful Javascript charts with minimal code

Project description

https://img.shields.io/pypi/v/chartkick.svg https://img.shields.io/pypi/dm/chartkick.svg https://travis-ci.org/mher/chartkick.py.svg?branch=master

Create beautiful Javascript charts with minimal code. Demo!

Supports Chart.js, Google Charts, and Highcharts

Works with Django, Flask/Jinja2 and most browsers (including IE 6). Also available in Ruby and pure JavaScript

Usage

Line chart:

{% line_chart data %}

Pie chart:

{% pie_chart data with id='chart-1' height='400px' %}

Column chart:

{% column_chart data with min=400 max=1000 %}

Bar chart:

{% bar_chart data %}

Area chart:

{% area_chart data %}

Data

Data can be a dictionary or a list:

{'Chrome': 52.9, 'Opera': 1.6, 'Firefox': 27.7}

[['Chrome', 52.9], ['Firefox', 27.7], ['Opera', 1.6]]

For multiple series:

[{'data': [['2013-04-01 00:00:00 UTC', 52.9], ['2013-05-01 00:00:00 UTC', 50.7]], 'name': 'Chrome'},
 {'data': [['2013-04-01 00:00:00 UTC', 27.7], ['2013-05-01 00:00:00 UTC', 25.9]], 'name': 'Firefox'}]

Options

Charting library options can be passed through the library variable:

{% column_chart data with library={"title":"Super chart","width":"400px"} %}

Or using chartkick.json file. Chartkick tries to locate chartkick.json file in template path and match options by id.

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:

    ck = Blueprint('ck_page', __name__, static_folder=chartkick.js(), static_url_path='/static')
    app.register_blueprint(ck, url_prefix='/ck')
    app.jinja_env.add_extension("chartkick.ext.charts")

Load JS scripts:

  • Chart.js

    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.4/Chart.bundle.min.js"></script>
    <script src="ck/static/chartkick.js"></script>
  • Google Charts

    <script src="http://www.google.com/jsapi"></script>
    <script src="ck/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="ck/static/chartkick.js"></script>

Project details


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.5.0.tar.gz (13.7 kB view details)

Uploaded Source

File details

Details for the file chartkick-0.5.0.tar.gz.

File metadata

  • Download URL: chartkick-0.5.0.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for chartkick-0.5.0.tar.gz
Algorithm Hash digest
SHA256 1cc0306b4a6de1e33ed8a849e077e4ed517c0bd4fca05e2a286c46585e89a52b
MD5 22567255ed0384866004cb182273ef7d
BLAKE2b-256 ccce623769bffe0a4849e4008b52d17a2d4ef57d42eca96954e8593325670967

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page