示例说明
在灵活分析的柱图上添加箭头。
设置方法
在报表宏界面新建客户端模块,在弹出的新建模块对话框中选择对象为simpleReport;事件为onRenderTable;并把下面宏代码复制到代码区域。
宏类型
类型 | 对象 | 事件 |
ClientSide | simpleReport | onRenderTable |
宏代码
function main(simpleReport, simpleReportContext) { //@smartbi.static_resource:img/mmsh/up_24.png //@smartbi.static_resource:img/mmsh/down_24.png var valueArray = new Array(5); var grid = simpleReport.grid; var col = grid.getFieldIndexByAlias("标志"); for (var i = grid.getHeaderRows(); i < grid.getRowCount() && i < grid.getHeaderRows() + 5; i++) { valueArray[i - grid.getHeaderRows()] = parseFloat(grid.getCellText(i, col)); } simpleReport.trTail.style.display = ""; simpleReport.trTail.parentElement.parentElement.cellSpacing = "0"; simpleReport.trTail.parentElement.parentElement.cellPadding = "0"; simpleReport.trTail.parentElement.childNodes[1].firstChild.firstChild.cellSpacing = "0"; simpleReport.trTail.parentElement.childNodes[1].firstChild.firstChild.cellPadding = "0"; var fontHTML = "<div style='vertical-align:bottom;height:24px;line-height:26px;width:48px;text-align:center;background-color:#FFF;border:1px solid #DCDCDC;float:left;color:#770077;font-weight:bold;'>"; var upImg = "<img src='./img/mmsh/up_24.png' align='left' style='float:left;margin-left:20px;margin-right:40px;'/>"; var downImg = "<img src='./img/mmsh/down_24.png' align='left' style='float:left;margin-left:20px;margin-right:40px;'/>"; var innerHTML = "<div style='width:400px;height:33px;margin-top:0px;top:0px;'>"; innerHTML += "<div style='height:28px;width:480px;margin-left:20px;padding:6px 1px 1px 3px;'>"; innerHTML += fontHTML + "同比</div>"; for (var j = 0; j < valueArray.length; j++) { innerHTML += valueArray[j] > 0 ? upImg: downImg; } innerHTML += fontHTML + "33.65%</div>"; innerHTML += "</div></div>"; simpleReport.setTail(innerHTML); simpleReport.reportTail.firstChild.firstChild.childNodes[0].style.width = "40px"; simpleReport.reportTail.firstChild.firstChild.childNodes[5].style.marginRight = "2px"; simpleReport.reportTail.firstChild.firstChild.childNodes[6].style.height = "22px"; simpleReport.reportTail.firstChild.firstChild.childNodes[6].style.lineHeight = "24px"; } |
关键对象总结