Skip to content

Commit 0cfbb7e

Browse files
committed
Merge remote-tracking branch 'origin/master' into noDefaultScales
2 parents b37c4f4 + dda0e5c commit 0cfbb7e

Some content is hidden

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

53 files changed

+2723
-942
lines changed

.github/release-drafter.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ categories:
2020
labels:
2121
- 'chore'
2222
- 'performance'
23+
- 'dependencies'
2324
exclude-labels:
2425
- 'infrastructure'
2526
change-template: '- #$NUMBER $TITLE'

docs/.vuepress/config.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ module.exports = {
9797
'types/point',
9898
'types/polygon'
9999
]
100-
}
100+
},
101+
'migrationV2'
101102
],
102103
'/samples/': [
103104
'intro',
@@ -107,6 +108,8 @@ module.exports = {
107108
'box/basic',
108109
'box/quarters',
109110
'box/disclosure',
111+
'box/canvas',
112+
'box/image',
110113
]
111114
},
112115
{
@@ -122,6 +125,9 @@ module.exports = {
122125
'label/basic',
123126
'label/point',
124127
'label/callout',
128+
'label/canvas',
129+
'label/image',
130+
'label/innerChart',
125131
'label/lowerUpper',
126132
]
127133
},
@@ -135,6 +141,8 @@ module.exports = {
135141
'line/standardDeviation',
136142
'line/visibility',
137143
'line/labelVisibility',
144+
'line/canvas',
145+
'line/image',
138146
'line/datasetBars',
139147
'line/animation',
140148
]
@@ -164,6 +172,7 @@ module.exports = {
164172
'charts/line',
165173
],
166174
},
175+
'utils',
167176
]
168177
}
169178
}

docs/guide/migrationV2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# 2.x Migration guide

