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.

Issues with @nivo/treemap example

See original GitHub issue

This code which is a reproduction of the webpage example is not rendering the treemap and no error is being displayed. I don’t really know what is missing. I’m passing the example root from the webpage

import React, { Component } from 'react';
import { ResponsiveTreeMap } from '@nivo/treemap'
import { useTheme } from '@nivo/core'
import Grid from '@material-ui/core/Grid';
import Typography from '@material-ui/core/Typography';
import { withStyles } from '@material-ui/core/styles';
import style from './style';

function TreeMap({ classes, root }) {
  return (
    <Grid container className={classes.root}>
      <ResponsiveTreeMap
        root={data}
        identity="name"
        value="loc"
        innerPadding={3}
        outerPadding={3}
        margin={{ top: 10, right: 10, bottom: 10, left: 10 }}
        label="loc"
        labelFormat=".0s"
        labelSkipSize={12}
        labelTextColor={{ from: 'color', modifiers: [ [ 'darker', 1.2 ] ] }}
        colors={{ scheme: 'nivo' }}
        borderColor={{ from: 'color', modifiers: [ [ 'darker', 0.3 ] ] }}
        animate={true}
        motionStiffness={90}
        motionDamping={11}
      />
    </Grid>
  );
}
export default withStyles(style)(TreeMap);

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

2reactions
picoLizardcommented, Dec 30, 2020

Do you have an example in codesandbox?

In the website examples, the ‘data’ object passed simply includes a ‘root’ key to start with:

{
  "root": {
    "name": "nivo",
    "color": "hsl(188, 70%, 50%)",
    "children": [
      {
        "name": "viz",
        "color": "hsl(17, 70%, 50%)",
        "children": [

instead, the data object should just launch straight into the first parent, without the need for the ‘root’ key, so the website example should read:

{
    "name": "nivo",
    "color": "hsl(188, 70%, 50%)",
    "children": [
      {
        "name": "viz",
        "color": "hsl(17, 70%, 50%)",
        "children": [

this is the same data object as the ‘Bubble’ - so if you look at that example, it is correct.

2reactions
wyzecommented, Dec 8, 2020

@totaland The website shows the data with a top level root key in the JSON, but what should be passed should be the value of the root key.

Read more comments on GitHub >

github_iconTop Results From Across the Web

@nivo/treemap examples - CodeSandbox
Learn how to use @nivo/treemap by viewing and forking example apps that make use of @nivo/treemap on CodeSandbox. nivoNivo example starter project.
Read more >
@nivo/treemap - npm
Start using @nivo/treemap in your project by running `npm i @nivo/treemap`. There are 10 other projects in the npm registry using @nivo/treemap.
Read more >
@nivo/treemap - npm Package Health Analysis | Snyk
Learn more about @nivo/treemap: package health score, popularity, security, maintenance, ... A total of 1 vulnerabilities or license issues were detected.
Read more >
Tree Map chart - Nivo
The TreeMap component is also available in the @nivo/api , see sample or try it using the API client. chartcodedataroll the dice.
Read more >
About hierarchy charts - NVivo 11 for Windows Help
A tree map is a diagram that shows hierarchical data as a set of nested rectangles of varying sizes. For example, use size...
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