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 4 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, null],
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, null],
}
]
},
Expand Down
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, null],
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, null],
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/element.point/rotation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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) {
Expand Down
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];

function newDataset(pointStyle, i) {
return {
Expand Down
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1825,6 +1825,7 @@ export type PointStyle =
| 'rectRot'
| 'star'
| 'triangle'
| false
| HTMLImageElement
| HTMLCanvasElement;

Expand Down