Skip to content

Commit b48ce42

Browse files
committed
added plot output for series
1 parent 6645633 commit b48ce42

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

pyjviz/obj_utils.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def dump_obj_state(obj, pyjviz_opts = None):
3030
if isinstance(obj, pd.DataFrame):
3131
dump_DataFrame_obj_state(obj_state_uri, obj, output_type)
3232
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)
3434
else:
3535
raise Exception(f"unknown obj type at {obj_state_uri}")
3636

@@ -53,6 +53,17 @@ def dump_DataFrame_obj_state(obj_state_uri, df, output_type):
5353
raise Exception(f"unknown output_type: {output_type}")
5454

5555

56-
def dump_Series_obj_state(obj_state_uri, s):
56+
def dump_Series_obj_state(obj_state_uri, s, output_type):
5757
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

Comments
 (0)