99import json
1010from collections import MutableSequence
1111from plotly import exceptions
12- import plotly
12+ from plotly import utils
1313
1414__all__ = None
1515
@@ -24,7 +24,7 @@ def __init__(self, data, name):
2424
2525 def __str__ (self ):
2626 max_chars = 10
27- jdata = json .dumps (self .data , cls = plotly . utils ._plotlyJSONEncoder )
27+ jdata = json .dumps (self .data , cls = utils ._plotlyJSONEncoder )
2828 if len (jdata ) > max_chars :
2929 data_string = jdata [:max_chars ] + "...]"
3030 else :
@@ -33,13 +33,16 @@ def __str__(self):
3333 return string .format (name = self .name , data = data_string , id = self .id )
3434
3535 def __repr__ (self ):
36- return 'Column("{}", {})' .format (self .data , self .name )
36+ return 'Column("{}", {})' .format (self .data , self .name )
37+
38+ def to_json (self ):
39+ return {'name' : self .name , 'data' : self .data }
3740
3841
3942class Grid (MutableSequence ):
4043 def __init__ (self , iterable_of_columns ):
4144 column_names = [column .name for column in iterable_of_columns ]
42- duplicate_name = plotly . utils .get_first_duplicate (column_names )
45+ duplicate_name = utils .get_first_duplicate (column_names )
4346 if duplicate_name :
4447 err = exceptions .NON_UNIQUE_COLUMN_MESSAGE .format (duplicate_name )
4548 raise exceptions .InputError (err )
0 commit comments