Skip to content

Option to disable log buttons - #609

Open
nvaytet wants to merge 2 commits into
mainfrom
option-to-disable-log-buttons
Open

nvaytet wants to merge 2 commits into
mainfrom
option-to-disable-log-buttons

Conversation

@nvaytet

@nvaytet nvaytet commented Sep 14, 2026

Copy link
Copy Markdown
Member

Sometimes, when we have many subplots, the log buttons on every axes get in the way (and they also slow things down when the mouse enters/leaves the axes).
We add an option to disable them.

ax=self.cax, label="log", position=(0.5, 0.98), va="top", **args
if not hide_log_buttons:
args = {"transform": self.ax.transAxes, "ha": "right", "va": "top"}
self._logx_button = CanvasToggleButton(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the attributes on self optional now? How does the rest of the class cope with this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff is misleading, the self._logx_button are set to None further up.

// Function to update SVG
function updateSVG() {
const svgData = new TextDecoder().decode(model.get('svg_data'));
svgContainer.innerHTML = svgData;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are sending unvalidated HTML to the DOM here. The same in HoverButtonWidget. But I guess this is well isolated enough that it doesn't receive arbitrary inputs?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I am? Suggestions for change?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be completely safe, I think you would have to do a bunch of validation manually or get a 3rd party library. But using an image element like this should help:

 <img src="data:image/svg+xml,{image-data}">

where {image-data} is the SVG source as a base64 encoded string.

Generally, this widget only receives inputs from Python, i.e., a process with system access. Python can do much worse than inject some malicious svg. So this might not be a concern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants