function ciy_chart_bank1_r1(opdata) { this.func = ['bank_r1']; this.lastdata = {}; this.resize = function () { } this.setdata = function (funame, data) { if (!data) return; for (var if1 in data.bplants) { data.bplants[if1].totalhtmoney = 0; data.bplants[if1].totalcontract = 0; for (var if2 in data.fbcontracts) { if (data.fbcontracts[if2].debtorid != data.bplants[if1].id) continue; data.bplants[if1].totalhtmoney += parseFloat(data.fbcontracts[if2].htmoney / 1000000.0); data.bplants[if1].totalcontract++; } } var cats = [{ min: 0, max: 300 }, { min: 300, max: 800 }, { min: 800, max: -1 } ]; var maxhtmoney = 0; var maxcontract = 0; var maxchs = 0; for (var i = 0; i < cats.length; i++) { cats[i].htmoney = 0; //贷款总额 cats[i].totalcontract = 0; //合同数 cats[i].chs = 0; //场户数 for (var if1 in data.bplants) { if (data.bplants[if1].totalhtmoney <= cats[i].min) continue; if (cats[i].max > -1 && data.bplants[if1].totalhtmoney > cats[i].max) continue; cats[i].chs++; cats[i].htmoney += data.bplants[if1].totalhtmoney; cats[i].totalcontract += data.bplants[if1].totalcontract; } if (maxhtmoney < cats[i].htmoney) maxhtmoney = cats[i].htmoney; if (maxcontract < cats[i].totalcontract) maxcontract = cats[i].totalcontract; if (maxchs < cats[i].chs) maxchs = cats[i].chs; } for (var i = 0; i < cats.length; i++) { $5('#r' + i + '_c1_num', opdata.container).text(parseInt(cats[i].htmoney).toLocaleString()); $5('#r' + i + '_c2_num', opdata.container).text(cats[i].totalcontract.toLocaleString()); $5('#r' + i + '_c3_num', opdata.container).text(cats[i].chs.toLocaleString()); var wid = cats[i].htmoney * 100 / maxhtmoney; $5('#r' + i + '_c1_bar', opdata.container).css('width', (wid > 5 ? wid : 5) + '%'); var wid = cats[i].totalcontract * 100 / maxcontract; $5('#r' + i + '_c2_bar', opdata.container).css('width', (wid > 5 ? wid : 5) + '%'); var wid = cats[i].chs * 100 / maxchs; $5('#r' + i + '_c3_bar', opdata.container).css('width', (wid > 5 ? wid : 5) + '%'); } } this.distory = function () { } opdata.container.append(`
贷款金额分布
贷款 (万元) 合同 (份) 单位 (家)
300万以内
--
--
--
300-800万
--
--
--
800万以上
--
--
--
`); var style = document.createElement("style"); style.innerHTML = ` #r1 td{padding:0.5em;} #r1 td.titleft{line-height: 3em;text-align:right;padding-right:1em;color:#6dcdee;} #r1 .datanum{text-align:right;font-family: eng01;font-size:2em;} #r1 .databar{text-align:right;} #r1 .databar>div{ width: 100%; height: 5px; background: #ffffff14; border-radius: 3px; display: flex; justify-content: flex-end; } #r1 .databar>div>div{ height: 5px; background: #00dcff; border-radius: 3px; transition: 0.5s; } `; window.document.head.appendChild(style); }