OpenFlashChart是一个flash的图表,官方网站是http://teethgrinder.co.uk/open-flash-chart-2/,从官方下载压缩包。
OFC解压之后,里面有很多实例。首先是添加个open-flash-chart.swf,swfobject.js。关于json2.js还没弄清楚在什么情况下使用,最好加入到页面中。简单实例如下:
://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>OFC-helloworld</title>
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript">
var flashvars = {};
var params = {menu: "false",scale: "noScale",wmode:"opaque"};
swfobject.embedSWF("open-flash-chart.swf", "helloworld", "550px", "350px", "9.0.0","expressInstall.swf", flashvars,params);
</script>
</head>
<body>
<h3>HelloWorld</h3>
<div id="helloworld"></div>
</body>
</html>
有两种方法传递数据源给OFC,
一是 var flashvars = {"data-file":"data-files/data.txt"}; data是json格式的数据。
二是 http://localhost:/app/hello?ofc=data-files/data.txt传入数据。
另一种加载方式,本质是不是一样就不知道了。
<head>
<script type="text/javascript" src="${ctx }/js/swfobject.js"></script>
<script type="text/javascript" src="${ctx }/js/json/json2.js"></script>
<script type="text/javascript">
swfobject.embedSWF("open-flash-chart-SimplifiedChinese.swf", "chart", "800", "600", "9.0.0", "expressInstall.swf");
var data = ${data};
function ofc_ready(){
}
function open_flash_chart_data(){
return JSON.stringify(data);
}
${data}是基于json格式的数据
</script>
</head>
<body>
<div id="chart"></div>
</body>