I have a list of ~7500 items which all have a similar signature:
{
revenue: integer,
title: string,
sector: string
}
The revenue will range from 0 to ~1 Billion. I'd like to construct a scale such that, given a particular company's revenue..it returns its position relative to the following 'buckets':
$0-5 Million
$5-10 Million
$10-25 Million
$25-50 Million
$50-100 Million
$100-250 Million
> $250 Million
I believe I should be able to accomplish this with either a quantize or quantile scale in d3, but have had difficulties getting the expected results. So far, I have something like:
var max_rev = 1000000000 // 1 Billion
scale = d3.scale.quantize().domain(_.range(max_rev)).range([5000000, 10000000, 25000000, 50000000, 100000000, 250000000])
One obvious issue is calling _.range(max_rev) creates an array 1 billion items long, so I'm wondering how I can do that more effectively (something like .domain([0, 1000000000])?)
What would be the best way to define this scale so that, scale(75000000) would return 50000000. Once I have that, I could check it against a hash and return the correct label:
{
...
...
50000000: "$50-100 Million",
100000000: "$100-250 Million",
...
}
Thanks so much! Please let me know if there is any other information I can provide.