<commit_before>class Histogram extends Ubret.Graph
  name: 'Histogram'
  axes: 1
  
  constructor: (selector) ->
    super selector
    @opts.axis2  = 'Count'
    @binFunc = d3.layout.histogram()

  setupData: =>
    data = _(@opts.data).map (d) => d[@opts.axis1]
    @xDomain = d3.extent data
    @graphData = @binFunc data
    @yDomain = [0, d3.max(@graphData, (d) -> d.y)]

  drawData: =>
    @bars = @svg.append('g').selectAll('.bar')
      .data(@graphData)
      .enter().append('rect')
        .attr('class', 'bar')
        .attr('x', (d) => @x(d.x))
        .attr('width', @x(@graphData[1].x) - @x(@graphData[0].x))
        .attr('y', (d) => @y(d.y))
        .attr('height', (d) => @graphHeight - @y(d.y))
        .attr('fill', '#0071E5')
        .attr('stroke', '#FAFAFA')

  drawBrush: =>
    @brush = @svg.append('g')
      .attr('class', 'brush')
      .attr('width', @graphWidth)
      .attr('height', @graphHeight)
      .call(d3.svg.brush().x(@x)
      .on('brushend', @brushend))
      .selectAll('rect')
      .attr('height', @graphHeight)
      .attr('opacity', 0.5)
      .attr('fill', '#CD3E20')
<commit_msg>Add support for different binning methods, partial fix for issue #16<commit_after>class Histogram extends Ubret.Graph
  name: 'Histogram'
  axes: 1
  
  constructor: (selector) ->
    super selector
    @opts.axis2  = 'Count'

  start: =>
    @binFunc = if @opts.bins? then d3.layout.histogram(@opts.bins) else d3.layout.histogram()
    super

  setupData: =>
    data = _(@opts.data).pluck @opts.axis1
    @xDomain = d3.extent data
    @graphData = @binFunc data
    @yDomain = [0, d3.max(@graphData, (d) -> d.y)]

  drawData: =>
    @bars = @svg.append('g').selectAll('.bar')
      .data(@graphData)
      .enter().append('rect')
        .attr('class', 'bar')
        .attr('x', (d) => @x(d.x))
        .attr('width', @x(@graphData[1].x) - @x(@graphData[0].x))
        .attr('y', (d) => @y(d.y))
        .attr('height', (d) => @graphHeight - @y(d.y))
        .attr('fill', '#0071E5')
        .attr('stroke', '#FAFAFA')

  drawBrush: =>
    @brush = @svg.append('g')
      .attr('class', 'brush')
      .attr('width', @graphWidth)
      .attr('height', @graphHeight)
      .call(d3.svg.brush().x(@x)
      .on('brushend', @brushend))
      .selectAll('rect')
      .attr('height', @graphHeight)
      .attr('opacity', 0.5)
      .attr('fill', '#CD3E20')

{'fraction_non_alphanumeric': 0.2224087284934956, 'fraction_numerical': 0.0180444817456987, 'mean_word_length': 2.6012084592145017, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '4523507', 'n_tokens_mistral': 927, 'n_tokens_neox': 894, 'n_words': 166}