关键词:
//Function to check if the div is visible on the screen
$(function()
var loaded = false;
var oTop = $('#instances').offset().top - window.innerHeight;
checkPosition();
$(window).scroll(function()
checkPosition();
);
function checkPosition()
var pTop = $('body').scrollTop();
if( pTop > oTop )
if(!loaded)
loaded = true;
loadChart();
);
//Data for div
var data =
[ "instance": "OpenAM", "progress": 100 ,
"instance": "OpenDJ", "progress": 90 ,
"instance": "OpenIDM", "progress": 90 ,
"instance": "OpenIG", "progress": 80 ];
anchorLeft = d3.select("#instances")
//Bind data for bars
var divLeft = anchorLeft.selectAll("#instances div")
.data(data);
//Add shadow for the bars
divLeft.enter().append("div")
.attr("class", "shadow");
//Create the bars
d3.select("body").selectAll(".shadow")
.append("div")
.attr("class","bar");
//Create the path
d3.select("body").selectAll(".bar")
.append("div")
.attr("class","path");
//Add the pattern for the bars
d3.select("body").selectAll(".path")
.append("div")
.attr("class","pattern");
//Animate the bars when they are both visible on screen
function loadChart()
var start_val = 0;
//add the percentage to the progress bar and transition the number
d3.select("body").selectAll(".pattern")
.append("div")
.text(start_val)
.attr("class", "percentage")
.transition()
.delay(function(d, i)
return i * 200;
)
.duration(1000)
.style("min-width", function(d, i)
return (d.progress * 3)/2 + "px";
console.log(1);
)
.tween(".percentage", function(d)
var i = d3.interpolateNumber(this.textContent, d.progress),
prec = (d.progress + "").split("."),
round = (prec.length > 1) ? Math.pow(10, prec[1].length) : 1;
return function(t)
this.textContent = Math.round(i(t) * round) / round + "%";
// var p = Math.max(0, d3.precisionFixed(0.05) - 2),
// f = d3.format("." + p + "%");
;
);
// $('div .shadow').each(function()
// $(this).prepend(document.createTextNode("data.Instance"));
// );
//transition the width of the path
d3.select("body").selectAll(".path")
.transition()
.delay(function(d, i)
return i * 200;
)
.duration(1000)
.style("width", function(d, i)
return d.progress*3 + "px";
);
//transition between the different colors depending on the value
d3.select("body").selectAll(".pattern")
//transition to first color
.transition()
.delay(function(d, i)
return i * 200;
)
.duration(250)
.style("background-color", function(d)
if(d.progress < 40)
return "#FB7457";
else
return "#FBB272";
)
//transition to second color
.transition()
.delay(function(d, i)
return (i * 200) + 250;
)
.duration(250)
.style("background-color", function(d)
if(d < 40)
return "#FB7457";
else if (d.progress < 60)
return "#FBB272";
else
return "#FFE584";
)
//transition to third color
.transition()
.delay(function(d, i)
return (i * 200) + 500;
)
.duration(250)
.style("background-color", function(d)
if(d.progress < 40)
return "#FB7457";
else if (d.progress < 60)
return "#FBB272";
else if (d.progress < 80)
return "#FFE584";
else
return "#C9D790";
)
//transition to fourth color
.transition()
.delay(function(d, i)
return (i * 200) + 750;
)
.duration(250)
.style("background-color", function(d)
if(d.progress < 40)
return "#FB7457";
else if (d.progress < 60)
return "#FBB272";
else if (d.progress < 80)
return "#FFE584";
else if (d.progress < 100)
return "#C9D790";
else
return "#7AC191";
);
//transition the sadow under the progress bar
d3.select("body").selectAll(".shadow")
.transition()
.delay(function(d, i)
return i * 200;
)
.duration(1000)
.style("width", function(d, i)
return d.progress*3-6 + "px";
);
javascriptd3.jsで分散情节をburshし,スタイル変更と同时に选択したオブジェクトを操作する方法。(代码片段)
查看详情
shbash进度条(代码片段)
查看详情
java进度条(代码片段)
查看详情
python进度条(代码片段)
查看详情
pythonpythoncli进度条(代码片段)
查看详情
xml进度条(代码片段)
查看详情
pythonpythoncli进度条(代码片段)
查看详情
python进度条(代码片段)
查看详情
shbash进度条(代码片段)
查看详情
html进度条(代码片段)
查看详情
powershell进度条(代码片段)
查看详情
进度条(代码片段)
num=0importsys,timeforiinrange(20):num+=1sys.stdout.write(‘|%s%s|%s%%‘%(‘ 查看详情
flutter进度条(代码片段)
条形进度条value:表示当前进度,取值范围为[0,1]。如果value为null则进度条会执行循环动画(模糊进度);如果value不为null,则进度条有具体进度。valueColor:进度条颜色。可以通过AlwaysStoppedAnimation指定... 查看详情
pythonrsync的进度条(代码片段)
查看详情
csscss时间进度条(代码片段)
查看详情
python打印进度条。(代码片段)
查看详情
html类似进度条(代码片段)
查看详情
进度条(代码片段)
@time2019/12/1910:01importsysimporttimeforiinrange(10):sys.stdout.write("#")sys.stdout.flush()time.sleep(0.5) 查看详情