Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/python_nvd3-0.14.2-py3.8.egg/nvd3/cumulativeLineChart.py: 32%
19 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 cumulativeLineChart(TemplateMixin, NVD3Chart):
16 """
17 A cumulative line chart is used when you have one important grouping representing
18 an ordered set of data and one value to show, summed over time.
20 Python example::
22 from nvd3 import cumulativeLineChart
23 chart = cumulativeLineChart(name='cumulativeLineChart', x_is_date=True)
24 xdata = [1365026400000, 1365026500000, 1365026600000]
25 ydata = [6, 5, 1]
26 y2data = [36, 55, 11]
28 extra_serie = {"tooltip": {"y_start": "There are ", "y_end": " calls"}}
29 chart.add_serie(name="Serie 1", y=ydata, x=xdata, extra=extra_serie)
31 extra_serie = {"tooltip": {"y_start": "", "y_end": " mins"}}
32 chart.add_serie(name="Serie 2", y=y2data, x=xdata, extra=extra_serie)
33 chart.buildhtml()
34 print(chart.content)
37 Javascript generated:
40 .. include:: ./examples/cumulativeLineChart.html
43 """
45 CHART_FILENAME = "./cumulativelinechart.html"
46 template_chart_nvd3 = NVD3Chart.template_environment.get_template(CHART_FILENAME)
48 def __init__(self, **kwargs):
49 super(cumulativeLineChart, self).__init__(**kwargs)
50 self.model = 'cumulativeLineChart'
52 height = kwargs.get('height', 450)
53 width = kwargs.get('width', None)
55 if kwargs.get('x_is_date', False):
56 self.set_date_flag(True)
57 self.create_x_axis('xAxis',
58 format=kwargs.get('x_axis_format', '%d %b %Y'),
59 date=True)
60 self.set_custom_tooltip_flag(True)
61 else:
62 self.create_x_axis('xAxis', format=kwargs.get(
63 'x_axis_format', '.2f'))
65 self.create_y_axis('yAxis', format=kwargs.get('y_axis_format', '.1%'))
67 self.set_graph_height(height)
68 if width:
69 self.set_graph_width(width)