abbadon1334/gnuplot
Composer 安装命令:
composer require abbadon1334/gnuplot
包简介
GnuPlot library - forked from gregwar/gnuplot
README 文档
README
A PHP Library for using GnuPlot
This is the output of the demo/write.php:
Requirements
You need to have a server with gnuplot installed and the safe mode
disabled (to be able to run proc_open())
Usage
There is examples in the demo/ directory.
You can create a graph and populate it like this:
<?php use Gregwar\GnuPlot\GnuPlot; $plot = new GnuPlot; // Setting the main graph title $plot->setGraphTitle('Demo graph'); // Adding three points to the first curve $plot ->setTitle(0, 'The first curve') ->push(0, 4) ->push(1, 5) ->push(2, 6) ; // Adding three points on the other curve and drawing it as a line of connected points, colored in red and smoothed // (with index 1) $plot ->setTitle(1, 'The first curve') ->setLineType(1, 'rgb #ff0000') ->setLineMode(1, 'lp') ->setLineSmooth(1, GnuPlot::SMOOTH_CSPLINE) ->push(0, 8, 1) ->push(1, 9, 1) ->push(2, 10, 1) ; // Drawing the area between the two curves in blue $plot ->setLineMode(2, GnuPlot::LINEMODE_FILLEDCURVES) ->setLineType(2, 'rgb #0000ff') ->setTitle(2, 'Area') ->push(0, [4, 8], 2) ->push(1, [5, 9], 2) ->push(2, [6,10], 2) ;
You can then save it to a file, have a look to write.php for example:
<?php // Write the graph to out.png $plot->writePng('out.png');
Or render it directly into a browser, you can try out.php for
example:
<?php header('Content-type: image/png'); echo $plot->get();
Or display it on the screen (useful with CLI scripts), run the
demo.php script for example:
<?php $plot->display();
Or display it, and re-feed it in real time (with CLI scripts), you can
run realTime.php for example:
<?php $plot->refresh();
API
push($x, $y, $index=0), add a point to the $index-nth curve ($y can be an array if the linemode isGnuPlot::LINEMODE_FILLEDCURVES)display(), renders the graph on the screen (asuming you are using it as a CLI with an X Serverrefresh(), same asdisplay(), but will replot the graph after the first callget(), gets the PNG data for your imagewritePng($filename), writes the data to the output PNG filewritePDF($filename), writes the data to the output PDF filewriteEPS($filename), writes the data to the output EPS filesetTitle($index, $title), sets the title of the $index-nt curvesetLineWidth($index, $width), sets the width of the $index-nt curvesetLineMode($index, $mode), sets the line mode of the $index-nt curve (set toGnuPlot::LINEMODE_FILLEDCURVESto fill an area between two lines)setLinePoint($index, $point), sets the line point of the $index-nt curvesetLineType($index, $type), sets the line type of the $index-nt curvesetLineColor($index, $color), sets the line color of the $index-nt curvesetLineSmooth($index, $smooth), sets the smooth type of the $index-nt curve. Available smooths areSMOOTH_NONE,SMOOTH_BEZIER,SMOOTH_CSPLINE, defined as constants on theGnuPlotclass.setGraphTitle($title), sets the main title for the graphsetXTimeFormat($format), sets the X axis as a time axis and specify data formatsetTimeFormatString($format), specify the X axis time presentation formatsetXLabel($text), sets the label for the X axissetYLabel($text), sets the label for the Y axissetYFormat($format), sets Y axis formattingsetXRange($min, $max), set the X min & maxsetYRange($min, $max), set the Y min & maxsetXTics($tics), set the X ticssetYTics($tics), set the Y ticssetMXTics($tics), set the micro X ticssetMYTics($tics), set the micro Y ticssetMinorGrid($status), enabled/disables the grid for microticssetGridPlacement($layer), sets the placement of the grid, can beGnuPlot::GRID_DEFAULT,GnuPlot::GRID_FRONTorGnuPlot::GRID_BACKsetWidth($width), sets the width of the graphsetHeight($height), sets the height of the graphsetCanvasWidth($width), sets the width of the canvas (if not set, the width value is used)setCanvasHeight($height), sets the height of the canvas (if not set, the height value is used)setOrigin($x, $y), sets the origin of the graphsetSleepTime($sleepTime), sets the sleep time after saving a fileaddLabel($x, $y, $text), add some label at a pointflush(), completely flushes the internal state and resets the object to its initial state
License
Gregwar\GnuPlot is under MIT license
abbadon1334/gnuplot 适用场景与选型建议
abbadon1334/gnuplot 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 46 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 10 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「image」 「graph」 「stats」 「png」 「gnuplot」 「plot」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 abbadon1334/gnuplot 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 abbadon1334/gnuplot 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 abbadon1334/gnuplot 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Helper to handle stats table with multiple formatter
Netgen Open Graph Bundle is an Ibexa Platform bundle that allows simple integration with Open Graph protocol.
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
Rserve client library for PHP
A tool for scraping URL resources (oEmbed, OpenGraph, Twitter cards, JSON-LD)
统计信息
- 总下载量: 46
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-10-09
