Chart.js: Line label option for line chart legends

Created on 5 Sep 2017  ·  9Comments  ·  Source: chartjs/Chart.js

Expected Behavior

I'd like to customize a legend for line data so that the legend graphic is a line (styled like the actual data line) rather than a box. Currently there is the usePointStyle option, maybe adding another one called useLineStyle to accomplish this? Example:

line legend:

Current Behavior

ChartJS legend label is a box with a fill and darker outline.

Environment

  • Chart.js version: 2.6.0
  • Browser name and version: Chrome 60
help wanted enhancement

Most helpful comment

Or perhaps adding the option to adjust the height of the box. Currently there is a boxWidth setting under legend label options, perhaps by setting boxHeight you could accomplish this? Maybe this should be a separate feature request in and of itself...

All 9 comments

Or perhaps adding the option to adjust the height of the box. Currently there is a boxWidth setting under legend label options, perhaps by setting boxHeight you could accomplish this? Maybe this should be a separate feature request in and of itself...

+1

+1

+1

+1

@cyril851122 @zeewelc @jackheywood @Thiyagarajan27 & @JewelsJLF If you want to show your interest into this issue, please use the Subscribe button on the right and don't spam the other subscribers.

image

Best regards

This is the approach I used to cope with the issue. It works fine (for me) and avoids boxes larger than the fontSize to simplify the mathematics. The patch below was made against 2.7.2. The property is called boxHeight and sits next to the already existing boxWidth.

height.txt

I was not able to use the code tag (broken results) so I made the attachment.

Results:

aa

Use pointStyle: 'line' or pointStyle: 'dash'

any movement in getting this feature merged?

Was this page helpful?
0 / 5 - 0 ratings