데이터베이스에서 오는 값을 드롭 다운하여 하나의 드롭 다운 (Account_type)을 만들었습니다. ie : value1, value 2, value3 ... 값을 선택하여 내 차트를 업데이트하고 싶습니다. 그러나 현재 시나리오에서는 동일한 차트를 업데이트하는 대신 다른 차트를 만들 것입니다 .Again Again은 별도의 차트를 만듭니다. 도표d3 차트를 사용하여 차트를 업데이트 할 수 없습니다.
My code here
var svg = d3.select("#"+this.htmlObject).append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");data.forEach(function(d) {
d.frequency = +d.frequency;
});
x.domain(data.map(function(d) { return d.letter; }));
y.domain([0, d3.max(data, function(d) { return d.frequency; })]);
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("y", -75)
.attr("dy", ".71em")
.attr("dx","-18em")
.style("text-anchor", "end")
.text("Frequency");
svg.selectAll(".bar")
.data(data)
.enter().append("rect")
.attr("class", "bar")
.attr("x", function(d) { return x(d.letter); })
.attr("width", x.rangeBand())
.attr("y", function(d) { return y(d.frequency); })
.attr("height", function(d) { return height - y(d.frequency); });
나는 이것을 어떻게 얻을 수 있습니까?
항상 새 SVG를 추가합니다. 새 SVG를 추가하기 전에 기존 SVG를 다시 사용하거나 이전 SVG를 제거하십시오. –
어떻게이 가능할 수 PLZ 나에게 가능한 모든 샘플을 제공 할 수 있습니다 .. 또는 내가 어떻게 제거하거나 이것을 재사용 할 수 있습니다 .. –
제거하려면 예. 'd3.selectAll ("svg"). remove()'. –