您尚未登录。

楼主 #1 2020-02-10 22:43:19

phpweb
会员
注册时间: 2020-02-05
已发帖子: 3
积分: 3

推荐一个php平台下绚丽的图表组件 ---- pChart

离线

楼主 #2 2020-02-10 22:45:11

phpweb
会员
注册时间: 2020-02-05
已发帖子: 3
积分: 3

Re: 推荐一个php平台下绚丽的图表组件 ---- pChart

QQ截图20200210224406.png

QQ截图20200210224429.png

离线

楼主 #3 2020-02-11 09:03:41

phpweb
会员
注册时间: 2020-02-05
已发帖子: 3
积分: 3

Re: 推荐一个php平台下绚丽的图表组件 ---- pChart

pChart自带了字体文件, 但是那个字体不支持中文, 代码里面要重设一个中文字库,不过要注意字库版权,比如微软雅黑版权属于方正的,用于图片估计不合规。

离线

楼主 #4 2020-02-11 09:30:38

phpweb
会员
注册时间: 2020-02-05
已发帖子: 3
积分: 3

Re: 推荐一个php平台下绚丽的图表组件 ---- pChart

1569822308727921.png


/* 极地和雷达图 */
 
//引入 pChart 库
include("../class/pData.class.php");
include("../class/pDraw.class.php");
include("../class/pRadar.class.php");
include("../class/pImage.class.php");
 
//图像大小
$width = 500;
$height = 500;
//绘制位置
$x = 100;
$y = 100;
//分数
$scores = array(
    "身份特质"=>5,
    "履约能力"=>4,
    "信用历史"=>5.5,
    "人脉关系"=>4,
    "行为偏好"=>3.5
);
 
//创建并赋值 pData 对象
$MyData = new pData();
$MyData->addPoints(array_values($scores), "Score");
$MyData->setSerieDescription("Score", "Application A");
$MyData->setPalette("Score", array("R" => 0, "G" => 180, "B" => 138));
 
//定义 absissa
$MyData->addPoints(array_keys($scores), "Labels");
$MyData->setAbscissa("Labels", array("R" => 10, "G" => 170, "B" => 133));
 
//创建 pChart 对象
$myPicture = new pImage($width, $height, $MyData);
 
//设置默认字体属性(这里我使用开源的字体:思源黑体)
$myPicture->setFontProperties(array("FontName" => "../fonts/SOURCEHANSANSCN-MEDIUM.OTF", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80));
 
//创建 pRadar 对象
$SplitChart = new pRadar();
 
//绘制雷达图
$myPicture->setGraphArea($x, $y, $width-$x, $height-$y);        //设置雷达图区域位开始位置和结束位置
$Options = array(
    "Layout" => RADAR_LAYOUT_STAR,            //雷达布局 RADAR_LAYOUT_STAR=>尖角雷达图,RADAR_LAYOUT_CIRCLE=>圆角雷达图
    "LabelPos" => RADAR_LABELS_HORIZONTAL,    //类型标签 RADAR_LABELS_HORIZONTAL=>水平,RADAR_LABELS_ROTATED=>旋转
    "BackgroundGradient" => array(            //背景梯度渐变
        "StartR" => 246,
        "StartG" => 246,
        "StartB" => 246,
        "StartAlpha" => 100,
        "EndR" => 246,
        "EndG" => 246,
        "EndB" => 246,
        "EndAlpha" => 100
    ),
    'AxisR' => 225,
    'AxisG' => 225,
    'AxisB' => 225,
    'AxisAlpha' => 100,
    'AxisRotation' => -90,                //旋转轴(角度)
    'DrawAxisValues' => false,        //画坐标轴的值
    'DrawPoly' => true,                //区域阴影
    "ValueFontSize" => 8,                //在坐标轴顶点标注数值字体大小
    'WriteValues' => false,            //在坐标轴顶点标注数值
    'WriteValuesInBubble' => false,    //在顶点气泡中标注
    'ValuePadding' => 0,                //在顶点气泡中标注大小
    'OuterBubbleRadius' => 0,            //顶点气泡颜色
    'DrawPoints' => false,                //画坐标顶点的小圆点
    'PointRadius' => 5,                    //坐标顶点的小圆点大小
    'DrawLines' => true,                //画坐标点连接线(首尾点不连接 适用于xy坐标轴)
    'LineLoopStart' => true,            //链接首尾的点
    'SegmentHeight' => 2,                //设置每个坐标格大小
    'Segments' => 3,                    //设置雷达图显示几个坐标格
);
$SplitChart->drawRadar($myPicture, $MyData, $Options);
 
//渲染图片(选择最佳方式)
$myPicture->autoOutput("pictures/example.radar.values.png");

https://www.weizhixi.com/user/index/article/id/95.html

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn