Scatter

Parent Components

Scatter consumes context provided by these components:

Child Components

Scatter provides context for these components:

  • activeShape(union of 12 variants)optional

    This component is rendered when this graphical item is activated (could be by mouse hover, touch, keyboard, programmatically).

    FORMAT:

    <Scatter activeShape={{ fill: 'red' }} />
  • animationBeginnumberoptional

    Specifies when the animation should begin, the unit of this option is ms.

    DEFAULT: 0

  • animationDurationnumberoptional

    Specifies the duration of animation, the unit of this option is ms.

    DEFAULT: 400

  • animationEasing"ease" | "ease-in" | "ease-in-out" | "ease-out" | "linear" | "spring" | EasingFunction | `cubic-bezier(${number},${number},${number},${number})`optional

    The type of easing function.

    DEFAULT: "linear"

  • animationInterpolateFnAnimationInterpolateFn<ScatterPointItem, CartesianLayout>optional

    Custom animation function for interpolating data items. When provided, this replaces the default animation interpolation.

    Available since Recharts 3.9

  • animationMatchBy"append" | "index" | AnimationMatchBy<ScatterPointItem>optional

    Strategy for matching previous items to next items during animation. Determines how Recharts pairs old data points with new data points to create smooth transitions.

    • matchAppend (default): match sequentially by index and treat newly appended items as new
    • matchByIndex: match by array position with proportional stretching
    • matchByDataKey('someKey'): match by a data key from the payload
    • Custom function (item, index) => key: match by the returned key

    Available since Recharts 3.9

    DEFAULT: "append"

  • childrenReactNodeoptional

  • classNamestringoptional

  • dataReadonlyArray<DataPointType>optional

    The source data. Each element should be an object. The properties of each object represent the values of different data dimensions.

    Use the dataKey prop to specify which properties to use.

    FORMAT:

    data={[{ name: 'a', value: 12 }]}
    data={[{ label: 'foo', measurements: [5, 12] }]}
  • dataKeyTypedDataKey<DataPointType, DataValueType>optional

    The data that you provide via the data prop is an array of objects. Each object can have multiple properties, each representing a different data dimension. Use the dataKey prop to specify which property (or dimension) to use for this component.

    Typically, you will want to have one dataKey on the X axis, and different dataKey on the Y axis, where they extract different values from the same data objects.

    Decides how to extract the value from the data:

    • string: the name of the field in the data object;
    • number: the index of the field in the data;
    • function: a function that receives the data object and returns the value.

  • formatterFormatteroptional

    Formats the value displayed in the tooltip for this Scatter. When set, takes precedence over the formatter prop on the Tooltip component.

  • hidebooleanoptional

    Hides the whole graphical element when true.

    Hiding an element is different from removing it from the chart: Hidden graphical elements are still visible in Legend, and can be included in axis domain calculations, depending on includeHidden props of your XAxis/YAxis.

    DEFAULT: false

  • idstringoptional

    Unique identifier of this component. Used as an HTML attribute id, and also to identify this element internally.

    If undefined, Recharts will generate a unique ID automatically.

  • isAnimationActive"auto" | false | trueoptional

    If set false, animation of Scatter points will be disabled. If set "auto", the animation will be disabled in SSR and will respect the user's prefers-reduced-motion system preference for accessibility.

    DEFAULT: "auto"

  • labelFunction | Props | ReactNode | false | trueoptional

    Renders one label for each data point. Options:

    • true: renders default labels;
    • false: no labels are rendered;
    • object: the props of LabelList component;
    • ReactElement: a custom SVG label element, such as <text> or <g>. HTML elements such as <div> are not valid inside the chart SVG and may trigger React DOM warnings.
    • function: a render function of custom label.

    DEFAULT: false

  • legendType"circle" | "cross" | "diamond" | "line" | "none" | "plainline" | "rect" | "square" | "star" | "triangle" | "wye"optional

    The type of icon in legend. If set to 'none', no legend item will be rendered.

    DEFAULT: "circle"

    FORMAT:

    <Scatter legendType="diamond" />
  • line(union of 5 variants)optional

    Renders line connecting individual points. Options:

    • false: no line is drawn.
    • true: a default line is drawn.
    • ReactElement: the option is the custom line element.
    • function: the function will be called to render customized line.
    • object: the option is the props of Curve element.

    Also see the lineType prop which controls how is this line calculated.

    DEFAULT: false

    FORMAT:

    <Scatter line />
    <Scatter line={CustomizedLineComponent} />
    <Scatter line={{ strokeDasharray: '5 5' }} />
  • lineJointType"basis" | "basisClosed" | "basisOpen" | "bump" | "bumpX" | "bumpY" | "linear" | "linearClosed" | "monotone" | "monotoneX" | "monotoneY" | "natural" | "step" | "stepAfter" | "stepBefore" | CurveFactoryoptional

    Determines the shape of joint line. Same as type prop on Curve, Line and Area components.

    Has no effect if line prop is not set or is false or if lineType is 'fitting'.

    DEFAULT: "linear"

  • lineType"fitting" | "joint"optional

    Determines calculation method of the line if the line prop is set. Options:

    • 'joint': line will be generated by connecting all the points.
    • 'fitting': line will be generated by fitting algorithm (linear regression).

    Has no effect if line prop is not set or is false.

    DEFAULT: "joint"

    FORMAT:

    <Scatter line lineType="fitting" />
  • namestringoptional

    The name of data. This option will be used in tooltip and legend to represent this graphical item. If no value was set to this option, the value of dataKey will be used alternatively.

  • shape(union of 12 variants)optional

    Determines the shape of individual data points.

    • Can be one of the predefined shapes as a string, which will be passed to Symbols component.
    • If set a ReactElement, the shape of point can be customized.
    • If set a function, the function will be called to render customized shape.
    • During animations, the function shape also receives animationElapsedTime, isAnimating, and isEntrance.

    DEFAULT: "circle"

    FORMAT:

    <Scatter shape={CustomizedShapeComponent} />
    <Scatter shape="diamond" />
  • tooltipType"none"optional

  • xAxisIdnumber | stringoptional

    The id of XAxis which is corresponding to the data. Required when there are multiple XAxes.

    DEFAULT: 0

  • yAxisIdnumber | stringoptional

    The id of YAxis which is corresponding to the data. Required when there are multiple YAxes.

    DEFAULT: 0

  • zAxisIdnumber | stringoptional

    The id of ZAxis which is corresponding to the data. Required when there are multiple ZAxes.

    ZAxis does not render directly, has no ticks and no tick line. It is used to control the size of each scatter point.

    DEFAULT: 0

  • zIndexnumberoptional

    Z-Index of this component and its children. The higher the value, the more on top it will be rendered. Components with higher zIndex will appear in front of components with lower zIndex. If undefined or 0, the content is rendered in the default layer without portals.

    Available since Recharts 3.4

    DEFAULT: 600