question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Style Reference Line Label

See original GitHub issue

Request for documentation

I am unable to style the reference line label to match this example: http://recharts.org/#/en-US/api/ReferenceLine

image

It ends up looking like this:

image

I tried passing a ReactComponent into the label props. The result is no that no label gets displayed.

My code looked like <ReferenceLine x={firstQuadPercentile} stroke={'green'} label={<text>{'25th percentile'}</text>} />

and

<ReferenceLine x={firstQuadPercentile} stroke={'green'} label={<div>{'25th percentile'}</div>} />

Since no label gets displayed, it didn’t seem like this solution would work.

How can I style the label to match the first example shown in this request?

My recharts version : 1.0.0-alpha.2

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:12
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

20reactions
wewoorcommented, Sep 25, 2017

@westoncolemanl @fengshuo

The below is my custom ReferenceLabel component. you can try it.

export function ReferenceLabel(props) {
    const { 
        fill, value, textAnchor, 
        fontSize, viewBox, dy, dx,
    } = props;
    const x = viewBox.width + viewBox.x + 20;
    const y = viewBox.y - 6;
    return (
        <text 
            x={x} y={y}
            dy={dy}
            dx={dx}
            fill={fill}
            fontSize={fontSize || 10} 
            textAnchor={textAnchor}>
            {value}
        </text>
    )
}

use it

<ReferenceLine label={<ReferenceLabel  />} /> 

hope it can help you.

17reactions
xile611commented, Nov 7, 2017

@wewoor @westoncolemanl

You can try the props position of label.

<ReferenceLine x="Page C" stroke="red" label={{ position: 'top',  value: 'Max PV PAGE', fill: 'red', fontSize: 14 }}/>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom Name for a Reference Line | Tableau Software
In the Line section, select Custom from the Label drop-down menu. ... Click OK. Click the reference line and select Format to customize...
Read more >
Questions from Tableau Training: Moving Reference Line ...
Formatting Labels in Tableau. For starters, right-click directly on top of your reference line and select Format.
Read more >
How do I Customise Labels on Reference Lines in Tableau?
To add a Reference Line we need to go to the Analytics tab and select Reference Line. · To proceed from here you...
Read more >
Reference Line Label Format - Qlik Community - 1641343
Reference Line Label Format. LCLbug.PNG. I am finding that on reference lines added to my line chart visualization that negative numbers are ...
Read more >
Add label to ReferenceLine in recharts - Stack Overflow
Change the position from center to top <ReferenceLine type="monotone" y={props.data.avgAll} fill="violett" stroke="#8884d8"> <Label ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found