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

Legend placement inside the grid

Open jan-tosovsky-cz opened this issue 7 years ago • 6 comments

Feature Proposal

In jqPlot library it is possible to place the legend inside the grid. It is a handy space saver if both chart values and legend entries are informative only and it doesn't mind these are covered (intersected): http://www.jqplot.com/docs/files/jqplot-core-js.html#Legend.placement

image

Feature Use Case

If there are many series in the chart, it is better to display the legend not on the top/bottom, but rather on left/right (every series on separate line).

If series labels are long, the legend width occupies too much space of the chart area. Moreover, if there are many similar charts on the same page, every chart can have different width which looks weird.

If the legend is placed inside grid, all charts can occupy the entire width, which looks much more consistent. And because the legend background is semi-transparent, the legend width variations between subsequent charts are not so apparent.

jan-tosovsky-cz avatar Apr 05 '19 13:04 jan-tosovsky-cz

@jan-tosovsky-cz
Hey, i would like to work on this

jatiny17 avatar Sep 07 '19 11:09 jatiny17

@jan-tosovsky-cz The thing you want to achieve can be done by using this .. legend:{ dockInsidePlotArea: true/false }..

jatiny17 avatar Oct 14 '19 19:10 jatiny17

dockInsidePlotArea appears to be related to CanvasJS, which is a different library than Chart.js. That option has no effect with this library

benmccann avatar Oct 23 '19 02:10 benmccann

You can use position: 'chartArea', but it goes to the left side and you can not control that currently.

image

kurkle avatar Dec 18 '20 13:12 kurkle

Good thought @kurkle. I tried with the dynamic positioning I added for axes, ie position: { x: 'c', y: 2 } but it didn't work. That might be the way to handle this. I think we might also need some measuring improvements in the legend since it will receive a box that is the entire chart area in size.

etimberg avatar Dec 18 '20 17:12 etimberg

Duplicate of #3787

etimberg avatar Mar 06 '21 23:03 etimberg