<commit_before>import {ScaleType} from 'vega-typings/types';
import {array} from 'vega-util';
import {Axis} from '../../axis';
import {PositionScaleChannel} from '../../channel';
import {Config} from '../../config';
import {isQuantitative} from '../../scale';
import {titlecase} from '../../util';
import {getStyleConfig} from '../common';

function getAxisConfigFromConfigTypes(configTypes: string[], config: Config) {
  // TODO: add special casing to add conditional value based on orient signal
  return Object.assign.apply(null, [{}, ...configTypes.map(configType => config[configType])]);
}

export type AxisConfigs = ReturnType<typeof getAxisConfigs>;

export function getAxisConfigs(channel: PositionScaleChannel, scaleType: ScaleType, orient: string, config: Config) {
  const typeBasedConfigTypes =
    scaleType === 'band'
      ? ['axisDiscrete', 'axisBand']
      : scaleType === 'point'
      ? ['axisDiscrete', 'axisPoint']
      : isQuantitative(scaleType)
      ? ['axisQuantitative']
      : scaleType === 'time' || scaleType === 'utc'
      ? ['axisTemporal']
      : [];

  const axisChannel = channel === 'x' ? 'axisX' : 'axisY';
  const axisOrient = 'axis' + titlecase(orient); // axisTop, axisBottom, ...

  const vlOnlyConfigTypes = [
    // technically Vega does have axisBand, but if we make another separation here,
    // it will further introduce complexity in the code
    ...typeBasedConfigTypes,
    ...typeBasedConfigTypes.map(c => axisChannel + c.substr(4))
  ];

  const vgConfigTypes = ['axis', axisOrient, axisChannel];

  return {
    vlOnlyAxisConfig: getAxisConfigFromConfigTypes(vlOnlyConfigTypes, config),
    vgAxisConfig: getAxisConfigFromConfigTypes(vgConfigTypes, config),
    axisConfigStyle: getAxisConfigStyle([...vlOnlyConfigTypes, ...vgConfigTypes], config)
  };
}

export function getAxisConfigStyle(axisConfigTypes: string[], config: Config) {
  const toMerge = [{}];
  for (const configType of axisConfigTypes) {
    // TODO: add special casing to add conditional value based on orient signal
    let style = config[configType]?.style;
    if (style) {<commit_msg>fix: correct precedence for axis config style (#6290)<commit_after>import {ScaleType} from 'vega-typings/types';
import {array} from 'vega-util';
import {Axis} from '../../axis';
import {PositionScaleChannel} from '../../channel';
import {Config} from '../../config';
import {isQuantitative} from '../../scale';
import {titlecase} from '../../util';
import {getStyleConfig} from '../common';

function getAxisConfigFromConfigTypes(configTypes: string[], config: Config) {
  // TODO: add special casing to add conditional value based on orient signal
  return Object.assign.apply(null, [{}, ...configTypes.map(configType => config[configType])]);
}

export type AxisConfigs = ReturnType<typeof getAxisConfigs>;

export function getAxisConfigs(channel: PositionScaleChannel, scaleType: ScaleType, orient: string, config: Config) {
  const typeBasedConfigTypes =
    scaleType === 'band'
      ? ['axisDiscrete', 'axisBand']
      : scaleType === 'point'
      ? ['axisDiscrete', 'axisPoint']
      : isQuantitative(scaleType)
      ? ['axisQuantitative']
      : scaleType === 'time' || scaleType === 'utc'
      ? ['axisTemporal']
      : [];

  const axisChannel = channel === 'x' ? 'axisX' : 'axisY';
  const axisOrient = 'axis' + titlecase(orient); // axisTop, axisBottom, ...

  const vlOnlyConfigTypes = [
    // technically Vega does have axisBand, but if we make another separation here,
    // it will further introduce complexity in the code
    ...typeBasedConfigTypes,
    ...typeBasedConfigTypes.map(c => axisChannel + c.substr(4))
  ];

  const vgConfigTypes = ['axis', axisOrient, axisChannel];

  return {
    vlOnlyAxisConfig: getAxisConfigFromConfigTypes(vlOnlyConfigTypes, config),
    vgAxisConfig: getAxisConfigFromConfigTypes(vgConfigTypes, config),
    axisConfigStyle: getAxisConfigStyle([...vgConfigTypes, ...vlOnlyConfigTypes], config)
  };
}

export function getAxisConfigStyle(axisConfigTypes: string[], config: Config) {
  const toMerge = [{}];
  for (const configType of axisConfigTypes) {
    // TODO: add special casing to add conditional value based on orient signal
    let style = config[configType]?.style;
    if (style) {
{'fraction_non_alphanumeric': 0.1417875526438933, 'fraction_numerical': 0.0014038371548900327, 'mean_word_length': 4.163043478260869, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '5801365', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1208, 'n_words': 345}