Skip to content

Commit 112213f

Browse files
committed
fix: restore docs
1 parent 71bfc4a commit 112213f

File tree

19 files changed

+1055
-0
lines changed

19 files changed

+1055
-0
lines changed

docs/.vitepress/config.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { defineConfig } from 'vitepress';
2+
import { name, description, repository, license, author } from '../../package.json';
3+
import typedocSidebar from '../api/typedoc-sidebar.json';
4+
5+
const cleanName = name.replace('@sgratzl/', '');
6+
7+
// https://vitepress.dev/reference/site-config
8+
export default defineConfig({
9+
title: cleanName,
10+
description,
11+
base: `/${cleanName}/`,
12+
useWebFonts: false,
13+
themeConfig: {
14+
// https://vitepress.dev/reference/default-theme-config
15+
nav: [
16+
{ text: 'Home', link: '/' },
17+
{ text: 'Getting Started', link: '/getting-started' },
18+
{ text: 'Examples', link: '/examples/' },
19+
{ text: 'API', link: '/api/' },
20+
{ text: 'Related Plugins', link: '/related' },
21+
],
22+
23+
sidebar: [
24+
{
25+
text: 'Examples',
26+
items: [
27+
{ text: 'Basic', link: '/examples/' },
28+
{ text: 'Dendrogram', link: '/examples/dendrogram' },
29+
{ text: 'Tree', link: '/examples/tree' },
30+
{ text: 'Force Directed Graph', link: '/examples/force' },
31+
{ text: 'Tree with Labels', link: '/examples/label' },
32+
{ text: 'Directed Tree', link: '/examples/directed' },
33+
{ text: 'Tree Orientations', link: '/examples/orientation' },
34+
],
35+
},
36+
{
37+
text: 'API',
38+
collapsed: true,
39+
items: typedocSidebar,
40+
},
41+
],
42+
43+
socialLinks: [{ icon: 'github', link: repository.url.replace('.git', '') }],
44+
45+
footer: {
46+
message: `Released under the <a href="${repository.url.replace(
47+
'.git',
48+
''
49+
)}/tree/main/LICENSE">${license} license</a>.`,
50+
copyright: `Copyright © 2019-present <a href="${author.url}">${author.name}</a>`,
51+
},
52+
53+
editLink: {
54+
pattern: `${repository.url.replace('.git', '')}/edit/main/docs/:path`,
55+
},
56+
57+
search: {
58+
provider: 'local',
59+
},
60+
},
61+
});

docs/.vitepress/theme/index.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import Theme from 'vitepress/theme';
2+
import { createTypedChart } from 'vue-chartjs';
3+
import { Tooltip, LineElement, PointElement, LinearScale } from 'chart.js';
4+
import { DendrogramController, ForceDirectedGraphController, EdgeLine, TreeController } from '../../../src';
5+
import ChartPluginDataLabel from 'chartjs-plugin-datalabels';
6+
7+
export default {
8+
...Theme,
9+
enhanceApp({ app }) {
10+
const deps = [
11+
Tooltip,
12+
LineElement,
13+
PointElement,
14+
DendrogramController,
15+
ForceDirectedGraphController,
16+
EdgeLine,
17+
TreeController,
18+
LinearScale,
19+
ChartPluginDataLabel,
20+
];
21+
app.component('DendrogramChart', createTypedChart('dendrogram', deps));
22+
app.component('TreeChart', createTypedChart('tree', deps));
23+
app.component('ForceDirectedGraphChart', createTypedChart('forceDirectedGraph', deps));
24+
},
25+
};

docs/examples/dendrogram.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: Dendrogram
3+
---
4+
5+
# Dendrogram
6+
7+
<script setup>
8+
import {config} from './dendrogram';
9+
</script>
10+
11+
<DendrogramChart
12+
:options="config.options"
13+
:data="config.data"
14+
/>
15+
16+
### Code
17+
18+
:::code-group
19+
20+
<<< ./dendrogram.ts#config [config]
21+
22+
<<< ./dendrogram.ts#data [data]
23+
24+
:::

docs/examples/dendrogram.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import type { ChartConfiguration } from 'chart.js';
2+
import type {} from '../../src';
3+
import 'chartjs-plugin-datalabels';
4+
5+
// #region data
6+
import nodes from './tree.json';
7+
8+
export const data: ChartConfiguration<'dendrogram'>['data'] = {
9+
labels: nodes.map((d) => d.name),
10+
datasets: [
11+
{
12+
pointBackgroundColor: 'steelblue',
13+
pointRadius: 5,
14+
data: nodes.map((d) => Object.assign({}, d)),
15+
},
16+
],
17+
};
18+
// #endregion data
19+
// #region config
20+
export const config: ChartConfiguration<'dendrogram'> = {
21+
type: 'dendrogram',
22+
data,
23+
options: {
24+
plugins: {
25+
datalabels: {
26+
display: false,
27+
},
28+
},
29+
},
30+
};
31+
// #endregion config

