Coder Social home page Coder Social logo

django-graphos's Introduction

Graphos

Build Status

Graphos is a Django app to plot data into a live graph. Demo at http://agiliq.com/demo/graphos/. Docs at http://agiliq.com/docs/django-graphos/.

Supported Backends:

  • Python Nested lists
  • CSV Files
  • MongoDB
  • Redis
  • Django ORM

Charting API Supported

Chart types supported

Flot

  • Line chart
  • Bar Chart
  • Point Chart

Google Charts

  • Line chart
  • Column chart
  • Bar chart
  • Candlestick charts
  • Pie chart
  • Treemap chart

YUI

  • Line chart
  • Column chart
  • Bar chart
  • Pie chart

Morris.js

  • Line chart
  • Column chart
  • Donut chart

Highcharts

(You will need to buy a license if you use highcharts for commerical use)

  • Line Chart
  • Bar Chart
  • Column Chart
  • Pie Chart

Matplotlib

  • LineChart
  • BarChart

Demo

Install the requirements, manage.py runserver. The installed demo app shows the various suported chart types.

Overview of Plot generation

Generating a plot requires two things. A DataSource and a Chart object.

In your view, you do something like this:

data =  [
        ['Year', 'Sales', 'Expenses'],
        [2004, 1000, 400],
        [2005, 1170, 460],
        [2006, 660, 1120],
        [2007, 1030, 540]
    ]
Chart = LineChart(SimpleDataSource(data=data), html_id="line_chart")

And then in the template:

{{ chart.as_html }}

Examples

Generating a plot from python list

data =  [
        ['Year', 'Sales', 'Expenses'],
        [2004, 1000, 400],
        [2005, 1170, 460],
        [2006, 660, 1120],
        [2007, 1030, 540]
    ]
Chart = LineChart(SimpleDataSource(data=data))

Generating a plot from CSV file

csv_file = open("hello.csv")
LineChart(CSVDataSource(csv_file))

Generating a plot from the ORM

queryset = Accounts.objects.filter(foo=bar)
LineChart(ModelDataSource(queryset, fields=["year", "sales", "expenses"]))

Generating a plot from Redis

Todo

Generating a plot from MongoDB

Todo

Installation

Todo - need to publish the app at Pypi after competion

Creating new DataSource

A DataSource is a class which has these three methods.

get_data
get_header
get_first_column

get_header is used by a Renderer to create the labels. get_first_column is used to set the x axis labels get_data is used to get the data for display. It should always return a nested list. Eg:

[
    ['Year', 'Sales', 'Expenses'],
    [2004, 1000, 400],
    [2005, 1170, 460],
    [2006, 660, 1120],
    [2007, 1030, 540]
]

If you create a class extending SimpleDataSource, and implement get_data. You get get_header and get_first_column for free.

Creating new Renderer

A renderer is a class which takes a DataSource and can convert it to the html to display.

The only required method on a Renderer is as_html. This will convert the dat ato a format which can display the chart.

Generally you will convert the data to json and pass it to the template which you return.

License

BSD

django-graphos's People

Contributors

akshar-raaj avatar atmb4u avatar balu-varanasi avatar krvc avatar mahmoudhossam avatar shabda avatar tuxcanfly avatar

Watchers

 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.