I am struggling to find the error in my function and wonder what is the best way to do this:
In
I play with exploring different ways to visualize a chess game. I wanted to see how it looks like to add the moves as a text on a textpath.
The visualization returned from the function version5() works as expected and shows the moves along the path. There is obviously an overlap problem but also the orientation of the text is sometimes upside down.
I tried to fix the latter with version6().
It just differs form version5() by adding a .attr(ātransformā, rotate) to flip the text. however the moves which are supposed to be flipped are disappearing (I suppose the translation before the rotation is wrong)
So the function which does something wrong is the function rotate which is defined as follows:
For general notebook debugging, are you making use of your browserās dev tools? I often use console.log to print out intermediate values in the dev console and debugger to set a breakpoint in the JavaScript debugger (which you can then use to step through execution). Thereās some basic advice here.
I guess because getBBox is failing. Maybe related to this post?
In Chrome bbox becomes an SVGRect {x: 0, y: 0, width: 0, height: 0}, which causes all rx and ry to be zero, and seems like it may not be what you want.
Yes, I use Google Chromes dev tools - or Visual code studio and its debugging options.
WIth observable I donāt know how to find my source code in the browsers dev tool (so I canāt set a breakpoint) But the classic console.log helped!
As you mentioned, the reason for this behaviour is probably due to the explanation of Mike that the DOM is not build yet which you linked.
I wasnāt able to easily adopt this solution to my case - but found a way to compute the position without needing the access to this.getBBox().
and when I have more time, I want to import and adjust your @bchen observable so the user can also input a game by moving pieces with chessboard.js.
Thanks for the great help!
When Iām having a problem with something in Observable, and Iām using the online editor, I find Iām not using the browser debuggers as often anymore. I usually break the problem function and code down, line by line as needed into separate cells, starting with a copy of the original cell/function and using Alt-Enter to break up until I find a bad value or logic. If I need to peek into some code with svg or canvas elements, Iāll set the value property so I can inspect the internal variables or selections outside the cell if needed. i.e. svg.property(āvalueā, {xA, yA, svg, g_pnts}).