src/widgets/Tagcloud.js
branchnew-model
changeset 883 d35ad8111c5e
parent 882 61c384dda19e
child 906 4b6e154ae8de
equal deleted inserted replaced
882:61c384dda19e 883:d35ad8111c5e
    64         .sortBy(function(_v) {
    64         .sortBy(function(_v) {
    65             return - _v.count;
    65             return - _v.count;
    66         })
    66         })
    67         .first(this.tag_count)
    67         .first(this.tag_count)
    68         .value();
    68         .value();
       
    69     if (!_words.length) {
       
    70         return;
       
    71     }
    69     var _max = _words[0].count,
    72     var _max = _words[0].count,
    70         _min = Math.min(_words[_words.length - 1].count, _max - 1),
    73         _min = Math.min(_words[_words.length - 1].count, _max - 1),
    71         _scale = (this.max_font_size - this.min_font_size) / Math.sqrt(_max - _min);
    74         _scale = (this.max_font_size - this.min_font_size) / Math.sqrt(_max - _min);
    72     IriSP._(_words).each(function(_word) {
    75     IriSP._(_words).each(function(_word) {
    73             _word.size = Math.floor( _this.min_font_size + _scale * Math.sqrt(_word.count - _min) );
    76             _word.size = Math.floor( _this.min_font_size + _scale * Math.sqrt(_word.count - _min) );