이러한 종류의 목록 차트는 d3으로 쉽게 생성 할 수 있습니다. 간단한 데이터 객체를 사용하여 생성 할 수 있습니다. 아래, 왼쪽 및 오른쪽에 별도로 rect를 만든 다음 레이블을 추가했습니다. 오른쪽 막대의 색은 데이터 개체의 status
필드를 기반으로합니다. 이 바이올린 밖으로
확인 : https://jsfiddle.net/qf9po0L5/
svg.selectAll("bar")
.data(data)
.enter().append("rect")
.attr("x", 10)
.attr("width", 200)
.attr("y", function(d, i) {
return i * 32
})
.attr("height", 30)
.attr("fill", function(d, i) {
return i % 2 ? "#83adef" : "lightblue";
});
svg.selectAll("second-bar")
.data(data)
.enter().append("rect")
.style("fill", function(d) {
return d.status === 0 ? "red" : "green";
})
.attr("x", 212)
.attr("width", 20)
.attr("y", function(d, i) {
return i * 32
})
.attr("height", 30);
var yTextPadding = 20;
svg.selectAll(".bartext")
.data(data)
.enter()
.append("text")
.attr("class", "bartext")
.attr("text-anchor", "middle")
.attr("fill", "white")
.attr("x", 55)
.attr("y", function(d, i) {
return (i * 32) + 22;
})
.text(function(d) {
return d.name;
})
.attr("fill", "black");
이이 C3.js 실행하도록 할 수있는 기회가 있습니까? – TheAuzzieJesus
^이것을 놓친 경우. – TheAuzzieJesus
@TheAuzzieJesus "C3.js와 함께 실행되도록"이란 정확히 무엇을 의미합니까? – sparta93