Skip to content

Commit 370d3a1

Browse files
committed
add another linechart example showing new features
1 parent f3a64d1 commit 370d3a1

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

‎examples/lineChartXY.py‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/python
2+
# -*- coding: utf-8 -*-
3+
4+
"""
5+
Examples for Python-nvd3 is a Python wrapper for NVD3 graph library.
6+
NVD3 is an attempt to build re-usable charts and chart components
7+
for d3.js without taking away the power that d3.js gives you.
8+
9+
Project location : https://github.com/areski/python-nvd3
10+
"""
11+
12+
from nvd3 import lineChart
13+
import math
14+
from numpy import sin,pi,linspace
15+
16+
output_file = open('test_lineChartXY.html', 'w')
17+
18+
chart = lineChart(name="lineChart", date=False, x_format="f",y_format="f", width=500, height=500, show_legend=False)
19+
20+
#lissajous parameters of a/b
21+
a = [1,3,5,3]
22+
b = [1,5,7,4]
23+
delta = pi/2
24+
t = linspace(-pi,pi,300)
25+
26+
for i in range(0,4):
27+
x = sin(a[i] * t + delta)
28+
y = sin(b[i] * t)
29+
30+
chart.add_serie(y=y, x=x, name='lissajous-n%d' % i, color='red' if i == 0 else 'black')
31+
32+
chart.buildhtml()
33+
34+
output_file.write(chart.htmlcontent)
35+
36+
output_file.close()

0 commit comments

Comments
 (0)