-
-
Notifications
You must be signed in to change notification settings - Fork 836
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
legendCallback() doesn't render a custom legend #144
Comments
I think that is because legend.display is set to false. And legendCallback does not automatically substitute the default legends. Did I answer your question? |
Not really, but I took a better look at the implementation, and the legend should be set to false, but indeed you need to generate the legend in a separate div. For me this isn't apparent from the documentation, and replacing the default legend seems more obvious to me. Anyways, I am going to try out the new method and will post my findings :-) |
@MOKuper any updates on your findings? I need to generate a custom legend to but am having some problems getting it to work... |
You can generate a complete custom legend, if you want. In the scaleBeginAtZero: true,
legendTemplate: '<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<segments.length; i++){%><li class="chapter__item"><span style="background-color:<%=segments[i].fillColor%>"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>',
legend: {
display: false,
position: 'left',
fullWidth: true,
labels: {
fontSize: isXsScreen ? 13 : 18,
fontFamily: "'Open Sans', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"
}
}, Then you can generate it and save if in a local var this.legendMarkup = this.$data._chart.generateLegend() And in your template you can do <div class="legend__list" ref="legend" v-html="legendMarkup"></div> |
@apertureless where in the docs says that? when are the owners going to update the docs |
With the current version of chart.js they removed Just check out the Docs. http://www.chartjs.org/docs/latest/configuration/legend.html#html-legends |
Yes, you need to use the |
iam using with react
and i am not able to see generated dom legend. Any thoughts? |
legend: { |
Expected Behavior
The legendCallback() as explained here chartjs docs html legend
should generate a custom legend
Actual Behavior
The new chart options, of which legendCallback() is one, is being fired, but the legend doesn't end up in the chart
I made a codepen with a little example
https://codepen.io/MOKuper/pen/QgVmNq
Environment
Do I love chart.js
yes I do
The text was updated successfully, but these errors were encountered: