Skip to content

Commit eded389

Browse files
authored
Add initial docs (#456)
* Add initial docs * Remove autocolors * Bugfix * Capitalize Installation * Prevent tension in scatter * Add basic sample * Update default sample * Add options * Update deps * Remove unused sensitivity option * Implement most of samples in docs * Add linting for types * tests * Add missing parser
1 parent 15c443d commit eded389

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+32779
-3835
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: documentation
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
push:
7+
branches: [master]
8+
9+
jobs:
10+
checks:
11+
if: github.event_name != 'push'
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v1
15+
- uses: actions/setup-node@v1
16+
with:
17+
node-version: '14.x'
18+
- name: Test Build
19+
run: |
20+
npm ci
21+
npm run docs
22+
gh-release:
23+
if: github.event_name != 'pull_request'
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v1
27+
- uses: actions/setup-node@v1
28+
with:
29+
node-version: '14.x'
30+
- name: Build
31+
run: |
32+
npm ci
33+
npm run docs
34+
- name: Release to GitHub Pages
35+
uses: peaceiris/actions-gh-pages@v3
36+
with:
37+
github_token: ${{ secrets.GH_AUTH_TOKEN }}
38+
publish_dir: dist/docs

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
node_modules/*
44
custom/*
55

6-
docs/index.md
7-
86
coverage/*
97

108
nbproject/*

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ plugins: {
118118
// Minimal zoom distance required before actually applying zoom
119119
threshold: 2,
120120

121-
// On category scale, minimal zoom level before actually applying zoom
122-
sensitivity: 3,
123-
124121
// Function called while the user is zooming
125122
onZoom: function({chart}) { console.log(`I'm zooming!!!`); },
126123
// Function called once zooming is completed

docs/.vuepress/config.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
const path = require('path');
2+
const base = process.env.MY_PLATFORM === "cloudflare" ? '/' : `/chartjs-plugin-zoom/`;
3+
4+
module.exports = {
5+
title: 'chartjs-plugin-zoom',
6+
description: 'A zoom and pan plugin for Chart.js >= 3.0.0',
7+
theme: 'chartjs',
8+
base,
9+
dest: path.resolve(__dirname, '../../dist/docs'),
10+
head: [
11+
['link', {rel: 'icon', href: '/favicon.ico'}],
12+
],
13+
plugins: [
14+
['flexsearch'],
15+
['redirect', {
16+
redirectors: [
17+
// Default sample page when accessing /samples.
18+
{base: '/samples', alternative: ['basic']},
19+
],
20+
}],
21+
],
22+
chainWebpack: (config) => {
23+
config.merge({
24+
resolve: {
25+
alias: {
26+
// Hammerjs requires window, using ng-hammerjs instead
27+
'hammerjs': 'ng-hammerjs',
28+
}
29+
}
30+
});
31+
},
32+
themeConfig: {
33+
repo: 'chartjs/chartjs-plugin-zoom',
34+
logo: '/favicon.ico',
35+
lastUpdated: 'Last Updated',
36+
searchPlaceholder: 'Search...',
37+
editLinks: false,
38+
docsDir: 'docs',
39+
chart: {
40+
imports: [
41+
['scripts/register.js'],
42+
['scripts/defaults.js'],
43+
['scripts/utils.js', 'Utils'],
44+
]
45+
},
46+
nav: [
47+
{text: 'Home', link: '/'},
48+
{text: 'Guide', link: '/guide/'},
49+
{text: 'Samples', link: `/samples/`},
50+
{
51+
text: 'Ecosystem',
52+
ariaLabel: 'Community Menu',
53+
items: [
54+
{ text: 'Awesome', link: 'https://github.com/chartjs/awesome' },
55+
]
56+
}
57+
],
58+
sidebar: {
59+
'/guide/': [
60+
'',
61+
'integration',
62+
'usage',
63+
'options',
64+
'animations',
65+
],
66+
'/samples/': [
67+
'basic',
68+
'over-scale-mode',
69+
'bar',
70+
'log',
71+
],
72+
}
73+
}
74+
};

docs/.vuepress/public/favicon.ico

32.2 KB
Binary file not shown.

docs/.vuepress/public/favicon.png

10.1 KB
Loading

docs/.vuepress/public/hero.svg

Lines changed: 41 additions & 0 deletions
Loading

docs/guide/animations.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Animations
2+
3+
The drag-to-zoom animation can be customized by configuring the `zoom` transition in your chart config:
4+
5+
```javascript
6+
{
7+
options: {
8+
transitions: {
9+
zoom: {
10+
animation: {
11+
duration: 1000,
12+
easing: 'easeOutCubic'
13+
}
14+
}
15+
}
16+
}
17+
}
18+
```
19+
20+
If you want to disable zoom animations:
21+
22+
```javascript
23+
{
24+
options: {
25+
transitions: {
26+
zoom: {
27+
animation: {
28+
duration: 0
29+
}
30+
}
31+
}
32+
}
33+
}
34+
```

docs/guide/index.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Getting Started
2+
3+
A zoom and pan plugin for Chart.js >= 3.0.0
4+
5+
Panning can be done via the mouse or with a finger.
6+
Zooming is done via the mouse wheel or via a pinch gesture. [Hammer.js](https://hammerjs.github.io/) is used for gesture recognition.
7+
8+
## Installation
9+
10+
```bash
11+
> npm install chartjs-plugin-zoom
12+
```
13+
14+
:::tip
15+
16+
**Important Note:** For Chart.js 2.6.0 to 2.9.x support, use [version 0.7.7 of this plugin](https://github.com/chartjs/chartjs-plugin-zoom/releases/tag/v0.7.7).
17+
Documentation for v0.7.7 can be found on [GitHub](https://github.com/chartjs/chartjs-plugin-zoom/blob/v0.7.7/README.md).
18+
19+
:::

docs/guide/integration.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Integration
2+
3+
**chartjs-plugin-zoom** can be integrated with plain JavaScript or with different module loaders. The examples below show to load the plugin in different systems.
4+
5+
## Script Tag
6+
7+
```html
8+
<script src="path/to/chartjs/dist/chart.min.js"></script>
9+
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
10+
<script src="path/to/chartjs-plugin-zoom/dist/chartjs-plugin-zoom.min.js"></script>
11+
<script>
12+
var myChart = new Chart(ctx, {...});
13+
</script>
14+
```
15+
16+
## Bundlers (Webpack, Rollup, etc.)
17+
18+
```javascript
19+
import { Chart } from 'chart.js';
20+
import zoomPlugin from 'chartjs-plugin-zoom';
21+
22+
Chart.register(zoomPlugin);
23+
```

0 commit comments

Comments
 (0)