2

I have been trying to search for a solution to get the legend colorboxes as line using chartjs, but it looks like we can only reduce them to vertical boxes using boxWidth parameter but not horizontal due to the absence of boxLength parameter. I cannot tweak the chartjs library as the production environment downloads it on the go.

I have used the pointStyle as line to get it for the linechart alone, but I cannot find a way to get the same for barcharts and pie charts

here is the code I have used for linechart

legend: {
                onClick: this.onLegendCallBack,
                display: true,
                position : 'bottom',
                labels: {
                    fontFamily: 'sans-serif',
                    fontSize: 12,
                    boxWidth : 1,
                    usePointStyle: true
                }
            }
Vamsi
  • 388
  • 2
  • 12
  • 1
    The best way you can do this is by using a html legend ( https://www.chartjs.org/docs/latest/configuration/legend.html#html-legends ), in the new beta you will also be able to use pointstyle for bar charts by default but not any other charts – LeeLenalee Mar 10 '21 at 10:49
  • Thanks for your comment [LeeLenalee](https://stackoverflow.com/users/8682983/leelenalee) , So technically we cannot construct a line bar for legend with the inbuilt configuration for all type of charts – Vamsi Mar 15 '21 at 10:53

0 Answers0