Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

Many lengend take all space v2.0 Beta, pie is too small

Open Garric15 opened this issue 10 years ago • 5 comments

In the v2.0 Beta, when I have many lengends, I can't see the pie chart when I resize or in a mobile. I tried to set Chart.defaults.global.legend.fullWidth to false, but same result.

chartjs

I think the legend should not take the place of the pie. Or is there a setting that is not in the doc ?

You can try to resize : http://jsbin.com/werifuyeyo/edit

Garric15 avatar Feb 01 '16 17:02 Garric15

Some possible solutions

  • create your own HTML legend and disable the on-canvas legend
  • Set a smaller font for the legend

etimberg avatar Feb 01 '16 18:02 etimberg

Had recently same problem (https://github.com/nnnick/Chart.js/issues/1933) Solved by disabling the legend for small screens

window.chart1.options.legend.display=(document.getElementById("canvas1").height >250);
window.chart1.update();

Dergonic avatar Feb 02 '16 07:02 Dergonic

Closing since there is a great solution from @Dergonic

etimberg avatar Feb 27 '16 00:02 etimberg

Sorry but this is not a "great" solution. The legend should induce some extra space bellow the chart just as one may have used his own HTML rendered legend. The same issue may appear with a very long title.

darkengines avatar Sep 09 '16 15:09 darkengines

Helllo, You have to play with he aspect ratio of the chart vs. legend. Like this: Chart.defaults.pie.aspectRatio = 1; Or Chart.defaults.global.maintainAspectRatio = false; One of this statements should do the trick. JJ

joao-jeronimo avatar Dec 07 '17 17:12 joao-jeronimo