Skip to content

Commit

Permalink
[ipython] fix canvas width/height usage
Browse files Browse the repository at this point in the history
Use GetCanvasWidth()/GetCanvasHeight() for obtain proper dimension
Do not swap width/height arguments
  • Loading branch information
linev committed Sep 19, 2023
1 parent 06d8baa commit 14673b8
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions bindings/jupyroot/python/JupyROOT/helpers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
// We are in jupyter notebooks, use require.js which should be configured already
requirejs.config({{
paths: {{ 'JSRootCore' : [ 'build/jsroot', 'https://root.cern/js/7.2.1/build/jsroot', 'https://jsroot.gsi.de/7.2.1/build/jsroot' ] }}
paths: {{ 'JSRootCore' : [ 'build/jsroot', 'https://root.cern/js/7.3.4/build/jsroot', 'https://jsroot.gsi.de/7.3.4/build/jsroot' ] }}
}})(['JSRootCore'], function(Core) {{
display_{jsDivId}(Core);
}});
Expand All @@ -94,7 +94,7 @@
// Try loading a local version of requirejs and fallback to cdn if not possible.
script_load_{jsDivId}(base_url + 'static/build/jsroot.js', function(){{
console.error('Fail to load JSROOT locally, please check your jupyter_notebook_config.py file');
script_load_{jsDivId}('https://root.cern/js/7.2.1/build/jsroot.js', function(){{
script_load_{jsDivId}('https://root.cern/js/7.3.4/build/jsroot.js', function(){{
document.getElementById("{jsDivId}").innerHTML = "Failed to load JSROOT";
}});
}});
Expand Down Expand Up @@ -529,21 +529,21 @@ def _getJsCode(self):
divId = 'root_plot_' + str(self._getUID())

height = _jsCanvasHeight
width = _jsCanvasHeight
width = _jsCanvasWidth
options = "all"

if self.isCanvas:
height = self.drawableObject.GetWw()
width = self.drawableObject.GetWh()
if self.drawableObject.GetWindowWidth() > 0: width = self.drawableObject.GetWindowWidth()
if self.drawableObject.GetWindowHeight() > 0: height = self.drawableObject.GetWindowHeight()
options = ""

if self.isRCanvas:
if (self.drawableObject.GetWidth() > 0): width = self.drawableObject.GetWidth()
if (self.drawableObject.GetHeight() > 0): height = self.drawableObject.GetHeight()
if self.drawableObject.GetWidth() > 0: width = self.drawableObject.GetWidth()
if self.drawableObject.GetHeight() > 0: height = self.drawableObject.GetHeight()
options = ""

thisJsCode = _jsCode.format(jsCanvasWidth = height,
jsCanvasHeight = width,
thisJsCode = _jsCode.format(jsCanvasWidth = width,
jsCanvasHeight = height,
jsonContent = json,
jsDrawOptions = options,
jsDivId = divId)
Expand Down

0 comments on commit 14673b8

Please sign in to comment.