我使用Chart.js創建雷達圖表。我想從菜單中點擊一個按鈕時開始動畫。現在它開始當您加載該網站。單擊按鈕後Chart.js動畫圖表
下面是實際的腳本:
var radarChartData = {
labels : ["Html5","Responsive","LESS","SASS","JavaScript","WordPress","Git","WebGL","LAMP","CSS3","User Interface Design","SEO","Web applications"],
datasets : [{
fillColor : "rgba(255,255,255,0.5)",
strokeColor : "rgba(250,250,250,1)",
pointColor : "rgba(255,255,255,1)",
pointStrokeColor : "#fff",
data : [100,100,80,80,80,70,50,30,100,100,80,70,70]
}]
}
var myRadar = new Chart(document.getElementById("skill-radar").getContext("2d"))
.Radar(radarChartData, {
scaleShowLabels : true,
scaleOverride : true,
scaleSteps : 10,
scaleStepWidth : 10,
scaleLineColor : "rgba(250,250,250,.5)",
angleLineColor : "rgba(250,250,250,.3)",
scaleFontFamily : "'Exo'",
scaleFontColor : "#fff",
scaleFontSize : 10,
scaleBackdropColor : "rgba(0,0,0,0.75)",
pointLabelFontFamily : "'Exo'",
pointLabelFontSize : 16,
pointLabelFontColor : "#fff",
animationEasing : "easeOutSine",
animationSteps : 100,
pointLabelFontSize : 10
});
var chartJsConstruct = function(){
//..your chart.js invocation with 'new' as shown above
new Chart(document.getElementById("skill-radar").getContext("2d"))
.Radar(radarChartData, {
scaleShowLabels : true,
scaleOverride : true,
scaleSteps : 10,
scaleStepWidth : 10,
scaleLineColor : "rgba(250,250,250,.5)",
angleLineColor : "rgba(250,250,250,.3)",
scaleFontFamily : "'Exo'",
scaleFontColor : "#fff", scaleFontSize : 10,
scaleBackdropColor : "rgba(0,0,0,0.75)",
pointLabelFontFamily : "'Exo'",
pointLabelFontSize : 16,
pointLabelFontColor : "#fff",
animationEasing : "easeOutSine",
animationSteps : 100,
pointLabelFontSize : 10
});
};
var skillsLink = document.getElementById('ui-id-2'); // find the target to add behavior
// add behavior agnostic of browser
if (skillsLink.addEventListener){// for Non-IE browsers
skillsLink.addEventListener('click', chartJsConstruct);
} else if(skillsLink.attachEvent){// for IE9 and below
skillsLink.attachEvent('onclick', chartJsConstruct);
}
這裏是http://alejuu.com/。我試着做的是當你點擊技能菜單時開始動畫,而不是在網站加載時開始。 感謝 –
下圖是在技能部分 –