generateLabels(chart) {
const data = chart.data;
if (data.labels.length && data.datasets.length) {
+ const {labels: {pointStyle}} = chart.legend.options;
+
return data.labels.map((label, i) => {
const meta = chart.getDatasetMeta(0);
const style = meta.controller.getStyle(i);
fillStyle: style.backgroundColor,
strokeStyle: style.borderColor,
lineWidth: style.borderWidth,
+ pointStyle: pointStyle,
hidden: !chart.getDataVisibility(i),
// Extra data used for toggling the correct item
generateLabels(chart) {
const data = chart.data;
if (data.labels.length && data.datasets.length) {
+ const {labels: {pointStyle}} = chart.legend.options;
+
return data.labels.map((label, i) => {
const meta = chart.getDatasetMeta(0);
const style = meta.controller.getStyle(i);
fillStyle: style.backgroundColor,
strokeStyle: style.borderColor,
lineWidth: style.borderWidth,
+ pointStyle: pointStyle,
hidden: !chart.getDataVisibility(i),
// Extra data used for toggling the correct item
--- /dev/null
+{
+ "config": {
+ "type": "doughnut",
+ "data": {
+ "labels": [""],
+ "datasets": [{
+ "data": [10],
+ "backgroundColor": "#00ff00",
+ "borderWidth": 0
+ }]
+ },
+ "options": {
+ "plugins": {
+ "legend": {
+ "labels": {
+ "pointStyle": "triangle",
+ "usePointStyle": true
+ }
+ }
+ }
+ }
+ },
+ "options": {
+ "canvas": {
+ "height": 256,
+ "width": 512
+ }
+ }
+}
index: 0,
strokeStyle: '#000',
textAlign: undefined,
- lineWidth: 2
+ lineWidth: 2,
+ pointStyle: undefined
}, {
text: 'label2',
fillStyle: 'green',
index: 1,
strokeStyle: '#000',
textAlign: undefined,
- lineWidth: 2
+ lineWidth: 2,
+ pointStyle: undefined
}, {
text: 'label3',
fillStyle: 'blue',
index: 2,
strokeStyle: '#000',
textAlign: undefined,
- lineWidth: 2
+ lineWidth: 2,
+ pointStyle: undefined
}];
expect(chart.legend.legendItems).toEqual(expected);
});
index: 0,
strokeStyle: '#000',
textAlign: undefined,
- lineWidth: 2
+ lineWidth: 2,
+ pointStyle: undefined
}, {
text: 'label2',
fillStyle: 'green',
index: 1,
strokeStyle: '#000',
textAlign: undefined,
- lineWidth: 2
+ lineWidth: 2,
+ pointStyle: undefined
}, {
text: 'label3',
fillStyle: 'blue',
index: 2,
strokeStyle: '#000',
textAlign: undefined,
- lineWidth: 2
+ lineWidth: 2,
+ pointStyle: undefined
}];
expect(chart.legend.legendItems).toEqual(expected);
});