Image generation on Choropleth workflow is failing

Hi Knimers,
I’m making my first steps in “JavaScript country” and after climbing over the first hurdles I’m getting stuck on the image generation of the Google geochart I created (I have several of them and I want them to be included in a BIRT report). I’m using KNIME 4.5.2 on Windows10.

In order to get this working I made the following simplified workflow with just a Generic JavaScript View node.
afbeelding
This is the export of the above workflow.
question.knwf (9.7 KB)

I found these topics already on this subject: Generic Javascript Views -- How to SVG image generation --? and a solution of @wiswedel given in 07_Choropleth_World_Map - export image from generic javascript view - #6 by Rich_ard
But when I apply the exact “JavaScript to retrieve the generated SVG as a string” as provided in the solution I get the follow erring in my console:

ERROR Generic JavaScript View 0:100:0:67 Caught “BridgeException”: The markup in the document preceding the root element must be well-formed.

When I comment the try and catch like below this error disappears and the node can be excecuted normally.

The interactive view does shows up in the same way as without the image generation, but the actual image is not generated and giving this error:

Though the interactive view is working the console shows the following error:

ERROR Generic JavaScript View 7:102 Executing script failed after 10 attempts. The script is: ‘return document.getElementById(‘node-SINGLE’).contentWindow.knimeGenericView.getSVG();’

The knime.log shows, besides this error, the following:

2022-09-21 10:34:18,139 : DEBUG : main : : ExecuteAndOpenViewAction : : : Creating ‘Execute and Open Views’ job for 1 node(s)…
2022-09-21 10:34:18,240 : DEBUG : main : : NodeContainer : : : Generic JavaScript View 7:102 has new state: CONFIGURED_MARKEDFOREXEC
2022-09-21 10:34:18,241 : DEBUG : main : : NodeContainer : : : Generic JavaScript View 7:102 has new state: CONFIGURED_QUEUED
2022-09-21 10:34:18,438 : DEBUG : main : : NodeContainer : : : question 7 has new state: EXECUTING
2022-09-21 10:34:18,443 : DEBUG : KNIME-Worker-140-Generic JavaScript View 7:102 : : WorkflowManager : Generic JavaScript View : 7:102 : Generic JavaScript View 7:102 doBeforePreExecution
2022-09-21 10:34:18,640 : DEBUG : KNIME-Worker-140-Generic JavaScript View 7:102 : : NodeContainer : Generic JavaScript View : 7:102 : Generic JavaScript View 7:102 has new state: PREEXECUTE
2022-09-21 10:34:18,644 : DEBUG : KNIME-Worker-140-Generic JavaScript View 7:102 : : WorkflowDataRepository : Generic JavaScript View : 7:102 : Adding handler e4c9ef23-465f-4abf-adf3-5bea1458dc11 (Generic JavaScript View 7:102: ) - 2 in total
2022-09-21 10:34:18,844 : DEBUG : KNIME-Worker-140-Generic JavaScript View 7:102 : : WorkflowManager : Generic JavaScript View : 7:102 : Generic JavaScript View 7:102 doBeforeExecution
2022-09-21 10:34:19,062 : DEBUG : KNIME-Worker-140-Generic JavaScript View 7:102 : : NodeContainer : Generic JavaScript View : 7:102 : Generic JavaScript View 7:102 has new state: EXECUTING
2022-09-21 10:34:19,067 : DEBUG : KNIME-Worker-140-Generic JavaScript View 7:102 : : LocalNodeExecutionJob : Generic JavaScript View : 7:102 : Generic JavaScript View 7:102 Start execute
2022-09-21 10:34:22,160 : INFO : KNIME-Worker-140-Generic JavaScript View 7:102 : : JavaScriptViewCreator : Generic JavaScript View : 7:102 : JavaScript view - Generic JavaScript View - created. Debug output at: C:\Users\in732mel\AppData\Local\Temp\knimeViewContainer456\debug_166374926215815255011293782544854.html
2022-09-21 10:34:24,691 : ERROR : KNIME-Worker-140-Generic JavaScript View 7:102 : : CEFImageGenerator : Generic JavaScript View : 7:102 : Executing script failed after 10 attempts. The script is: ‘return document.getElementById(‘node-SINGLE’).contentWindow.knimeGenericView.getSVG();’
2022-09-21 10:34:24,883 : INFO : KNIME-Worker-140-Generic JavaScript View 7:102 : : LocalNodeExecutionJob : Generic JavaScript View : 7:102 : Generic JavaScript View 7:102 End execute (5 secs)
2022-09-21 10:34:25,100 : DEBUG : KNIME-Worker-140-Generic JavaScript View 7:102 : : WorkflowManager : Generic JavaScript View : 7:102 : Generic JavaScript View 7:102 doBeforePostExecution
2022-09-21 10:34:25,105 : DEBUG : KNIME-Worker-140-Generic JavaScript View 7:102 : : NodeContainer : Generic JavaScript View : 7:102 : Generic JavaScript View 7:102 has new state: POSTEXECUTE
2022-09-21 10:34:25,327 : DEBUG : KNIME-Worker-140-Generic JavaScript View 7:102 : : WorkflowManager : Generic JavaScript View : 7:102 : Generic JavaScript View 7:102 doAfterExecute - success
2022-09-21 10:34:25,334 : DEBUG : KNIME-Worker-140-Generic JavaScript View 7:102 : : NodeContainer : Generic JavaScript View : 7:102 : Generic JavaScript View 7:102 has new state: EXECUTED
2022-09-21 10:34:25,563 : DEBUG : KNIME-Worker-140-Generic JavaScript View 7:102 : : NodeContainer : Generic JavaScript View : 7:102 : question 7 has new state: EXECUTED
2022-09-21 10:34:25,814 : DEBUG : main : : OpenInteractiveWebViewAction : : : Open Interactive Web Node View Generic JavaScript View
2022-09-21 10:34:26,027 : DEBUG : main : : GenericJSViewNodeModel : : : Registering view at model (total count 8)

Does anyone know how to create an SVG-image out of a geochart from Google?

Hello @JanDuo,

Apologies for the late response, I am looking into this right now and will see what I can find out. Again thanks for your patience!

Regards,
Ryan

Hi @rsrudd

No worries, I’m glad that you want to look into this :slight_smile:

@JanDuo,

So looking at the image generation tab and seeing what is being outputted it looks like the charts innerhtml is not returning in a clear syntax. This is why when we do tag(‘svg’) command it is not finding anything to actually grab. Also I noticed that changing the value, “additional wait time after initialization in ms: 2000” was helpful in debugging.

Regards,
Ryan

Hi Ryan (@rsrudd ),

I’m a complete newby in Javscript. I’ve no idea how to debug this (where to put this additional wait time in the code and how to view things). Can you give me some clues how to do this?

Regards,
Jan

@JanDuo,

In the Generic Javascript View node, under the image generation node you should see additional wait time after initialization in ms (I saw the example had it at the value 2000). I was using the prompt command to actually check the values of these html elements to see what the difference was.

My next approach would be to check why the Google API is not returning a similarly structured response.

Regards,
Ryan

Hi Ryan (@rsrudd )

Thanks for your input, but this debugging thing is way above my head, being a newbie in JS-land. I found the debug.html files for with and without image generation in their respective containers. They open in Edge, Firefox and Chrome, but in none of them is this map visible (nor an error is shown). Maybe this was a silly thing to attempt, but this happens if you’re on unfamiliar territory :slight_smile:

I will just accept these Google-maps cannot be converted into SVG images and won’t spend more time on it.

Thanks again.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.