@@ -30,7 +30,7 @@ def dump_obj_state(obj, pyjviz_opts = None):
30
30
if isinstance (obj , pd .DataFrame ):
31
31
dump_DataFrame_obj_state (obj_state_uri , obj , output_type )
32
32
elif isinstance (obj , pd .Series ):
33
- dump_Series_obj_state (obj_state_uri , obj )
33
+ dump_Series_obj_state (obj_state_uri , obj , output_type )
34
34
else :
35
35
raise Exception (f"unknown obj type at { obj_state_uri } " )
36
36
@@ -53,6 +53,17 @@ def dump_DataFrame_obj_state(obj_state_uri, df, output_type):
53
53
raise Exception (f"unknown output_type: { output_type } " )
54
54
55
55
56
- def dump_Series_obj_state (obj_state_uri , s ):
56
+ def dump_Series_obj_state (obj_state_uri , s , output_type ):
57
57
fstriplestore .triple_store .dump_triple (obj_state_uri , "<df-shape>" , f'"{ s .shape } "' )
58
-
58
+ if output_type == 'head' :
59
+ pass
60
+ elif output_type == 'plot' :
61
+ out_fd = io .BytesIO ()
62
+ fig = s .plot ().get_figure ()
63
+ fig .savefig (out_fd )
64
+ #ipdb.set_trace()
65
+ im_s = base64 .b64encode (out_fd .getvalue ()).decode ('ascii' )
66
+ fstriplestore .triple_store .dump_triple (obj_state_uri , '<df-plot>' , '"' + im_s + '"' )
67
+ else :
68
+ raise Exception (f"unknown output_type: { output_type } " )
69
+
0 commit comments