[英]Line chart is drawing before first point in Chart.js
我正在尝试绘制折线图和条形图。 每当我尝试绘制折线图(我尝试仅绘制折线图,同样的错误)时,都会在第一个点之前绘制一条线:
这是我第一次尝试Chart.js 2.0,我画的其他图表看起来很棒,除了这个...还有什么想法吗?
码:
function Data() {
$scope.barChartData = {
labels: $scope.mesesLabels,
datasets: [
{
type: 'bar',
label: "" + myDate.getFullYear() - 1,
backgroundColor: "#5799c7",
data: $scope.infoAnoAnterior,
borderColor: 'white',
borderWidth: 2,
},
{
type: 'bar',
label: "" + myDate.getFullYear(),
backgroundColor: "#ff7c40",
data: $scope.infoAnoAtual,
},
{
type: 'line',
label: 'Média entre anos',
backgroundColor: "rgba(220,20,20,0)",
data: $scope.mediaEntreAnos,
borderColor: 'red',
borderWidth: 2,
pointBorderColor: 'black',
pointBackgroundColor: 'black'
}, ]
};
drawChart();
}
function drawChart(){
var ctx = document.getElementById("base").getContext("2d");
window.myBar = new Chart(ctx, {
type: 'bar',
data: $scope.barChartData,
options: {
responsive: true,
title: {
display: true,
text: 'Chart.js Combo Bar Line Chart'
},
legend: {
display: true,
labels: {
fontColor: 'rgb(255, 99, 132)'
}
},
}
});
}
输入值而不是图表选项是否可能有问题? 即一些重复的值。
为了获得预期的结果,请在选项下面添加
scaleStartValue: 0
我在项目中添加了最新版本的chart.js(2.2.1),它可以正常工作,不知道为什么2.0没有,但是感谢您的宝贵时间!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.