我正在尝试使用chart.js键入'scatter'来显示堆叠的线条 . 不幸的是,选项“stacked:true”似乎不适用于此 .
请检查以下示例(或此this fiddle) .
var ctx = $('#myChart');
var chart = new Chart (ctx,{
type: 'scatter',
data: {
datasets: [{
label: 'Line 1',
fillColor: 'rgb(200,200,200)',
strokeColor: 'rgb(0,0,0)',
data: [{
x: 2020,
y: 20000
},{
x: 2030,
y: 30000
},{
x: 2040,
y: 40000
}]
},{
label: 'Linie 2',
fillColor: 'rgb(200,200,200)',
strokeColor: 'rgb(0,0,0)',
data: [{
x: 2020,
y: 5000
},{
x: 2030,
y: 10000
},{
x: 2040,
y: 15000
}]
}]
},
options: {
elements: {
line: {
tension: 0.000001
}
},
showLines: true,
scales: {
yAxes: [{
stacked: true
}]
},
legend: {
position: 'bottom'
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<html>
<head>
</head>
<body>
<canvas id="myChart"></canvas>
</body>
</html>
Chart.js Documentation says "The scatter chart supports all of the same properties as the line chart.",对于折线图,有一个"stacked"选项(参见here) . 另外,这个在GitHub上报道的issue似乎也证明,散点图有一个"stacked"选项 .
知道我做错了什么吗?