Reputation: 11
I'm trying to draw a line plus bar chart. Whenever i try to draw the line chart (I tried drawing only the line chart, same error), a line is drawn before the first point:
This is the first time i tried Chart.js 2.0, the other charts i drew look great, except this one... Any ideas?
Code:
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)'
}
},
}
});
}
Upvotes: 0
Views: 1175
Reputation: 11
I added the latest versions of chart.js (2.2.1) on my project and it worked, dunno why 2.0 didn't, but thanks for your time!
Upvotes: 0
Reputation: 531
Is it possible you have a problem with input values, not with chart options? I.e. some duplicate values.
Upvotes: 1
Reputation: 10975
To achieve expected result, add below to options
scaleStartValue: 0
Upvotes: 0