<commit_before>import {truncateText} from "../../../common/d3-utils";
import { determineForegroundColor } from "../../../common/colors";


const nodeWidth = 160;
const nodeHeight = 26;
const nodeFontSize = 12;


export const NODE_DIMENSIONS = {
    width: nodeWidth,
    height: nodeHeight,  // 3 * section.height
    section: {
        height: (nodeHeight - 2) / 2
    },
    text: {
        dy: 12,
        dx:nodeWidth / 8 + nodeWidth / 16,
        fontSize: nodeFontSize
    }
};


export const NODE_STYLES = {
    nodeTitle: "wrd-node-title",
    nodeExternalId: "wrd-node-external-id",
    nodeChangeInitiative: "wrd-node-change-initiative",
    nodeCell: "wrd-node-cell",
    nodeCellRatingIndicator: "node-cell-rating-indicator",
    nodeCellCommentIndicator: "node-cell-comment-indicator"
};


export function updateUnit(selection, options) {

    const colorScale = options.colorScale;

    selection
        .selectAll("text")
        .attr("fill", d => {
            const color = colorScale(d.state.rating).brighter(2.5);
            return determineForegroundColor(color.r, color.g, color.b);
        });

    selection
        .select(`rect.${NODE_STYLES.nodeCell}`)
        .attr("stroke",  d => colorScale(d.state.rating))
        .attr("fill", d => colorScale(d.state.rating).brighter(2.5));

    selection
        .select(`rect.${NODE_STYLES.nodeCellRatingIndicator}`)
        .attr("fill", d => colorScale(d.state.rating))
        .attr("stroke",  d => colorScale(d.state.rating));

    selection
        .select(`path.${NODE_STYLES.nodeCellCommentIndicator}`)
        .attr("fill", d => colorScale(d.state.rating).brighter(d.state.comment ? 0 : 2.5));
}


export function drawUnit(selection, options) {

    selection
        .append("rect")<commit_msg>Roadmap: Scenario cell text color white/black<commit_after>import {truncateText} from "../../../common/d3-utils";
import { determineForegroundColor } from "../../../common/colors";


const nodeWidth = 160;
const nodeHeight = 26;
const nodeFontSize = 12;


export const NODE_DIMENSIONS = {
    width: nodeWidth,
    height: nodeHeight,  // 3 * section.height
    section: {
        height: (nodeHeight - 2) / 2
    },
    text: {
        dy: 12,
        dx:nodeWidth / 8 + nodeWidth / 16,
        fontSize: nodeFontSize
    }
};


export const NODE_STYLES = {
    nodeTitle: "wrd-node-title",
    nodeExternalId: "wrd-node-external-id",
    nodeChangeInitiative: "wrd-node-change-initiative",
    nodeCell: "wrd-node-cell",
    nodeCellRatingIndicator: "node-cell-rating-indicator",
    nodeCellCommentIndicator: "node-cell-comment-indicator"
};


export function updateUnit(selection, options) {

    const colorScale = options.colorScale;

    selection
        .selectAll("text")
        .attr("fill", d => {
            const color = colorScale(d.state.rating).brighter(2);
            return determineForegroundColor(color.r, color.g, color.b);
        });

    selection
        .select(`rect.${NODE_STYLES.nodeCell}`)
        .attr("stroke",  d => colorScale(d.state.rating))
        .attr("fill", d => colorScale(d.state.rating).brighter(2));

    selection
        .select(`rect.${NODE_STYLES.nodeCellRatingIndicator}`)
        .attr("fill", d => colorScale(d.state.rating))
        .attr("stroke",  d => colorScale(d.state.rating));

    selection
        .select(`path.${NODE_STYLES.nodeCellCommentIndicator}`)
        .attr("fill", d => colorScale(d.state.rating).brighter(d.state.comment ? 0 : 2));
}


export function drawUnit(selection, options) {

    selection
        .append("rect")
{'fraction_non_alphanumeric': 0.15137101287073307, 'fraction_numerical': 0.012031337437045327, 'mean_word_length': 2.8194444444444446, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '6965723', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1126, 'n_words': 208}