fidelize / flowchart-to-png

该软件包最新版本(1.1.0)没有提供许可信息。

将流程图JSON编码转换为PNG格式

安装数: 7,168

依赖关系: 0

建议者: 0

安全: 0

星标: 1

关注者: 12

分支: 3

类型:项目

1.1.0 2017-04-17 11:39 UTC

This package is auto-updated.

Last update: 2024-09-29 04:36:42 UTC


README

设置

将库添加到项目中的 composer.json 文件

{
  "require": {
      "fidelize/flowchart-to-png": "1.0.0"
  }
}

使用 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]);