-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
1,106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { defineConfig } from 'vitepress'; | ||
import { name, description, repository, license, author } from '../../package.json'; | ||
import typedocSidebar from '../api/typedoc-sidebar.json'; | ||
|
||
const cleanName = name.replace('@sgratzl/', ''); | ||
|
||
// https://vitepress.dev/reference/site-config | ||
export default defineConfig({ | ||
title: cleanName, | ||
description, | ||
base: `/${cleanName}/`, | ||
useWebFonts: false, | ||
themeConfig: { | ||
// https://vitepress.dev/reference/default-theme-config | ||
nav: [ | ||
{ text: 'Home', link: '/' }, | ||
{ text: 'Getting Started', link: '/getting-started' }, | ||
{ text: 'Examples', link: '/examples/' }, | ||
{ text: 'API', link: '/api/' }, | ||
{ text: 'Related Plugins', link: '/related' }, | ||
], | ||
|
||
sidebar: [ | ||
{ | ||
text: 'Examples', | ||
items: [ | ||
{ text: 'Basic', link: '/examples/' }, | ||
{ text: 'Choropleth US Map', link: '/examples/choropleth' }, | ||
{ text: 'Bubble Map', link: '/examples/bubbleMap' }, | ||
{ text: 'Custom Color Scale', link: '/examples/custom' }, | ||
{ text: 'Legend Customization', link: '/examples/legend' }, | ||
{ text: 'Tooltip Center', link: '/examples/center' }, | ||
{ text: 'Projection Offset', link: '/examples/offset' }, | ||
{ text: 'Equal Earth Projection', link: '/examples/projection' }, | ||
{ text: 'World Atlas', link: '/examples/earth' }, | ||
{ text: 'Bubble Map Area Mode', link: '/examples/area' }, | ||
], | ||
}, | ||
{ | ||
text: 'API', | ||
collapsed: true, | ||
items: typedocSidebar, | ||
}, | ||
], | ||
|
||
socialLinks: [{ icon: 'github', link: repository.url.replace('.git', '') }], | ||
|
||
footer: { | ||
message: `Released under the <a href="${repository.url.replace( | ||
'.git', | ||
'' | ||
)}/tree/main/LICENSE">${license} license</a>.`, | ||
copyright: `Copyright © 2019-present <a href="${author.url}">${author.name}</a>`, | ||
}, | ||
|
||
editLink: { | ||
pattern: `${repository.url.replace('.git', '')}/edit/main/docs/:path`, | ||
}, | ||
|
||
search: { | ||
provider: 'local', | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import Theme from 'vitepress/theme'; | ||
import { createTypedChart } from 'vue-chartjs'; | ||
import { Tooltip, PointElement } from 'chart.js'; | ||
import { | ||
BubbleMapController, | ||
ChoroplethController, | ||
ColorScale, | ||
ColorLogarithmicScale, | ||
SizeLogarithmicScale, | ||
SizeScale, | ||
GeoFeature, | ||
ProjectionScale, | ||
} from '../../../src'; | ||
|
||
export default { | ||
...Theme, | ||
enhanceApp({ app }) { | ||
app.component( | ||
'BubbleMapChart', | ||
createTypedChart('bubbleMap', [ | ||
ProjectionScale, | ||
BubbleMapController, | ||
SizeScale, | ||
SizeLogarithmicScale, | ||
PointElement, | ||
GeoFeature, | ||
Tooltip, | ||
]) | ||
); | ||
app.component( | ||
'ChoroplethChart', | ||
createTypedChart('choropleth', [ | ||
ProjectionScale, | ||
ChoroplethController, | ||
ColorScale, | ||
ColorLogarithmicScale, | ||
GeoFeature, | ||
Tooltip, | ||
]) | ||
); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type { ChartConfiguration } from 'chart.js'; | ||
import { Feature, topojson } from '../../src'; | ||
|
||
// #region data | ||
import states10m from 'us-atlas/states-10m.json'; | ||
|
||
const nation: Feature = topojson.feature(states10m as any, states10m.objects.nation as any).features[0]; | ||
const states: Feature = topojson.feature(states10m as any, states10m.objects.states as any).features; | ||
|
||
export const data: ChartConfiguration<'choropleth'>['data'] = { | ||
labels: states.map((d) => d.properties.name), | ||
datasets: [ | ||
{ | ||
label: 'States', | ||
outline: nation, | ||
data: states.map((d) => ({ | ||
feature: d, | ||
value: Math.random() * 11, | ||
})), | ||
}, | ||
], | ||
}; | ||
// #endregion data | ||
// #region config | ||
export const config: ChartConfiguration<'choropleth'> = { | ||
type: 'choropleth', | ||
data, | ||
options: { | ||
scales: { | ||
projection: { | ||
axis: 'x', | ||
projection: 'albersUsa', | ||
}, | ||
color: { | ||
axis: 'x', | ||
quantize: 5, | ||
legend: { | ||
position: 'bottom-right', | ||
align: 'right', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
// #endregion config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
title: Bubble Map Area Mode | ||
--- | ||
|
||
# Bubble Map Area Mode | ||
|
||
<script setup> | ||
import {config} from './area'; | ||
</script> | ||
|
||
<BubbleMapChart | ||
:options="config.options" | ||
:data="config.data" | ||
/> | ||
|
||
### Code | ||
|
||
:::code-group | ||
|
||
<<< ./area.ts#config [config] | ||
|
||
<<< ./bubbleMap.ts#data [data] | ||
|
||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type { ChartConfiguration } from 'chart.js'; | ||
import { Feature, topojson } from '../../src'; | ||
import { data } from './bubbleMap'; | ||
|
||
// #region config | ||
export const config: ChartConfiguration<'bubbleMap'> = { | ||
type: 'bubbleMap', | ||
data, | ||
options: { | ||
scales: { | ||
projection: { | ||
axis: 'x', | ||
projection: 'albersUsa', | ||
}, | ||
size: { | ||
axis: 'x', | ||
size: [1, 20], | ||
mode: 'area', | ||
}, | ||
}, | ||
layout: { | ||
// padding: 20 | ||
}, | ||
}, | ||
}; | ||
// #endregion config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
title: Bubble Map | ||
--- | ||
|
||
# Bubble Map | ||
|
||
<script setup> | ||
import {config} from './bubbleMap'; | ||
</script> | ||
|
||
<BubbleMapChart | ||
:options="config.options" | ||
:data="config.data" | ||
/> | ||
|
||
### Code | ||
|
||
:::code-group | ||
|
||
<<< ./bubbleMap.ts#config [config] | ||
|
||
<<< ./bubbleMap.ts#data [data] | ||
|
||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import type { ChartConfiguration } from 'chart.js'; | ||
import { Feature, topojson } from '../../src'; | ||
// #region data | ||
import states10m from 'us-atlas/states-10m.json'; | ||
import capitals from './data/us-capitals.json'; | ||
import ChartDataLabels from 'chartjs-plugin-datalabels'; | ||
|
||
const states: Feature = topojson.feature(states10m as any, states10m.objects.states as any).features; | ||
|
||
export const data: ChartConfiguration<'bubbleMap'>['data'] = { | ||
labels: capitals.map((d) => d.description), | ||
datasets: [ | ||
{ | ||
outline: states, | ||
showOutline: true, | ||
backgroundColor: 'steelblue', | ||
data: capitals.map((d) => Object.assign(d, { value: Math.round(Math.random() * 10) })), | ||
}, | ||
], | ||
}; | ||
// #endregion data | ||
// #region config | ||
export const config: ChartConfiguration<'bubbleMap'> = { | ||
type: 'bubbleMap', | ||
data, | ||
options: { | ||
plugins: { | ||
datalabels: { | ||
align: 'top', | ||
formatter: (v) => { | ||
return v.description; | ||
}, | ||
}, | ||
}, | ||
scales: { | ||
projection: { | ||
axis: 'x', | ||
projection: 'albersUsa', | ||
}, | ||
size: { | ||
axis: 'x', | ||
size: [1, 20], | ||
}, | ||
}, | ||
layout: { | ||
// padding: 20 | ||
}, | ||
}, | ||
plugins: [ChartDataLabels], | ||
}; | ||
// #endregion config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
title: Custom Tooltip Center | ||
--- | ||
|
||
# Custom Tooltip Center | ||
|
||
<script setup> | ||
import {config} from './center'; | ||
</script> | ||
|
||
<ChoroplethChart | ||
:options="config.options" | ||
:data="config.data" | ||
/> | ||
|
||
### Code | ||
|
||
:::code-group | ||
|
||
<<< ./center.ts#config [config] | ||
|
||
<<< ./center.ts#data [data] | ||
|
||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import type { ChartConfiguration } from 'chart.js'; | ||
import { Feature, topojson } from '../../src'; | ||
|
||
// #region data | ||
import states10m from 'us-atlas/states-10m.json'; | ||
import capitals from './data/us-capitals.json'; | ||
|
||
const nation: Feature = topojson.feature(states10m as any, states10m.objects.nation as any).features[0]; | ||
const states: Feature = topojson.feature(states10m as any, states10m.objects.states as any).features; | ||
|
||
const lookup = new Map(capitals.map(({ name, latitude, longitude }) => [name, { latitude, longitude }])); | ||
|
||
export const data: ChartConfiguration<'choropleth'>['data'] = { | ||
labels: states.map((d) => d.properties.name), | ||
datasets: [ | ||
{ | ||
label: 'States', | ||
outline: nation, | ||
data: states.map((d) => ({ | ||
feature: d, | ||
center: lookup.get(d.properties.name), | ||
value: Math.random() * 11, | ||
})), | ||
}, | ||
], | ||
}; | ||
// #endregion data | ||
// #region config | ||
export const config: ChartConfiguration<'choropleth'> = { | ||
type: 'choropleth', | ||
data, | ||
options: { | ||
scales: { | ||
projection: { | ||
axis: 'x', | ||
projection: 'albersUsa', | ||
}, | ||
color: { | ||
axis: 'x', | ||
quantize: 5, | ||
legend: { | ||
position: 'bottom-right', | ||
align: 'right', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
// #endregion config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
title: Choropleth US Map | ||
--- | ||
|
||
# Choropleth US Map | ||
|
||
<script setup> | ||
import {config} from './albers'; | ||
</script> | ||
|
||
<ChoroplethChart | ||
:options="config.options" | ||
:data="config.data" | ||
/> | ||
|
||
### Code | ||
|
||
:::code-group | ||
|
||
<<< ./albers.ts#config [config] | ||
|
||
<<< ./albers.ts#data [data] | ||
|
||
::: |
Oops, something went wrong.