How do I specify domain in d3.scale.ordinal() ?
d3.js, javascript, visualization
Solution
If you want the domain of the ordinal scale to be the indexes of your data, then use d3.range. For example, `d3.range(data.length)` returns `[0, 1, 2, 3, 4, 5]`.
Problem
``` var W = 100; var H = 200; var data = [{v:4}, {v:8}, {v:15}, {v:16}, {v:23}, {v:42}]; var x = d3.scale.linear().domain([0, max_x]).range([0, W]); var y = d3.scale.ordinal().domain([0, 1, 2, 3, 4, 5]).rangeBands([0, H]); ``` How do I automatically enumerate the domain of data without typing it out e.g., 0, 1, 2, 3 I have tried `domain(data)`, and `domain([0, data.length])`, but I need all the values in between.