📔 Table of Contents
Give item's tag name and it's incomming/outgoing items' name, to get a graph (DAG, or Directed Acyclic Graph) that shows the visualized dependencies graph among these items.
- Create items by Tags and their edges (arrows / dependencies)
- Update item's title by double click
- Delete item and its edges (arrows)
- delete all
- delete by Tag
- Drag and drop support
- Select arrows style
- Dark/Light mode
- Local storage to keep items datas between sessions
Node version v14.17.0
- Clone the repo
git clone https://github.com/benson00077/dag_graph-ts.git
- Install NPM packages
npm install
- Basic CRUD on items
- Drag and drop support
- Select arrows style
- Dark/Light mode
- Local storage to keep items datas between sessions
- useDrawConnectorDynamic 利用閉包來做 Memoizer
- update vertex name (double click)
- 利用 vertex name / value 資料結構 - 僅顯示端顯示沒問題
- 處理 click / double click 兩者,利用可取消的 Promise
- delete vertex (maybe hover over trash can icon) -- instance of class 造成 uncontorlled component
- 封裝在 dagContext 內,並新增 update state 通知 React dag 內部已經修改
- bar select different arrows style
Directedd Acyclic Graph
-
舉例,按照以下順序創建 vertex ,箭頭 → 表示彼此流向關係:
Incomming → Vertex → Outgoing Benson Alice Alice Catherine Ben Benson Catherine Eva Benson David [ Ben, Flora ] Catherine [ David, George ] -
graph.vertices
Object byconsole.table()
:
┌───────────┬─────────────┬───────────────────────────────────────────┬────────────────────────────────┬─────────────┬───────┐
│ (index) │ name │ incoming │ incomingNames │ hasOutgoing │ value │
├───────────┼─────────────┼───────────────────────────────────────────┼────────────────────────────────┼─────────────┼───────┤
│ Benson │ 'Benson' │ { Ben: [Object], Eva: [Object] } │ [ 'Ben', 'Eva' ] │ true │ null │
│ Alice │ 'Alice' │ { Benson: [Object] } │ [ 'Benson' ] │ true │ null │
│ Catherine │ 'Catherine' │ [Object] │ [ 'Alice', 'Benson', 'Flora' ] │ true │ null │
│ Ben │ 'Ben' │ {} │ [] │ true │ null │
│ David │ 'David' │ { Benson: [Object], Catherine: [Object] } │ [ 'Benson', 'Catherine' ] │ false │ null │
│ Eva │ 'Eva' │ {} │ [] │ true │ null │
│ George │ 'George' │ { Catherine: [Object] } │ [ 'Catherine' ] │ false │ null │
│ Flora │ 'Flora' │ {} │ [] │ true │ null │
└───────────┴─────────────┴───────────────────────────────────────────┴────────────────────────────────┴─────────────┴───────┘
graph.rank
Object byconsole.table()
:
┌───────────┬────────┐
│ (index) │ Values │
├───────────┼────────┤
│ George │ 0 │
│ David │ 0 │
│ Catherine │ 1 │
│ Flora │ 2 │
│ Alice │ 2 │
│ Benson │ 3 │
│ Eva │ 4 │
│ Ben │ 4 │
└───────────┴────────┘
🌲 Directory Structure
./src/components/
├── Arrow
│ └── Arrow.tsx
├── ArrowRenderer.tsx
├── DeleteVertex # 🔺 Controller on DAG
│ ├── DeleteVertex.tsx
│ └── style.ts
├── Draggble
│ ├── Draggable.tsx
│ ├── DraggableCore.tsx
│ ├── domFns.ts
│ ├── draggable.test.tsx
│ ├── log.ts
│ ├── positionFns.ts
│ └── types.ts
├── DrawGraph.tsx # 🔺 View on DAG
├── GraphMiddleWare.tsx # 🔺
├── InputForm # 🔺 Controller on DAG
│ ├── VertexInput.tsx
│ └── styles.ts
├── ResetDag # 🔺 Controller on DAG
│ ├── ResetDag.tsx
│ └── style.ts
├── SelectArrowStyle
│ ├── SelectArrowStyle.tsx
│ └── style.ts
├── TogglerButton
│ ├── ToggleButton.tsx
│ └── styles.ts
├── Vertex
│ ├── Rename.tsx
│ ├── Vertex.tsx
│ └── styles.ts
├── VertexRenderer.tsx
├── contexts
│ ├── DagContext.tsx
│ ├── PositionContext.tsx
│ ├── ThemeContext.tsx
│ └── types.ts
├── hooks
│ ├── useCancellablePromises.ts
│ ├── useDagStorage.ts
│ ├── useDrawSVGConnector.ts
│ └── useThemeMode.ts
├── styles
│ ├── global.ts
│ └── themes.ts
└── utils
├── arrowsInfoGetter.ts
├── cancellablePromise.ts
├── inputParser.ts
├── svgPathHandler.ts
└── uitls.test.ts