Home / File/ ChartNode.js — react Source File

ChartNode.js — react Source File

Architecture documentation for ChartNode.js, a javascript file in the react codebase. 3 imports, 2 dependents.

File javascript BabelCompiler Validation 3 imports 2 dependents 5 functions

Entity Profile

Dependency Diagram

graph LR
  56bcba00_c929_183d_07ac_24aeb71afa91["ChartNode.js"]
  58541c36_41d0_ed99_b1b6_08bbf90ec241["ChartNode.css"]
  56bcba00_c929_183d_07ac_24aeb71afa91 --> 58541c36_41d0_ed99_b1b6_08bbf90ec241
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  56bcba00_c929_183d_07ac_24aeb71afa91 --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  ebb48597_9981_bb7d_08db_b9fe29a0f62e["SyntheticEvent"]
  56bcba00_c929_183d_07ac_24aeb71afa91 --> ebb48597_9981_bb7d_08db_b9fe29a0f62e
  6d32cfc6_78ff_92b2_0a33_092cde10d395["CommitFlamegraphListItem.js"]
  6d32cfc6_78ff_92b2_0a33_092cde10d395 --> 56bcba00_c929_183d_07ac_24aeb71afa91
  89b916c8_640c_20f1_5b9e_9022ade373b8["CommitRankedListItem.js"]
  89b916c8_640c_20f1_5b9e_9022ade373b8 --> 56bcba00_c929_183d_07ac_24aeb71afa91
  style 56bcba00_c929_183d_07ac_24aeb71afa91 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow
 */

import * as React from 'react';

import styles from './ChartNode.css';
import typeof {SyntheticMouseEvent} from 'react-dom-bindings/src/events/SyntheticEvent';

type Props = {
  color: string,
  height: number,
  isDimmed?: boolean,
  label: string,
  onClick: (event: SyntheticMouseEvent) => mixed,
  onDoubleClick?: (event: SyntheticMouseEvent) => mixed,
  onMouseEnter: (event: SyntheticMouseEvent) => mixed,
  onMouseLeave: (event: SyntheticMouseEvent) => mixed,
  placeLabelAboveNode?: boolean,
  textStyle?: Object,
  width: number,
  x: number,
  y: number,
};

const minWidthToDisplay = 35;

export default function ChartNode({
  color,
  height,
  isDimmed = false,
  label,
  onClick,
  onMouseEnter,
  onMouseLeave,
  onDoubleClick,
  textStyle,
  width,
  x,
  y,
}: Props): React.Node {
  return (
    <g className={styles.Group} transform={`translate(${x},${y})`}>
      <rect
        width={width}
        height={height}
        fill={color}
        onClick={onClick}
        onMouseEnter={onMouseEnter}
        onMouseLeave={onMouseLeave}
        onDoubleClick={onDoubleClick}
        className={styles.Rect}
        style={{
          opacity: isDimmed ? 0.5 : 1,
        }}
      />
      {width >= minWidthToDisplay && (
        <foreignObject
          width={width}
          height={height}
          className={styles.ForeignObject}
          style={{
            paddingLeft: x < 0 ? -x : 0,
            opacity: isDimmed ? 0.75 : 1,
            display: width < minWidthToDisplay ? 'none' : 'block',
          }}
          y={0}>
          <div className={styles.Div} style={textStyle}>
            {label}
          </div>
        </foreignObject>
      )}
    </g>
  );
}

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does ChartNode.js do?
ChartNode.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in ChartNode.js?
ChartNode.js defines 5 function(s): ChartNode, type.onClick, type.onDoubleClick, type.onMouseEnter, type.onMouseLeave.
What does ChartNode.js depend on?
ChartNode.js imports 3 module(s): ChartNode.css, SyntheticEvent, react.
What files import ChartNode.js?
ChartNode.js is imported by 2 file(s): CommitFlamegraphListItem.js, CommitRankedListItem.js.
Where is ChartNode.js in the architecture?
ChartNode.js is located at packages/react-devtools-shared/src/devtools/views/Profiler/ChartNode.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src/devtools/views/Profiler).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free