renato127 / flowchart-to-png
此软件包最新版本(dev-master)没有可用的许可证信息。
将流程图JSON编码转换为PNG格式
dev-master
2017-03-21 14:01 UTC
This package is not auto-updated.
Last update: 2024-09-28 23:33:22 UTC
README
设置
将库添加到您的项目中的 composer.json 文件
{ "require": { "renato127/flowchart-to-png": "dev-master" } }
使用 Composer 安装库
$ php composer.phar install
Composer将在您的vendor文件夹中安装flowchart-to-png。然后您可以将以下内容添加到您的.php文件中以使用库和自动加载。
require_once(__DIR__ . '/vendor/autoload.php');
用法
$json = '{ "nodes": [ { "id": "flowchartStart", "type": "start", "text": "Start", "left": "20px", "top": "180px", "countSource": null }, { "id": "flowchartEnd", "type": "end", "text": "End", "left": "940px", "top": "180px", "countSource": null }, { "id": "flowchartWindow1489779664638", "type": "action", "text": "Approve", "left": "680px", "top": "260px", "action": "Approve", "extraParams": "", "countSource": "1" }, { "id": "flowchartWindow1489779672763", "type": "action", "text": "Reject", "left": "620px", "top": "40px", "action": "Reject", "extraParams": "", "countSource": "1" } ], "edges": [ { "source": "flowchartStart", "target": "flowchartWindow1489779664638", "data": { "label": "", "positionSource": "RightMiddle", "positionTarget": "LeftMiddle" } }, { "source": "flowchartStart", "target": "flowchartWindow1489779672763", "data": { "label": "", "positionSource": "RightMiddle", "positionTarget": "LeftMiddle" } }, { "source": "flowchartWindow1489779672763", "target": "flowchartEnd", "data": { "label": "Success", "return": "success", "positionSource": "RightMiddle", "positionTarget": "LeftMiddle" } }, { "source": "flowchartWindow1489779664638", "target": "flowchartEnd", "data": { "label": "Success", "return": "success", "positionSource": "RightMiddle", "positionTarget": "LeftMiddle" } } ] }'; $flowChartImage = new FlowChartImage(); $flowChartImage->setContent($json); $flowChartImage->generate()->toPng($path);
更改节点颜色
$image->setSelectedAction('flowchartWindow1489779664638'); $image->setSelectedColor([255, 0, 0]);