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.

Colors from data not being displayed in Nivo ResponsiveHeatMap

See original GitHub issue

Suppose I am inputting the following data into my ResponsiveHeatMap

const data = [
    {
      resultID: 'shopping',
      accepted: 2,
      acceptedColor: 'hsl(130,72%,65%)',
      exception: 0,
      exceptionColor: 'hsl(72,72%,44%)'
    }
    .
    .
    .
  ]

I am currently passing the following into the colors prop and it’s not working.

  colors={({mapData}) => {
       return mapData.data[`${mapData.id}Color`]
  }}

I have checked out the following issues but they appear ResponsiveBar specific and aren’t useful for Responsive Heatmaps #581 #1417

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
wyzecommented, Jun 1, 2021

Can you show a full example of the code you are trying and we should be able to get it to work?

1reaction
wyzecommented, May 31, 2021

You need to process your colors to an array first and then pass it to colors property. See https://codesandbox.io/s/long-cherry-prbfw?file=/src/charts/HeatMap.tsx

const keys = [ ... ]
const props = { keys, ... }

function MyHeatMap({ data }) {
  const colors = props.keys.map(key => data[0][`${key}Color`]) as string[]

  return <HeatMap colors={colors} data={data} {...props} />
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Colors from data not being displayed in Nivo ResponsiveBar
I have a ResponsiveBar component in my React app, but the colors are not being displayed as intended. I have followed the guidelines...
Read more >
Heat Map chart - Nivo
An heat map matrix, you can chose between various colors scales, you also have the ability to change the cell shape for rectangle...
Read more >
Colors Guide | nivo
Using colors in nivo, color schemes, color scales… ... The colors property. Beside highlighting data insights, your dataviz should be pretty, right?
Read more >
Legends Guide - Nivo
Let's see how to add legends to your charts. Legend components are available via the @nivo/legends package, however it's added as a dependency...
Read more >
Choropleth chart - Nivo
The Choropleth component displays divided geographical areas shaded in relation to some data variable. It's build on top of primitives from the GeoMap ......
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