Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/python_nvd3-0.14.2-py3.8.egg/nvd3/multiBarHorizontalChart.py: 43%
14 statements
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-03 06:16 +0000
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-03 06:16 +0000
1#!/usr/bin/python
2# -*- coding: utf-8 -*-
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.
9Project location : https://github.com/areski/python-nvd3
10"""
12from .NVD3Chart import NVD3Chart, TemplateMixin
15class multiBarHorizontalChart(TemplateMixin, NVD3Chart):
16 """
17 A multiple horizontal bar graph contains comparisons of two or more categories or bars.
19 Python example::
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]
27 extra_serie = {"tooltip": {"y_start": "", "y_end": " balls"}}
28 chart.add_serie(name="Serie 1", y=ydata, x=xdata, extra=extra_serie)
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)
35 Javascript generated:
37 .. include:: ./examples/multiBarHorizontalChart.html
39 """
41 CHART_FILENAME = "./multibarcharthorizontal.html"
42 template_chart_nvd3 = NVD3Chart.template_environment.get_template(CHART_FILENAME)
44 def __init__(self, **kwargs):
45 super(multiBarHorizontalChart, self).__init__(**kwargs)
46 height = kwargs.get('height', 450)
47 width = kwargs.get('width', None)
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'))
52 self.set_graph_height(height)
53 if width:
54 self.set_graph_width(width)