我希望以序数比例(从数组数组构建)获得每个唯一值。假设这是我的数据集:
var people = [
["Mary", "Mary Smith", "ID00001", 9.99 ],
["James", "James Smith", "ID00002", 19.99 ],
["Frank", "Frank Black","ID00003", 19.96 ],
["Mary","Mary Brown","ID00004", 9.95 ],
["Tony", "Tony Stark", "ID00005", 2319.99 ],
["Frank", "Frank Howard","ID00006", 219.96 ],
["Mary","Mary Brown","ID00004", 339.95 ]
];
然后我从这些数据构建我的比例:
var ordScale = d3.scale.ordinal()
.domain(people.map( function (d) { return d[0]; }))
.rangeBands([0, 10], 0);
即使有六个不同的人,我最终只会在我的域名中使用四个名字(据我所知!):
我有两个问题: