Giter Site home page Giter Site logo

chartkick.py's Introduction

Chartkick.py

https://badge.fury.io/py/chartkick.png https://travis-ci.org/mher/chartkick.py.png?branch=master https://pypip.in/d/chartkick/badge.png Bitdeli badge

Create beautiful Javascript charts with minimal code. Demo!

Supports 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:

    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>
    

chartkick.py's People

Contributors

bitdeli-chef avatar mher avatar orf avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.