支持MDX XMLA的OLAP客户端---FlexOlapView开发手册

支持MDX XMLA的OLAP客户端---FlexOlapView开发手册

概述

         FlexOlapView构件是一个用于多维分析的FLASH控件,可通过XMLA标准协议连接至OLAP服务器,如:微软的SQL Server分析服务器(MS SSAS2005/2008)和Pentaho分析服务(Mondrian)等,它可以用数据透视表和多种图表展示多维分析数据,实现实时业务分析。本文讲述开发者怎样将FlexOlapView控件应用到自已的项目中。

详见:http://www.flexolap.com
 

架构


样例

可以传入不同的参数,定义FlexOlapView的展现形式,可以只展示图形,多维表格,或是复杂的分析工具界面,举例如下:





参数说明

开发人员将控件放入网页,并正确设置以下参数:

参数

说明

备注

show_mode

显示模式

1:report;  2:view;  3:edit;  4:columnchart 5:piechart  6:lineChart  7:barChart

show_toolbar

是否显示工具栏

1:显示
0:不显示

mdx

MDX查询语句

可以为空

dataSource

数据源

"Provider=Mondrian;DataSource=Pentaho";   

cubeName

Cube名

"SteelWheelsSales";

serviceURL

OLAP 服务URL

"http://localhost:8080/pentaho/Xmla?userid=joe&password=password";

useNumberColor

是否用不同颜色标识数据

0:否
1:是

highColor

高过上限的数据颜色

16711680; //FF0000

lowColor

低于下限的数据颜色

204;  //0x00FF00

highThreshold

数值上限

10000;

lowThreshold

数值下限

1000;

举例如下:


例子

  <script type="text/javascript">
// For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection.
var swfVersionStr = "11.1.0";
// To use express install, set to playerProductInstall.swf, otherwise the empty string.
var xiSwfUrlStr = "playerProductInstall.swf";
var flashvars = {};
                        flashvars.show_mode=3;//1:report;  2:view;  3:edit;  4:columnchart 5:piechart  6:lineChart  7:barChart
                        flashvars.show_toolbar=1;
                        flashvars.mdx="select NON EMPTY  {[Measures]} on columns, {[Customers].[All Customers].children} on rows  from [SteelWheelsSales]";
                                          flashvars.dataSource="Provider=Mondrian;DataSource=Pentaho";                               
                                          flashvars.cubeName="SteelWheelsSales";
flashvars.serviceURL="http://localhost:8080/pentaho/Xmla?userid=joe&password=password";
                                          flashvars.useNumberColor=0;
                                          flashvars.highColor=16711680;//FF0000
                                          flashvars.lowColor=204;//0x00FF00
                                          flashvars.highThreshold=10000;
                                          flashvars.lowThreshold=1000;

var params = {};

params.quality = "high";
params.bgcolor = "#ffffff";
params.allowscriptaccess = "sameDomain";
params.allowfullscreen = "true";
var attributes = {};
attributes.id = "FlexOlapView";
attributes.name = "FlexOlapView";
attributes.align = "middle";
swfobject.embedSWF(
"FlexOlapView.swf", "flashContent",
"100%", "100%",
swfVersionStr, xiSwfUrlStr,
flashvars, params, attributes);
// JavaScript enabled so display the flashContent div in case it is not replaced with a swf object.
swfobject.createCSS("#flashContent", "display:block;text-align:left;");
</script>

参考文档:

《flash使用FlashVars接收html参数》

一、在HTML网页中使用js获取参数。
我们知道HTML页面是在客户端执行的,这样要获取参数必须使用客户端脚本(如JavaScript),在这点上不同于服务器端脚本获取参数方式。
下面的这段js代码获取HTML网页形如"test.html?foo=mytest&program=flash" "?"后所有参数。
<script language=javascript>
<!--
var hrefstr,pos,parastr;
hrefstr = window.location.href;
pos = hrefstr.indexOf("?");
parastr = hrefstr.substring(pos+1);
if (pos>0){
document.write("所有参数:"+parastr);
} else {
document.write("无参数");
}
//-->
</script>

