C
+
S
L
G
A
V
C
-
N
M

    import React, { Component } from 'react';
    import { Grid, Rect, Svg } from 'number-picture'
    import { interpolateRgb } from 'd3-interpolate';
    import itsSet from 'its-set';
  
    export default class C extends Component {
  
      constructor() {
        super();
        this.displayName = 'C';
        this.state = {};
      }
  
      render() {
        const { nodes, width, height } = this.props;
  
        const count = nodes.length;
        const fill = interpolateRgb('#ff3a55', '#333333');
  
        return (
          <Svg height={height} width={width}>
            <Grid data={nodes} bands size={[width, height]}>
              <Rect
                x={({ datum }) => datum.x}
                y={({ datum }) => datum.y}
                width={({ datum }) => datum.nodeSize[0]}
                height={({ datum }) => datum.nodeSize[1]}
                fill={({ index }) => fill((index + 1) / count)}
                style={({ datum }) => ({
                  opacity: itsSet(datum.opacity) ? datum.opacity : 1,
                })}
  
                enterDuration={3000}
                enterEase='easeLinear'
                enterDatum={() => ({ opacity: 0, nodeSize: [0, 0], x: width, y: height })}
                updateDuration={3000}
                updateEase='easeLinear'
                exitDuration={3000}
                exitEase='easeLinear'
                exitDatum={() => ({ opacity: 0, nodeSize: [0, 0], x: width, y: height })}
              />
            </Grid>
          </Svg>
        );
      }
    }