<commit_before>const { DEFAULT_COLUMN_WIDTH } = require('../constants')

const categoricalChart = (g, data, config = {}) => {
  const top       = config.top   || 0
  const left      = config.left  || 0
  const width     = config.width || DEFAULT_COLUMN_WIDTH
  const keys      = config.keys  || []
  const className = config.className
  const increment = width / keys.length
  const barWidth  = Math.max(2, increment)

  const myG = g.append('g')
   .classed(className, true)
   .attr('transform', (d, i) => `translate(${left}, ${top})`)

  myG.selectAll('rect')
    .data(data)
    .enter().append('rect')
    .classed('stripe', true)
    .classed('null',        (d)    => d === null)
    .classed('categorical', (d)    => d !== null)
    .style('y',             (d, i) => i)
    .style('x',             (d)    => d === null ? 0  : keys.indexOf(d) * increment)
    .style('width',         (d)    => d === null ? width : barWidth - 1)
    .append('svg:title')
    .text(                  (d)    => config.name + ': ' + (d === null ? 'null' : d))
}

module.exports = {
  categoricalChart
}<commit_msg>cleanup<commit_after>const { DEFAULT_COLUMN_WIDTH } = require('../constants')

const categoricalChart = (g, data, config = {}) => {
  const top       = config.top   || 0
  const left      = config.left  || 0
  const width     = config.width || DEFAULT_COLUMN_WIDTH
  const keys      = config.keys  || []
  const className = config.className
  const increment = width / keys.length
  const barWidth  = Math.max(2, increment)

  const myG = g.append('g')
   .classed(className, true)
   .attr('transform', () => `translate(${left}, ${top})`)

  myG.selectAll('rect')
    .data(data)
    .enter().append('rect')
    .classed('stripe', true)
    .classed('null',        (d)    => d === null)
    .classed('categorical', (d)    => d !== null)
    .style('y',             (d, i) => i)
    .style('x',             (d)    => d === null ? 0  : keys.indexOf(d) * increment)
    .style('width',         (d)    => d === null ? width : barWidth - 1)
    .append('svg:title')
    .text(                  (d)    => config.name + ': ' + (d === null ? 'null' : d))
}

module.exports = {
  categoricalChart
}
{'fraction_non_alphanumeric': 0.19223744292237444, 'fraction_numerical': 0.0045662100456621, 'mean_word_length': 2.309667673716012, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '6484742', 'n_tokens_mistral': 747, 'n_tokens_neox': 737, 'n_words': 168}