@@ -43,7 +43,14 @@ def iplot(self, *args, **kwargs):
4343 res = self .__callplot (* args , ** kwargs )
4444 width = kwargs .get ('width' , 600 )
4545 height = kwargs .get ('height' , 600 )
46- s = '<iframe height="' + str (height + 50 )+ '" id="igraph" scrolling="no" seamless="seamless" src="' + res ['url' ]+ '/' + str (width )+ '/' + str (height )+ '" width="' + str (width + 50 )+ '"></iframe>'
46+ s = '<iframe height="%s" id="igraph" scrolling="no" seamless="seamless" src="%s" width="%s"></iframe>' % \
47+ (height + 50 , "/" .join (map (str , [res ['url' ], width , height ])), width + 50 )
48+ try :
49+ # see, if we are in the SageMath Cloud
50+ from sage_salvus import html
51+ return html (s , hide = False )
52+ except :
53+ pass
4754 try :
4855 from IPython .display import HTML
4956 return HTML (s )
@@ -171,11 +178,21 @@ def pandasJSONEncoder(self, obj):
171178 except :
172179 pass
173180 return None
181+ def sageJSONEncoder (self , obj ):
182+ try :
183+ from sage .all import RR , ZZ
184+ if obj in RR :
185+ return float (obj )
186+ elif obj in ZZ :
187+ return int (obj )
188+ except :
189+ pass
190+ return None
174191 def default (self , obj ):
175192 try :
176193 return json .dumps (obj )
177194 except TypeError as e :
178- encoders = (self .datetimeJSONEncoder , self .numpyJSONEncoder , self .pandasJSONEncoder )
195+ encoders = (self .datetimeJSONEncoder , self .numpyJSONEncoder , self .pandasJSONEncoder , self . sageJSONEncoder )
179196 for encoder in encoders :
180197 s = encoder (obj )
181198 if s is not None :
0 commit comments