<commit_before>import React from "react";
import XYGraph from "../XYGraph";

import {
    axisBottom,
    axisLeft,
    extent,
    format,
    nest,
    scaleBand,
    scaleTime,
    select,
    map,
    min
} from "d3";

import {properties} from "./default.config"

export default class HeatmapGraph extends XYGraph {

    constructor(props) {
        super(props, properties);
    }

    render() {
        const {
            data,
            width,
            height
        } = this.props;

        if (!data || !data.length)
            return;

        const {
          chartHeightToPixel,
          chartWidthToPixel,
          circleToPixel,
          colorColumn,
          colors,
          legend,
          margin,
          padding,
          stroke,
          xColumn,
          xLabel,
          xTickFormat,
          xTickGrid,
          xTicks,
          xTickSizeInner,
          xTickSizeOuter,
          yColumn,
          yTickFormat,
          yTickGrid,
          yTicks,
          yTickSizeInner,
          yTickSizeOuter,
          legendColumn
        } = this.getConfiguredProperties();


        const isVerticalLegend = legend.orientation === 'vertical';
        const xLabelFn         = (d) => d[xColumn];
        const yLabelFn         = (d) => d[yColumn];
        const legendFn         = (d) => d[legendColumn];
        const label            = (d) => d["key"];
        const scale            = this.scaleColor(data, legendColumn);
        const getColor         = (d) => scale ? scale(d[colorColumn] || d[legendColumn] || d["key"]) : stroke.color || colors[0];

        const cellColumnsData  = nest()
            .key((d) => legendColumn ? d[legendColumn] : "Cell")
            .entries(data);

        let xAxisHeight       = xLabel ? chartHeightToPixel : 0;
        let legendWidth       = legend.show && cellColumnsData.length > 1 ? this.longestLabelLength(data, legendFn) * chartWidthToPixel : 0;

        let yLabelWidth       = this.longestLabelLength(data, yLabelFn) * chartWidthToPixel;

        let leftMargin        = margin.left + yLabelWidth;
        let availableWidth    = width - (margin.left + margin.right + yLabelWidth);
        let availableHeight   = height - (margin.top + margin.bottom + chartHeightToPixel + xAxisHeight);



        if (legend.show) {
            legend.width = legendWidth;

            // Compute the available space considering a legend
            if (isVerticalLegend)
            {
                leftMargin      +=  legend.width;
                availableWidth  -=  legend.width;
            }
            else {
                const nbElementsPerLine  = parseInt(availableWidth / legend.width, 10);
                const nbLines            = parseInt(cellColumnsData.length / nbElementsPerLine, 10);
                availableHeight         -= nbLines * legend.circleSize * circleToPixel + chartHeightToPixel;
            }
        }

        //For Making xAxis BANDSCALE
        const xBandScale = scaleBand()
            .domain(map(data, xLabelFn).keys().sort());
        xBandScale.rangeRound([0, availableWidth]);

        const xScale = scaleTime()
          .domain(extent(data, xLabelFn));

        const yScale = scaleBand()
          .domain(map(data, yLabelFn).keys().sort());

        xScale.range([0, availableWidth], 0.1);
        yScale.rangeRound([availableHeight, 0]).padding(padding);

        const xAxis = axisBottom(xScale)
          .tickSizeInner(xTickGrid ? -availableHeight : xTickSizeInner)
          .tickSizeOuter(xTickSizeOuter);

        if(xTickFormat){
            xAxis.tickFormat(format(xTickFormat));
        }

        if(xTicks){
            xAxis.ticks(xTicks);
        }
<commit_msg>Fixed the Heatmap Boundary contact by offseting the max time<commit_after>import React from "react";
import XYGraph from "../XYGraph";

import {
    axisBottom,
    axisLeft,
    extent,
    format,
    nest,
    scaleBand,
    scaleTime,
    select,
    map,
    min,
    utcHour
} from "d3";

import {properties} from "./default.config"

export default class HeatmapGraph extends XYGraph {

    constructor(props) {
        super(props, properties);
    }

    render() {
        const {
            data,
            width,
            height
        } = this.props;

        if (!data || !data.length)
            return;

        const {
          chartHeightToPixel,
          chartWidthToPixel,
          circleToPixel,
          colorColumn,
          colors,
          legend,
          margin,
          padding,
          stroke,
          xColumn,
          xLabel,
          xTickFormat,
          xTickGrid,
          xTicks,
          xTickSizeInner,
          xTickSizeOuter,
          yColumn,
          yTickFormat,
          yTickGrid,
          yTicks,
          yTickSizeInner,
          yTickSizeOuter,
          legendColumn
        } = this.getConfiguredProperties();


        const isVerticalLegend = legend.orientation === 'vertical';
        const xLabelFn         = (d) => d[xColumn];
        const yLabelFn         = (d) => d[yColumn];
        const legendFn         = (d) => d[legendColumn];
        const label            = (d) => d["key"];
        const scale            = this.scaleColor(data, legendColumn);
        const getColor         = (d) => scale ? scale(d[colorColumn] || d[legendColumn] || d["key"]) : stroke.color || colors[0];

        const cellColumnsData  = nest()
            .key((d) => legendColumn ? d[legendColumn] : "Cell")
            .entries(data);

        let xAxisHeight       = xLabel ? chartHeightToPixel : 0;
        let legendWidth       = legend.show && cellColumnsData.length > 1 ? this.longestLabelLength(data, legendFn) * chartWidthToPixel : 0;

        let yLabelWidth       = this.longestLabelLength(data, yLabelFn) * chartWidthToPixel;

        let leftMargin        = margin.left + yLabelWidth;
        let availableWidth    = width - (margin.left + margin.right + yLabelWidth);
        let availableHeight   = height - (margin.top + margin.bottom + chartHeightToPixel + xAxisHeight);



        if (legend.show) {
            legend.width = legendWidth;

            // Compute the available space considering a legend
            if (isVerticalLegend)
            {
                leftMargin      +=  legend.width;
                availableWidth  -=  legend.width;
            }
            else {
                const nbElementsPerLine  = parseInt(availableWidth / legend.width, 10);
                const nbLines            = parseInt(cellColumnsData.length / nbElementsPerLine, 10);
                availableHeight         -= nbLines * legend.circleSize * circleToPixel + chartHeightToPixel;
            }
        }

        //For Making xAxis BANDSCALE
        const xBandScale = scaleBand()
            .domain(map(data, xLabelFn).keys().sort());
        xBandScale.rangeRound([0, availableWidth]);

        let xValues = extent(data, xLabelFn);

        const xScale = scaleTime()
          .domain([xValues[0], utcHour.offset(xValues[1], 1)]);

        const yScale = scaleBand()
          .domain(map(data, yLabelFn).keys().sort());

        xScale.range([0, availableWidth], 0.1);
        yScale.rangeRound([availableHeight, 0]).padding(padding);

        const xAxis = axisBottom(xScale)
          .tickSizeInner(xTickGrid ? -availableHeight : xTickSizeInner)
          .tickSizeOuter(xTickSizeOuter);

        if(xTickFormat){
            xAxis.tickFormat(format(xTickFormat));
        }

        if(xTicks){
            xAxis.ticks(xTicks);
        }

{'fraction_non_alphanumeric': 0.10195974576271187, 'fraction_numerical': 0.0041048728813559325, 'mean_word_length': 1.747544561658785, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '3096238', 'n_tokens_mistral': 2134, 'n_tokens_neox': 2058, 'n_words': 447}