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 label style option #5622
Conversation
- Add style option to legend labels config suppoting box, line and point style - Deprecate usePointStyle option - BoxWidth is now calculated for each legend item as it can have different width - Fix the existing tests and add more tests - Update document
I'm not sure we should deprecate I think the following use cases should be valid for a line or radar chart:
|
@simonbrunel |
I thought
I think it should be a dashed line in this case and I would not do special cases based on the chart type. If we want the labels to use the point color/border/ ... instead of the line options, then we should introduce a new option (if |
In the current implementation, In this PR, I'm just focusing on "shapes". |
Really appreciate this. Only I would expect: datasets: [{
type: 'line', to be: datasets: [{
labelType: 'line', //box, line, circle And that the labelType property in the dataset, overrides whatever is set as default at Edit: Never mind i was confused about |
|
||
return { | ||
text: label, | ||
fillStyle: fill, | ||
strokeStyle: stroke, | ||
lineWidth: bw, | ||
hidden: isNaN(ds.data[i]) || meta.data[i].hidden, | ||
// `usePointStyle` is deprecated. To be removed at version 3 | ||
style: !style && labelOpts.usePointStyle ? 'point' : style, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding support for the older option
@@ -6,6 +6,32 @@ describe('Deprecations', function() { | |||
expect(Chart.layoutService).toBe(Chart.layouts); | |||
}); | |||
}); | |||
|
|||
describe('Legend Labels: usePointStyle option', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simonbrunel should we put this inside a describe('Version 2.8.0', ...)
block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already inside 2.8.0 deprecations
@nagix I totally get that this PR is not about color/border/etc. but #5621 uses I don't really like the term So I would rather keep Finally,
It's not exclusive, it allows to use the point color/border/etc. while displaying a box, which I'm sure is a valid use case. The other way is also valid: What do you guys think? (sorry for the long comment) |
I agree that we keep
Basically, this is fine. But, I would like to enable 'the point symbol on the line' when Any comments? |
I would call the point shape (triangle, circle, etc.) a
I still think it's a valid use case, why enforcing such restriction? -- Actually, #4811 is closer to what I'm thinking about customizing the legend labels: allow the user to pick any available So I think I prefer the new option to select / override the label symbol (any of this list) while |
Ok, in that case, I can wait for #4811. |
@nagix I'm not completely understanding the conclusion that you and Simon came to. Is this PR a duplicate of #4811 and should be closed? Or only partially a duplicate and still adds some new functionality in which case it should be updated to add only the new functionality? I'm hoping we can either update or close the PR. I'd like to make sure all the open PRs are in a reviewable state. Otherwise it gets really hard to keep track of which we need to review and which we shouldn't |
@nagix should this PR be updated or closed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop in favor of #4811 or update to include only functionality not addressed there
@nagix I'm going to close this PR as inactive since there hasn't been any response and it's not clear to me from the comments that it's still needed. Please feel free to reopen if I'm wrong about that |
This feature was proposed several times in the past (#4163, #4496, #4811 and #4890) in order to use a line or a custom-sized box as a legend for a line in line charts, but no PR has been merged yet. I would like to try a bit different approach.
usePointStyle
legend label optionstyle
legend label option, which can have'box'
,'line'
and'point'
value'box'
: The same appearance as the current implementation'line'
: The line style is used. Border width, border color, line cap style, line join style and line dashes are inherited from the corresponding dataset'point'
: The same appearance as the currentusePointStyle
option.'line'
style is used for line elements, and the'box'
style for other elements.See https://jsfiddle.net/nagix/d86rvwn5/
Note that the chart with
style: 'point'
shows a dashed circle, but this should not be a dashed line. I'm trying to fix this with #5621.The existing tests are fixed more tests are added. Also, document is updated.
Fixes #4727