feat(legend): add custom legend component#1889
Conversation
|
💚 CLA has been signed |
|
Community pull request, @elastic/datavis please add the |
|
buildkite test this |
|
Community pull request, @elastic/datavis please add the |
07ae4b5 to
5194bd9
Compare
|
Community pull request, @elastic/datavis please add the |
2752cd0 to
1a73845
Compare
markov00
left a comment
There was a problem hiding this comment.
I've took the chance to push a commit to:
- fix the legend style (avoiding the box shadow on the legend title)
- add a small notice about always using the
legendSizewhen using thecustomLegend(it can probably be enforced with typescript somehow, because if not the auto-legend-size will kick in and the available size for the legend will not reflect the actual custom legend size
|
buildkite update screenshots |
|
buildkite test this |
|
buildkite update screenshots |
|
Sorry @yannbolliger the ci should permit you to run the buildkite update screenshots command when the |
546964a to
2ec1b55
Compare
|
buildkite test this |
|
buildkite test this |
|
@nickofthyme @yannbolliger I'm taking a loot at that added selector in the Legend component. It will triggers a react component rerendering (most of the time will not change the DOM but still execute the legend component and diff the results) on every mouse move. I prefer to avoid that if possible. I think we need to improve the current |
We could connect only the custom legend component (and not the regular one) via Redux to this additional selector. |
That could work, is anyway just a workaround, the output of such selector, is always the same if you hover over the same geometry but you move slightly your mouse |
277ff8c to
0cdc273
Compare
|
OK, so I changed the PR to only provide the |
markov00
left a comment
There was a problem hiding this comment.
Tested locally, looks good to me.
Thanks @yannbolliger for the changes.
@nickofthyme Yann was right, we are will rerendering the legend independently from the changes in this PR. The legend selectors are firing too on each mouse move, is better to double-check this and fix it on our selectors.
# [51.2.0](v51.1.1...v51.2.0) (2022-12-19) ### Bug Fixes * **axis:** truncate titles longer then the available space ([#1905](#1905)) ([3526a69](3526a69)) * **deps:** update dependency @elastic/eui to ^70.4.0 ([#1893](#1893)) ([6576041](6576041)) * **deps:** update dependency @elastic/eui to v71 ([#1898](#1898)) ([da596a5](da596a5)) ### Features * **legend:** add custom legend component ([#1889](#1889)) ([2e1648d](2e1648d))
Summary
The settings now have a new prop
customLegendwhich lets users provide there own legend React component that is rendered with the chart state into the legend container.Details
Analogously to the
customTooltipin theTooltip, thecustomLegendtakes a React component which will receive the state of the standard legend as props. This allows users to provide their own legend implementation. The legend is still rendered inside of thediv.echLegendListContainer.Issues
Fixes #862 because it is now feasible with a custom component as well as fixes #561.
Checklist
closes #123,fixes #123)packages/charts/src/index.ts:interactions,:axis)