yiitagcloud

Simple Yii Framework tag cloud extension
12 followers

Simple Yii Framework Tag Cloud Extension.

Requirements

Yii 1.1 or above

Installation

  • Extract 'YiiTagCloud' folder to protected/extensions/YiiTagCloud.

Usage

$this->widget('application.extensions.YiiTagCloud.YiiTagCloud', 
            array(
                'beginColor' => '00089A',
                'endColor' => 'A3AEFF',
                'minFontSize' => 8,
                'maxFontSize' => 20,
                'arrTags' => array (
                        'MVC'     => array('weight'=> 2),
                        'PHP'     => array('weight'=> 9, 'url' => 'http://php.net'),
                        'MySQL'   => array('weight'=> 8, 'url' => 'http://mysql.com'),
                        'jQuery'  => array('weight'=> 6, 'url' => 'http://jquery.com'),
                        'SQL'     => array('weight'=> 9),
                        'C#'      => array('weight'=> 2),
                ),
          )
);

Resources

Total 8 comments

#15288 report it
venom4eg at 2013/10/23 06:17pm
Division by zero exception

When minWeight == maxWeight (if only one tag is given), division by zero excwption fires in this line

return round(((($weight - $this->minWeight) * ($this->maxFontSize - $this->minFontSize)) / ($this->maxWeight - $this->minWeight)) + $this->minFontSize);
    }

to fix it changed it to

return round(((($weight - $this->minWeight) * ($this->maxFontSize - $this->minFontSize)) / (($this->maxWeight - $this->minWeight) || 1)) + $this->minFontSize);
    }
#13545 report it
mbala at 2013/06/05 08:34am
good one

useful extension

#13389 report it
Stefano Mtangoo at 2013/05/27 05:34am
Adding some CSS class

Adding a CSS class in options for flexible styling will be nice!

#13364 report it
EvandroSwk at 2013/05/24 01:27pm
Thanks

Thanks guys!!

@David Walker I'll think in a way of implement your suggestions

#13359 report it
David Walker at 2013/05/24 07:07am
AJAX Update

Well I setup an AJAX request that renders a Partial view and it works rather well :D

For my purposes i did have to make some changes to the YiiTagCloud.php as when I was populating the tag array it was possible for all my qeights to be 0 which was causing an illeagal division by zero error. Changes as below

public function calcFontSize($weight) {
                if ($this->maxWeight - $this->minWeight == 0)
                {
                    return round(($weight - $this->minWeight) + $this->minFontSize);
                }
                else
                {
                    return round(((($weight - $this->minWeight) * ($this->maxFontSize - $this->minFontSize)) / ($this->maxWeight - $this->minWeight)) + $this->minFontSize);
                }
    }

When this happened The tags were all showing as the beginColor which wasn't what I required so I changed the generate colors method with

if ($this->minWeight == 0  && $this->maxWeight == 0)
        {
            $beginColor = hexdec($this->endColor);
            $endColor = hexdec($this->endColor);
 
        }

after

$endColor = hexdec($this->endColor);

Might be an idea to add a class option for display color if all weights are the same?

#13347 report it
David Walker at 2013/05/23 12:08pm
AJAX Update?

Really nice extension. I am planning on using this on a dashboard interface. I already have setup some charts, gauges, etc that use AJAX to update their contents every minute or so. A really neat feature would be add a way to update the tags dynamically.

I suppose you could use jquery to create and ajax request to a render partial but thats a bit inelegant :(

#13337 report it
kztime at 2013/05/22 02:47pm
Nice

Nice

#13312 report it
WebDevPT at 2013/05/22 05:07am
Good work

Good work!

Leave a comment

Please to leave your comment.

Create extension