<commit_before>import { ChartProxy, ChartProxyParams } from "../chartProxy";
import { _, AxisOptions, AxisType, CartesianChartOptions, SeriesOptions, ChartType } from "@ag-grid-community/core";
import {
    CartesianChart, CategoryAxis,
    ChartAxis,
    ChartAxisPosition,
    find,
    GroupedCategoryAxis,
    GroupedCategoryChart, NumberAxis, TimeAxis, ChartTheme
} from "ag-charts-community";
import { ChartDataModel } from "../../chartDataModel";
import { deepMerge, mergeDeep } from "../../object";

export abstract class CartesianChartProxy<T extends SeriesOptions> extends ChartProxy<CartesianChart | GroupedCategoryChart, CartesianChartOptions<T>> {

    protected constructor(params: ChartProxyParams) {
        super(params);
    }

    protected getDefaultOptionsFromTheme(theme: ChartTheme): CartesianChartOptions<T> {
        const options = super.getDefaultOptionsFromTheme(theme);
        const standaloneChartType = this.getStandaloneChartType();
        const flipXY = standaloneChartType === 'bar';

        let xAxisType = 'category';
        let yAxisType = 'number';

        if (flipXY) {
            [xAxisType, yAxisType] = [yAxisType, xAxisType];
        }

        options.xAxis = theme.getConfig(standaloneChartType + '.axes.' + xAxisType);
        options.yAxis = theme.getConfig(standaloneChartType + '.axes.' + yAxisType);

        return options;
    }

    public getAxisProperty<T = string>(expression: string): T {
        return _.get(this.chartOptions.xAxis, expression, undefined) as T;
    }

    public setAxisProperty(expression: string, value: any) {
        _.set(this.chartOptions.xAxis, expression, value);
        _.set(this.chartOptions.yAxis, expression, value);

        const chart = this.chart;

        this.chart.axes.forEach(axis => _.set(axis, expression, value));

        chart.performLayout();

        this.raiseChartOptionsChangedEvent();
    }

