1#!/usr/bin/python
2# -*- coding: utf-8 -*-
3
4"""
5Python-nvd3 is a Python wrapper for NVD3 graph library.
6NVD3 is an attempt to build re-usable charts and chart components
7for d3.js without taking away the power that d3.js gives you.
8
9Project location : https://github.com/areski/python-nvd3
10"""
11
12from .NVD3Chart import NVD3Chart, TemplateMixin
13
14
15class multiBarHorizontalChart(TemplateMixin, NVD3Chart):
16 """
17 A multiple horizontal bar graph contains comparisons of two or more categories or bars.
18
19 Python example::
20
21 from nvd3 import multiBarHorizontalChart
22 chart = multiBarHorizontalChart(name='multiBarHorizontalChart', height=400, width=400)
23 xdata = [-14, -7, 7, 14]
24 ydata = [-6, 5, -1, 9]
25 y2data = [-23, -6, -32, 9]
26
27 extra_serie = {"tooltip": {"y_start": "", "y_end": " balls"}}
28 chart.add_serie(name="Serie 1", y=ydata, x=xdata, extra=extra_serie)
29
30 extra_serie = {"tooltip": {"y_start": "", "y_end": " calls"}}
31 chart.add_serie(name="Serie 2", y=y2data, x=xdata, extra=extra_serie)
32 chart.buildhtml()
33 print(chart.content)
34
35 Javascript generated:
36
37 .. include:: ./examples/multiBarHorizontalChart.html
38
39 """
40
41 CHART_FILENAME = "./multibarcharthorizontal.html"
42 template_chart_nvd3 = NVD3Chart.template_environment.get_template(CHART_FILENAME)
43
44 def __init__(self, **kwargs):
45 super(multiBarHorizontalChart, self).__init__(**kwargs)
46 height = kwargs.get('height', 450)
47 width = kwargs.get('width', None)
48
49 self.create_x_axis('xAxis', format=kwargs.get('x_axis_format', '.2f'))
50 self.create_y_axis('yAxis', format=kwargs.get('y_axis_format', '.2f'))
51
52 self.set_graph_height(height)
53 if width:
54 self.set_graph_width(width)