Skip to content

Commit 333fc84

Browse files
authored
Adds common annotation options section in the documentation (#747)
1 parent 5487062 commit 333fc84

File tree

10 files changed

+81
-116
lines changed

10 files changed

+81
-116
lines changed

docs/.vuepress/config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const path = require('path');
12
const docsVersion = "VERSION";
23
const base = process.env.NODE_ENV === "development" ? '/chartjs-plugin-annotation/master/' : `/chartjs-plugin-annotation/${docsVersion}/`;
34

@@ -60,6 +61,11 @@ module.exports = {
6061
},
6162
}],
6263
],
64+
markdown: {
65+
extendMarkdown: md => {
66+
md.use(require('markdown-it-include'), path.resolve(__dirname, '../'));
67+
}
68+
},
6369
themeConfig: {
6470
repo: 'chartjs/chartjs-plugin-annotation',
6571
logo: '/favicon.png',

docs/guide/types/_commonOptions.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
### Common options to all annotations
2+
3+
The following options are available for all annotations.
4+
5+
| Name | Type | [Scriptable](../options#scriptable-options) | Default
6+
| ---- | ---- | :----: | ----
7+
| [`adjustScaleRange`](#general) | `boolean` | Yes | `true`
8+
| [`backgroundColor`](#styling) | [`Color`](../options#color) | Yes | `options.color`
9+
| [`borderColor`](#styling) | [`Color`](../options#color) | Yes | `options.color`
10+
| [`borderDash`](#styling) | `number[]` | Yes | `[]`
11+
| [`borderDashOffset`](#styling) | `number` | Yes | `0`
12+
| [`borderShadowColor`](#styling) | [`Color`](../options#color) | Yes | `'transparent'`
13+
| [`display`](#general) | `boolean` | Yes | `true`
14+
| [`drawTime`](#general) | `string` | Yes | `'afterDatasetsDraw'`
15+
| [`shadowBlur`](#styling) | `number` | Yes | `0`
16+
| [`shadowOffsetX`](#styling) | `number` | Yes | `0`
17+
| [`shadowOffsetY`](#styling) | `number` | Yes | `0`
18+
| [`xMax`](#general) | `number` \| `string` | Yes | `undefined`
19+
| [`xMin`](#general) | `number` \| `string` | Yes | `undefined`
20+
| [`xScaleID`](#general) | `string` | Yes | `undefined`
21+
| [`yMin`](#general) | `number` \| `string` | Yes | `undefined`
22+
| [`yMax`](#general) | `number` \| `string` | Yes | `undefined`
23+
| [`yScaleID`](#general) | `string` | Yes | `undefined`
24+
| [`z`](#general) | `number` | Yes | `0`

docs/guide/types/box.md

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,35 +47,21 @@ module.exports = {
4747

4848
## Configuration
4949

50+
### Box annotation specific options
51+
5052
The following options are available for box annotations.
5153

5254
| Name | Type | [Scriptable](../options#scriptable-options) | Default
5355
| ---- | ---- | :----: | ----
54-
| [`adjustScaleRange`](#general) | `boolean` | Yes | `true`
55-
| [`backgroundColor`](#styling) | [`Color`](../options#color) | Yes | `options.color`
5656
| [`backgroundShadowColor`](#styling) | [`Color`](../options#color) | Yes | `'transparent'`
5757
| [`borderCapStyle`](#styling) | `string` | Yes | `'butt'`
58-
| [`borderColor`](#styling) | [`Color`](../options#color) | Yes | `options.color`
59-
| [`borderDash`](#styling) | `number[]` | Yes | `[]`
60-
| [`borderDashOffset`](#styling) | `number` | Yes | `0`
6158
| [`borderJoinStyle`](#styling) | `string` | Yes | `'miter'`
6259
| [`borderRadius`](#styling) | `number` \| `object` | Yes | `0`
63-
| [`borderShadowColor`](#styling) | [`Color`](../options#color) | Yes | `'transparent'`
6460
| [`borderWidth`](#styling) | `number`| Yes | `1`
65-
| [`display`](#general) | `boolean` | Yes | `true`
66-
| [`drawTime`](#general) | `string` | Yes | `'afterDatasetsDraw'`
6761
| [`label`](#label) | `object` | Yes |
6862
| [`rotation`](#general) | `number`| Yes | `0`
69-
| [`shadowBlur`](#styling) | `number` | Yes | `0`
70-
| [`shadowOffsetX`](#styling) | `number` | Yes | `0`
71-
| [`shadowOffsetY`](#styling) | `number` | Yes | `0`
72-
| [`xMax`](#general) | `number` \| `string` | Yes | `undefined`
73-
| [`xMin`](#general) | `number` \| `string` | Yes | `undefined`
74-
| [`xScaleID`](#general) | `string` | Yes | `undefined`
75-
| [`yMin`](#general) | `number` \| `string` | Yes | `undefined`
76-
| [`yMax`](#general) | `number` \| `string` | Yes | `undefined`
77-
| [`yScaleID`](#general) | `string` | Yes | `undefined`
78-
| [`z`](#general) | `number` | Yes | `0`
63+
64+
!!!include(./guide/types/_commonOptions.md)!!!
7965

8066
### General
8167

docs/guide/types/ellipse.md

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,31 +47,17 @@ module.exports = {
4747

4848
## Configuration
4949

50+
### Ellipse annotation specific options
51+
5052
The following options are available for ellipse annotations.
5153

5254
| Name | Type | [Scriptable](../options#scriptable-options) | Default
5355
| ---- | ---- | :----: | ----
54-
| [`adjustScaleRange`](#general) | `boolean` | Yes | `true`
55-
| [`backgroundColor`](#styling) | [`Color`](../options#color) | Yes | `options.color`
5656
| [`backgroundShadowColor`](#styling) | [`Color`](../options#color) | Yes | `'transparent'`
57-
| [`borderColor`](#styling) | [`Color`](../options#color) | Yes | `options.color`
58-
| [`borderDash`](#styling) | `number[]`| Yes | `[]`
59-
| [`borderDashOffset`](#styling) | `number`| Yes | `0`
60-
| [`borderShadowColor`](#styling) | [`Color`](../options#color) | Yes | `'transparent'`
6157
| [`borderWidth`](#styling) | `number`| Yes | `1`
62-
| [`display`](#general) | `boolean` | Yes | `true`
63-
| [`drawTime`](#general) | `string` | Yes | `'afterDatasetsDraw'`
6458
| [`rotation`](#general) | `number`| Yes | `0`
65-
| [`shadowBlur`](#styling) | `number` | Yes | `0`
66-
| [`shadowOffsetX`](#styling) | `number` | Yes | `0`
67-
| [`shadowOffsetY`](#styling) | `number` | Yes | `0`
68-
| [`xMax`](#general) | `number` \| `string` | Yes | `undefined`
69-
| [`xMin`](#general) | `number` \| `string` | Yes | `undefined`
70-
| [`xScaleID`](#general) | `string` | Yes | `undefined`
71-
| [`yMax`](#general) | `number` \| `string` | Yes | `undefined`
72-
| [`yMin`](#general) | `number` \| `string` | Yes | `undefined`
73-
| [`yScaleID`](#general) | `string` | Yes | `undefined`
74-
| [`z`](#general) | `number` | Yes | `0`
59+
60+
!!!include(./guide/types/_commonOptions.md)!!!
7561

7662
### General
7763

docs/guide/types/label.md

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,49 +49,35 @@ module.exports = {
4949

5050
## Configuration
5151

52+
### Label annotation specific options
53+
5254
The following options are available for label annotations.
5355

5456
| Name | Type | [Scriptable](../options#scriptable-options) | Default
5557
| ---- | ---- | :----: | ----
56-
| [`adjustScaleRange`](#general) | `boolean` | Yes | `true`
57-
| [`backgroundColor`](#styling) | [`Color`](../options#color) | Yes | `transparent`
5858
| [`backgroundShadowColor`](#styling) | [`Color`](../options#color) | Yes | `'transparent'`
5959
| [`borderCapStyle`](#styling) | `string` | Yes | `'butt'`
60-
| [`borderColor`](#styling) | [`Color`](../options#color) | Yes | `options.color`
61-
| [`borderDash`](#styling) | `number[]` | Yes | `[]`
62-
| [`borderDashOffset`](#styling) | `number` | Yes | `0`
6360
| [`borderJoinStyle`](#styling) | `string` | Yes | `'miter'`
6461
| [`borderRadius`](#borderradius) | `number` \| `object` | Yes | `0`
65-
| [`borderShadowColor`](#styling) | [`Color`](../options#color) | Yes | `'transparent'`
6662
| [`borderWidth`](#styling) | `number`| Yes | `0`
6763
| [`callout`](#callout) | `object` | Yes |
6864
| [`color`](#styling) | [`Color`](../options#color) | Yes | `'black'`
6965
| [`content`](#general) | `string`\|`string[]`\|[`Image`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image)\|[`HTMLCanvasElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement) | Yes | `null`
70-
| [`display`](#general) | `boolean` | Yes | `true`
71-
| [`drawTime`](#general) | `string` | Yes | `'afterDatasetsDraw'`
7266
| [`font`](#styling) | [`Font`](../options#font) | Yes | `{}`
7367
| [`height`](#general) | `number`\|`string` | Yes | `undefined`
7468
| [`padding`](#general) | [`Padding`](../options#padding) | Yes | `6`
7569
| [`position`](#position) | `string`\|`{x: string, y: string}` | Yes | `'center'`
7670
| [`rotation`](#general) | `number`| Yes | `0`
77-
| [`shadowBlur`](#styling) | `number` | Yes | `0`
78-
| [`shadowOffsetX`](#styling) | `number` | Yes | `0`
79-
| [`shadowOffsetY`](#styling) | `number` | Yes | `0`
8071
| [`textAlign`](#general) | `string` | Yes | `'center'`
8172
| [`textStrokeColor`](#styling) | [`Color`](../options#color) | Yes | `undefined`
8273
| [`textStrokeWidth`](#styling) | `number` | Yes | `0`
8374
| [`width`](#general) | `number`\|`string` | Yes | `undefined`
8475
| [`xAdjust`](#general) | `number` | Yes | `0`
85-
| [`xMax`](#general) | `number` \| `string` | Yes | `undefined`
86-
| [`xMin`](#general) | `number` \| `string` | Yes | `undefined`
87-
| [`xScaleID`](#general) | `string` | Yes | `undefined`
8876
| [`xValue`](#general) | `number` \| `string` | Yes | `undefined`
8977
| [`yAdjust`](#general) | `number` | Yes | `0`
90-
| [`yMax`](#general) | `number` \| `string` | Yes | `undefined`
91-
| [`yMin`](#general) | `number` \| `string` | Yes | `undefined`
92-
| [`yScaleID`](#general) | `string` | Yes | `undefined`
9378
| [`yValue`](#general) | `number` \| `string` | Yes | `undefined`
94-
| [`z`](#general) | `number` | Yes | `0`
79+
80+
!!!include(./guide/types/_commonOptions.md)!!!
9581

9682
### General
9783

docs/guide/types/line.md

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -46,33 +46,20 @@ module.exports = {
4646

4747
## Configuration
4848

49-
The following options are available for line annotations. All of these options can be .
49+
### Line annotation specific options
50+
51+
The following options are available for line annotations.
5052

5153
| Name | Type | [Scriptable](../options#scriptable-options) | Default
5254
| ---- | ---- | :----: | ----
53-
| [`adjustScaleRange`](#general) | `boolean` | Yes | `true`
5455
| [`arrowHeads`](#arrow-heads) | `{start: object, end:object}` | Yes |
55-
| [`borderColor`](#styling) | [`Color`](../options#color) | Yes | `options.color`
56-
| [`borderDash`](#styling) | `number[]` | Yes | `[]`
57-
| [`borderDashOffset`](#styling) | `number` | Yes | `0`
58-
| [`borderShadowColor`](#styling) | [`Color`](../options#color) | Yes | `'transparent'`
5956
| [`borderWidth`](#styling) | `number` | Yes | `2`
60-
| [`display`](#general) | `boolean` | Yes | `true`
61-
| [`drawTime`](#general) | `string` | Yes | `'afterDatasetsDraw'`
6257
| [`endValue`](#positioning) | `number` | Yes | `undefined`
6358
| [`label`](#label) | `object` | Yes |
6459
| [`scaleID`](#positioning) | `string` | Yes | `undefined`
65-
| [`shadowBlur`](#styling) | `number` | Yes | `0`
66-
| [`shadowOffsetX`](#styling) | `number` | Yes | `0`
67-
| [`shadowOffsetY`](#styling) | `number` | Yes | `0`
6860
| [`value`](#positioning) | `number` | Yes | `undefined`
69-
| [`xMax`](#general) | `number` \| `string` | Yes | `undefined`
70-
| [`xMin`](#general) | `number` \| `string` | Yes | `undefined`
71-
| [`xScaleID`](#positioning) | `string` | Yes | `undefined`
72-
| [`yMax`](#general) | `number` \| `string` | Yes | `undefined`
73-
| [`yMin`](#general) | `number` \| `string` | Yes | `undefined`
74-
| [`yScaleID`](#positioning) | `string` | Yes | `undefined`
75-
| [`z`](#general) | `number` | Yes | `0`
61+
62+
!!!include(./guide/types/_commonOptions.md)!!!
7663

7764
### General
7865

@@ -85,21 +72,17 @@ If one of the axes does not match an axis in the chart then the line behaviors a
8572
The 2 coordinates, start, end, are optional. If not specified, the line is expanded out to the edges in the respective direction.
8673
The 4 coordinates, xMin, xMax, yMin, yMax are optional. If not specified, the line is expanded out to the edges in the respective direction.
8774

88-
| Name | Description
89-
| ---- | ----
90-
| `adjustScaleRange` | Should the scale range be adjusted if this annotation is out of range.
91-
| `display` | Whether or not this annotation is visible.
92-
| `drawTime` | See [drawTime](../options#draw-time).
93-
| `z` | The `z` property determines the drawing stack level of the line annotation element. All visible elements will be drawn in ascending order of `z` option, with the same `drawTime` option.
94-
95-
### Positioning
75+
#### Positioning
9676

9777
The line can be positioned in two different ways. If `scaleID` is set, then `value` and `endValue` must also be set to indicate the endpoints of the line. The line will be perpendicular to the axis identified by `scaleID`.
9878

9979
If `scaleID` is unset, then `xScaleID` and `yScaleID` are used to draw a line from `(xMin, yMin)` to `(xMax, yMax)`.
10080

10181
| Name | Description
10282
| ---- | ----
83+
| `adjustScaleRange` | Should the scale range be adjusted if this annotation is out of range.
84+
| `display` | Whether or not this annotation is visible.
85+
| `drawTime` | See [drawTime](../options#draw-time).
10386
| `endValue` | End two of the line when a single scale is specified.
10487
| `scaleID` | ID of the scale in single scale mode. If unset, `xScaleID` and `yScaleID` are used.
10588
| `value` | End one of the line when a single scale is specified.
@@ -109,6 +92,7 @@ If `scaleID` is unset, then `xScaleID` and `yScaleID` are used to draw a line fr
10992
| `yMax` | Y coordinate of end two of the line in units along the y axis.
11093
| `yMin` | Y coordinate of end one of the line in units along the y axis.
11194
| `yScaleID` | ID of the Y scale to bind onto. If missing, the plugin will try to use the scale of the chart, configured as `'y'` axis. If more than one scale has been defined in the chart as `'y'` axis, the option is mandatory to select the right scale.
95+
| `z` | The `z` property determines the drawing stack level of the line annotation element. All visible elements will be drawn in ascending order of `z` option, with the same `drawTime` option.
11296

11397
### Styling
11498

docs/guide/types/point.md

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,37 +45,23 @@ module.exports = {
4545

4646
## Configuration
4747

48+
### Point annotation specific options
49+
4850
The following options are available for point annotations.
4951

5052
| Name | Type | [Scriptable](../options#scriptable-options) | Default
5153
| ---- | ---- | :----: | ----
52-
| [`adjustScaleRange`](#general) | `boolean` | Yes | `true`
53-
| [`backgroundColor`](#styling) | [`Color`](../options#color) | Yes | `options.color`
5454
| [`backgroundShadowColor`](#styling) | [`Color`](../options#color) | Yes | `'transparent'`
55-
| [`borderColor`](#styling) | [`Color`](../options#color) | Yes | `options.color`
56-
| [`borderDash`](#styling) | `number[]`| Yes | `[]`
57-
| [`borderDashOffset`](#styling) | `number`| Yes | `0`
58-
| [`borderShadowColor`](#styling) | [`Color`](../options#color) | Yes | `'transparent'`
5955
| [`borderWidth`](#styling) | `number`| Yes | `1`
60-
| [`display`](#general) | `boolean` | Yes | `true`
61-
| [`drawTime`](#general) | `string` | Yes | `'afterDatasetsDraw'`
6256
| [`pointStyle`](#styling) | [`PointStyle`](../options#point-style) | Yes | `'circle'`
6357
| [`radius`](#general) | `number` | Yes | `10`
6458
| [`rotation`](#general) | `number` | Yes | `0`
65-
| [`shadowBlur`](#styling) | `number` | Yes | `0`
66-
| [`shadowOffsetX`](#styling) | `number` | Yes | `0`
67-
| [`shadowOffsetY`](#styling) | `number` | Yes | `0`
6859
| [`xAdjust`](#general) | `number` | Yes | `0`
69-
| [`xMax`](#general) | `number` \| `string` | Yes | `undefined`
70-
| [`xMin`](#general) | `number` \| `string` | Yes | `undefined`
71-
| [`xScaleID`](#general) | `string` | Yes | `undefined`
7260
| [`xValue`](#general) | `number` \| `string` | Yes | `undefined`
7361
| [`yAdjust`](#general) | `number` | Yes | `0`
74-
| [`yMax`](#general) | `number` \| `string` | Yes | `undefined`
75-
| [`yMin`](#general) | `number` \| `string` | Yes | `undefined`
76-
| [`yScaleID`](#general) | `string` | Yes | `undefined`
7762
| [`yValue`](#general) | `number` \| `string` | Yes | `undefined`
78-
| [`z`](#general) | `number` | Yes | `0`
63+
64+
!!!include(./guide/types/_commonOptions.md)!!!
7965

8066
### General
8167

docs/guide/types/polygon.md

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,40 +47,26 @@ module.exports = {
4747

4848
## Configuration
4949

50+
### Polygon annotation specific options
51+
5052
The following options are available for polygon annotations.
5153

5254
| Name | Type | [Scriptable](../options#scriptable-options) | Default
5355
| ---- | ---- | :----: | ----
54-
| [`adjustScaleRange`](#general) | `boolean` | Yes | `true`
55-
| [`backgroundColor`](#styling) | [`Color`](../options#color) | Yes | `options.color`
5656
| [`backgroundShadowColor`](#styling) | [`Color`](../options#color) | Yes | `'transparent'`
5757
| [`borderCapStyle`](#styling) | `string` | Yes | `'butt'`
58-
| [`borderColor`](#styling) | [`Color`](../options#color) | Yes | `options.color`
59-
| [`borderDash`](#styling) | `number[]`| Yes | `[]`
60-
| [`borderDashOffset`](#styling) | `number`| Yes | `0`
6158
| [`borderJoinStyle`](#styling) | `string` | Yes | `'miter'`
62-
| [`borderShadowColor`](#styling) | [`Color`](../options#color) | Yes | `'transparent'`
6359
| [`borderWidth`](#styling) | `number`| Yes | `1`
64-
| [`display`](#general) | `boolean` | Yes | `true`
65-
| [`drawTime`](#general) | `string` | Yes | `'afterDatasetsDraw'`
6660
| [`point`](#point) | `object` | Yes | `{radius: 0}`
6761
| [`radius`](#general) | `number` | Yes | `10`
6862
| [`rotation`](#general) | `number` | Yes | `0`
69-
| [`shadowBlur`](#styling) | `number` | Yes | `0`
70-
| [`shadowOffsetX`](#styling) | `number` | Yes | `0`
71-
| [`shadowOffsetY`](#styling) | `number` | Yes | `0`
7263
| [`sides`](#general) | `number` | Yes | `3`
7364
| [`xAdjust`](#general) | `number` | Yes | `0`
74-
| [`xMax`](#general) | `number` \| `string` | Yes | `undefined`
75-
| [`xMin`](#general) | `number` \| `string` | Yes | `undefined`
76-
| [`xScaleID`](#general) | `string` | Yes | `'x'`
7765
| [`xValue`](#general) | `number` \| `string` | Yes | `undefined`
7866
| [`yAdjust`](#general) | `number` | Yes | `0`
79-
| [`yScaleID`](#general) | `string` | Yes | `'y'`
80-
| [`yMax`](#general) | `number` \| `string` | Yes | `undefined`
81-
| [`yMin`](#general) | `number` \| `string` | Yes | `undefined`
8267
| [`yValue`](#general) | `number` \| `string` | Yes | `undefined`
83-
| [`z`](#general) | `number` | Yes | `0`
68+
69+
!!!include(./guide/types/_commonOptions.md)!!!
8470

8571
### General
8672

package-lock.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"karma-jasmine": "^4.0.1",
5757
"karma-jasmine-html-reporter": "^1.5.4",
5858
"karma-rollup-preprocessor": "^7.0.7",
59+
"markdown-it-include": "^2.0.0",
5960
"mocha": "^9.1.3",
6061
"pixelmatch": "^5.2.1",
6162
"rollup": "^2.45.2",

0 commit comments

Comments
 (0)