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

Add pointStyle false #10758

Closed
wants to merge 6 commits into from
Closed
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be

Suggested change
'false'
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ module.exports = {
config: {
type: 'radar',
data: {
labels: [0, 1, 2, 3, 4, 5],
kurkle marked this conversation as resolved.
Show resolved Hide resolved
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'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

]
},
{
// 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
Original file line number Diff line number Diff line change
@@ -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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

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
Original file line number Diff line number Diff line change
@@ -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'];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same


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
Original file line number Diff line number Diff line change
Expand Up @@ -1834,6 +1834,7 @@ export type PointStyle =
| 'rectRot'
| 'star'
| 'triangle'
| false
| HTMLImageElement
| HTMLCanvasElement;

Expand Down