    protected updateLabelRotation(categoryId: string, isHorizontalChart = false) {
        let labelRotation = 0;
        const axisKey = isHorizontalChart ? 'yAxis' : 'xAxis';
        const themeOverrides = this.chartProxyParams.getChartThemeOverrides();
        // debugger;

        const chartType = this.getStandaloneChartType();
        let userThemeOverrideRotation = undefined;
        const commonRotation = _.get(themeOverrides, 'defaults.common.axes.category.label.rotation', undefined);
        const cartesianRotation = _.get(themeOverrides, 'defaults.cartesian.axes.category.label.rotation', undefined);
        const chartTypeRotation = _.get(themeOverrides, `defaults.${chartType}.axes.category.label.rotation`, undefined);
        if (typeof chartTypeRotation === 'number' && isFinite(chartTypeRotation)) {
            userThemeOverrideRotation = chartTypeRotation;
        } else if (typeof cartesianRotation === 'number' && isFinite(cartesianRotation)) {
            userThemeOverrideRotation = cartesianRotation;
        } else if (typeof commonRotation === 'number' && isFinite(commonRotation)) {
            userThemeOverrideRotation = commonRotation;
        }

        if (categoryId !== ChartDataModel.DEFAULT_CATEGORY && !this.chartProxyParams.grouping) {
            const { label } = this.chartOptions[axisKey];

            if (label) {
                if (userThemeOverrideRotation !== undefined) {
                    labelRotation = userThemeOverrideRotation;
                } else {
                    labelRotation = label.rotation || 335;
                }
            }
        }

        const axisPosition = isHorizontalChart ? ChartAxisPosition.Left : ChartAxisPosition.Bottom;
        const axis = find(this.chart.axes, axis => axis.position === axisPosition);
<commit_msg>AG-2821 - removed debugger statement<commit_after>import { ChartProxy, ChartProxyParams } from "../chartProxy";
import { _, AxisOptions, AxisType, CartesianChartOptions, SeriesOptions, ChartType } from "@ag-grid-community/core";
import {
    CartesianChart, CategoryAxis,
    ChartAxis,
    ChartAxisPosition,
    find,
    GroupedCategoryAxis,
    GroupedCategoryChart, NumberAxis, TimeAxis, ChartTheme
} from "ag-charts-community";
import { ChartDataModel } from "../../chartDataModel";
import { deepMerge, mergeDeep } from "../../object";

export abstract class CartesianChartProxy<T extends SeriesOptions> extends ChartProxy<CartesianChart | GroupedCategoryChart, CartesianChartOptions<T>> {

    protected constructor(params: ChartProxyParams) {
        super(params);
    }

    protected getDefaultOptionsFromTheme(theme: ChartTheme): CartesianChartOptions<T> {
        const options = super.getDefaultOptionsFromTheme(theme);
        const standaloneChartType = this.getStandaloneChartType();
        const flipXY = standaloneChartType === 'bar';

        let xAxisType = 'category';
        let yAxisType = 'number';

        if (flipXY) {
            [xAxisType, yAxisType] = [yAxisType, xAxisType];
        }

        options.xAxis = theme.getConfig(standaloneChartType + '.axes.' + xAxisType);
        options.yAxis = theme.getConfig(standaloneChartType + '.axes.' + yAxisType);

        return options;
    }

    public getAxisProperty<T = string>(expression: string): T {
        return _.get(this.chartOptions.xAxis, expression, undefined) as T;
    }

    public setAxisProperty(expression: string, value: any) {
        _.set(this.chartOptions.xAxis, expression, value);
        _.set(this.chartOptions.yAxis, expression, value);

        const chart = this.chart;

        this.chart.axes.forEach(axis => _.set(axis, expression, value));

        chart.performLayout();

        this.raiseChartOptionsChangedEvent();
    }

    protected updateLabelRotation(categoryId: string, isHorizontalChart = false) {
        let labelRotation = 0;
        const axisKey = isHorizontalChart ? 'yAxis' : 'xAxis';
        const themeOverrides = this.chartProxyParams.getChartThemeOverrides();

        const chartType = this.getStandaloneChartType();
        let userThemeOverrideRotation = undefined;
        const commonRotation = _.get(themeOverrides, 'defaults.common.axes.category.label.rotation', undefined);
        const cartesianRotation = _.get(themeOverrides, 'defaults.cartesian.axes.category.label.rotation', undefined);
        const chartTypeRotation = _.get(themeOverrides, `defaults.${chartType}.axes.category.label.rotation`, undefined);
        if (typeof chartTypeRotation === 'number' && isFinite(chartTypeRotation)) {
            userThemeOverrideRotation = chartTypeRotation;
        } else if (typeof cartesianRotation === 'number' && isFinite(cartesianRotation)) {
            userThemeOverrideRotation = cartesianRotation;
        } else if (typeof commonRotation === 'number' && isFinite(commonRotation)) {
            userThemeOverrideRotation = commonRotation;
        }

        if (categoryId !== ChartDataModel.DEFAULT_CATEGORY && !this.chartProxyParams.grouping) {
            const { label } = this.chartOptions[axisKey];

            if (label) {
                if (userThemeOverrideRotation !== undefined) {
                    labelRotation = userThemeOverrideRotation;
                } else {
                    labelRotation = label.rotation || 335;
                }
            }
        }

        const axisPosition = isHorizontalChart ? ChartAxisPosition.Left : ChartAxisPosition.Bottom;
        const axis = find(this.chart.axes, axis => axis.position === axisPosition);

{'fraction_non_alphanumeric': 0.10647153598281418, 'fraction_numerical': 0.001611170784103115, 'mean_word_length': 3.1268698060941826, 'pattern_counts': {'":': 0, '<': 13, '<?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': '5665211', 'n_tokens_mistral': 1967, 'n_tokens_neox': 1906, 'n_words': 414}