Skip to content
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

[FEATURE] actionable labels on radar chart (I will pay $) #5344

Closed
gsovereignty opened this issue Mar 14, 2018 · 5 comments · Fixed by #8588
Closed

[FEATURE] actionable labels on radar chart (I will pay $) #5344

gsovereignty opened this issue Mar 14, 2018 · 5 comments · Fixed by #8588

Comments

@gsovereignty
Copy link

I'd like to make the labels on the radar chart actionable (onClick, onHover, etc) without resorting to hardcoded image locations on canvas. The idea here is to solve this issue.

It's just plain rude to request new features without offering cold hard cash for the work. I don't really have time to do this myself, and someone who's very familiar with the codebase can probably do it a billion times faster than me anyway, so I'm perfectly happy to pay. Anyone interested simply comment here or email me directly if you prefer (gareth.hayes A gmail.com).

@gsovereignty gsovereignty changed the title [FEATURE REQUEST] actionable labels on radar chart (I will pay $) [FEATURE] actionable labels on radar chart (I will pay $) Mar 14, 2018
@etimberg
Copy link
Member

This could be implemented with APIs that look inside the internal _pointLabelSizes property of the scale. https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js#L159

Something would need to be added to the click handlers. Perhaps a decent solution is to make a public API on the radar chart scale that exposes this as rectangles that way a click handler could do detection

@janat08
Copy link

janat08 commented Mar 16, 2018

If you mean fixed boxes size of labels over the canvas, why not just make the labels that too?

@janat08
Copy link

janat08 commented Mar 16, 2018

to then use template literals to pass in proper HTML/JS content.

@simonbrunel
Copy link
Member

simonbrunel commented Mar 16, 2018

That would need to be designed in a more general way (all labels of all scales) to avoid multiplying inconsistent APIs. It should be flexible and use cases independent: for example, we should not hard code the hover behavior (changing colors, etc.) but instead offer an API that allows to tweak whatever properties dynamically, certainly via scriptable options. I really want to avoid hover* options as we currently have for elements.

I don't think users want to intersect themselves label boxes because detecting hover events is a bit more work than click events. It requires to monitor when the mouse enter and leave a label from mousemove events only. The implementation must be optimized to avoid spending time intersecting if there is no handler. Many people don't want label interactions, so there should be no performance impact for them (including all existing projects).

I submitted a PR for the datalabels plugin (chartjs/chartjs-plugin-datalabels#40) that goes in that direction, maybe there are some ideas we can reuse here? It may be better to kick off this feature as an external plugin since it can become quite complex.

Though, it may be easier to make the datalabels plugin fits your needs than the scale labels.

@simoncoggins
Copy link

I have created #6549 which links to a JSfiddle containing a workaround to achieve this for version 2.8.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants