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
Legend boxes don't reflect the gradient #28
Comments
Forgot to write that if the user set own |
It would be great if the legend plugin would resolve the colors with a different context, so a different gradient could be returned based on that. But it does not, so your suggestion might be the only option. |
yeah, at he moment it sounds so. I know in CHART.JS v4 there is the plan to re-write legend plugin... in version 4! Just FYI, I'm creating a prototype. I'll show it to you soon. |
In advance, to do that I think we need to map more hooks of plugin (i.e. to set the callback) and also leverage on chart states map (as done in plugin annotation). |
@kurkle FYI, generateLabels callback is not the right direction because, when invoked, the legendItems size is not calculated yet. I've found another way. |
Do you think the support to version 2.x is still needed also for this enhancement? |
Feature Proposal
As I have seen in my lib, when you use gradients, the gradients are not reflected in the legend.
To be precise, the gradient is applied to the legend but due to the gradient size is limited to the scales, the legend are out side of the gradient and then the canvas use the color related to the position.
See example in codepen: https://codepen.io/stockinail/pen/xxpENVM
As you can see the legend is using the
red
color because is the color from the gradient for legend position.The same is for polarArea (using the radial gradient) where all legend items are colored with the color of the gradient.
The proposal is to reflect on the legend the gradient.
Possible Implementation
I see only 1 option, creating a
generateLabels
callback in the plugin to set to the chart in order to create a specific gradient (with dimension of the legend box).For polarArea, the
generateLabels
callback could return the color at the data index, calculating the last color for the data index. For this, I have got already a code (even if is written in Java) that it can be translated and used.The text was updated successfully, but these errors were encountered: