Recreating D3 example failed
See original GitHub issue🐛 Bug
I tried to recreate an example for this D3 network graph in PyScript (minimal example here) then came across this error:
Uncaught TypeError: jsargs is not iterable (cannot read property undefined)
at Proxy.apply (pyproxy.gen.ts:1145:19)
at Dispatch.call (d3-dispatch.js:58:18)
at step (d3-force.js:228:13)
at timerFlush (d3-timer.js:49:15)
at wake (d3-timer.js:58:5)
To Reproduce
See https://github.com/Cheukting/Cheukting.github.io/blob/master/assets/html/min-network-d3.html
Expected behavior
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Recreate D3 Multi-Line Chart on Resize (responsive)
1 Answer 1 · Parse the data, append svg with initial height and width, append X, Y axes just once but move drawBars...
Read more >D3 chunk fails where D3 js file succeeds when `split ... - GitHub
The D3 file is rendered correctly without an error. Since D3 handles the data correctly, r2d3 in a an R Markdown's d3 chunk...
Read more >D3.js Tutorial – Data Visualization for Beginners
In this article, I'm going to walk you through how to use D3.js in a step by step and beginner-friendly way. We'll talk...
Read more >Introduction to D3, Part 1 / UW Interactive Data Lab - Observable
In this notebook, we will gain familiarity with one of the most widely used visualization grammars: D3.js. Let's start by importing the D3...
Read more >The Big List of D3.js Examples - Christophe Viau
... A KoExtensions example: #d3js KnockoutJS, RavenDB, WebAPI, Bootstrap · A line chart plotting unit sales, colored by price for d3 data visualisations ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for investigating @leriomaggio and @hoodmane for fixing it in #3101!
Ok so I played with it a little bit and here is what I found.
Expanding a bit about this (with the help of Browser inspector) in
d3-dispatch.js
(around lines51-59
)L58
gets evaluated becausethis
(theDispatch
) looks like:args
will later be thejargs
in question forPyProxy
that is indeedundefined
as none of the previous lines incall
(fromd3-dispatch.js
) where evaluated.Therefore, from the Pyodide side, these situations could be potentially accounted for by checking whether
jargs
isundefined
or not and so call thePyObject
accordingly.I don’t know whether that makes any sense, tbh (disclaimer 😅 ), but I think the issue here is perhaps a bit more philosophical (re specific example, see below)
Proxy
conversion - that is perhaps not the right thing to do here.TLDR; I replaced
create_proxy
withcreate_once_callable
for theticked
PyFunction and it works! This function is meant to be called once (on("end"..)
in fact) Therefore I thought that a quick to consumePyProxy
object is what was more appropriate… and it worked 🎉More specifically on the issue: I looked carefully at what happens on the
call stack
when it generates the error.With Porxy,
d3-dispatch
evaluates immediatelypyproxy-gen-ts
(L1145
) that raises the exception as the object inthis
is a Proxy (not being available yet from the promise? 🤔 )With Once Callable,
this
contains directly thewrapper
function ready to be invoked bypyodide-asm
(L14
) which is indeed already the callable we need there 😃I hope this helps in shading some light on the issue at hand?