docs/guide/types/box.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ The following options are available for box annotations.
6565
| [`display`](#general) | `boolean` | Yes | `true`
6666
| [`drawTime`](#general) | `string` | Yes | `'afterDatasetsDraw'`
6767
| [`label`](#label) | `object` | Yes |
68+
| [`rotation`](#general) | `number`| Yes | `0`
6869
| [`shadowBlur`](#styling) | `number` | Yes | `0`
6970
| [`shadowOffsetX`](#styling) | `number` | Yes | `0`
7071
| [`shadowOffsetY`](#styling) | `number` | Yes | `0`
@@ -84,6 +85,7 @@ If one of the axes does not match an axis in the chart, the box will take the en
8485
| `adjustScaleRange` | Should the scale range be adjusted if this annotation is out of range.
8586
| `display` | Whether or not this annotation is visible.
8687
| `drawTime` | See [drawTime](../options#draw-time).
88+
| `rotation` | Rotation of the box in degrees.
8789
| `xMax` | Right edge of the box in units along the x axis.
8890
| `xMin` | Left edge of the box in units along the x axis.
8991
| `xScaleID` | ID of the X scale to bind onto. If missing, the plugin will try to use the scale of the chart, configured as `'x'` axis. If more than one scale has been defined in the chart as `'x'` axis, the option is mandatory to select the right scale.
@@ -101,7 +103,7 @@ If one of the axes does not match an axis in the chart, the box will take the en
101103
| `borderColor` | Stroke color.
102104
| `borderDash` | Length and spacing of dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash).
103105
| `borderDashOffset` | Offset for border line dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset).
104-
| `borderJoinStyle` | Border line joint style. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin).
106+
| `borderJoinStyle` | Border line join style. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin).
105107
| [`borderRadius`](#borderradius) | Radius of box rectangle (in pixels).
106108
| `borderShadowColor` | The color of the border shadow. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/shadowColor).
107109
| `borderWidth` | Border line width (in pixels).
@@ -129,7 +131,10 @@ All of these options can be [Scriptable](../options#scriptable-options)
129131
| `height` | `number`\|`string` | `undefined` | Overrides the height of the image or canvas element. Could be set in pixel by a number, or in percentage of current height of image or canvas element by a string. If undefined, uses the height of the image or canvas element. It is used only when the content is an image or canvas element.
130132
| `padding` | [`Padding`](../options#padding) | `6` | The padding to add around the text label.
131133
| [`position`](#position) | `string`\|`{x: string, y: string}` | `'center'` | Anchor position of label in the box.
134+
| `rotation` | `number` | `undefined` | Rotation of label, in degrees. If `undefined`, the box rotation is used.
132135
| `textAlign` | `string` | `'start'` | Text alignment of label content when there's more than one line. Possible options are: `'left'`, `'start'`, `'center'`, `'end'`, `'right'`.
136+
| `textStrokeColor` | [`Color`](../options#color) | `undefined` | The color of the stroke around the text.
137+
| `textStrokeWidth` | `number` | `0` | Stroke width around the text.
133138
| `width` | `number`\|`string` | `undefined` | Overrides the width of the image or canvas element. Could be set in pixel by a number, or in percentage of current width of image or canvas element by a string. If undefined, uses the width of the image or canvas element. It is used only when the content is an image or canvas element.
134139
| `xAdjust` | `number` | `0` | Adjustment along x-axis (left-right) of label relative to computed position. Negative values move the label left, positive right.
135140
| `yAdjust` | `number` | `0` | Adjustment along y-axis (top-bottom) of label relative to computed position. Negative values move the label up, positive down.

docs/guide/types/ellipse.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ If one of the axes does not match an axis in the chart, the ellipse will take th
8181
| `adjustScaleRange` | Should the scale range be adjusted if this annotation is out of range.
8282
| `display` | Whether or not this annotation is visible.
8383
| `drawTime` | See [drawTime](../options#draw-time).
84-
| `rotation` | Rotatation of the ellipse in degrees, default is 0.
84+
| `rotation` | Rotation of the ellipse in degrees, default is 0.
8585
| `xMax` | Right edge of the ellipse in units along the x axis.
8686
| `xMin` | Left edge of the ellipse in units along the x axis.
8787
| `xScaleID` | ID of the X scale to bind onto. If missing, the plugin will try to use the scale of the chart, configured as `'x'` axis. If more than one scale has been defined in the chart as `'x'` axis, the option is mandatory to select the right scale.

docs/guide/types/label.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,13 @@ The following options are available for label annotations.
7373
| [`height`](#general) | `number`\|`string` | Yes | `undefined`
7474
| [`padding`](#general) | [`Padding`](../options#padding) | Yes | `6`
7575
| [`position`](#position) | `string`\|`{x: string, y: string}` | Yes | `'center'`
76+
| [`rotation`](#general) | `number`| Yes | `0`
7677
| [`shadowBlur`](#styling) | `number` | Yes | `0`
7778
| [`shadowOffsetX`](#styling) | `number` | Yes | `0`
7879
| [`shadowOffsetY`](#styling) | `number` | Yes | `0`
7980
| [`textAlign`](#general) | `string` | Yes | `'center'`
81+
| [`textStrokeColor`](#styling) | [`Color`](../options#color) | Yes | `undefined`
82+
| [`textStrokeWidth`](#styling) | `number` | Yes | `0`
8083
| [`width`](#general) | `number`\|`string` | Yes | `undefined`
8184
| [`xAdjust`](#general) | `number` | Yes | `0`
8285
| [`xMax`](#general) | `number` \| `string` | Yes | `undefined`
@@ -103,6 +106,7 @@ The 4 coordinates, xMin, xMax, yMin, yMax are optional. If not specified, the bo
103106
| `drawTime` | See [drawTime](../options#draw-time).
104107
| `height` | Overrides the height of the image or canvas element. Could be set in pixel by a number, or in percentage of current height of image or canvas element by a string. If undefined, uses the height of the image or canvas element. It is used only when the content is an image or canvas element.
105108
| `padding` | The padding to add around the text label.
109+
| `rotation` | Rotation of the label in degrees.
106110
| `textAlign` | Text alignment of label content when there's more than one line. Possible options are: `'left'`, `'start'`, `'center'`, `'end'`, `'right'`.
107111
| `width` | Overrides the width of the image or canvas element. Could be set in pixel by a number, or in percentage of current width of image or canvas element by a string. If undefined, uses the width of the image or canvas element. It is used only when the content is an image or canvas element.
108112
| `xAdjust` | Adjustment along x-axis (left-right) of label relative to computed position. Negative values move the label left, positive right.
@@ -126,14 +130,16 @@ The 4 coordinates, xMin, xMax, yMin, yMax are optional. If not specified, the bo
126130
| `borderColor` | Stroke color.
127131
| `borderDash` | Length and spacing of dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash).
128132
| `borderDashOffset` | Offset for border line dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset).
129-
| `borderJoinStyle` | Border line joint style. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin).
133+
| `borderJoinStyle` | Border line join style. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin).
130134
| `borderShadowColor` | The color of the border shadow. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/shadowColor).
131135
| `borderWidth` | Stroke width (in pixels).
132136
| `color` | Text color.
133137
| `font` | Text font.
134138
| `shadowBlur` | The amount of blur applied to shadow of the box where the label is located. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/shadowBlur).
135139
| `shadowOffsetX` | The distance that shadow, of the box where the label is located, will be offset horizontally. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/shadowOffsetX).
136140
| `shadowOffsetY` | The distance that shadow, of the box where the label is located, will be offset vertically. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/shadowOffsetY).
141+
| `textStrokeColor` | The color of the stroke around the text.
142+
| `textStrokeWidth` | Stroke width around the text.
137143

138144
### Position
139145

@@ -216,7 +222,7 @@ All of these options can be [Scriptable](../options#scriptable-options).
216222
| `borderColor` | [`Color`](../options#color) | `undefined` | Stroke color of the pointer of the callout.
217223
| `borderDash` | `number[]` | `[]` | Length and spacing of dashes of callout. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash).
218224
| `borderDashOffset` | `number` | `0` | Offset for line dashes of callout. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset).
219-
| `borderJoinStyle` | `string` | `'miter'` | Border line joint style of the callout. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin).
225+
| `borderJoinStyle` | `string` | `'miter'` | Border line join style of the callout. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin).
220226
| `borderWidth` | `number` | `1` | Stroke width of the pointer of the callout.
221227
| `enabled` | `boolean` | `false` | If true, the callout is drawn.
222228
| `margin` | `number` | `5` | Amount of pixels between the label and the callout separator.

docs/guide/types/line.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ All of these options can be [Scriptable](../options#scriptable-options)
135135
| `borderColor` | [`Color`](../options#color) | `black` | The border line color.
136136
| `borderDash` | `number[]` | `[]` | Length and spacing of dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash).
137137
| `borderDashOffset` | `number` | `0` | Offset for border line dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset).
138-
| `borderJoinStyle` | `string` | `'miter'` | Border line joint style. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin).
138+
| `borderJoinStyle` | `string` | `'miter'` | Border line join style. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin).
139139
| [`borderRadius`](#borderradius) | `number` \| `object` | `6` | Radius of label box corners in pixels.
140140
| `borderShadowColor` | [`Color`](../options#color) | `'transparent'` | The color of border shadow of the box where the label is located. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/shadowColor).
141141
| `borderWidth` | `number` | `0` | The border line width (in pixels).
@@ -152,6 +152,8 @@ All of these options can be [Scriptable](../options#scriptable-options)
152152
| `shadowOffsetX` | `number` | `0` | The distance that shadow, of the box where the label is located, will be offset horizontally. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/shadowOffsetX).
153153
| `shadowOffsetY` | `number` | `0` | The distance that shadow, of the box where the label is located, will be offset vertically. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/shadowOffsetY).
154154
| `textAlign` | `string` | `'center'` | Text alignment of label content when there's more than one line. Possible options are: `'start'`, `'center'`, `'end'`.
155+
| `textStrokeColor` | [`Color`](../options#color) | `undefined` | The color of the stroke around the text.
156+
| `textStrokeWidth` | `number` | `0` | Stroke width around the text.
155157
| `width` | `number`\|`string` | `undefined` | Overrides the width of the image or canvas element. Could be set in pixel by a number, or in percentage of current width of image or canvas element by a string. If undefined, uses the width of the image or canvas element. It is used only when the content is an image or canvas element.
156158
| `xAdjust` | `number` | `0` | Adjustment along x-axis (left-right) of label relative to computed position. Negative values move the label left, positive right.
157159
| `xPadding` | `number` | `6` | Padding of label to add left/right. This is **deprecated**. Use `padding`.
@@ -177,7 +179,7 @@ All of these options can be [Scriptable](../options#scriptable-options)
177179

178180
Enabling it, you can add arrow heads at start and/or end of a line. It uses the `borderWidth` of the line options to configure the line width of the arrow head.
179181

180-
The following options are available for can be specified per (`start` and/or `end`) arrow head, or at the top level (`arrowHeads`) which apply to all arrow heads.
182+
The following options can be specified per (`start` and/or `end`) arrow head, or at the top level (`arrowHeads`) which apply to all arrow heads.
181183

182184
All of these options can be [Scriptable](../options#scriptable-options)
183185

docs/guide/types/polygon.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ The 4 coordinates, xMin, xMax, yMin, yMax are optional. If not specified, the bo
116116
| `borderCapStyle` | Cap style of the border of polygon. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap).
117117
| `borderDash` | Length and spacing of dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash).
118118
| `borderDashOffset` | Offset for line dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset).
119-
| `borderJoinStyle` | Border line joint style. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin).
119+
| `borderJoinStyle` | Border line join style. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin).
120120
| `borderShadowColor` | The color of the border shadow. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/shadowColor).
121121
| `borderWidth` | Stroke width.
122122
| `shadowBlur` | The amount of blur applied to shadow. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/shadowBlur).

docs/samples/box/canvas.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Using canvas as labels
2+
3+
```js chart-editor
4+
// <block:setup:3>
5+
const DATA_COUNT = 12;
6+
const MIN = 10;
7+
const MAX = 100;
8+
9+
const numberCfg = {count: DATA_COUNT, min: MIN, max: MAX};
10+
11+
const data = {
12+
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
13+
datasets: [{
14+
data: Utils.numbers(numberCfg)
15+
}]
16+
};
17+
// </block:setup>
18+
19+
// <block:annotation1:1>
20+
const annotation1 = {
21+
type: 'box',
22+
backgroundColor: 'rgba(165, 214, 167, 0.2)',
23+
borderWidth: 0,
24+
xMax: 2,
25+
xMin: 5,
26+
label: {
27+
enabled: true,
28+
content: Utils.getSpiral(),
29+
position: {
30+
x: 'center',
31+
y: 'start'
32+
}
33+
}
34+
};
35+
// </block:annotation1>
36+
37+
// <block:annotation2:2>
38+
const annotation2 = {
39+
type: 'box',
40+
backgroundColor: 'rgba(188, 170, 164, 0.2)',
41+
borderWidth: 0,
42+
xMax: 6,
43+
xMin: 10,
44+
label: {
45+
enabled: true,
46+
content: Utils.getHouse(),
47+
position: {
48+
x: 'center',
49+
y: 'end'
50+
}
51+
}
52+
};
53+
// </block:annotation2>
54+
55+
/* <block:config:0> */
56+
const config = {
57+
type: 'line',
58+
data,
59+
options: {
60+
scales: {
61+
y: {
62+
beginAtZero: true,
63+
}
64+
},
65+
plugins: {
66+
annotation: {
67+
annotations: {
68+
annotation1,
69+
annotation2
70+
}
71+
}
72+
}
73+
}
74+
};
75+
/* </block:config> */
76+
77+
const actions = [
78+
{
79+
name: 'Randomize',
80+
handler: function(chart) {
81+
chart.data.datasets.forEach(function(dataset, i) {
82+
dataset.data = dataset.data.map(() => Utils.rand(MIN, MAX));
83+
});
84+
chart.update();
85+
}
86+
}
87+
];
88+
89+
module.exports = {
90+
actions: actions,
91+
config: config
92+
};
93+
```

docs/samples/box/image.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Using images as labels
2+
3+
```js chart-editor
4+
// <block:setup:2>
5+
const DATA_COUNT = 12;
6+
const MIN = 10;
7+
const MAX = 100;
8+
9+
const numberCfg = {count: DATA_COUNT, min: MIN, max: MAX};
10+
11+
const data = {
12+
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
13+
datasets: [{
14+
data: Utils.numbers(numberCfg)
15+
}]
16+
};
17+
// </block:setup>
18+
19+
// <block:annotation:1>
20+
const annotation = {
21+
type: 'box',
22+
backgroundColor: 'rgba(0, 0, 0, 0.2)',
23+
borderWidth: 1,
24+
borderColor: '#F27173',
25+
yMin: 30,
26+
yMax: 80,
27+
xMax: 2,
28+
xMin: 5,
29+
label: {
30+
enabled: true,
31+
content: Utils.getImage(),
32+
width: 150,
33+
height: 150,
34+
position: 'center'
35+
}
36+
};
37+
// </block:annotation>
38+
39+
/* <block:config:0> */
40+
const config = {
41+
type: 'line',
42+
data,
43+
options: {
44+
scales: {
45+
y: {
46+
beginAtZero: true
47+
}
48+
},
49+
plugins: {
50+
annotation: {
51+
annotations: {
52+
annotation
53+
}
54+
}
55+
}
56+
}
57+
};
58+
/* </block:config> */
59+
60+
const actions = [
61+
{
62+
name: 'Randomize',
63+
handler: function(chart) {
64+
chart.data.datasets.forEach(function(dataset, i) {
65+
dataset.data = dataset.data.map(() => Utils.rand(MIN, MAX));
66+
});
67+
chart.update();
68+
}
69+
}
70+
];
71+
72+
module.exports = {
73+
actions: actions,
74+
config: config
75+
};
76+
```

0 commit comments

Comments
 (0)