Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pointstyle false #10886

Merged
merged 7 commits into from Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/configuration/elements.md
Expand Up @@ -47,6 +47,7 @@ When a string is provided, the following values are supported:
- `'rectRot'`
- `'star'`
- `'triangle'`
- `false`

If the value is an image or a canvas element, that image or canvas element is drawn on the canvas using [drawImage](https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D/drawImage).

Expand Down
9 changes: 9 additions & 0 deletions docs/samples/line/point-styling.md
Expand Up @@ -92,6 +92,15 @@ const actions = [
});
chart.update();
}
},
{
name: 'pointStyle: false',
handler: (chart) => {
chart.data.datasets.forEach(dataset => {
dataset.pointStyle = false;
});
chart.update();
}
}
];
// </block:actions>
Expand Down
3 changes: 3 additions & 0 deletions src/helpers/helpers.canvas.js
Expand Up @@ -256,6 +256,9 @@ export function drawPointLegend(ctx, options, x, y, w) {
ctx.moveTo(x, y);
ctx.lineTo(x + Math.cos(rad) * (w ? w / 2 : radius), y + Math.sin(rad) * radius);
break;
case false:
ctx.closePath();
break;
}

ctx.fill();
Expand Down
7 changes: 4 additions & 3 deletions test/fixtures/controller.line/pointStyle/indexable.js
Expand Up @@ -2,11 +2,11 @@ module.exports = {
config: {
type: 'line',
data: {
labels: [0, 1, 2, 3, 4, 5],
labels: [0, 1, 2, 3, 4, 5, 6],
datasets: [
{
// option in dataset
data: [0, 5, 10, null, -10, -5],
data: [0, 5, 10, null, -10, -5, 0],
pointBackgroundColor: '#ff0000',
pointBorderColor: '#ff0000',
pointStyle: [
Expand All @@ -16,11 +16,12 @@ module.exports = {
'dash',
'line',
'rect',
false
]
},
{
// option in element (fallback)
data: [4, -5, -10, null, 10, 5],
data: [4, -5, -10, null, 10, 5, -4],
}
]
},
Expand Down
Binary file modified test/fixtures/controller.line/pointStyle/indexable.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions test/fixtures/controller.radar/pointStyle/indexable.js
Expand Up @@ -2,11 +2,11 @@ module.exports = {
config: {
type: 'radar',
data: {
labels: [0, 1, 2, 3, 4, 5],
labels: [0, 1, 2, 3, 4, 5, 6],
datasets: [
{
// option in dataset
data: [0, 5, 10, null, -10, -5],
data: [0, 5, 10, null, -10, -5, 0],
pointBackgroundColor: '#ff0000',
pointBorderColor: '#ff0000',
pointStyle: [
Expand All @@ -16,11 +16,12 @@ module.exports = {
'dash',
'line',
'rect',
false
]
},
{
// option in element (fallback)
data: [4, -5, -10, null, 10, 5],
data: [4, -5, -10, null, 10, 5, -4],
}
]
},
Expand Down
Binary file modified test/fixtures/controller.radar/pointStyle/indexable.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions test/fixtures/element.point/rotation.js
@@ -1,10 +1,10 @@
var gradient;

var datasets = ['circle', 'cross', 'crossRot', 'dash', 'line', 'rect', 'rectRounded', 'rectRot', 'star', 'triangle'].map(function(style, y) {
var datasets = ['circle', 'cross', 'crossRot', 'dash', 'line', 'rect', 'rectRounded', 'rectRot', 'star', 'triangle', false].map(function(style, y) {
return {
pointStyle: style,
data: Array.apply(null, Array(17)).map(function(v, x) {
return {x: x, y: 10 - y};
return {x: x, y: 11 - y};
})
};
});
Expand Down
Binary file modified test/fixtures/element.point/rotation.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/fixtures/plugin.tooltip/point-style.js
@@ -1,4 +1,4 @@
const pointStyles = ['circle', 'cross', 'crossRot', 'dash', 'line', 'rect', 'rectRounded', 'rectRot', 'star', 'triangle'];
const pointStyles = ['circle', 'cross', 'crossRot', 'dash', 'line', 'rect', 'rectRounded', 'rectRot', 'star', 'triangle', false];

function newDataset(pointStyle, i) {
return {
Expand Down
Binary file modified test/fixtures/plugin.tooltip/point-style.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions types/index.d.ts
Expand Up @@ -1834,6 +1834,7 @@ export type PointStyle =
| 'rectRot'
| 'star'
| 'triangle'
| false
| HTMLImageElement
| HTMLCanvasElement;

Expand Down