Skip to content
Snippets Groups Projects
README.md 3.85 KiB
Newer Older
Elora-V's avatar
Elora-V committed
# Viz-layout-panel
Elora-V's avatar
Elora-V committed

Elora-V's avatar
Elora-V committed
The `VizLayoutPanel` component provides a draggable and positionable panel to configure the [viz layout](https://forgemia.inra.fr/metabohub/web-components/viz-layout).
Elora-V's avatar
Elora-V committed

Elora-V's avatar
Elora-V committed
## Props
Elora-V's avatar
Elora-V committed

Elora-V's avatar
Elora-V committed
| Props | Type | default | Description | Optional |
| ----- | ---- | ------- | ----------- | -------- |
| draggable | boolean | false | Allows you to move the panel | Yes |
| x | number | 0 | X position of the panel | Yes |
| y | number | 0 | Y position of the panel | Yes |
Elora-V's avatar
Elora-V committed
| network-style | `GraphStyleProperties` | - | A network style object containing classes and styles associated with nodes. It enables the estimation of certain default parameters, such as spacing, based on the defined node sizes in the object. | Yes
Elora-V's avatar
Elora-V committed

Elora-V's avatar
Elora-V committed
## Events
Elora-V's avatar
Elora-V committed

Elora-V's avatar
Elora-V committed
| Name |  Description | Output |
| ---- | ------- |----|
| @closePanel | Indicate to close the panel| - |
| @applyLayout |  Return the layout function to apply on a network with the correct parameters| `(network:Network, networkStyle?:GraphStyleProperties):Promise<Network>`| 
Elora-V's avatar
Elora-V committed

Elora-V's avatar
Elora-V committed

#### Types 

Types `GraphStyleProperties` and `Network` are defined in the repository of the [layout](https://forgemia.inra.fr/metabohub/web-components/viz-layout).
Elora-V's avatar
Elora-V committed

## Use the package in another project

```sh
Elora-V's avatar
Elora-V committed
npm i @metabohub/viz-layout-panel
Elora-V's avatar
Elora-V committed
```

If your project is not using vuetify, you need to import it in `src/main.ts` :
```ts
import { createApp } from 'vue'
import App from './App.vue'
Elora-V's avatar
Elora-V committed
import { vuetify } from "@metabohub/viz-layout-panel";
Elora-V's avatar
Elora-V committed

createApp(App).use(vuetify).mount('#app')
```

Use the component : 
```ts
<script setup lang="ts">
Elora-V's avatar
Elora-V committed
import { VizLayoutPanel } from "@metabohub/viz-layout-panel";
Elora-V's avatar
Elora-V committed
</script>

<template>
Elora-V's avatar
Elora-V committed
  <VizLayoutPanel
    :draggable="true"
    x="150"
    y="50"
Elora-V's avatar
Elora-V committed
    :network-style="networkStyle"
Elora-V's avatar
Elora-V committed
    @closePanel="yourFunctionToClosePanel"
    @applyLayout="yourFunctionToApplyLayout"
  />
Elora-V's avatar
Elora-V committed
</template>

Elora-V's avatar
Elora-V committed
<script setup lang="ts">
Elora-V's avatar
Elora-V committed

Elora-V's avatar
Elora-V committed
const network:Network = { ... }; // see usage of viz-layout repository
const  networkStyle :GraphStyleProperties = { ... }; // see usage of viz-layout repository
Elora-V's avatar
Elora-V committed

Elora-V's avatar
Elora-V committed
async function yourFunctionToApplyLayout(applyLayout:Function):void{
  const newNetwork = await applyLayout(network,networkStyle);
Elora-V's avatar
Elora-V committed
  // or
Elora-V's avatar
Elora-V committed
  const newNetworkWithoutStyle = await applyLayout(network);
}
</script>
Elora-V's avatar
Elora-V committed

<style>
@import '@metabohub/viz-layout-panel/dist/style.css';
</style>

Elora-V's avatar
Elora-V committed
```

## Panel 

The panel has 2 tabs : 
  - **default tab** : contains a launch button that trigger `@applyLayout` and return the layout function with default parameters

  - **advanced tab** : contains parameters, help, start/stop and reset buttons. The start button will trigger `@applyLayout` when clicked and on parameter changes. The stop button halts the emission of the `@applyLayout` event on parameter changes. The reset button trigger halts the emission of the `@applyLayout` and reset parameters to default. If the networkStyle has changed, the new style may define updated default parameters for spacing.

### Parameters of the layout

See section "Types for parameters" of the repository of the [layout](https://forgemia.inra.fr/metabohub/web-components/viz-layout).

The panel is designed to be integrated into a tool that draws network in an svg, thus `shiftCoord` is set to false.

- **Minimal horizontal spacing** : `spacePixelHorizontal` layout parameter

- **Minimal vertical spacing** : `spacePixelVertical` layout parameter

- **Treatment of directed cycles** : `doCycle` layout parameter

- **Treatment of duplicated nodes** : if true, `doPutAsideSideCompounds` and `doInsertionSideCompounds` set to true, else set to false. `doDuplicateSideCompounds` always false as the panel is designed to be integrated into a tool that enables duplication of nodes.

- **Definition of nodes groups** : if "No groups", `doMainChain` set to false. Else, `doMainChain` is true and each "Solution" corresponds to a `pathType` (LONGEST, ALL_LONGEST and ALL). The `merge` parameter is true for ALL_LONGEST and ALL.