timdream / wordcloud2.js

Tag cloud/Wordle presentation on 2D canvas or HTML

Home Page:https://wordcloud2-js.timdream.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't read list from huge variable

ammoradi opened this issue · comments

I couldn't pass list through a huge variable even using Promise / setTimout.
I have an array in the format of [['txt',123],...] and it has about 2000 items.
my code :

$(document).ready(() => {
    let xhr = new XMLHttpRequest();
    let xhrPromise = new Promise((resolve, reject) => {
        xhr.onreadystatechange = function() {
            if (xhr.readyState == XMLHttpRequest.DONE) {
                resolve(xhr.responseText);
            }
        }
        xhr.open('GET', 'http://sth.com', true);
        xhr.send(null);
    }).then(result => {
        setTimeout(() => {
            WordCloud(document.getElementById('my_canvas'), { list: result } );
        },2000)
    })
})

and i will see :

Uncaught DOMException: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The source width is 0.
at getTextInfo (http://localhost:8080/wordcloud.js:612:34)
at putWord (http://localhost:8080/wordcloud.js:913:24)
at Array.loop (http://localhost:8080/wordcloud.js:1179:29)
at setZeroTimeoutMessage (http://localhost:8080/wordcloud.js:53:34)

p.s : I checked your source code using console.log() and I found the fontWeight couldn't be generated and it is NaN

I Sliced result to (0,10) but also gave me same error.

Then I tried to push some statics data on list it worked for about 20 items but didn't work for more than 100 items.

@timdream no it didn't work

your module is sync and xhr req is async then i used Promise ( i thought maybe the list first passed to module then filled with xhr ... )

@timdream ok i'll send it . But I tested that list in static mode and it was correct ( but for a list with more than 400 item it didn't work )

Any news about this?

@lucasa nothing! i used another library...

@ammoradi Which library did you use?

@raviraj16 i used d3-cloud library.
an implementation example could be found here.