<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import { FONT_AXIS_LABEL } from '../../constants/graph';
import { COLOR_LIGHT_MED, COLOR_DARK, COLOR_GRAPH_TITLE } from '../../constants/colors';
import { rgba } from '../../helpers/color';
import { formatValue } from '../../helpers/funds';
import { getTimeScale } from '../../components/Graph/helpers';

function calculateTicksY({ tickSizeY, minY, maxY, pixY }) {
    // calculate tick range
    const numTicks = typeof tickSizeY === 'undefined' || isNaN(tickSizeY)
        ? 0
        : Math.floor((maxY - minY) / tickSizeY);

    if (!numTicks) {
        return [];
    }

    return new Array(numTicks)
        .fill(0)
        .map((item, key) => {
            const value = minY + (key + 1) * tickSizeY;
            const pos = Math.floor(pixY(value)) + 0.5;

            return { value, pos };
        });
}

export default function Axes(props) {
    const textColor = rgba(COLOR_DARK);
    const [fontSize, fontFamily] = FONT_AXIS_LABEL;

    const { startTime, mode, minX, maxX, minY, maxY, pixX, pixY } = props;

    const x0 = pixX(minX);
    const xMax = pixX(maxX);
    const y0 = pixY(minY);
    const yMax = pixY(maxY);

    const tickSize = 10;
    const tickAngle = -30;
    const transformText = (xPix, yPix) => `rotate(${tickAngle} ${xPix} ${yPix})`;

    const axisColor = value => {
        if (value === 0) {
            return rgba(COLOR_DARK);
        }

        return rgba(COLOR_LIGHT_MED);
    };

    const ticksY = calculateTicksY(props).map(({ pos, value }) => (
        <g key={value}>
            <line x1={x0} y1={pos} x2={xMax} y2={pos}
                stroke={axisColor(value)} strokeWidth={1} />
            <text x={xMax} y={pos - 2} color={textColor}
                fontSize={fontSize} fontFamily={fontFamily}
                alignmentBaseline="baseline" textAnchor="end">{formatValue(value, mode)}</text>
        </g>
    ));

    const timeTicks = getTimeScale(props)(startTime);

    const tickColors = [rgba(COLOR_DARK), rgba(COLOR_GRAPH_TITLE)];
    const getColor = major => tickColors[(major > 0) >> 0];
    const getTickSize = major => tickSize * 0.5 * (major + 1);

    const timeTicksSmall = timeTicks.map(({ pix, major }, key) => (
        <line key={key} x1={pix} y1={y0} x2={pix} y2={y0 - getTickSize(major)}
            stroke={getColor(major)} strokeWidth={1} />
    ));

    const timeTicksMajor = timeTicks.filter(({ major }) => major > 1)
        .map(({ pix, major }, key) => (
            <line key={key} x1={pix} y1={y0 - getTickSize(major)} x2={pix} y2={yMax}
                stroke={axisColor} strokeWidth={1} />
        ));

    const timeTicksText = timeTicks.filter(({ text }) => text)
        .map(({ text, pix, major }) => (
            <text key={pix} x={pix} y={y0 - getTickSize(major)}
                fontFamily={fontFamily} fontSize={fontSize} alignmentBaseline="baseline"
                transform={transformText(pix, y0 - getTickSize(major))}
            >{text}</text>
        ));<commit_msg>Fixed vertical lines on funds graph<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import { FONT_AXIS_LABEL } from '../../constants/graph';
import { COLOR_LIGHT_MED, COLOR_DARK, COLOR_GRAPH_TITLE } from '../../constants/colors';
import { rgba } from '../../helpers/color';
import { formatValue } from '../../helpers/funds';
import { getTimeScale } from '../../components/Graph/helpers';

function calculateTicksY({ tickSizeY, minY, maxY, pixY }) {
    // calculate tick range
    const numTicks = typeof tickSizeY === 'undefined' || isNaN(tickSizeY)
        ? 0
        : Math.floor((maxY - minY) / tickSizeY);

    if (!numTicks) {
        return [];
    }

    return new Array(numTicks)
        .fill(0)
        .map((item, key) => {
            const value = minY + (key + 1) * tickSizeY;
            const pos = Math.floor(pixY(value)) + 0.5;

            return { value, pos };
        });
}

export default function Axes(props) {
    const textColor = rgba(COLOR_DARK);
    const [fontSize, fontFamily] = FONT_AXIS_LABEL;

    const { startTime, mode, minX, maxX, minY, maxY, pixX, pixY } = props;

    const x0 = pixX(minX);
    const xMax = pixX(maxX);
    const y0 = pixY(minY);
    const yMax = pixY(maxY);

    const tickSize = 10;
    const tickAngle = -30;
    const transformText = (xPix, yPix) => `rotate(${tickAngle} ${xPix} ${yPix})`;

    const axisColor = value => {
        if (value === 0) {
            return rgba(COLOR_DARK);
        }

        return rgba(COLOR_LIGHT_MED);
    };

    const ticksY = calculateTicksY(props).map(({ pos, value }) => (
        <g key={value}>
            <line x1={x0} y1={pos} x2={xMax} y2={pos}
                stroke={axisColor(value)} strokeWidth={1} />
            <text x={xMax} y={pos - 2} color={textColor}
                fontSize={fontSize} fontFamily={fontFamily}
                alignmentBaseline="baseline" textAnchor="end">{formatValue(value, mode)}</text>
        </g>
    ));

    const timeTicks = getTimeScale(props)(startTime);

    const tickColors = [rgba(COLOR_DARK), rgba(COLOR_GRAPH_TITLE)];
    const getColor = major => tickColors[(major > 0) >> 0];
    const getTickSize = major => tickSize * 0.5 * (major + 1);

    const timeTicksSmall = timeTicks.map(({ pix, major }, key) => (
        <line key={key} x1={pix} y1={y0} x2={pix} y2={y0 - getTickSize(major)}
            stroke={getColor(major)} strokeWidth={1} />
    ));

    const timeTicksMajor = timeTicks.filter(({ major }) => major > 1)
        .map(({ pix, major }, key) => (
            <line key={key} x1={pix} y1={y0 - getTickSize(major)} x2={pix} y2={yMax}
                stroke={axisColor(1)} strokeWidth={1} />
        ));

    const timeTicksText = timeTicks.filter(({ text }) => text)
        .map(({ text, pix, major }) => (
            <text key={pix} x={pix} y={y0 - getTickSize(major)}
                fontFamily={fontFamily} fontSize={fontSize} alignmentBaseline="baseline"
                transform={transformText(pix, y0 - getTickSize(major))}
            >{text}</text>
        ));
{'fraction_non_alphanumeric': 0.16484055600981193, 'fraction_numerical': 0.013246116107931317, 'mean_word_length': 2.5475638051044083, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 51, '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': '6944668', 'n_tokens_mistral': 2104, 'n_tokens_neox': 1995, 'n_words': 459}