diff --git a/.changeset/cold-badgers-develop.md b/.changeset/cold-badgers-develop.md
new file mode 100644
index 0000000..9be875e
--- /dev/null
+++ b/.changeset/cold-badgers-develop.md
@@ -0,0 +1,5 @@
+---
+"pnpm-workspace-graph": minor
+---
+
+Support change direction: Top to Bottom or Left to Right
diff --git a/README.md b/README.md
index e7f314c..c1fb9bb 100644
--- a/README.md
+++ b/README.md
@@ -66,6 +66,18 @@ Visualize project relationships in your [PNPM](https://pnpm.io/) workspace
An example graph made by cloning the https://github.com/pnpm/pnpm workspace
+## Features
+
+1. Layout the graph with different directions: Top to Bottom or Left to Right.
+
+Top to Bottom | Left to Right
+:-------------------------:|:-------------------------:
+ |
+
+2. Save the graph to PNG for later use.
+
+
+
## CLI parameters
```shell
diff --git a/assets/direction-lr.png b/assets/direction-lr.png
new file mode 100644
index 0000000..db9f7ce
Binary files /dev/null and b/assets/direction-lr.png differ
diff --git a/assets/direction-tb.png b/assets/direction-tb.png
new file mode 100644
index 0000000..c57d744
Binary files /dev/null and b/assets/direction-tb.png differ
diff --git a/assets/example-settings.png b/assets/example-settings.png
index f320fc6..e29323e 100644
Binary files a/assets/example-settings.png and b/assets/example-settings.png differ
diff --git a/assets/save-graph.png b/assets/save-graph.png
new file mode 100644
index 0000000..78129bc
Binary files /dev/null and b/assets/save-graph.png differ
diff --git a/client/ControlPanel.tsx b/client/ControlPanel.tsx
index 4b97312..1a504d5 100644
--- a/client/ControlPanel.tsx
+++ b/client/ControlPanel.tsx
@@ -9,6 +9,8 @@ import {
Toolbar,
} from "@fluentui/react-components";
import {
+ ArrowDown20Regular,
+ ArrowRight20Filled,
ChevronLeft20Regular,
ChevronRight20Regular,
DataFunnel20Regular,
@@ -21,7 +23,7 @@ import { FieldValues, FormProvider, useForm } from "react-hook-form";
import { saveAs } from "file-saver";
import { ControlledTextFieldArray } from "./ControlledFormComponent/ControlledTextFieldArray";
import { GraphService } from "./service/Graph";
-import { useState } from "react";
+import { useEffect, useState } from "react";
const gs = GraphService.getInstance();
@@ -37,6 +39,28 @@ export const ControlPanel = () => {
const [isExpandActions, { toggle: toggleExpandActions }] = useBoolean(true);
const [isExportingImage, setIsExportImage] = useState(false);
+ const [direction, setDirection] = useState<'TB' | 'LR'>(gs.getLayoutConfig().rankDir || 'TB');
+ let directionIcon = null;
+ if (direction === 'TB') {
+ directionIcon =
+ } else if (direction === 'LR') {
+ directionIcon =
+ }
+ const directionText: string = direction === 'LR' ? 'Left to Right' : 'Top to Bottom'
+ const toggleDirection = () => {
+ if (direction === 'TB') {
+ setDirection('LR')
+ gs.setLayoutConfig({
+ rankDir: 'LR',
+ })
+ } else {
+ setDirection('TB')
+ gs.setLayoutConfig({
+ rankDir: 'TB',
+ })
+ }
+ }
+
const onSave = () => {
console.log("on save");
setIsExportImage(true);
@@ -121,6 +145,14 @@ export const ControlPanel = () => {
>
{isExpandActions ? "Filter" : ""}
+
+ {isExpandActions ? directionText : ''}
+
): void {
+ this._dagreLayoutConfig = {
+ ...this._dagreLayoutConfig,
+ ...config,
+ }
+ this.showAllProjects();
+ }
+
+ public getLayoutConfig(): Partial {
+ return this._dagreLayoutConfig;
+ }
+
public exportToPNG(): Promise | undefined {
if (this._fgGraph) {
return this._fgGraph.png({