scikit-hep / vegascope

View Vega/Vega-Lite plots in your web browser from local or remote Python processes.
BSD 3-Clause "New" or "Revised" License
35 stars 4 forks source link

[unexpected behavior] using canvas.svg() in loop #9

Open MaGrMo opened 4 years ago

MaGrMo commented 4 years ago

hello have a problem with unexpected behavior using svg() method in loop here is code sample:

There duplicated SVG outputs files. or some of them is empty or both conditions managers = ['man1','man2','man3'] canvas = vegascope.LocalCanvas() for man in managers: canvas.svg(get_vega_data(man), man)

if init of the object LocalCanvas in loop there works ok, but there lot of browser tabs is opened. managers = ['man1','man2','man3'] for man in managers: canvas = vegascope.LocalCanvas() canvas.svg(get_vega_data(man), man)

thanks a Lot! (Editor wraps formatting Sorry( ) )

jpivarski commented 4 years ago

I have to think hard to remember how this worked, but I think that vegascope.LocalCanvas() is supposed to create a new browser tab. To reuse an existing tab, you should call canvas.svg repeatedly on the same canvas. (My apologies if I have the interface wrong—it's all documented on the GitHub readme—take this as a hint that there is one command to make new tabs and other to refill the same tab.)

MaGrMo commented 4 years ago

Thanks but i 1st case of code I'm reusing of the instance canvas = vegascope.LocalCanvas() but there is problem That saved svg - data browser is showing ok, but saving is not predictable behavior.