下面的这段js代码则可以更加细化获取HTML网页某一参数
<script language=javascript>
<!--
function getparastr(strname) {
var hrefstr,pos,parastr,para,tempstr;
hrefstr = window.location.href;
pos = hrefstr.indexOf("?")
parastr = hrefstr.substring(pos+1);

para = parastr.split("&");
tempstr="";
for(i=0;i<para.length;i++)
{
tempstr = para[i];
pos = tempstr.indexOf("=");
if(tempstr.substring(0,pos) == strname) {
return tempstr.substring(pos+1);
}
}
return null;
}
// 获取program参数
var programstr = getparastr("program");
document.write(programstr);
//-->
</script>

二、在HTML网页中向swf传递参数。
方法一:在网页中使用js,SetVariable设置flashobject中的变量,代码如:
// "HtmlToSwf"为网页中的flashobject ID
HtmlToSwf.SetVariable("_root.info_str","Happy Newyear");
方法二:路径参数,如test.swf?foo=happy2005
方法三:使用FlashVars,以下主要介绍FlashVars的用法。使用FlashVars后嵌入HTML的flashobject代码如下:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="550" height="400" id="FlashVars" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="FlashVars.swf" />
<param name="FlashVars" value="foo=happy2005&program=flash&language=简体中文-中国" />
< param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="FlashVars.swf" quality="high" bgcolor="#ffffff" width="550" height="400" name="FlashVars" align="middle" allowScriptAccess="sameDomain" FlashVars="foo=happy2005&program=flash&language=简体中文-中国" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />

通过上面的代码,在SWF(FlashVars.swf)中就可以直接获取foo、program、language变量数据。FlashVars.fla获取FlashVars参数的代码如下:
// 创建三个文本字段
_root.createTextField("foo_txt",1,0,0,16,16);
_root.createTextField("program_txt",2,0,32,16,16);
_root.createTextField("language_txt",3,0,64,16,16);
foo_txt.autoSize = true;
foo_txt.border = true;
program_txt.autoSize = true;
program_txt.border = true;
language_txt.autoSize = true;
language_txt.border = true;
// 获取FlashVars变量
foo_txt.text = "HTML中的foo参数:"+foo;
program_txt.text = "HTML中的program参数:"+program;
language_txt.text = "HTML中的language参数:"+language;

三、两者的有效结合。
在HTML网页中使用js获取参数,然后将获取的参数作为FlashVars写入flashobject传递给swf。代码如下:
<script language=javascript>
<!--
function writeflashobject(parastr) {
document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"550\" height=\"400\" id=\"FlashVars\" align=\"middle\"\>\n");
document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" /\>\n");
document.write("<param name=\"movie\" value=\"FlashVars.swf\" /\>\n");
document.write("<param name=\"FlashVars\" value=\""+ parastr +"\" /\>\n");
document.write("<param name=\"quality\" value=\"high\" /\>\n");
document.write("<param name=\"bgcolor\" value=\"#ffffff\" /\>\n");
document.write("<embed src=\"FlashVars.swf\" quality=\"high\" bgcolor=\"#ffffff\" width=\"550\" height=\"400\" name=\"FlashVars\" align=\"middle\" allowScriptAccess=\"sameDomain\" FlashVars=\""+ parastr +"\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /\>");
document.write("</object\>");
}
function getparastr() {
var hrefstr,pos,parastr,para,tempstr1;
hrefstr = window.location.href;
pos = hrefstr.indexOf("?")
parastr = hrefstr.substring(pos+1);
return parastr;
}
var parastr = getparastr();
writeflashobject(parastr);
//-->
</script>

         

猜你喜欢

转载自xj1998.iteye.com/blog/1969261
MDX