GVKun编程网logo

php标签云的实现代码(php 标签)

42

本文将分享php标签云的实现代码的详细内容,并且还将对php标签进行详尽解释,此外,我们还将为大家带来关于c#–帮助理解标签云的算法、phpFlash标签云(flashtagcloud)的实现代码、p

本文将分享php标签云的实现代码的详细内容,并且还将对php 标签进行详尽解释,此外,我们还将为大家带来关于c# – 帮助理解标签云的算法、php Flash标签云(flash tagcloud)的实现代码、php 三维饼图的实现代码_PHP教程、php 云标签的实现代码的相关知识,希望对你有所帮助。

本文目录一览:

php标签云的实现代码(php 标签)

php标签云的实现代码(php 标签)

数据库中,存放文章的表中有“Tag”字段,用来存放标签。标签之间用“,”分隔。比如“PHP,VB,随笔”。
下面的实现代码,将标签从数据库中搜出来,并格式化处理,使其以出现的次数为依据显示出不同大小的文字连接。
其中的细节,不做解释了!
观念陈、方法笨、效率低的标签云的实现代码如下:
<div><adata="29757"id="copybut29757" onclick="doCopy('code29757')"> 代码如下:

c# – 帮助理解标签云的算法

c# – 帮助理解标签云的算法

我想了解标签云的算法/实现.

在标签云中我们得到以下标签(重量)

>标签:标签是搜索的字符串或术语(或父,具体取决于云的类型)
>权重:标签的数值频率

现在在标签云控件中,只有值的子集以不同的字体大小显示.考虑以下示例空间tag1(1)… tagx(2),然后是几个大标签tag2(4000).现在在UI上我想显示堡垒大小的标签(html元素).有了这样一个独特的样本,最终无法显示出1000px的大字体.需要处理这些数据,以获得点浓度的平板,这样我得到的值如下:

>对于点浓度移动1 – 4,以便我将它分成4块板,每块2个(1个2px,2个4px,…… 4-8px)
> 4000和一些K少,所以我想制作两块板(1000 – 2000 = 10px)和(2000及以上= 12px)

我正在使用ASP.NET C#.请让我知道如何实现这一目标.我真的不擅长数学(统计学).请帮我解决这个问题.或链接到数学/教程或良好的样本将有所帮助.

解决方法

有一个名为 Building Tag Clouds in Perl and PHP的可下载的O’Reilly电子书(40个页面)(从我记忆中,它是前一段时间)有很好的基础知识,并且(如标题所示)Perl和PHP中的示例实现.

php Flash标签云(flash tagcloud)的实现代码

