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.

Legend not rendering for ResponsiveLine chart

See original GitHub issue

Hey, 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: 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:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
plouccommented, Mar 25, 2019

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 😃

0reactions
JMPiechowiakcommented, Mar 25, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

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