Skip to content

Commit

Permalink
Pointstyle false (#10886)
Browse files Browse the repository at this point in the history
* fix-#10755

* none to false

* str to bool

* str to bool

* 10/10

* fix test

Co-authored-by: puneetkathar1 <puneetkathar1@gmail.com>
Co-authored-by: Puneet Kathar <73285338+puneetkathar1@users.noreply.github.com>
  • Loading branch information
3 people committed Nov 18, 2022
1 parent 934c140 commit 9a9ff6f
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 9 deletions.
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 @@ -1823,6 +1823,7 @@ export type PointStyle =
| 'rectRot'
| 'star'
| 'triangle'
| false
| HTMLImageElement
| HTMLCanvasElement;

Expand Down

0 comments on commit 9a9ff6f

Please sign in to comment.