次の構造の JSON リストがあります。
[
{'uid': 4, 'x': -1.2354657, 'y': -0.992893}
{'uid': 26, 'x': 0.2783682, 'y': -0.1931}
...
{'uid': 26, 'x': -0.278356, 'y': 0.082983}
]
このリストのとの値で指定されたポイントにsvg:circle
要素を接続しようとしています。AJAX リクエストは正しく機能しますが、.svg
x
y
Error: Invalid value for <circle> attribute cy="[object Object]"
関連する JavaScript コード:
var svg = d3.select('#d3')
.append('svg')
.append('g')
.attr('class', 'main')
...
var x = d3.scale.linear()
.domain(d3.extent(data, function (d) {return d.x;}))
.range([0, width]);
var y = d3.scale.linear()
.domain(d3.extent(data, function (d) {return d.y;}))
.range([height, 0]);
...
svg.selectAll('.bloom')
.data(data)
.enter()
.append('g')
.attr('class', 'bloom')
.append('circle')
.attr('class', 'bloom-circle')
.attr('cx', function (d) {return x(d.x);})
.attr('cy', function (d) {return y(d.y);})
.attr('r', 10)
.style('fill', 'purple')
.style('stroke', 'white')
.style('stroke-width', '5px');
d3.scale.linear
で常に値を返す必要があるため、文字通り何が起こっているのかわかりませんrange
。なぜこれが起こっているのか誰にも分かりますか?