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

NVD3Chart

class nvd3.NVD3Chart.NVD3Chart(**kwargs)

NVD3Chart Base class

Attributes:

  • axislist - All X, Y axis list
  • charttooltip_dateformat - date format for tooltip if x-axis is in date format
  • charttooltip - Custom tooltip string
  • color_category - Defien color category (eg. category10, category20, category20c)
  • color_list - used by pieChart (eg. [‘red’, ‘blue’, ‘orange’])
  • container - Place for graph
  • containerheader - Header for javascript code
  • count - chart count
  • custom_tooltip_flag - False / True
  • date_flag - x-axis contain date format or not
  • dateformat - see https://github.com/mbostock/d3/wiki/Time-Formatting
  • header_css - False / True
  • header_js - Custom tooltip string
  • height - Set graph height
  • htmlcontent - Contain the htmloutput
  • htmlheader - Contain the html header
  • jschart - Javascript code as string
  • margin_bottom - set the bottom margin
  • margin_left - set the left margin
  • margin_right - set the right margin
  • margin_top - set the top margin
  • model - set the model (ex. pieChart, LineWithFocusChart, MultiBarChart)
  • resize - False / True
  • series - Series are list of data that will be plotted
  • stacked - False / True
  • style - Special style
  • template_page_nvd3 - template variable
  • use_interactive_guideline - False / True
  • width - Set graph width
  • x_axis_date - False / True
  • show_legend - False / True
  • show_labels - False / True
  • assets_directory directory holding the assets (./bower_components/)
add_serie(y, x, name=None, extra={}, **kwargs)

add serie - Series are list of data that will be plotted y {1, 2, 3, 4, 5} / x {1, 2, 3, 4, 5}

Attributes:

  • name - set Serie name
  • x - x-axis data
  • y - y-axis data

kwargs:

  • shape - for scatterChart, you can set different shapes (circle, triangle etc...)
  • size - for scatterChart, you can set size of different shapes
  • type - for multiChart, type should be bar
  • bar - to display bars in Chart
  • color_list - define list of colors which will be used by pieChart
  • color - set axis color
  • disabled -

extra:

  • tooltip - set tooltip flag
  • date_format - set date_format for tooltip if x-axis is in date format
buildcontainer()

generate HTML div

buildcontent()

Build HTML content only, no header or body tags. To be useful this will usually require the attribute juqery_on_ready to be set which will wrap the js in $(function(){<regular_js>};)

buildhtml()

Build the HTML page Create the htmlheader with css / js Create html page Add Js code for nvd3

buildhtmlheader()

generate HTML header content

buildjschart()

generate javascript code for the chart

create_x_axis(name, label=None, format=None, date=False, custom_format=False)

Create X-axis

create_y_axis(name, label=None, format=None, custom_format=False)

Create Y-axis

set_containerheader(containerheader)

Set containerheader

set_custom_tooltip_flag(custom_tooltip_flag)

Set custom_tooltip_flag & date_flag

set_date_flag(date_flag=False)

Set date flag

set_graph_height(height)

Set Graph height

set_graph_width(width)

Set Graph width

slugify_name(name)

Slufigy name with underscore