Skip to content

Allow legendFormatter function to return DOM elements  #958

@J-Rojas

Description

@J-Rojas

It would be useful to allow the legendFormatter function to return DOM elements or an HTML string.

This would allow a user to supply elements that have more complex formatting and attached event handlers. For example, I'd like to create a legend that supports click events on legend labels to change the visibility or styling of series plot lines.

I think this would be pretty easy to add to legend.js and could supply the PR for this. Let me know what you think.

It might be easiest to allow the returned item to be a DocumentFragment or a String. The DocumentFragment would be appended instead of using innerHTML. If a String is returned, innerHTML is used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions