Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time

Python Wrapper for NVD3 - It's time for beautiful charts

Description:Python-nvd3 is a wrapper for NVD3 graph library
D3:Data-Driven Documents
Maintainers:Areski & Oz
Contributors:list of contributors Latest Version Downloads Supported Python versions License Requirements Status

NVD3 is an attempt to build re-usable charts and chart components for d3.js without taking away the power that d3.js offers you.

Python-NVD3 makes your life easy! You write Python and the library renders JavaScript for you! These graphs can be part of your web application:

Want to try it yourself? Install python-nvd3, enter your python shell and try this quick demo:

>>> from nvd3 import pieChart
>>> type = 'pieChart'
>>> chart = pieChart(name=type, color_category='category20c', height=450, width=450)
>>> xdata = ["Orange", "Banana", "Pear", "Kiwi", "Apple", "Strawberry", "Pineapple"]
>>> ydata = [3, 4, 0, 1, 5, 7, 3]
>>> extra_serie = {"tooltip": {"y_start": "", "y_end": " cal"}}
>>> chart.add_serie(y=ydata, x=xdata, extra=extra_serie)
>>> chart.buildcontent()
>>> print chart.htmlcontent

This will output the following HTML to render a live chart. The HTML could be stored into a HTML file, used in a Web application, or even used via Ipython Notebook:

<div id="pieChart"><svg style="width:450px;height:450px;"></svg></div>
data_pieChart=[{"values": [{"value": 3, "label": "Orange"},
               {"value": 4, "label": "Banana"},
               {"value": 0, "label": "Pear"},
               {"value": 1, "label": "Kiwi"},
               {"value": 5, "label": "Apple"},
               {"value": 7, "label": "Strawberry"},
               {"value": 3, "label": "Pineapple"}], "key": "Serie 1"}];

nv.addGraph(function() {
    var chart = nv.models.pieChart();
    chart.margin({top: 30, right: 60, bottom: 20, left: 60});
    var datum = data_pieChart[0].values;
            chart.tooltipContent(function(key, y, e, graph) {
                var x = String(key);
                var y =  String(y)  + ' cal';
                tooltip_str = '<center><b>'+x+'</b></center>' + y;
                return tooltip_str;
        .x(function(d) { return d.label })
        .y(function(d) { return d.value });
    chart.height(450);'#pieChart svg')
        .attr('width', 450)
        .attr('height', 450)


Check out the documentation on Read the Docs for some live Chart examples!


Install, upgrade and uninstall python-nvd3 with these commands:

$ pip install python-nvd3
$ pip install --upgrade python-nvd3
$ pip uninstall python-nvd3


D3 and NvD3 can be installed through bower (which itself can be installed through npm). See and for further information. To install bower globally execute:

$ npm install -g bower

Note : you might prefer to save your npm dependencies locally in a package.json file.

Then in the directory where you will use python-nvd3, just execute the following commands:

$ bower install d3#3.5.17
$ bower install nvd3#1.8.6

This will create a directory "bower_components" where d3 & nvd3 will be saved.

Note : you might prefer to save your bower dependencies locally in a bower.json file. You can also configure the directory where your bower dependencies will be saved adding a .bowerrc file in your project root directory.

Django Wrapper

There is also a django wrapper for nvd3 available:

IPython Notebooks

Python-NVD3 works nicely within IPython Notebooks (thanks to @jdavidheiser)

See the examples directory for an Ipython notebook with python-nvd3.


Python-nvd3 is licensed under MIT, see MIT-LICENSE.txt.