docs/examples/directed.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: Directed Tree
3+
---
4+
5+
# Directed Tree
6+
7+
<script setup>
8+
import {config} from './directed';
9+
</script>
10+
11+
<TreeChart
12+
:options="config.options"
13+
:data="config.data"
14+
/>
15+
16+
### Code
17+
18+
:::code-group
19+
20+
<<< ./directed.ts#config [config]
21+
22+
<<< ./directed.ts#data [data]
23+
24+
:::

docs/examples/directed.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import type { ChartConfiguration } from 'chart.js';
2+
import type {} from '../../src';
3+
import 'chartjs-plugin-datalabels';
4+
5+
// #region data
6+
import nodes from './tree.json';
7+
8+
export const data: ChartConfiguration<'tree'>['data'] = {
9+
labels: nodes.map((d) => d.name),
10+
datasets: [
11+
{
12+
pointBackgroundColor: 'steelblue',
13+
pointRadius: 5,
14+
directed: true,
15+
data: nodes.map((d) => Object.assign({}, d)),
16+
},
17+
],
18+
};
19+
// #endregion data
20+
// #region config
21+
export const config: ChartConfiguration<'tree'> = {
22+
type: 'tree',
23+
data,
24+
options: {
25+
plugins: {
26+
datalabels: {
27+
display: false,
28+
},
29+
},
30+
},
31+
};
32+
// #endregion config

docs/examples/force.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: Force Directed Graph
3+
---
4+
5+
# Force Directed Graph
6+
7+
<script setup>
8+
import {config} from './force';
9+
</script>
10+
11+
<ForceDirectedGraphChart
12+
:options="config.options"
13+
:data="config.data"
14+
/>
15+
16+
### Code
17+
18+
:::code-group
19+
20+
<<< ./force.ts#config [config]
21+
22+
<<< ./force.ts#data [data]
23+
24+
:::

docs/examples/force.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import type { ChartConfiguration } from 'chart.js';
2+
import type {} from '../../src';
3+
import 'chartjs-plugin-datalabels';
4+
5+
// #region data
6+
import miserables from './miserables.json';
7+
export const data: ChartConfiguration<'forceDirectedGraph'>['data'] = {
8+
labels: miserables.nodes.map((d) => d.id),
9+
datasets: [
10+
{
11+
pointBackgroundColor: 'steelblue',
12+
pointRadius: 5,
13+
data: miserables.nodes,
14+
edges: miserables.links,
15+
},
16+
],
17+
};
18+
// #endregion data
19+
// #region config
20+
export const config: ChartConfiguration<'forceDirectedGraph'> = {
21+
type: 'forceDirectedGraph',
22+
data,
23+
options: {
24+
plugins: {
25+
datalabels: {
26+
display: false,
27+
},
28+
},
29+
},
30+
};
31+
// #endregion config

docs/examples/index.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
title: Examples
3+
---
4+
5+
# Examples
6+
7+
<script setup>
8+
import {config as force} from './force';
9+
import {config as dendrogram} from './dendrogram';
10+
import {config as tree} from './tree';
11+
</script>
12+
13+
## Force Directed Graph
14+
15+
<ForceDirectedGraphChart
16+
:options="force.options"
17+
:data="force.data"
18+
/>
19+
20+
### Code
21+
22+
:::code-group
23+
24+
<<< ./force.ts#config [config]
25+
26+
<<< ./force.ts#data [data]
27+
28+
:::
29+
30+
## Dendrogram
31+
32+
<DendrogramChart
33+
:options="dendrogram.options"
34+
:data="dendrogram.data"
35+
/>
36+
37+
### Code
38+
39+
:::code-group
40+
41+
<<< ./dendrogram.ts#config [config]
42+
43+
<<< ./dendrogram.ts#data [data]
44+
45+
:::
46+
47+
## Tree
48+
49+
<TreeChart
50+
:options="tree.options"
51+
:data="tree.data"
52+
/>
53+
54+
### Code
55+
56+
:::code-group
57+
58+
<<< ./tree.ts#tree [config]
59+
60+
<<< ./tree.ts#data [data]
61+
62+
:::

docs/examples/label.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: Tree with Labels
3+
---
4+
5+
# Tree with Labels
6+
7+
<script setup>
8+
import {config, radial} from './label';
9+
</script>
10+
11+
<TreeChart
12+
:options="config.options"
13+
:data="config.data"
14+
/>
15+
16+
### Code
17+
18+
:::code-group
19+
20+
<<< ./label.ts#config [config]
21+
22+
<<< ./label.ts#data [data]
23+
24+
:::
25+
26+
## Radial Tree with Labels
27+
28+
<TreeChart
29+
:options="radial.options"
30+
:data="radial.data"
31+
/>
32+
33+
### Code
34+
35+
:::code-group
36+
37+
<<< ./label.ts#radial [config]
38+
39+
<<< ./label.ts#data [data]
40+
41+
:::

0 commit comments

Comments
 (0)