php Flash标签云(flash tagcloud)的实现代码

  1. require("config.php");
  2. require_once ''Tags.php'';
  3. $sql = "SELECT tags FROM demo"; //在这里你可以随机或者限制一下取出的个数.
  4. $rs = $db->query($sql);
  5. while ($tags = $db->fetch_array($rs)) {
  6. $arr[] = split("\|",iconv("gb2312","utf-8",$tags[''tags'']));
  7. }
  8. $tags = new Tags($arr);
  9. $tagsArr = $tags->getTags();
  10. $tagsStr = '''';
  11. foreach ($tagsArr as $value){
  12. $tagsStr .= urlencode(''''.$value.'''');
  13. }
  14. $tagsStr .= ''
  15. '';
  16. ?>
复制代码

js代码部分:

复制代码


php 三维饼图的实现代码_PHP教程

php 三维饼图的实现代码_PHP教程

经过努力pie3d完成了,好东西与大家分享。不过小弟是php新手,代码可能不够精炼,希望大家指教共同来完善这个程序。记得通知我(estorm@yeah.net)
+------------------------+
| pie3dfun.php//公用函数 |
+------------------------+
define("ANGLE_STEP",5);//定义画椭圆弧时的角度步长
function chx_getdarkcolor($img,$clr){//求$clr对应的暗色
$rgb=imagecolorsforindex($img,$clr);
return array($rgb["red"]/2,$rgb["green"]/2,$rgb["blue"]/2);
}
function chx_getexy($a,$b,$d){//求角度$d对应的椭圆上的点坐标
$d=deg2rad($d);
return array(round($a*Cos($d)),round($b*Sin($d)));
}
function chx_arc($img,$ox,$oy,$a,$b,$sd,$ed,$clr){//椭圆弧函数
$n=ceil(($ed-$sd)/ANGLE_STEP);
$d=$sd;
list($x0,$y0)=chx_getexy($a,$b,$d);
for($i=0;$i$d=($d+ANGLE_STEP)>$ed?$ed:($d+ANGLE_STEP);
list($x,$y)=chx_getexy($a,$b,$d);
imageline($img,$x0+$ox,$y0+$oy,$x+$ox,$y+$oy,$clr);
$x0=$x;
$y0=$y;
}
}
function chx_sector($img,$ox,$oy,$a,$b,$sd,$ed,$clr){//画扇面
$n=ceil(($ed-$sd)/ANGLE_STEP);
$d=$sd;
list($x0,$y0)=chx_getexy($a,$b,$d);
imageline($img,$x0+$ox,$y0+$oy,$ox,$oy,$clr);
for($i=0;$i$d=($d+ANGLE_STEP)>$ed?$ed:($d+ANGLE_STEP);
list($x,$y)=chx_getexy($a,$b,$d);
imageline($img,$x0+$ox,$y0+$oy,$x+$ox,$y+$oy,$clr);
$x0=$x;
$y0=$y;
}
imageline($img,$x0+$ox,$y0+$oy,$ox,$oy,$clr);
list($x,$y)=chx_getexy($a/2,$b/2,($d+$sd)/2);
imagefill($img,$x+$ox,$y+$oy,$clr);
}
function chx_sector3d($img,$ox,$oy,$a,$b,$v,$sd,$ed,$clr){//3d扇面
chx_sector($img,$ox,$oy,$a,$b,$sd,$ed,$clr);
if($sdlist($R,$G,$B)=chx_getdarkcolor($img,$clr);
$clr=imagecolorallocate($img,$R,$G,$B);
if($ed>180) $ed=180;
list($sx,$sy)=chx_getexy($a,$b,$sd);
$sx+=$ox;
$sy+=$oy;
list($ex,$ey)=chx_getexy($a,$b,$ed);
$ex+=$ox;
$ey+=$oy;
imageline($img,$sx,$sy,$sx,$sy+$v,$clr);
imageline($img,$ex,$ey,$ex,$ey+$v,$clr);
chx_arc($img,$ox,$oy+$v,$a,$b,$sd,$ed,$clr);
list($sx,$sy)=chx_getexy($a,$b,($sd+$ed)/2);
$sy+=$oy+$v/2;
$sx+=$ox;
imagefill($img,$sx,$sy,$clr);
}
}
function chx_getindexcolor($img,$clr){//RBG转索引色
$R=($clr>>16) & 0xff;
$G=($clr>>8)& 0xff;
$B=($clr) & 0xff;
return imagecolorallocate($img,$R,$G,$B);
}
?>
+--------------------------+
| pie3d.php //三维饼图文件 |
+--------------------------+
require("pie3dfun.php");
$a=150;//椭圆长半轴
$b=50;//椭圆段半轴
$v=20;//圆饼高度
$font=5;//字体
$ox=5+$a;
$oy=5+$b;
$fw=imagefontwidth($font);
$fh=imagefontheight($font);

$datLst=array(30,10,20,20,10,20,10,20);//数据
$labLst=array("a1","a2","a3","a4","a5","a6","a7","a8");//标签
$clrLst=array(0x99ff00,0xff6666,0x0099ff,0xff99ff,0xffff99,0x99ffff,0xff3333,0x009999);
$w=10+$a*2;
$h=10+$b*2+$v+($fh+2)*count($datLst);
$img=imagecreate($w,$h);
//转RGB为索引色
for($i=0;$i
$clrbk=imagecolorallocate($img,0xff,0xff,0xff);
$clrt=imagecolorallocate($img,0x00,0x00,0x00);
//填充背景色
imagefill($img,0,0,$clrbk);
//求和
$tot=0;
for($i=0;$i
$sd=0;
$ed=0;
$ly=10+$b*2+$v;
for($i=0;$i $sd=$ed;
$ed+=$datLst[$i]/$tot*360;
//画圆饼
chx_sector3d($img,$ox,$oy,$a,$b,$v,$sd,$ed,$clrLst[$i]);//$sd,$ed,$clrLst[$i]);
//画标签
imagefilledrectangle($img,5,$ly,5+$fw,$ly+$fh,$clrLst[$i]);
imagerectangle($img,5,$ly,5+$fw,$ly+$fh,$clrt);
imagestring($img,$font,5+2*$fw,$ly,
$labLst[$i].":".$datLst[$i]."(".(round(10000*($datLst[$i]/$tot))/100)."%)",
$clrt);
$ly+=$fh+2;
}
//输出图形
header("Content-type:image/gif");
imagegif($img);
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/319534.htmlTechArticle经过努力pie3d完成了,好东西与大家分享。不过小弟是php新手,代码可能不够精炼,希望大家指教共同来完善这个程序。记得通知我(estor...

php 云标签的实现代码

php 云标签的实现代码

为大家分享一个php 云标签的代码,现在这个很流行的哦,有需要的朋友参考下吧。

在如今的php网站中,云标签的大量应用,使页面显得生效而有趣,也增加了相关内容的索引与检索。 本节分享一段php 云标签的实现代码,有兴趣的朋友,可以研究下。

1,css代码部分

<style type="text/css">
#tagcloud{
        color: #dda0dd;
        font-family: Arial, verdana, sans-serif;
        width:200px;
        border: 1px solid black;
 text-align: center;
}

#tagcloud a{
        color: green;
        text-decoration: none;
        text-transform: capitalize;
}
</style>
登录后复制

2,php 云标签的展示部分

<div id="tagcloud">
<?php
/** this is our array of tags
 * We feed this array of tags and links the tagCloud
 * class method createTagCloud
 */
$tags = array(
        array(''weight''  =>40, ''tagname'' =>''tutorials'', ''url''=>''http://bbs.it-home.org/tutorials/''),
        array(''weight''  =>12, ''tagname'' =>''examples'', ''url''=>''http://bbs.it-home.org/examples/''),
        array(''weight''  =>10, ''tagname'' =>''contact'', ''url''=>''http://bbs.it-home.org/contact/''),
        array(''weight''  =>15, ''tagname'' =>''quotes'', ''url''=>''http://bbs.it-home.org/quotes/''),
        array(''weight''  =>28, ''tagname'' =>''devel'', ''url''=>''http://bbs.it-home.org/phpdev/''),
        array(''weight''  =>35, ''tagname'' =>''manual'', ''url''=>''http://bbs.it-home.org/en/index.html''),
        array(''weight''  =>20, ''tagname'' =>''articles'', ''url''=>''http://bbs.it-home.org/articles/''),
);
 
/*** create a new tag cloud object ***/
$tagCloud = new tagCloud($tags);

echo $tagCloud -> displayTagCloud();

?>
</div>
</body>
</html>
<?php
/**
* php 云标签类
* by bbs.it-home.org
*/
class tagCloud{

/*** the array of tags ***/
private $tagsArray;


public function __construct($tags){
 /*** set a few properties ***/
 $this->tagsArray = $tags;
}

/**
 *
 * Display tag cloud
 *
 * @access public
 *
 * @return string
 *
 */
public function displayTagCloud(){
 $ret = '''';
 shuffle($this->tagsArray);
 foreach($this->tagsArray as $tag)
    {
    $ret.=''''.$tag[''tagname''].''''."\n";
    }
 return $ret;
}
    

} /*** end of class ***/

?>
登录后复制

php 云标签的演示效果,如下图: php云标签



关于php标签云的实现代码php 标签的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于c# – 帮助理解标签云的算法、php Flash标签云(flash tagcloud)的实现代码、php 三维饼图的实现代码_PHP教程、php 云标签的实现代码的相关知识,请在本站寻找。

本文标签: