Chart.js legend took up too much spaces

后端 未结 5 2023
执笔经年
执笔经年 2020-12-10 15:27

I was having some problem with chart.js legend. The legend with long text took up too much spaces which resulting in the reduce in the size of my pie chart:

Another

5条回答
  •  既然无缘
    2020-12-10 15:56

    I bumped into a similar issue while using a bar chart with several items in legend positioned at the bottom, I set responsive:true

     options: {
        responsive: true,
        legend: {
          display: true,
          position: "bottom",
          labels: {
            fontColor: "#3f5761"
          }
        },
        scales: {
          yAxes: [
            {
              ticks: {
                beginAtZero: true
              },
              scaleLabel: {
                display: true,
                labelString: "No. of tasks",
                fontSize: 10
              }
            }
          ]
        }
      }
    

    and set the height to the canvas as I wanted the width to be responsive. It looks better now.

    
    

提交回复
热议问题