Legend not rendering for ResponsiveLine chart
See original GitHub issueHey, legend is not rendering for my ResponsiveLine chart component. I even set an anchor to center becouse I was suspecting that maybe it doesn’t fit in a div, but still nothing. Here is my chart:
and here is the code:
<ResponsiveLine
data={data}
margin={{
"top": 50,
"right": 60,
"bottom": 60,
"left": 60
}}
xScale={{
"type": "point"
}}
yScale={{
"type": "linear",
"stacked": true,
"min": "auto",
"max": "auto"
}}
axisTop={null}
axisRight={null}
axisBottom={{
"orient": "bottom",
"tickSize": 5,
"tickPadding": 5,
"tickRotation": 35,
"legend": t(this.state.mode),
"legendOffset": 52,
"legendPosition": "center"
}}
axisLeft={{
"orient": "left",
"tickSize": 5,
"tickPadding": 5,
"tickRotation": 0,
"legend": t('value'),
"legendOffset": -40,
"legendPosition": "center"
}}
dotSize={10}
dotColor="inherit:darker(0.3)"
dotBorderWidth={2}
dotBorderColor="#ffffff"
enableDotLabel={true}
dotLabel="y"
dotLabelYOffset={-12}
animate={true}
motionStiffness={90}
motionDamping={15}
legends={[
{
"anchor": "center",
"direction": "column",
"justify": false,
"translateX": 0,
"translateY": 0,
"itemsSpacing": 0,
"itemDirection": "left-to-right",
"itemWidth": 80,
"itemHeight": 20,
"itemOpacity": 0.75,
"symbolSize": 12,
"symbolShape": "circle",
"symbolBorderColor": "rgba(0, 0, 0, .5)",
"effects": [
{
"on": "hover",
"style": {
"itemBackground": "rgba(0, 0, 0, .03)",
"itemOpacity": 1
}
}
]
}
]}
/>
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Why is nivo's responsive line chart not rendered in jsdom ...
If i am not wrong; nivo doesnt render custom data-* props. So giving it a data-testid might not work.
Read more >Show or hide a chart legend or data table - Microsoft Support
Select a chart and then select the plus sign to the top right. Point to Legend and select the arrow next to it....
Read more >Morningstar Design System v2.37.0 - Morningstar Base Charts ...
Updated legend rendering logic to address issues with scrollbar overlap and ... the Donut chart from rendering properly when it did not have...
Read more >Line chart | nivo
See the dedicated guide on how to setup legends for this component. chartcodedataroll the dice. plane helicopter boat train subway bus car moto...
Read more >Beautiful and Responsive Line Charts Using Nivo, React and ...
legendPosition : "middle", tickSize: 0, tickValues: 2, tickPadding: 4, };. Since we used up some space for displaying axis information ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m glad you solved your problem. nivo is the old (deprecated) all-in-one package. You don’t want to import ~40 components with all their dependencies while you only use one 😃
Okay I figured this out. The problem was i was importing ResponsiveLine from “nivo” not from “@nivo/line”. Now everything seems to work perfectly.
This import statement was not obvious to be honest. I thought that nivo library contains everything.