birt一点一滴系列之根据选择的指标实现不同统计图表切换

9 篇文章 0 订阅
本文介绍如何在BIRT报告中根据选择的指标实现统计图表的动态切换。通过在Grid中添加控件,设置报表参数,利用JavaScript判断并控制饼图的扇面大小,从而达到切换图表的效果。
摘要由CSDN通过智能技术生成

1、在grid中得合适位置添加 切换指标元素控件。如:html中得列表列表控件

<script type="text/javascript">
function funSelectIndex() {
	var tar = new String(document.getElementById("selectIndex").value);
	var temp = new String(location.href);
	var targetURL = new String();
	if(temp.indexOf("&startTime=") != -1 ){
		targetURL = temp.substring(0, temp.indexOf("&startTime"));
	}else{
		targetURL = temp;
	}
	targetURL += "&startTime=<VALUE-OF>params["startTime"].value</VALUE-OF>";
    targetURL += "&endTime=<VALUE-OF>params["endTime"].value</VALUE-OF>";
	targetURL += "&paraDep=<VALUE-OF>params["paraDep"].value</VALUE-OF>";
	targetURL += "&paraTermp=<VALUE-OF>params["paraTerm"].value</VALUE-OF>";
	targetURL += "&dealerName=<VALUE-OF>params["dealerName"].value</VALUE-OF>";
	targetURL += "&pSelectIndex=" + tar;
	alert(targetURL);
	location.replace(targetURL);	
}

</script>

<select id="selectIndex" οnchange="funSelectIndex()">
<option value="amount" <VALUE-OF>if(params["pSelectIndex"].value=="amount"){selectted="selected"}</VALUE-OF>>实付金额</option>
<option value="cost" <VALUE-OF>if(params["pSelectIndex"].value=="cost"){selectted="selected"}</VALUE-OF>>实收金额</option>
<option value="orderNum" <VALUE-OF>if(params["pSelectIndex"].value=="orderNum"){selectted="selected"}</VALUE-OF>>订单数量</option>
<option value="price" <VALUE-OF>if(params["pSelectIndex"].value=="price"){selectted="selected"}</VALUE-OF>>课单价</option>
<option value="perforpercent" <VALUE-OF>if(params["pSelectIndex"].value=="perforpercent"){selectted="selected"}</VALUE-OF>>成单率</option>
</select>

2、 设置器效果


 

3、在报表参数中定义选择参数项。如:selectIndex

 

4、点击饼图 在“扇面大小”中添加判断js脚本

 

if(params["pSelectIndex"].value=="amount")
{	
	row["paidamount"]
}else if(params["pSelectIndex"].value=="cost")
{	
	row["costamount"]
}else if(params["pSelectIndex"].value=="orderNum")
{	
	row["ordersNum"]
}else if(params["pSelectIndex"].value=="price")
{
	row["ordersNum"]
}else
{
	row["perforpercent"]
}

 目的是根据pSelectIndex选择的数值实现对 统计指标的切换

 

5、运行效果




 

 
 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值