I am currently learning different visualization libraries, I have built a line chart using canvasjs, https://jsfiddle.net/r60xdqbb/
I am trying to built the same using chartjs, but unable to add similar animation. I found one https://codepen.io/anon/pen/xqGGaV
but it it is originating from bottom to top, I tried multiple approaches like by adding datasets to graph using looping, but in that case whole graph is increasing including X and Y axes.
Is there any way I can generate the same behavior using Chartjs?
Thanks in Advance.
CanvasJS JS:
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
axisY: {
title: " Y AXIS",
tickLength: 0,
lineThickness: 0,
margin: 0,
valueFormatString: " ", //comment this to show numeric values
includeZero: false,
gridColor: "transparent",
},
axisX: {
title: "X Axis",
tickLength: 0,
margin: 0,
lineThickness: 0,
valueFormatString: " ", //comment this to show numeric values
includeZero: false,
},
data: [{
type: "line",
color: "#E77973",
dataPoints: [
{ y: 450 },
{ y: 414 },
{ y: 520 },
{ y: 460 },
{ y: 450 },
{ y: 500 },
{ y: 480 },
{ y: 480 },
{ y: 410 },
{ y: 500 },
{ y: 480 },
{ y: 510 }
]
},
{
type: "line",
lineDashType: "dash",
color: "black",
markerType: "none",
dataPoints: [
{ y: 460 },
{ y: 460 }, { y: 460 }, { y: 460 }, { y: 460 }, { y: 460 }, { y: 460 }, { y: 460 }, { y: 460 }, { y: 460 }, { y: 460 }, { y: 460 }
]
}]
});
chart.render();
ChartJS Javascript Code
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'line',
options: {
legend: {
display: false,
},
scales: {
xAxes: [{
gridLines: {
display: false,
},
ticks: {
fontSize: 15,
fontColor: 'lightgrey'
}
}],
yAxes: [{
gridLines: {
drawBorder: false,
},
ticks: {
beginAtZero: true,
fontSize: 15,
fontColor: 'lightgrey',
maxTicksLimit: 5,
padding: 25,
}
}]
},
tooltips: {
backgroundColor: '#1e90ff'
}
},
data: {
labels: ['M', 'Tu', 'W', 'Th', 'F', 'Sa', 'Su'],
datasets: [{
data: [0, 0, 0, 11, 9, 17, 13],
tension: 0.0,
borderColor: 'rgb(255,190,70)',
backgroundColor: 'rgba(0,0,0,0.0)',
pointBackgroundColor: ['white', 'white', 'white', 'white', 'white', 'white', 'rgb(255,190,70)'],
pointRadius: 4,
borderWidth: 2
}]
}
});