Pointstyle false (#10886)

* 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>
This commit is contained in:
Jacco van den Berg 2022-11-18 19:14:47 +01:00 committed by GitHub
parent 934c14069f
commit 9a9ff6fdbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 25 additions and 9 deletions

View File

@ -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).

View File

@ -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>

View File

@ -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();

View File

@ -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: [
@ -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],
}
]
},

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -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: [
@ -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],
}
]
},

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -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};
})
};
});

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 52 KiB

View File

@ -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 {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 14 KiB

1
types/index.d.ts vendored
View File

@ -1823,6 +1823,7 @@ export type PointStyle =
| 'rectRot'
| 'star'
| 'triangle'
| false
| HTMLImageElement
| HTMLCanvasElement;