Skip to content

Commit 0871044

Browse files
committed
[jupyter] embed json with zip compression
Use TBufferJSON.zipJSON method. dev version of JSROOT has to be used to be able unpack such string.
1 parent ef43f93 commit 0871044

File tree

1 file changed

+7
-4
lines changed
  • bindings/jupyroot/python/JupyROOT/helpers

1 file changed

+7
-4
lines changed

bindings/jupyroot/python/JupyROOT/helpers/utils.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@
5757
function process_{jsDivId}() {{
5858
function drawPlot(Core) {{
5959
Core.settings.HandleKeys = false;
60-
const obj = Core.parse({jsonContent});
61-
Core.draw("{jsDivId}", obj, "{jsDrawOptions}");
60+
Core.unzipJSON({jsonLength},'{jsonZip}').then(json => {{
61+
const obj = Core.parse(json);
62+
Core.draw('{jsDivId}', obj, '{jsDrawOptions}');
63+
}});
6264
}}
63-
const servers = ['/static/', 'https://root.cern/js/7.9.1/', 'https://jsroot.gsi.de/7.9.1/'],
65+
const servers = ['/static/', 'https://jsroot.gsi.de/dev/', 'https://root.cern/js/dev/'],
6466
path = 'build/jsroot';
6567
if (typeof JSROOT !== 'undefined')
6668
drawPlot(JSROOT);
@@ -586,6 +588,7 @@ def _getJsCode(self):
586588

587589
width = _jsCanvasWidth
588590
height = _jsCanvasHeight
591+
jsonzip = ROOT.TBufferJSON.zipJSON(json)
589592
options = "all"
590593

591594
if self.isCanvas:
@@ -603,7 +606,7 @@ def _getJsCode(self):
603606
options = ""
604607

605608
thisJsCode = _jsCode.format(
606-
jsCanvasWidth=width, jsCanvasHeight=height, jsonContent=json, jsDrawOptions=options, jsDivId=divId
609+
jsCanvasWidth=width, jsCanvasHeight=height, jsonLength=len(json), jsonZip=jsonzip, jsDrawOptions=options, jsDivId=divId
607610
)
608611
return thisJsCode
609612

0 commit comments

Comments
 (0)