Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/nvd3/cumulativeLineChart.py: 30%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

20 statements  

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 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. 

19 

20 Python example:: 

21 

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] 

27 

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) 

30 

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) 

35 

36 

37 Javascript generated: 

38 

39 

40 .. include:: ./examples/cumulativeLineChart.html 

41 

42 

43 """ 

44 

45 CHART_FILENAME = "./cumulativelinechart.html" 

46 template_chart_nvd3 = NVD3Chart.template_environment.get_template(CHART_FILENAME) 

47 

48 def __init__(self, **kwargs): 

49 super(cumulativeLineChart, self).__init__(**kwargs) 

50 self.model = 'cumulativeLineChart' 

51 

52 height = kwargs.get('height', 450) 

53 width = kwargs.get('width', None) 

54 

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')) 

64 

65 self.create_y_axis('yAxis', format=kwargs.get('y_axis_format', '.1%')) 

66 

67 self.set_graph_height(height) 

68 if width: 

69 self.set_graph_width(width)