<commit_before>// @flow
import type {Node} from 'react';
import type {Dimension} from '../../useScales';
import type {ComponentType} from 'react';

import React from 'react';



const defaultDot = (props: Object): Node => {
    return <circle fill='black' r={3} {...props.position}/>;
};

const isNumber = (value) => typeof value === 'number' && !isNaN(value);

type Props = {
    x: Dimension,
    y: Dimension,
    color: Array<string>,
    Dot?: ComponentType<*>
};

export default function Scatter(props: Props) {
    const {y} = props;
    const {x} = props;
    const {Dot = defaultDot} = props;


    return <g>
        {y.scaledData.map((series, seriesIndex) => series.map((row, index) => {
            const xValue = x.scaledData[0][index][0];
            const yValue = y.stack ? row[1] : row[0];

            if(!isNumber(yValue) || !isNumber(xValue)) return null;
            return <Dot
                key={`${seriesIndex}.${index}`}
                position={{
                    cx: x.scaledData[0][index],
                    cy: yValue
                }}
            />;
        }))}
    </g>;
}

<commit_msg>Add color to scatter charts<commit_after>// @flow
import type {Node} from 'react';
import type {Dimension} from '../../useScales';
import type {ComponentType} from 'react';

import React from 'react';



const defaultDot = (props: Object): Node => {
    return <circle fill='black' r={3} {...props.position}/>;
};

const isNumber = (value) => typeof value === 'number' && !isNaN(value);

type Props = {
    x: Dimension,
    y: Dimension,
    color: Array<string>,
    Dot?: ComponentType<*>
};

export default function Scatter(props: Props) {
    const {y} = props;
    const {x} = props;
    const {color} = props;
    const {Dot = defaultDot} = props;


    return <g>
        {y.scaledData.map((series, seriesIndex) => series.map((row, index) => {
            const xValue = x.scaledData[0][index][0];
            const yValue = y.stack ? row[1] : row[0];

            if(!isNumber(yValue) || !isNumber(xValue)) return null;
            return <Dot
                key={`${seriesIndex}.${index}`}
                color={color[seriesIndex]}
                position={{
                    cx: x.scaledData[0][index],
                    cy: yValue
                }}
            />;
        }))}
    </g>;
}


{'fraction_non_alphanumeric': 0.16794871794871793, 'fraction_numerical': 0.005128205128205128, 'mean_word_length': 2.1635135135135135, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1057931', 'n_tokens_mistral': 744, 'n_tokens_neox': 725, 'n_words': 188}