-
Notifications
You must be signed in to change notification settings - Fork 122
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
Custom legend doesn't take mouse events? #2363
Comments
In terms of the legend mouse interactions, you would need to wire the ones you want manually by attaching an event listener to the element representing each item of the legend. Then on this trigger you need to call the respective action (i.e. const customLegend: CustomLegend = ({ items, pointerValue }) => (
<div style={{ width: '100%', position: 'relative' }}>
<p style={{ height: '1.5em' }}>{pointerValue ? moment(pointerValue?.value).format('HH:mm') : 'System Load'}</p>
{items.map((i) => (
<button
key={i.seriesIdentifiers[0].key}
onMouseOver={i.onItemOverActon}
onMouseOut={i.onItemOutAction}
onClick={() => i.onItemClickAction(false)}
style={{ display: 'block', color: i.isSeriesHidden ? 'gray' : i.color }}
>
{i.label} {i.extraValue?.formatted}
</button>
))}
</div>
); In the story example you are following, the As far as the It would help if you could reproduce the issue in a codesandbox demo. Or at a minimum share your code for the |
@nickofthyme Thanks for your response. I'm able to find the root cause: the I was just using flexbox to position my custom legends and didn't realize the relative positioning had any significance. In my local server, without the relative positioning, the custom legends show up with no problems. But in my code sandbox, omitting the relative positioning will cause the legends to be invisible. Maybe in the storybook, besides the warning about fixed legend size, there should be another tip about using |
Thanks for the demo! Ugh ok I found the issue(s). Yeah applying the We have a chart background element (
I'll open a PR to fix this but if you need it faster, a quick fix would be to add a .echChartBackground {
z-index: -1;
} Apart from the z-indexing issue I noticed in your demo the chart was being pushed out of the container due to the sizing of the legend. I opened a separate issue here ➡️ #2365 |
So I tried to use a custom legend following the example in the storybook
My custom legend follows closely to the example. But it doesn't seem mouse events are registered on the legend. I tried to log inside the itemActions, but nothing is being logged to the console.
For some reason, the css rule
cursor: pointer
doesn't even trigger. The cursor is still default when I hover.Lastly, I copied the example from the storybook. And even though pointerValue seems to work properly, the mouse event issue persists.
Are there any setting/rules that could be preventing mouse interaction for these charts?
The text was updated successfully, but these errors were encountered: