open flash chart 版本是2.0
使用加载js的方法获取flash chart,x现在的问题是,如果我在一个页面加载两个flash,一个bar,一个line,页面中显示的数据始终是第二个flash的数据(图也是第二个)
代码如下:
common.js:
function ofc_ready(){ //alert('ofc_ready'); } function open_flash_chart_data(){ //alert( 'reading data' ); return JSON.stringify(data); } function findSWF(movieName) { if (navigator.appName.indexOf("Microsoft")!= -1) { return window[movieName]; } else { return document[movieName]; } } function createChart(json,header,col,type) { data = { "elements": [ { "type": type, "text": "u5317u4eac", "values": [ 9.9355, 18.2142, 12.1315, 11.9911, 10.2637, 24.152, 35.8293, 17.8541, 17.1762, 25.2105, 24.9323, 23.5468, 22.7642, 32.9232, 30.6192, 17.9746, 26.1273, 14.5226, 17.3219, 52.0837, 22.1281, 18.9674, 8.3799, ] } ], "title": { "text": header.title }, "y_axis": { "min": 0, "max": 65, "steps": 4 }, "x_axis": { "steps":2, "labels": { "labels": [ "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", ] } }, "y_legend": { "text": "chinaticket.com chart 1:10000", "style": "color:#736AEF; font-size:14px;" } }; swfobject.embedSWF("../open-flash-chart.swf?r="+ Math.random() * 100000,header.id, "550", "400", "9.0.0"); }
2.test.html中的内容如下:
<html> <head> <script type="text/javascript" src="../js/json/json2.js"></script> <script type="text/javascript" src="../js/swfobject.js"></script> <script type="text/javascript" src="common.js"></script> </head> <body> <div id="my_chart"></div> <div id="my_chart2"></div> <script type="text/javascript"> var json={"values":[ {"date":"2001","value":"22"}, {"date":"2002","value":"32"}, {"date":"2003","value":"52"}, {"date":"2004","value":"72"} ]} var header={"title":"bar-chart","id":"my_chart"}; var header2={"title":"line-chart","id":"my_chart2"}; var col={"x":"日期","y":"访问量"}; createChart(json,header,col,"bar"); //alert("aaaa"); createChart(json,header2,col,"line"); </script> </body> </html>
因刚刚测试,故没有把json数据传入呢,暂时使用同样的数据。可是为什么两个图表显示的都是第二个图表的样式呢?不是应该一个bar图,一个line图的么?求高手解答