export const formatData = (values, metrics, dimension) => {
  const dataTemp = {}
  values.forEach(row => {
    dataTemp[row[dimension]] = []
    metrics.forEach(item => {
      dataTemp[row[dimension]].push(row[item])
    })
  })
  return dataTemp
}

export const getMaxData = (values, dimension) => {
  const datas = values.map((v, i) => {
    return v[dimension]
  })
  const nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]
  const maxData = Math.max(...datas)
  const num =
    (Number(maxData.toString().substring(0, 1)) + 1) *
    nums[maxData.toString().length - 1]
  return num
}
