问题
Good day! We wrote some basic animation logic for bubble charts to create a very basic version of the Gapminder motion charts when Google decided to abandon them. All was well until we recently started a run through updating our versions of jquery/ui/highcharts. I can't see what would have changed in the changelog between 5.06 and 5.07 that would have broken it, but it seems to be in those two versions. The jquery version doesn't seem to impact it. Any ideas?
function animateCircle(dataObject, year, autoContinue){
var country = dataObject.graphic.element.getAttribute('name'),
data = translatedData[year][country],
rawData = getDataByYearByCountry(year, country);
dataObject.x = rawData.x;
dataObject.y = rawData.y;
dataObject.z = rawData.z;
if(theChart.hoverPoint==dataObject){
theChart.tooltip.label.attr('text', '<b>'+country+' ('+ year +')</b><br/>'+xAxisVariable+': '+rawData.x+'<br/>'+yAxisVariable+': '+rawData.y+'<br/>'+zAxisVariable+': '+rawData.z);
}
currentYear = year;
yearSlider.slider('option', 'value', year);
yearSlider.slider('option', 'slide').call(yearSlider, null, {value: year});
dataObject.graphic.isAnimating = true;
dataObject.graphic.animate({cx: data.x, cy: data.y, r: data.z}, {duration: 1000, easing: 'linear', complete: function(){
this.isAnimating = false;
if(autoContinue && !stoppingAnimationNow){
animateCircle(dataObject, year==2013 ? 2000 : year+1, autoContinue);
}
}});
}
The bubbles seem to shift very slightly, and then nothing, but there are no error messages to track through.
回答1:
Since Highcharts v5.0.7, bubbles are no longer circles, but paths, so you need to animate x
and y
properties:
dataObject.graphic.animate({
x: data.x,
y: data.y,
r: data.z
}, ...);
Live demo: https://jsfiddle.net/BlackLabel/t6z5wL4j/
来源:https://stackoverflow.com/questions/58341724/change-in-highcharts-version-breaks-animation-of-elements