다른 데이터 세트에 대해 다른 막대 너비를 사용할 수 있습니까? 하나의 스택에 몇 개의 데이터 세트가 있고 자체 스택에 다른 데이터 세트가 있습니다. 단일 데이터 집합은 다른 스택보다 좁아야합니다.Chart.js 막대 차트의 여러 막대 너비
Example. 여기에서는 왼쪽 스택을 복제하여 오른쪽 스택의 두 배가되는 결과를 얻었습니다. 이 제로가 아닌 국경
var data = {
labels: ["1", "2", "3", "4", "5"],
datasets: [
{
label: "d1",
backgroundColor: "rgba(182,127,0,1)",
borderColor: "rgba(117,61,41,1)",
borderWidth: 1,
data: [42, 78, 64, 90, 97],
stack: "s1"
},
{
label: "d2",
backgroundColor: "rgba(71,161,65,1)",
borderColor: "rgba(36,93,56,1)",
borderWidth: 1,
data: [27, 63, 46, 64, 43],
stack: "s1"
},
{
label: "d3",
backgroundColor: "rgba(255,141,106,1)",
borderColor: "rgba(99,60,32,1)",
borderWidth: 1,
data: [18, 50, 23, 83, 35],
stack: "s1"
},
{
label: "d1",
backgroundColor: "rgba(182,127,0,1)",
borderColor: "rgba(117,61,41,1)",
borderWidth: 1,
data: [42, 78, 64, 90, 97],
stack: "s1b"
},
{
label: "d2",
backgroundColor: "rgba(71,161,65,1)",
borderColor: "rgba(36,93,56,1)",
borderWidth: 1,
data: [27, 63, 46, 64, 43],
stack: "s1b"
},
{
label: "d3",
backgroundColor: "rgba(255,141,106,1)",
borderColor: "rgba(99,60,32,1)",
borderWidth: 1,
data: [18, 50, 23, 83, 35],
stack: "s1b"
},
{
label: "d4",
backgroundColor: "rgba(160,160,160,1)",
borderColor: "rgba(60,60,60,1)",
borderWidth: 1,
data: [152, 141, 170, 194, 128],
stack: "s2",
barPercentage: 0.3
}
]
};
var options = {
scales: {
xAxes: [{
categoryPercentage: 0.6,
barPercentage: 1
}]
},
legend: {
display: false
}
};
var barChart = new Chart($("#myChart"), {
type: 'bar',
data: data,
options: options
});
필자가 필요로하는 것처럼 보이지만 수평 막대 차트에서 작동합니까? 귀하의 예제를 전환했는데 두 번째 축은 더 이상 표시되지 않습니다 http://codepen.io/MalikDrako/pen/RpjLRd?editors=0010 축이 일부 장소에서 스왑 된 것처럼 보이지만 다른 곳에서는 보이지 않습니다 - 타이 유형 설정을 시도했습니다. y 축에 대해 logarmic로 설정했지만 수직 축으로 설정 한 것으로 보입니다. –
예, 업데이트 된 답변의 예를 볼 수 있습니다. – jordanwillis