<commit_before>import * as d3 from 'd3'
import * as mmwr from 'mmwr-week'
import * as errors from './errors'

export const getXDateDomain = (timePoints, pointType) => {
  return d3.extent(timePoints.map(d => {
    if (pointType === 'mmwr-week') {
      return (new mmwr.MMWRDate(d.year, d.week)).toMomentDate()
    } else if (pointType === 'regular-week') {
      return d3.timeParse('%Y-%W')(d.year + '-' + d.week)
    } else {
      throw new errors.UnknownPointTypeException()
    }
  }))
}

export const getYDomain = (data, curveIdx) => {
  let modelMaxes = data.models.map(m => {
    let curveData = m.curves[curveIdx].data
    if (!curveData) {
      return 0
    } else {
      return Math.max(...curveData.map(d => d[1]))
    }
  })
  return [0, Math.max(...modelMaxes)]
}

export const getXDomain = (data, curveIdx) => {
  // This assumes an ordinal scale
  for (let i = 0; i < data.models.length; i++) {
    let curveData = data.models[i].curves[curveIdx].data
    if (curveData) {
      // Return the x series directly
      return curveData.map(d => d[0])
    } else {
      return [0, 0]
    }
  }
}<commit_msg>Fix x axis range function for distribution chart<commit_after>import * as d3 from 'd3'
import * as mmwr from 'mmwr-week'
import * as errors from './errors'

export const getXDateDomain = (timePoints, pointType) => {
  return d3.extent(timePoints.map(d => {
    if (pointType === 'mmwr-week') {
      return (new mmwr.MMWRDate(d.year, d.week)).toMomentDate()
    } else if (pointType === 'regular-week') {
      return d3.timeParse('%Y-%W')(d.year + '-' + d.week)
    } else {
      throw new errors.UnknownPointTypeException()
    }
  }))
}

export const getYDomain = (data, curveIdx) => {
  let modelMaxes = data.models.map(m => {
    let curveData = m.curves[curveIdx].data
    if (!curveData) {
      return 0
    } else {
      return Math.max(...curveData.map(d => d[1]))
    }
  })
  return [0, Math.max(...modelMaxes)]
}

export const getXDomain = (data, curveIdx) => {
  // This assumes an ordinal scale
  for (let i = 0; i < data.models.length; i++) {
    let curveData = data.models[i].curves[curveIdx].data
    if (curveData) {
      // Return the x series directly
      return curveData.map(d => d[0])
    }
  }
  return [0, 0]
}
{'fraction_non_alphanumeric': 0.1624007060900265, 'fraction_numerical': 0.009708737864077669, 'mean_word_length': 2.7846410684474123, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2346832', 'n_tokens_mistral': 821, 'n_tokens_neox': 799, 'n_words': 198}