Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Legend title #4466

Closed
dhuallanca opened this issue Jul 5, 2017 · 9 comments · Fixed by #6906
Closed

Add Legend title #4466

dhuallanca opened this issue Jul 5, 2017 · 9 comments · Fixed by #6906

Comments

@dhuallanca
Copy link

FEATURE requests

Expected Behavior

Add title for legend

Current Behavior

Legend doesn't sopport title

Possible Solution

Steps to Reproduce (for bugs)

Context

user expectation

Environment

@etimberg
Copy link
Member

etimberg commented Jul 6, 2017

@dhuallanca what kind of title do you envision for the legend?

@dhuallanca
Copy link
Author

@etimberg, I am using doughnut chart, I would like to have a title(Label) on the top of legends.

@ccario83
Copy link

Second this. If I have a data series with days of the week, it'd be nice to have 'Week' as the legend title. This is even more important when a chart's independent variable and series are both True/False.

@simonbrunel
Copy link
Member

What's the difference with the chart title? Can you provide a mockup of what you are trying to build?

@dhuallanca
Copy link
Author

What's the difference with the chart title? Can you provide a mockup of what you are trying to build?

image

@jatiny17
Copy link
Contributor

jatiny17 commented Sep 7, 2019

@dhuallanca ,
Hey i want to work on this ,can you explain a bit more about this

@dhuallanca
Copy link
Author

@jatiny17 , I want to add a Legend title on the top of legends items.

image

@RahulChouhan96
Copy link

same problem, any help with it?

@huyit88
Copy link

huyit88 commented Nov 5, 2019

I find the way to hack this behavior, however it's not supported by default.

legend.labels.generateLabels = chart => {
      var data = chart.data;
      let labels = Chart.defaults.global.legend.labels.generateLabels(chart);
      let title = {
        text: 'Legend Title',
        strokeStyle: 'transparent',
        fillStyle: 'transparent',
        lineWidth: 0
      };
      return [title, ...labels];
    };

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants