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>
@ -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).
|
||||
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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],
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
|
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 11 KiB |
@ -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],
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 19 KiB |
4
test/fixtures/element.point/rotation.js
vendored
@ -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};
|
||||
})
|
||||
};
|
||||
});
|
||||
|
||||
BIN
test/fixtures/element.point/rotation.png
vendored
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 52 KiB |
2
test/fixtures/plugin.tooltip/point-style.js
vendored
@ -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 {
|
||||
|
||||
BIN
test/fixtures/plugin.tooltip/point-style.png
vendored
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 14 KiB |
1
types/index.d.ts
vendored
@ -1823,6 +1823,7 @@ export type PointStyle =
|
||||
| 'rectRot'
|
||||
| 'star'
|
||||
| 'triangle'
|
||||
| false
|
||||
| HTMLImageElement
|
||||
| HTMLCanvasElement;
|
||||
|
||||
|
||||