Python-nvd3 is a Python wrapper for NVD3 graph library. NVD3 is an attempt to build re-usable charts and chart components for d3.js without taking away the power that d3.js gives you.

Project location : https://github.com/areski/python-nvd3

discreteBarChart

class nvd3.discreteBarChart.discreteBarChart(**kwargs)

A discrete bar chart or bar graph is a chart with rectangular bars with lengths proportional to the values that they represent.

../_images/discreteBarChart.png

Python example:

from nvd3 import discreteBarChart
chart = discreteBarChart(name='discreteBarChart', height=400, width=400)

xdata = ["A", "B", "C", "D", "E", "F"]
ydata = [3, 4, 0, -3, 5, 7]

chart.add_serie(y=ydata, x=xdata)
chart.buildhtml()

Javascript generated:

nv.addGraph(function() {
    var chart = nv.models.discreteBarChart();
    chart.tooltipContent(function(key, y, e, graph) {
        var x = String(graph.point.x);
        var y = String(graph.point.y);
        var y = String(graph.point.y);
        tooltip_str = '<center><b>'+key+'</b></center>' + y + ' at ' + x;
        return tooltip_str;
    });
    d3.select('#discreteBarChart svg')
        .datum(data_discreteBarChart)
        .transition().duration(500)
        .attr('width', 400)
        .attr('height', 400)
        .call(chart);

return chart;
});data_discreteBarChart=[
    {"key": "Serie 1",
    "yAxis": "1",
    "values": [{"x": "A", "y": 3},
               {"x": "B", "y": 4},
               {"x": "C", "y": 0},
               {"x": "D", "y": 3},
               {"x": "E", "y": 5},
               {"x": "F", "y": 7}
]}];