forked from areski/python-nvd3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinePlusBarWithFocusChart_AMPM.py
More file actions
51 lines (39 loc) · 1.53 KB
/
Copy pathlinePlusBarWithFocusChart_AMPM.py
File metadata and controls
51 lines (39 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Examples for 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
"""
from nvd3 import linePlusBarWithFocusChart
#Open File for test
output_file = open('test_linePlusBarWithFocusChart_AMPM.html', 'w')
#---------------------------------------
type = "linePlusBarWithFocusChart"
chart = linePlusBarWithFocusChart(name=type, x_is_date=False, x_axis_format="AM_PM")
chart.set_containerheader("\n\n<h2>" + type + "</h2>\n\n")
xdata = [i for i in range(0, 24)]
ydata = [0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 4, 3, 3, 5, 7, 5, 3, 16, 6, 9, 15, 4, 12]
ydata2 = [9, 8, 11, 8, 3, 7, 10, 8, 6, 6, 9, 6, 5, 4, 3, 10, 0, 6, 3, 1, 0, 0, 0, 1]
ydata3 = [9, 8, 15, 8, 4, 7, 20, 8, 4, 6, 0, 4, 5, 7, 3, 15, 30, 6, 3, 1, 0, 0, 0, 1]
extra_serie_1 = {
"tooltip": {"y_start": "$ ", "y_end": ""},
"date_format": "",
}
kwargs = {"bar": "true"}
chart.add_serie(name="serie 1", y=ydata, x=xdata, extra=extra_serie_1, **kwargs)
extra_serie_2 = {
"tooltip": {"y_start": "$ ", "y_end": ""},
"date_format": "",
}
chart.add_serie(name="serie 2", y=ydata2, x=xdata, extra=extra_serie_2)
extra_serie_3 = {
"tooltip": {"y_start": "$ ", "y_end": ""},
"date_format": "",
}
chart.add_serie(name="serie 3", y=ydata3, x=xdata, extra=extra_serie_3)
chart.buildhtml()
output_file.write(chart.htmlcontent)
#close Html file
output_file.close()