File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 11import collections
2-
32from functools import partial
43from itertools import chain
54import inspect
@@ -58,7 +57,6 @@ def __init__(self):
5857 if hasattr (base , 'options' ):
5958 update (self ._options , base .options )
6059
61-
6260 @property
6361 def series_json (self ):
6462 """
@@ -77,10 +75,14 @@ def options_json(self):
7775 """
7876 return json .dumps (self ._options )
7977
80- #add_bars
81- #add_line
82- #add_points
8378 def __getattr__ (self , value ):
79+ """
80+ add_bars
81+ add_line
82+ add_points
83+
84+ provides shortcut methods for adding series using a particular line type
85+ """
8486 if value .startswith ('add_' ):
8587 return partial (self .add_series_type , value [4 :])
8688
Original file line number Diff line number Diff line change @@ -99,6 +99,14 @@ def test_add_time_series(self):
9999 self .assertEqual (self .flot ._options ['xaxis' ],
100100 {'mode' : 'time' })
101101
102+ def test_add_bars (self ):
103+ "test the shortcut for adding a series as bars"
104+ series = {'data' : ((0 ,0 ), ) + S1 ,
105+ "bars" : {"barWidth" : 0.75 , "show" : True }}
106+ self .flot .add_bars (((0 ,0 ), ) + S1 )
107+ self .assertEqual (self .flot ._series [0 ]['bars' ], {'show' : True })
108+ self .assertEqual (json .dumps ([series ]), self .flot .series_json )
109+
102110 def test_empty_options_json (self ):
103111 "make sure conversion to JSON works for default options"
104112 self .assertEqual ("{}" , self .flot .options_json )
You can’t perform that action at this time.
0 commit comments