<commit_before>###
# Copyright 2015 ppy Pty. Ltd.
#
# This file is part of osu!web. osu!web is distributed with the hope of
# attracting more community contributions to the core ecosystem of osu!.
#
# osu!web is free software: you can redistribute it and/or modify
# it under the terms of the Affero GNU General Public License version 3
# as published by the Free Software Foundation.
#
# osu!web is distributed WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with osu!web.  If not, see <http://www.gnu.org/licenses/>.
###
class @LineChart
  constructor: (@area, @options = {}) ->
    @x = @options.scales?.x || d3.time.scale()

    @y = @options.scales?.y || d3.scale.linear()

    @svg = d3.select(@area).append 'svg'

    @createXAxisLine()

    @svgWrapper = @svg.append 'g'
      .classed 'chart__wrapper', true

    @svgXAxis = @svgWrapper.append 'g'
      .classed 'chart__axis chart__axis--x', true

    @svgYAxis = @svgWrapper.append 'g'
      .classed 'chart__axis chart__axis--y', true

    @svgLine = @svgWrapper.append 'path'
      .classed 'chart__line', true

    @xAxis = d3.svg.axis()
      .ticks 15
      .outerTickSize 0
      .tickPadding 5
      .tickFormat @options.formats?.x
      .orient 'bottom'

    @yAxis = d3.svg.axis()
      .ticks 4
      .tickFormat @options.formats?.y
      .orient 'left'

    @line = d3.svg.line()
      .interpolate 'monotone'


  margins:
    top: 20
    right: 20
    bottom: 50
    left: 100


  loadData: (data) =>
    @data = data
    @svgLine.datum data

    @resize()


  createXAxisLine: () =>
    @xAxisLine = @svg.append 'defs'
      .append 'linearGradient'
      .attr 'id', 'x-axis-line-gradient'
      .attr 'gradientUnits', 'userSpaceOnUse'
      .attr 'x1', '0'
      .attr 'x2', '0'
      .attr 'y1', '-100%'
      .attr 'y2', '0'

    @xAxisLine.append 'stop'
      .classed 'chart__tick-gradient chart__tick-gradient--start', true
      .attr 'offset', '20%'

    @xAxisLine.append 'stop'
      .classed 'chart__tick-gradient chart__tick-gradient--end', true
      .attr 'offset', '100%'


  setDimensions: =>
    areaDims = @area.getBoundingClientRect()

    @width = areaDims.width - (@margins.left + @margins.right)
    @height = areaDims.height - (@margins.top + @margins.bottom)


  setScalesRange: =>
    @x
      .range [0, @width]
      .domain d3.extent(@data, (d) => d.x)
    @y
      .range [@height, 0]
      .domain d3.extent(@data, (d) => d.y)


  setAxesSize: =>
    @xAxis<commit_msg>Customizable domains<commit_after>###
# Copyright 2015 ppy Pty. Ltd.
#
# This file is part of osu!web. osu!web is distributed with the hope of
# attracting more community contributions to the core ecosystem of osu!.
#
# osu!web is free software: you can redistribute it and/or modify
# it under the terms of the Affero GNU General Public License version 3
# as published by the Free Software Foundation.
#
# osu!web is distributed WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with osu!web.  If not, see <http://www.gnu.org/licenses/>.
###
class @LineChart
  constructor: (@area, @options = {}) ->
    @x = @options.scales?.x || d3.time.scale()

    @y = @options.scales?.y || d3.scale.linear()

    @svg = d3.select(@area).append 'svg'

    @createXAxisLine()

    @svgWrapper = @svg.append 'g'
      .classed 'chart__wrapper', true

    @svgXAxis = @svgWrapper.append 'g'
      .classed 'chart__axis chart__axis--x', true

    @svgYAxis = @svgWrapper.append 'g'
      .classed 'chart__axis chart__axis--y', true

    @svgLine = @svgWrapper.append 'path'
      .classed 'chart__line', true

    @xAxis = d3.svg.axis()
      .ticks 15
      .outerTickSize 0
      .tickPadding 5
      .tickFormat @options.formats?.x
      .orient 'bottom'

    @yAxis = d3.svg.axis()
      .ticks 4
      .tickFormat @options.formats?.y
      .orient 'left'

    @line = d3.svg.line()
      .interpolate 'monotone'


  margins:
    top: 20
    right: 20
    bottom: 50
    left: 100


  loadData: (data) =>
    @data = data
    @svgLine.datum data

    @resize()


  createXAxisLine: () =>
    @xAxisLine = @svg.append 'defs'
      .append 'linearGradient'
      .attr 'id', 'x-axis-line-gradient'
      .attr 'gradientUnits', 'userSpaceOnUse'
      .attr 'x1', '0'
      .attr 'x2', '0'
      .attr 'y1', '-100%'
      .attr 'y2', '0'

    @xAxisLine.append 'stop'
      .classed 'chart__tick-gradient chart__tick-gradient--start', true
      .attr 'offset', '20%'

    @xAxisLine.append 'stop'
      .classed 'chart__tick-gradient chart__tick-gradient--end', true
      .attr 'offset', '100%'


  setDimensions: =>
    areaDims = @area.getBoundingClientRect()

    @width = areaDims.width - (@margins.left + @margins.right)
    @height = areaDims.height - (@margins.top + @margins.bottom)


  setScalesRange: =>
    @x
      .range [0, @width]
      .domain @options.domains?.x || d3.extent(@data, (d) => d.x)
    @y
      .range [@height, 0]
      .domain @options.domains?.y || d3.extent(@data, (d) => d.y)


  setAxesSize: =>
    @xAxis
{'fraction_non_alphanumeric': 0.1370923161967938, 'fraction_numerical': 0.016215220195319697, 'mean_word_length': 2.7076502732240435, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '365999', 'n_tokens_mistral': 1949, 'n_tokens_neox': 1822, 'n_words': 524}