question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make notify-on-logging work with newPlot

See original GitHub issue

Right now we can’t use this function from Python because we only set config during newPlot.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
etpinardcommented, Mar 11, 2020

Currently, the loggers.js module requires the default plot config object:

https://github.com/plotly/plotly.js/blob/8f049fddbac0ca0382816984b8526857e9714fe6/src/lib/loggers.js#L13

and uses it to determine which log to show in the console and/or the notifier popups.

The default plot config object can be mutated using Plotly.setPlotConfig:

https://github.com/plotly/plotly.js/blob/8f049fddbac0ca0382816984b8526857e9714fe6/src/plot_api/plot_api.js#L402-L404

and this is the only way to get the logging and notifyOnLogging config option to work at the moment.

Routines that depend on the other config options do not rely on the default plot config object; they instead rely on the “graph” config (i.e context) coerced in gd._context during

https://github.com/plotly/plotly.js/blob/8f049fddbac0ca0382816984b8526857e9714fe6/src/plot_api/plot_api.js#L419-L524

So, to make the loggers.js know about gd._context, we’ll need to pass gd to all Lib.log, Lib.warn and Lib.error calls. For example,

// on https://github.com/plotly/plotly.js/blob/8f049fddbac0ca0382816984b8526857e9714fe6/src/plot_api/plot_api.js#L146
Lib.log('Legacy polar charts are deprecated!');

// would become
Lib.log(gd, 'Legacy polar charts are deprecated!');

Things might get annoying for cases when gd isn’t part of the scope in which Lib.(log|warn|error) is called from. Perhaps to make things easier to pass around, we could copy the logging and notifyOnLogging keys in fullLayout.


Note also, that queue module also uses the default plot config object:

https://github.com/plotly/plotly.js/blob/8f049fddbac0ca0382816984b8526857e9714fe6/src/lib/queue.js#L12

https://github.com/plotly/plotly.js/blob/8f049fddbac0ca0382816984b8526857e9714fe6/src/lib/queue.js#L91-L94

This thing is mostly deprecated, but maybe it would be a good idea to make it work with gd._context as well.

1reaction
nicolaskruchtencommented, Jul 6, 2020

We already have a config option for this, so all that’s needed is for it to work when set inline with newPlot 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Function reference in JavaScript - Plotly
Draws a new plot in an <div> element, overwriting any existing plot. To update an existing plot in a <div> , it is...
Read more >
plotly.js-dist | Yarn - Package Manager
... Add notifyOnLogging config option that allows log/warn/error messages to show up ... Make Plots.resize work when layout attribute is gone from graph...
Read more >
Source - GitHub
Rework `matches` and `scaleanchor` so they work together ... Add `notifyOnLogging` config option that allows log/warn/error messages to show up in notifiers ...
Read more >
CHANGELOG.md · res5692-no-longer-latest-cdn · mirrors / plotly ...
Rework matches and scaleanchor so they work together [#5287] ... Add notifyOnLogging config option that allows log/warn/error messages to show up in ...
Read more >
plotly Changelog - PyUp.io
Made the Plotly Express `trendline` argument more robust and made it work with ... Add `notifyOnLogging` config option that allows log/warn/error messages
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found