深圳全飞鸿

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 447|回复: 1
打印 上一主题 下一主题

pchart画直线的分析(drawLine)

[复制链接]

800

主题

1379

帖子

7704

积分

版主

Rank: 7Rank: 7Rank: 7

积分
7704
跳转到指定楼层
楼主
发表于 2021-8-29 16:17:39 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 zhgc 于 2022-1-5 21:56 编辑

pchart画直线的分析的
从pDraw.class.php截取
  1.    /* Draw a line between two points */
  2.    function drawLine($X1,$Y1,$X2,$Y2,$Format="")
  3.     {
  4.      $R                = isset($Format["R"]) ? $Format["R"] : 0;
  5.      $G                = isset($Format["G"]) ? $Format["G"] : 0;
  6.      $B                = isset($Format["B"]) ? $Format["B"] : 0;
  7.      $Alpha        = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
  8.      $Ticks        = isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
  9.      $Cpt        = isset($Format["Cpt"]) ? $Format["Cpt"] : 1;
  10.      $Mode        = isset($Format["Mode"]) ? $Format["Mode"] : 1;
  11.      $Weight        = isset($Format["Weight"]) ? $Format["Weight"] : NULL;
  12.      $Threshold        = isset($Format["Threshold"]) ? $Format["Threshold"] : NULL;
复制代码

画线,不需要其他功能部件:
  1. <?php
  2. /* Include all the classes */  
  3. include("../../pChart2.1.4/class/pDraw.class.php");  
  4. include("../../pChart2.1.4/class/pImage.class.php");  
  5. include("../../pChart2.1.4/class/pData.class.php");

  6. /* Create your dataset object */  
  7. $myData = new pData();  

  8. /* Create a pChart object and associate your dataset */  
  9. $myPicture = new pImage(1000,500,$myData,true);

  10. $myPicture->drawLine(370,160,650,160,array("R"=>255,"G"=>255,"B"=>255,"Ticks"=>4,"Weight"=>3));

  11. /* Render the picture (choose the best way) */
  12. $myPicture->autoOutput("example.basic.png");
  13. ?>
复制代码


回复

使用道具 举报

800

主题

1379

帖子

7704

积分

版主

Rank: 7Rank: 7Rank: 7

积分
7704
沙发
 楼主| 发表于 2021-8-29 16:21:33 | 只看该作者
example.drawLine.php



  1. <?php   
  2. /* CAT:Drawing */

  3. /* pChart library inclusions */
  4. include("../class/pDraw.class.php");
  5. include("../class/pImage.class.php");

  6. /* Create the pChart object */
  7. $myPicture = new pImage(700,230);

  8. /* Draw the background */
  9. $Settings = array("R"=>170, "G"=>183, "B"=>87, "Dash"=>1, "DashR"=>190, "DashG"=>203, "DashB"=>107);
  10. $myPicture->drawFilledRectangle(0,0,700,230,$Settings);

  11. /* Overlay with a gradient */
  12. $Settings = array("StartR"=>219, "StartG"=>231, "StartB"=>139, "EndR"=>1, "EndG"=>138, "EndB"=>68, "Alpha"=>50);
  13. $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,$Settings);
  14. $myPicture->drawGradientArea(0,0,700,20,DIRECTION_VERTICAL,array("StartR"=>0,"StartG"=>0,"StartB"=>0,"EndR"=>50,"EndG"=>50,"EndB"=>50,"Alpha"=>80));

  15. /* Draw the picture border */  
  16. $myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0));
  17.   
  18. /* Write the picture title */  
  19. $myPicture->setFontProperties(array("FontName"=>"../fonts/Silkscreen.ttf","FontSize"=>6));
  20. $myPicture->drawText(10,13,"drawLine() - Basis",array("R"=>255,"G"=>255,"B"=>255));

  21. /* Turn on shadow computing */  
  22. $myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>20));

  23. /* Draw some lines */  
  24. for($i=1;$i<=100;$i=$i+4)
  25.   $myPicture->drawLine($i+5,215,$i*7+5,30,array("R"=>rand(0,255),"G"=>rand(0,255),"B"=>rand(0,255),"Ticks"=>rand(0,4)));

  26. /* Draw an horizontal dashed line with extra weight */
  27. $myPicture->drawLine(370,160,650,160,array("R"=>0,"G"=>0,"B"=>0,"Ticks"=>4,"Weight"=>3));

  28. /* Another example of extra weight */
  29. $myPicture->drawLine(370,180,650,200,array("R"=>255,"G"=>255,"B"=>255,"Ticks"=>15,"Weight"=>1));

  30. /* Render the picture (choose the best way) */
  31. $myPicture->autoOutput("pictures/example.drawLine.png");
  32. ?>
复制代码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|nagomes  

GMT+8, 2025-5-5 00:51 , Processed in 0.036143 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表