# core/plugins/diagram.package.plugin.ts

> 19 lines of code and 4 definitions.

Tree: GovLab Docs
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/docs#file-docs-core-plugins-diagram-package-plugin-ts
Source text: https://banes-lab.com/source/docs/core/plugins/diagram.package.plugin.ts.txt

Listed in [core/plugins](https://banes-lab.com/api/source/docs/core/plugins.md), after [core/plugins/diagram.machine.plugin.ts](https://banes-lab.com/source/docs/core/plugins/diagram.machine.plugin.ts.md) and before [core/plugins/diagram.sequence.plugin.ts](https://banes-lab.com/source/docs/core/plugins/diagram.sequence.plugin.ts.md).

## Definitions

- `appliesTo` (method_definition, line 7, exported)
- `diagram` (lexical_declaration, line 6, exported)
- `render` (method_definition, line 12, exported)
- `model` (lexical_declaration, line 13, exported)

## Contained in

- [core/plugins](https://banes-lab.com/anatomy/docs/folder-docs-core-plugins.md)

## Uses

- [core/converters/graph.converter.ts](https://banes-lab.com/source/docs/core/converters/graph.converter.ts.md)

## Linked from

- [core/converters](https://banes-lab.com/anatomy/docs/folder-docs-core-converters.md)

## Source

```typescript
import { DIAGRAM_LEGENDS, DIAGRAM_TITLES } from "#configuration/strings/figure.strings";
import type { DiagramKind } from "#types/figure.types";
import { depGraphOf } from "#core/converters/graph.converter";
import { emitGraph } from "#core/formatters/diagram.formatter";

export const diagram: DiagramKind = {
    appliesTo(context) {
        return depGraphOf(context.moduleDeps, context.keepIsolated === true).nodes.length > 0;
    },
    id: "dependency",
    order: 3,
    render(context) {
        const model = depGraphOf(context.moduleDeps, context.keepIsolated === true);
        if (model.nodes.length === 0) {
            return null;
        }
        return { legend: DIAGRAM_LEGENDS.dependency, mermaid: emitGraph(model), sources: [] };
    },
    title: DIAGRAM_TITLES.dependency,
};
```
