prashant1rana / jQWCloud

jQWCloud: An JQuery plugin to generate Word Cloud
http://prashant1rana.github.io/jQWCloud/
Apache License 2.0
2 stars 4 forks source link

Missing Words #4

Closed Christophe06410 closed 4 years ago

Christophe06410 commented 4 years ago

Hi,

I have 4 words defined in the cloud data array and sometimes I see 2 of them, sometimes 3 or 4. Can you please explain a bit what the algorithm is so I can try to fix it?

Looking at the _placeOtherWord method, I can see two places where this line is not called: this.$target.append(span); at lines 430 and 480. Could that be the problem?

Thanks and regards Christophe

Christophe06410 commented 4 years ago

Hum, the reason the word is not added to the page is because if (alignmentIndCount>0) line 347 is never true. I am still unsure of the reason why. Looks like there is no empty room for the word to fit in the array of spaces. As example, using the following script, I am missing the second word ("Controle"):

    var cloudChartData = [ {'word': 'Documents', 'weight': 2},
{'word': 'Contrôle', 'weight': 4},
{'word': 'Fiscal', 'weight': 5},
{'word': 'Legal', 'weight': 2} ];

    $("#cloudChartContainer").jQWCloud({
        words: cloudChartData,

        // title
        title: 'JQ WOrd Cloud',

        // min/max font size
        minFont: 10,
        maxFont: 50,

        // font offset
        fontOffset: 0,

        // shows the algorithm of creating the word cloud
        showSpaceDIV: false,

        // Enables the vertical alignment of words
        verticalEnabled: true,

        // color
        cloud_color: "#0A4C5A",

        // font family
        cloud_font_family: null,

        // color of covering divs
        spaceDIVColor: 'white',

        // left padding of words
        padding_left: null,

        // classes with space to be applied on each word
        word_common_classes: null
    });
prashant1rana commented 4 years ago

I will look into it.. Sorry for delay.

prashant1rana commented 4 years ago

Hi,

I have 4 words defined in the cloud data array and sometimes I see 2 of them, sometimes 3 or 4. Can you please explain a bit what the algorithm is so I can try to fix it?

Looking at the _placeOtherWord method, I can see two places where this line is not called: this.$target.append(span); at lines 430 and 480. Could that be the problem?

Thanks and regards Christophe

You can find the algorithm https://github.com/prashant1rana/jQWCloud/blob/d7cd5fe22f66b260df56ca23e25798b71f12ffd7/Plugin/jQWCloudv3.4.1.js#L413 Although I will try to put more description of the algorithm. It has been more than 8 years, so will take some time.

Christophe06410 commented 4 years ago

Thanks. In the meantime, I've found what the problem is on my side. The div in which I put the cloud, was too small (width), so some words did not fit. Cheers Christophe

prashant1rana commented 4 years ago

I am closing the issue as of now.