I have this problem with animating of 2-datasets Stepped graph in Google Charts. It all worked well when it was just a LineChart, but my client would love to have SteppedArea chart. When I change the type from LineChart to SteppedAreaChart, the animation of the first dataset is OK, but the second dataset is somewhat wrong and I cannot figure out why. Can you please take a look at this code pen? Thank you very much
function drawStepChart() {
var data1 = new google.visualization.DataTable();
data1.addColumn('number', 'Year');
data1.addColumn('number', 'One');
data1.addColumn('number', 'Two');
var options = {
animation: {duration: 50},
areaOpacity: 0
};
var stepchart = new google.visualization.SteppedAreaChart(document.getElementById('step'));
var index = 0;
var index2 = 0;
var animate1 = function() {
if (index < values[1].length) {
data1.addRows([values[1][index]]);
stepchart.draw(data1, options);
index++;
} else {
if(index2 < values[0].length) {
data1.addRows([values[0][index2]]);
stepchart.draw(data1, options);
index2++;
}
}
}
google.visualization.events.addListener(stepchart, 'animationfinish', animate1);
stepchart.draw(data1, options);
animate1();
}
EDIT: in Google Charts documentation, they say, that animation of stepped charts doesn't support adding rows. But I'm not sure it that is the problem because it works alright in the first data set?