1
0
mirror of https://gitee.com/lvyeyou/DaShuJuZhiDaPingZhanShi.git synced 2025-06-16 22:49:56 +08:00
郎大伟 80397a6ddd 1.增加智慧运维可视化监控管理大屏模板
2.所有主题模板添加主页图片预览
3.大屏在线预览即将上线,尽请期待:)
2020-01-22 22:23:11 +08:00

70 lines
2.3 KiB
JavaScript

/**
* 创建进度条 组件
*/
function CreateSpeed(option){
this.option = option;
this.isFirstLoad = true;
this.init();
}
CreateSpeed.prototype = {
init:function () {
this.createSpeed();
},
createSpeed:function () {
var _view_ = this;
var html = '';
html += '<div id="'+_view_.option.id+'" class="speed-container">';
html += '<div class="speed-title">';
html += '<span><img src="'+_view_.option.icon+'"></span><span>'+_view_.option.title+'</span><span><img src="icon/xjt.png"></span>';
html += '</div>';
html += '<div class="speed-content">';
html += '<ul>';
html += '<ul>';
html += '</div>';
html += '</div>';
$("#"+_view_.option.id).append(html);
},
setData:function (series) {
var _view_ = this;
function toPoint(point){
var str=Number(point*100).toFixed(1);
str+="%";
return str;
}
var html = '';
series.forEach(function (item,index) {
html += '<li><span>'+item["name"]+'</span><span class="speed-line"><span id="'+_view_.option.id+index+'" class="speed-num" style="background-color: '+item["color"]+'"></span><span class="numText">'+item["data"]+'</span></span></li>';
});
$("#"+_view_.option.id + " ul").html(html);
//动画效果加载数据
if(_view_.isFirstLoad){
series.forEach(function (item,index) {
var dataNum = null;
if(_view_.option.max === null){
dataNum = item["data"];
}else{
dataNum = toPoint(item["data"]/_view_.option.max);
}
$("#"+_view_.option.id+index).animate({
width:dataNum
},2000);
});
_view_.isFirstLoad = false;
}else{
series.forEach(function (item,index) {
var dataNum = null;
if(_view_.option.max === null){
dataNum = item["data"];
}else{
dataNum = toPoint(item["data"]/_view_.option.max);
}
$("#"+_view_.option.id+index).width({
width:dataNum
})
});
}
}
};