nivo icon indicating copy to clipboard operation
nivo copied to clipboard

Allow custom legendNode for markers

Open Bigood opened this issue 1 year ago • 7 comments

Allow legendNode props on markers for finer control over legend.

Usecases :

  • Display other content than text (image, shape…)
  • Create tooltips to display additional information, when a lot of markers are rendered and remaining place is low

Usage :

...
markers={[{
    axis: "x",
    lineStyle: {
        stroke: "lightblue",
        strokeWidth: 5
    },
    legendPosition: "top",
    legendNode: <foreignObject x={0} y={0} width={32} height={32}>
                    <FontAwesomeIcon icon={faRocket} />
                </foreignObject>,
}]}

Expected result :

image

Codechanges :

Two lines changed to bypass legendNode creation with legend text. Doesn't break any existing functionality, and seams easy to maintain across updates.

Bigood avatar Sep 20 '23 15:09 Bigood

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nivo ❌ Failed (Inspect) Sep 20, 2023 3:06pm

vercel[bot] avatar Sep 20 '23 15:09 vercel[bot]

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 16ecb26baaf8dfbce301ae43e7ff4b4beb79c413:

Sandbox Source
nivo Configuration

codesandbox-ci[bot] avatar Sep 20 '23 15:09 codesandbox-ci[bot]

@plouc Can I do something to help this PR be merged ?

Bigood avatar Oct 13 '23 13:10 Bigood

lets aprovve this PR @plouc !

Nikholau avatar Feb 29 '24 12:02 Nikholau

Up'ing this, how can I help?

Bigood avatar Mar 27 '24 11:03 Bigood

@Bigood, sorry for the late reply, the PR needs to be rebased, I think it would be good to add a test for it as well, maybe not in the core though, it's probably better to test this on a chart supporting markers.

plouc avatar Apr 29 '24 23:04 plouc