1111from nvd3 import discreteBarChart
1212from nvd3 import pieChart
1313from nvd3 import multiBarChart
14+ from nvd3 import linePlusBarWithFocusChart
15+ from nvd3 .NVD3Chart import stab
1416from nvd3 .translator import Function , AnonymousFunction , Assignment
1517import random
1618import unittest
@@ -52,6 +54,29 @@ def test_lineChart(self):
5254 chart .add_serie (y = ydata , x = xdata )
5355 chart .add_serie (y = ydata2 , x = xdata )
5456 chart .buildhtml ()
57+ #extra tests
58+ chart .buildcontent ()
59+ chart .buildhtmlheader ()
60+
61+ def test_lineChart_tooltip (self ):
62+ """Test Line Chart"""
63+ type = "lineChart"
64+ chart = lineChart (name = type , date = True , height = 350 )
65+ nb_element = 100
66+ xdata = list (range (nb_element ))
67+ xdata = [1365026400000 + x * 100000 for x in xdata ]
68+ ydata = [i + random .randint (1 , 10 ) for i in range (nb_element )]
69+ ydata2 = [x * 2 for x in ydata ]
70+
71+ kwargs1 = {'color' : 'green' }
72+ kwargs2 = {'color' : 'red' }
73+
74+ extra_serie = {"tooltip" : {"y_start" : "There is " , "y_end" : " random values" }}
75+ chart .add_serie (name = "Random X-Axis" , y = ydata , x = xdata , extra = extra_serie , ** kwargs1 )
76+ extra_serie = {"tooltip" : {"y_start" : "" , "y_end" : " double values" }}
77+ chart .add_serie (name = "Double X-Axis" , y = ydata2 , x = xdata , extra = extra_serie , ** kwargs2 )
78+
79+ chart .buildhtml ()
5580
5681 def test_linePlusBarChart (self ):
5782 """Test line Plus Bar Chart"""
@@ -89,7 +114,8 @@ def test_MultiBarChart(self):
89114 nb_element = 10
90115 xdata = list (range (nb_element ))
91116 ydata = [random .randint (1 , 10 ) for i in range (nb_element )]
92- chart .add_serie (y = ydata , x = xdata )
117+ extra = {"type" : "bar" , "yaxis" : 1 }
118+ chart .add_serie (y = ydata , x = xdata , extra = extra )
93119 chart .buildhtml ()
94120
95121 def test_multiBarHorizontalChart (self ):
@@ -154,7 +180,8 @@ def test_pieChart(self):
154180 type = "pieChart"
155181 chart = pieChart (name = type , color_category = 'category20c' , height = 400 , width = 400 )
156182 xdata = ["Orange" , "Banana" , "Pear" , "Kiwi" , "Apple" , "Strawberry" , "Pineapple" ]
157- extra_serie = {"tooltip" : {"y_start" : "" , "y_end" : " cal" }}
183+ color_list = ['orange' , 'yellow' , '#C5E946' , '#95b43f' , 'red' , '#FF2259' , '#F6A641' ]
184+ extra_serie = {"tooltip" : {"y_start" : "" , "y_end" : " cal" }, "color_list" : color_list }
158185 ydata = [3 , 4 , 0 , 1 , 5 , 7 , 3 ]
159186 chart .add_serie (y = ydata , x = xdata , extra = extra_serie )
160187 chart .buildhtml ()
@@ -168,6 +195,38 @@ def test_donutPieChart(self):
168195 chart .add_serie (y = ydata , x = xdata )
169196 chart .buildhtml ()
170197
198+ def test_lineplusbarwithfocuschart (self ):
199+ "Test LinePlusBar With FocusChart"
200+ type = "linePlusBarWithFocusChart"
201+ chart = linePlusBarWithFocusChart (name = type , color_category = 'category20b' ,
202+ x_is_date = True , x_axis_format = "%d %b %Y" )
203+ chart .set_containerheader ("\n \n <h2>" + type + "</h2>\n \n " )
204+ nb_element = 100
205+ xdata = list (range (nb_element ))
206+ start_time = int (time .mktime (datetime .datetime (2012 , 6 , 1 ).timetuple ()) * 1000 )
207+ #prepare series
208+ xdata = [start_time + x * 1000000000 for x in xdata ]
209+ ydata = [i + random .randint (- 10 , 10 ) for i in range (nb_element )]
210+ ydata2 = [200 - i + random .randint (- 10 , 10 ) for i in range (nb_element )]
211+ extra_serie_1 = {
212+ "tooltip" : {"y_start" : "$ " , "y_end" : "" },
213+ "date_format" : "%d %b %Y" ,
214+ }
215+ kwargs = {"bar" : "true" }
216+ chart .add_serie (name = "serie 1" , y = ydata , x = xdata , extra = extra_serie_1 , ** kwargs )
217+ extra_serie_2 = {
218+ "tooltip" : {"y_start" : "$ " , "y_end" : "" },
219+ "date_format" : "%d %b %Y" ,
220+ }
221+ chart .add_serie (name = "serie 2" , y = ydata2 , x = xdata , extra = extra_serie_2 )
222+ chart .buildhtml ()
223+
224+
225+ class FuncTest (unittest .TestCase ):
226+
227+ def test_stab (self ):
228+ self .assertEqual (" " , stab (1 ))
229+
171230
172231class TranslatorTest (unittest .TestCase ):
173232
0 commit comments