3

I am using the following option to get point style legend with ChartJS 2:

options: {
    legend: {
        labels: {
            usePointStyle: true
        }
    }
}

However, as displayed in the next image, each dot includes a border and a shadow:

enter image description here

ChartJS 2.7.2 is used.

Is there an option to control the border and the drop shadow? How can I remove them?

Laurent
  • 14,122
  • 13
  • 57
  • 89

2 Answers2

5

After looking at the implementation, I noticed the border and shadow are controlled by the borderWidth property defined per dataset. Here is an example to remove the border and the shadow.

const dataset = [
    {
        borderWidth: 0,
        data: ...,
        label: ...,
        backgroundColor: ...,
        hoverBackgroundColor: ...,
    }
];

Note that the point diameter is linked to the label font size.

Laurent
  • 14,122
  • 13
  • 57
  • 89
1

As the borderWidth: 0 alone doesn't seem to work, a workaround is to set the borderColor with 0 opacity:

  datasets: [
    {
      data: defaultData,
      backgroundColor: colors,
      borderWidth: 0,
      borderColor: "rgba(0,0,0,0)", 
    },
Ben Anton
  • 31
  • 2