定制 abbadon1334/gnuplot 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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:

gnuplot

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 is GnuPlot::LINEMODE_FILLEDCURVES)
  • display(), renders the graph on the screen (asuming you are using it as a CLI with an X Server
  • refresh(), same as display(), but will replot the graph after the first call
  • get(), gets the PNG data for your image
  • writePng($filename), writes the data to the output PNG file
  • writePDF($filename), writes the data to the output PDF file
  • writeEPS($filename), writes the data to the output EPS file
  • setTitle($index, $title), sets the title of the $index-nt curve
  • setLineWidth($index, $width), sets the width of the $index-nt curve
  • setLineMode($index, $mode), sets the line mode of the $index-nt curve (set to GnuPlot::LINEMODE_FILLEDCURVES to fill an area between two lines)
  • setLinePoint($index, $point), sets the line point of the $index-nt curve
  • setLineType($index, $type), sets the line type of the $index-nt curve
  • setLineColor($index, $color), sets the line color of the $index-nt curve
  • setLineSmooth($index, $smooth), sets the smooth type of the $index-nt curve. Available smooths are SMOOTH_NONE, SMOOTH_BEZIER, SMOOTH_CSPLINE, defined as constants on the GnuPlot class.
  • setGraphTitle($title), sets the main title for the graph
  • setXTimeFormat($format), sets the X axis as a time axis and specify data format
  • setTimeFormatString($format), specify the X axis time presentation format
  • setXLabel($text), sets the label for the X axis
  • setYLabel($text), sets the label for the Y axis
  • setYFormat($format), sets Y axis formatting
  • setXRange($min, $max), set the X min & max
  • setYRange($min, $max), set the Y min & max
  • setXTics($tics), set the X tics
  • setYTics($tics), set the Y tics
  • setMXTics($tics), set the micro X tics
  • setMYTics($tics), set the micro Y tics
  • setMinorGrid($status), enabled/disables the grid for microtics
  • setGridPlacement($layer), sets the placement of the grid, can be GnuPlot::GRID_DEFAULT, GnuPlot::GRID_FRONT or GnuPlot::GRID_BACK
  • setWidth($width), sets the width of the graph
  • setHeight($height), sets the height of the graph
  • setCanvasWidth($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 graph
  • setSleepTime($sleepTime), sets the sleep time after saving a file
  • addLabel($x, $y, $text), add some label at a point
  • flush(), 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 abbadon1334/gnuplot 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 46
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 11
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 12
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-09