Hi,
I've downloaded https://github.com/timdream/wordcloud2.js (to create a wordcloud) and put that js file to the resources (deploy to target dir). Then I put an AddJavscriptTag action in the preparation of the screen. I added a container to the screen with id "my_canvas" and then I tried (in onclick extended propery):
"WordCloud(document.getElementById('my_canvas'), {[['Cent', 12],['Euro', 6]]}); return false;"
It is not working though. Do I miss something?
Regards, Harry
Hi Harry,
Here it goes the oml back to you. Two things that I changed:
"WordCloud(document.getElementById('" + my_canvas.Id + "'), {list: [['Cent', 12],['Euro', 6]]});"
Cheers,
José
I guess it's not getting the right Id for the element since the name that you give to the container is not the exact Id in the html.
Try this:
"WordCloud(document.getElementById('" + my_canvas.Id + '), {[['Cent', 12],['Euro', 6]]}); return false;"
José
Hi José,
I thought that GetElementById needed an Id and if I give a container an id ('my_canvas') that's would the right one. I tried your code though (added an " that was missing I think) but it still doesn't work.
Yes, It was missing an "...
Is there any javascript error when you click to execute that code? What is the error? Can you share a sample oml?
José,
No error, but no result (but 'strange' looking screen). OML attached.
Thank you so much! Do you know where I can find such things in the docs? ostagname was new to me.Now I have to pass a list from a server entity as the list in the js script, and I have a working tagcloud. Great.
I actually found out about the ostagname here in the forums. :)
Glad to help.
Hi José.
I want to replace the list in the js with contents of an entity, but this gives an error (Operand cannot be applied between text and list:
"WordCloud(document.getElementById('" + my_canvas.Id + "'), {list:" + GetWoorden.List + "});"
what is the proper way to do this?
Hello Harry,
The easier way (not the more performing, probably), is to iterate the list (in logic) and construct the string you have to use as argument to the action.
Cheers
Eduardo Jauch
I tried it, but I cannot get it to work. I (in an action) assign the values to the varWoord var and (debugged it) the value is:
"['Brievenbus',23],['Postbus',34]"
Then in the same action I use a RunJavascript action with:
"WordCloud(document.getElementById('" + my_canvas.Id + "'), {list:[" + varWoord + "]});return false;"
and after that an Ajax refresh of the my_canvas.
Nothing happens (except a 'flickering' of the screen (so something happens I guess)).
Any ideas why this is not working?
Solverd. Using an AjaxSubmit did the trick!
Yes. If you use a submit, things would not work unless the logic were in the preparation.
Please, mark Jose's answer as the correct one. As it is the answer to the original question :)