From: <jh...@us...> - 2009-02-06 17:39:50
|
Revision: 69 http://etch.svn.sourceforge.net/etch/?rev=69&view=rev Author: jheiss Date: 2009-02-06 17:39:44 +0000 (Fri, 06 Feb 2009) Log Message: ----------- Add the open_flash_chart plugin. http://www.pullmonkey.com/projects/open_flash_chart2/ Added Paths: ----------- trunk/server/public/javascripts/swfobject.js trunk/server/public/open-flash-chart.swf trunk/server/vendor/plugins/open_flash_chart/ trunk/server/vendor/plugins/open_flash_chart/MIT-LICENSE trunk/server/vendor/plugins/open_flash_chart/README trunk/server/vendor/plugins/open_flash_chart/Rakefile trunk/server/vendor/plugins/open_flash_chart/assets/ trunk/server/vendor/plugins/open_flash_chart/assets/javascripts/ trunk/server/vendor/plugins/open_flash_chart/assets/javascripts/swfobject.js trunk/server/vendor/plugins/open_flash_chart/assets/open-flash-chart.swf trunk/server/vendor/plugins/open_flash_chart/init.rb trunk/server/vendor/plugins/open_flash_chart/install.rb trunk/server/vendor/plugins/open_flash_chart/lib/ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/area_base.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/area_hollow.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/area_line.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_3d.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_base.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_filled.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_glass.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_sketch.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_stack.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/base.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/candle.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/chart.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/h_bar.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/line.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/line_base.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/line_dot.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/line_hollow.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/linear_regression.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/ofc_ajax.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/open_flash_chart_object.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/pie.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/radar_axis.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/radar_axis_labels.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/radar_spoke_labels.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/scatter.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/scatter_line.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/shape.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/title.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/tooltip.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/upload_image.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/x_axis.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/x_axis_label.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/x_axis_labels.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/x_legend.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/y_axis.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/y_axis_base.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/y_axis_right.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/y_legend.rb trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart.rb trunk/server/vendor/plugins/open_flash_chart/tasks/ trunk/server/vendor/plugins/open_flash_chart/tasks/open_flash_chart_tasks.rake trunk/server/vendor/plugins/open_flash_chart/test/ trunk/server/vendor/plugins/open_flash_chart/test/open_flash_chart_test.rb trunk/server/vendor/plugins/open_flash_chart/uninstall.rb Added: trunk/server/public/javascripts/swfobject.js =================================================================== --- trunk/server/public/javascripts/swfobject.js (rev 0) +++ trunk/server/public/javascripts/swfobject.js 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,5 @@ +/* SWFObject v2.0 <http://code.google.com/p/swfobject/> + Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis + This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> +*/ +var swfobject=function(){var Z="undefined",P="object",B="Shockwave Flash",h="ShockwaveFlash.ShockwaveFlash",W="application/x-shockwave-flash",K="SWFObjectExprInst",G=window,g=document,N=navigator,f=[],H=[],Q=null,L=null,T=null,S=false,C=false;var a=function(){var l=typeof g.getElementById!=Z&&typeof g.getElementsByTagName!=Z&&typeof g.createElement!=Z&&typeof g.appendChild!=Z&&typeof g.replaceChild!=Z&&typeof g.removeChild!=Z&&typeof g.cloneNode!=Z,t=[0,0,0],n=null;if(typeof N.plugins!=Z&&typeof N.plugins[B]==P){n=N.plugins[B].description;if(n){n=n.replace(/^.*\s+(\S+\s+\S+$)/,"$1");t[0]=parseInt(n.replace(/^(.*)\..*$/,"$1"),10);t[1]=parseInt(n.replace(/^.*\.(.*)\s.*$/,"$1"),10);t[2]=/r/.test(n)?parseInt(n.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof G.ActiveXObject!=Z){var o=null,s=false;try{o=new ActiveXObject(h+".7")}catch(k){try{o=new ActiveXObject(h+".6");t=[6,0,21];o.AllowScriptAccess="always"}catch(k){if(t[0]==6){s=true}}if(!s){try{o=new ActiveXObject(h)}catch(k){}}}if(!s&&o){try{n=o.GetVariable("$version");if(n){n=n.split(" ")[1].split(",");t=[parseInt(n[0],10),parseInt(n[1],10),parseInt(n[2],10)]}}catch(k){}}}}var v=N.userAgent.toLowerCase(),j=N.platform.toLowerCase(),r=/webkit/.test(v)?parseFloat(v.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,i=false,q=j?/win/.test(j):/win/.test(v),m=j?/mac/.test(j):/mac/.test(v);/*@cc_on i=true;@if(@_win32)q=true;@elif(@_mac)m=true;@end@*/return{w3cdom:l,pv:t,webkit:r,ie:i,win:q,mac:m}}();var e=function(){if(!a.w3cdom){return }J(I);if(a.ie&&a.win){try{g.write("<script id=__ie_ondomload defer=true src=//:><\/script>");var i=c("__ie_ondomload");if(i){i.onreadystatechange=function(){if(this.readyState=="complete"){this.parentNode.removeChild(this);V()}}}}catch(j){}}if(a.webkit&&typeof g.readyState!=Z){Q=setInterval(function(){if(/loaded|complete/.test(g.readyState)){V()}},10)}if(typeof g.addEventListener!=Z){g.addEventListener("DOMContentLoaded",V,null)}M(V)}();function V(){if(S){return }if(a.ie&&a.win){var m=Y("span");try{var l=g.getElementsByTagName("body")[0].appendChild(m);l.parentNode.removeChild(l)}catch(n){return }}S=true;if(Q){clearInterval(Q);Q=null}var j=f.length;for(var k=0;k<j;k++){f[k]()}}function J(i){if(S){i()}else{f[f.length]=i}}function M(j){if(typeof G.addEventListener!=Z){G.addEventListener("load",j,false)}else{if(typeof g.addEventListener!=Z){g.addEventListener("load",j,false)}else{if(typeof G.attachEvent!=Z){G.attachEvent("onload",j)}else{if(typeof G.onload=="function"){var i=G.onload;G.onload=function(){i();j()}}else{G.onload=j}}}}}function I(){var l=H.length;for(var j=0;j<l;j++){var m=H[j].id;if(a.pv[0]>0){var k=c(m);if(k){H[j].width=k.getAttribute("width")?k.getAttribute("width"):"0";H[j].height=k.getAttribute("height")?k.getAttribute("height"):"0";if(O(H[j].swfVersion)){if(a.webkit&&a.webkit<312){U(k)}X(m,true)}else{if(H[j].expressInstall&&!C&&O("6.0.65")&&(a.win||a.mac)){D(H[j])}else{d(k)}}}}else{X(m,true)}}}function U(m){var k=m.getElementsByTagName(P)[0];if(k){var p=Y("embed"),r=k.attributes;if(r){var o=r.length;for(var n=0;n<o;n++){if(r[n].nodeName.toLowerCase()=="data"){p.setAttribute("src",r[n].nodeValue)}else{p.setAttribute(r[n].nodeName,r[n].nodeValue)}}}var q=k.childNodes;if(q){var s=q.length;for(var l=0;l<s;l++){if(q[l].nodeType==1&&q[l].nodeName.toLowerCase()=="param"){p.setAttribute(q[l].getAttribute("name"),q[l].getAttribute("value"))}}}m.parentNode.replaceChild(p,m)}}function F(i){if(a.ie&&a.win&&O("8.0.0")){G.attachEvent("onunload",function(){var k=c(i);if(k){for(var j in k){if(typeof k[j]=="function"){k[j]=function(){}}}k.parentNode.removeChild(k)}})}}function D(j){C=true;var o=c(j.id);if(o){if(j.altContentId){var l=c(j.altContentId);if(l){L=l;T=j.altContentId}}else{L=b(o)}if(!(/%$/.test(j.width))&&parseInt(j.width,10)<310){j.width="310"}if(!(/%$/.test(j.height))&&parseInt(j.height,10)<137){j.height="137"}g.title=g.title.slice(0,47)+" - Flash Player Installation";var n=a.ie&&a.win?"ActiveX":"PlugIn",k=g.title,m="MMredirectURL="+G.location+"&MMplayerType="+n+"&MMdoctitle="+k,p=j.id;if(a.ie&&a.win&&o.readyState!=4){var i=Y("div");p+="SWFObjectNew";i.setAttribute("id",p);o.parentNode.insertBefore(i,o);o.style.display="none";G.attachEvent("onload",function(){o.parentNode.removeChild(o)})}R({data:j.expressInstall,id:K,width:j.width,height:j.height},{flashvars:m},p)}}function d(j){if(a.ie&&a.win&&j.readyState!=4){var i=Y("div");j.parentNode.insertBefore(i,j);i.parentNode.replaceChild(b(j),i);j.style.display="none";G.attachEvent("onload",function(){j.parentNode.removeChild(j)})}else{j.parentNode.replaceChild(b(j),j)}}function b(n){var m=Y("div");if(a.win&&a.ie){m.innerHTML=n.innerHTML}else{var k=n.getElementsByTagName(P)[0];if(k){var o=k.childNodes;if(o){var j=o.length;for(var l=0;l<j;l++){if(!(o[l].nodeType==1&&o[l].nodeName.toLowerCase()=="param")&&!(o[l].nodeType==8)){m.appendChild(o[l].cloneNode(true))}}}}}return m}function R(AE,AC,q){var p,t=c(q);if(typeof AE.id==Z){AE.id=q}if(a.ie&&a.win){var AD="";for(var z in AE){if(AE[z]!=Object.prototype[z]){if(z=="data"){AC.movie=AE[z]}else{if(z.toLowerCase()=="styleclass"){AD+=' class="'+AE[z]+'"'}else{if(z!="classid"){AD+=" "+z+'="'+AE[z]+'"'}}}}}var AB="";for(var y in AC){if(AC[y]!=Object.prototype[y]){AB+='<param name="'+y+'" value="'+AC[y]+'" />'}}t.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AD+">"+AB+"</object>";F(AE.id);p=c(AE.id)}else{if(a.webkit&&a.webkit<312){var AA=Y("embed");AA.setAttribute("type",W);for(var x in AE){if(AE[x]!=Object.prototype[x]){if(x=="data"){AA.setAttribute("src",AE[x])}else{if(x.toLowerCase()=="styleclass"){AA.setAttribute("class",AE[x])}else{if(x!="classid"){AA.setAttribute(x,AE[x])}}}}}for(var w in AC){if(AC[w]!=Object.prototype[w]){if(w!="movie"){AA.setAttribute(w,AC[w])}}}t.parentNode.replaceChild(AA,t);p=AA}else{var s=Y(P);s.setAttribute("type",W);for(var v in AE){if(AE[v]!=Object.prototype[v]){if(v.toLowerCase()=="styleclass"){s.setAttribute("class",AE[v])}else{if(v!="classid"){s.setAttribute(v,AE[v])}}}}for(var u in AC){if(AC[u]!=Object.prototype[u]&&u!="movie"){E(s,u,AC[u])}}t.parentNode.replaceChild(s,t);p=s}}return p}function E(k,i,j){var l=Y("param");l.setAttribute("name",i);l.setAttribute("value",j);k.appendChild(l)}function c(i){return g.getElementById(i)}function Y(i){return g.createElement(i)}function O(k){var j=a.pv,i=k.split(".");i[0]=parseInt(i[0],10);i[1]=parseInt(i[1],10);i[2]=parseInt(i[2],10);return(j[0]>i[0]||(j[0]==i[0]&&j[1]>i[1])||(j[0]==i[0]&&j[1]==i[1]&&j[2]>=i[2]))?true:false}function A(m,j){if(a.ie&&a.mac){return }var l=g.getElementsByTagName("head")[0],k=Y("style");k.setAttribute("type","text/css");k.setAttribute("media","screen");if(!(a.ie&&a.win)&&typeof g.createTextNode!=Z){k.appendChild(g.createTextNode(m+" {"+j+"}"))}l.appendChild(k);if(a.ie&&a.win&&typeof g.styleSheets!=Z&&g.styleSheets.length>0){var i=g.styleSheets[g.styleSheets.length-1];if(typeof i.addRule==P){i.addRule(m,j)}}}function X(k,i){var j=i?"visible":"hidden";if(S){c(k).style.visibility=j}else{A("#"+k,"visibility:"+j)}}return{registerObject:function(l,i,k){if(!a.w3cdom||!l||!i){return }var j={};j.id=l;j.swfVersion=i;j.expressInstall=k?k:false;H[H.length]=j;X(l,false)},getObjectById:function(l){var i=null;if(a.w3cdom&&S){var j=c(l);if(j){var k=j.getElementsByTagName(P)[0];if(!k||(k&&typeof j.SetVariable!=Z)){i=j}else{if(typeof k.SetVariable!=Z){i=k}}}}return i},embedSWF:function(n,u,r,t,j,m,k,p,s){if(!a.w3cdom||!n||!u||!r||!t||!j){return }r+="";t+="";if(O(j)){X(u,false);var q=(typeof s==P)?s:{};q.data=n;q.width=r;q.height=t;var o=(typeof p==P)?p:{};if(typeof k==P){for(var l in k){if(k[l]!=Object.prototype[l]){if(typeof o.flashvars!=Z){o.flashvars+="&"+l+"="+k[l]}else{o.flashvars=l+"="+k[l]}}}}J(function(){R(q,o,u);if(q.id==u){X(u,true)}})}else{if(m&&!C&&O("6.0.65")&&(a.win||a.mac)){X(u,false);J(function(){var i={};i.id=i.altContentId=u;i.width=r;i.height=t;i.expressInstall=m;D(i)})}}},getFlashPlayerVersion:function(){return{major:a.pv[0],minor:a.pv[1],release:a.pv[2]}},hasFlashPlayerVersion:O,createSWF:function(k,j,i){if(a.w3cdom&&S){return R(k,j,i)}else{return undefined}},createCSS:function(j,i){if(a.w3cdom){A(j,i)}},addDomLoadEvent:J,addLoadEvent:M,getQueryParamValue:function(m){var l=g.location.search||g.location.hash;if(m==null){return l}if(l){var k=l.substring(1).split("&");for(var j=0;j<k.length;j++){if(k[j].substring(0,k[j].indexOf("="))==m){return k[j].substring((k[j].indexOf("=")+1))}}}return""},expressInstallCallback:function(){if(C&&L){var i=c(K);if(i){i.parentNode.replaceChild(L,i);if(T){X(T,true);if(a.ie&&a.win){L.style.display="block"}}L=null;T=null;C=false}}}}}(); \ No newline at end of file Added: trunk/server/public/open-flash-chart.swf =================================================================== (Binary files differ) Property changes on: trunk/server/public/open-flash-chart.swf ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/server/vendor/plugins/open_flash_chart/MIT-LICENSE =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/MIT-LICENSE (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/MIT-LICENSE 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,20 @@ +Copyright (c) 2008 [name of plugin creator] + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Added: trunk/server/vendor/plugins/open_flash_chart/README =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/README (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/README 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,48 @@ +OpenFlashChart Version 2.0.0 11/14/2008 +============== + +1) rails ofc2_test_app +2) cd ofc2_test_app +3) script/plugin install git://github.com/pullmonkey/open_flash_chart.git +4) script/generate controller test_it + +5) Add the following to the test_it_controller.rb in RAILS_ROOT/app/controllers: +class TestItController < ApplicationController + + def index + respond_to do |wants| + wants.html { + @graph = open_flash_chart_object( 600, 300, url_for( :action => 'index', :format => :json ) ) + } + wants.json { + chart = OpenFlashChart.new( "MY TITLE" ) do |c| + c << BarGlass.new( :values => (1..10).sort_by{rand} ) + end + render :text => chart, :layout => false + } + end + end + +end + +6) Add the following to index.html.erb in RAILS_ROOT/app/views/test_it/: +<html> +<head> + <script type="text/javascript" src="/javascripts/swfobject.js"></script> +</head> +<body> +<%= @graph %> +</body> +</html> + +7) script/server +8) Let me know how it goes, thanks. + + +Example +======= + +Example above and more to follow here - http://www.pullmonkey.com/projects/open_flash_chart + + +Copyright (c) 2008 PullMonkey, released under the MIT license Added: trunk/server/vendor/plugins/open_flash_chart/Rakefile =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/Rakefile (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/Rakefile 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,22 @@ +require 'rake' +require 'rake/testtask' +require 'rake/rdoctask' + +desc 'Default: run unit tests.' +task :default => :test + +desc 'Test the open_flash_chart plugin.' +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.pattern = 'test/**/*_test.rb' + t.verbose = true +end + +desc 'Generate documentation for the open_flash_chart plugin.' +Rake::RDocTask.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'OpenFlashChart' + rdoc.options << '--line-numbers' << '--inline-source' + rdoc.rdoc_files.include('README') + rdoc.rdoc_files.include('lib/**/*.rb') +end Added: trunk/server/vendor/plugins/open_flash_chart/assets/javascripts/swfobject.js =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/assets/javascripts/swfobject.js (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/assets/javascripts/swfobject.js 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,5 @@ +/* SWFObject v2.0 <http://code.google.com/p/swfobject/> + Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis + This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> +*/ +var swfobject=function(){var Z="undefined",P="object",B="Shockwave Flash",h="ShockwaveFlash.ShockwaveFlash",W="application/x-shockwave-flash",K="SWFObjectExprInst",G=window,g=document,N=navigator,f=[],H=[],Q=null,L=null,T=null,S=false,C=false;var a=function(){var l=typeof g.getElementById!=Z&&typeof g.getElementsByTagName!=Z&&typeof g.createElement!=Z&&typeof g.appendChild!=Z&&typeof g.replaceChild!=Z&&typeof g.removeChild!=Z&&typeof g.cloneNode!=Z,t=[0,0,0],n=null;if(typeof N.plugins!=Z&&typeof N.plugins[B]==P){n=N.plugins[B].description;if(n){n=n.replace(/^.*\s+(\S+\s+\S+$)/,"$1");t[0]=parseInt(n.replace(/^(.*)\..*$/,"$1"),10);t[1]=parseInt(n.replace(/^.*\.(.*)\s.*$/,"$1"),10);t[2]=/r/.test(n)?parseInt(n.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof G.ActiveXObject!=Z){var o=null,s=false;try{o=new ActiveXObject(h+".7")}catch(k){try{o=new ActiveXObject(h+".6");t=[6,0,21];o.AllowScriptAccess="always"}catch(k){if(t[0]==6){s=true}}if(!s){try{o=new ActiveXObject(h)}catch(k){}}}if(!s&&o){try{n=o.GetVariable("$version");if(n){n=n.split(" ")[1].split(",");t=[parseInt(n[0],10),parseInt(n[1],10),parseInt(n[2],10)]}}catch(k){}}}}var v=N.userAgent.toLowerCase(),j=N.platform.toLowerCase(),r=/webkit/.test(v)?parseFloat(v.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,i=false,q=j?/win/.test(j):/win/.test(v),m=j?/mac/.test(j):/mac/.test(v);/*@cc_on i=true;@if(@_win32)q=true;@elif(@_mac)m=true;@end@*/return{w3cdom:l,pv:t,webkit:r,ie:i,win:q,mac:m}}();var e=function(){if(!a.w3cdom){return }J(I);if(a.ie&&a.win){try{g.write("<script id=__ie_ondomload defer=true src=//:><\/script>");var i=c("__ie_ondomload");if(i){i.onreadystatechange=function(){if(this.readyState=="complete"){this.parentNode.removeChild(this);V()}}}}catch(j){}}if(a.webkit&&typeof g.readyState!=Z){Q=setInterval(function(){if(/loaded|complete/.test(g.readyState)){V()}},10)}if(typeof g.addEventListener!=Z){g.addEventListener("DOMContentLoaded",V,null)}M(V)}();function V(){if(S){return }if(a.ie&&a.win){var m=Y("span");try{var l=g.getElementsByTagName("body")[0].appendChild(m);l.parentNode.removeChild(l)}catch(n){return }}S=true;if(Q){clearInterval(Q);Q=null}var j=f.length;for(var k=0;k<j;k++){f[k]()}}function J(i){if(S){i()}else{f[f.length]=i}}function M(j){if(typeof G.addEventListener!=Z){G.addEventListener("load",j,false)}else{if(typeof g.addEventListener!=Z){g.addEventListener("load",j,false)}else{if(typeof G.attachEvent!=Z){G.attachEvent("onload",j)}else{if(typeof G.onload=="function"){var i=G.onload;G.onload=function(){i();j()}}else{G.onload=j}}}}}function I(){var l=H.length;for(var j=0;j<l;j++){var m=H[j].id;if(a.pv[0]>0){var k=c(m);if(k){H[j].width=k.getAttribute("width")?k.getAttribute("width"):"0";H[j].height=k.getAttribute("height")?k.getAttribute("height"):"0";if(O(H[j].swfVersion)){if(a.webkit&&a.webkit<312){U(k)}X(m,true)}else{if(H[j].expressInstall&&!C&&O("6.0.65")&&(a.win||a.mac)){D(H[j])}else{d(k)}}}}else{X(m,true)}}}function U(m){var k=m.getElementsByTagName(P)[0];if(k){var p=Y("embed"),r=k.attributes;if(r){var o=r.length;for(var n=0;n<o;n++){if(r[n].nodeName.toLowerCase()=="data"){p.setAttribute("src",r[n].nodeValue)}else{p.setAttribute(r[n].nodeName,r[n].nodeValue)}}}var q=k.childNodes;if(q){var s=q.length;for(var l=0;l<s;l++){if(q[l].nodeType==1&&q[l].nodeName.toLowerCase()=="param"){p.setAttribute(q[l].getAttribute("name"),q[l].getAttribute("value"))}}}m.parentNode.replaceChild(p,m)}}function F(i){if(a.ie&&a.win&&O("8.0.0")){G.attachEvent("onunload",function(){var k=c(i);if(k){for(var j in k){if(typeof k[j]=="function"){k[j]=function(){}}}k.parentNode.removeChild(k)}})}}function D(j){C=true;var o=c(j.id);if(o){if(j.altContentId){var l=c(j.altContentId);if(l){L=l;T=j.altContentId}}else{L=b(o)}if(!(/%$/.test(j.width))&&parseInt(j.width,10)<310){j.width="310"}if(!(/%$/.test(j.height))&&parseInt(j.height,10)<137){j.height="137"}g.title=g.title.slice(0,47)+" - Flash Player Installation";var n=a.ie&&a.win?"ActiveX":"PlugIn",k=g.title,m="MMredirectURL="+G.location+"&MMplayerType="+n+"&MMdoctitle="+k,p=j.id;if(a.ie&&a.win&&o.readyState!=4){var i=Y("div");p+="SWFObjectNew";i.setAttribute("id",p);o.parentNode.insertBefore(i,o);o.style.display="none";G.attachEvent("onload",function(){o.parentNode.removeChild(o)})}R({data:j.expressInstall,id:K,width:j.width,height:j.height},{flashvars:m},p)}}function d(j){if(a.ie&&a.win&&j.readyState!=4){var i=Y("div");j.parentNode.insertBefore(i,j);i.parentNode.replaceChild(b(j),i);j.style.display="none";G.attachEvent("onload",function(){j.parentNode.removeChild(j)})}else{j.parentNode.replaceChild(b(j),j)}}function b(n){var m=Y("div");if(a.win&&a.ie){m.innerHTML=n.innerHTML}else{var k=n.getElementsByTagName(P)[0];if(k){var o=k.childNodes;if(o){var j=o.length;for(var l=0;l<j;l++){if(!(o[l].nodeType==1&&o[l].nodeName.toLowerCase()=="param")&&!(o[l].nodeType==8)){m.appendChild(o[l].cloneNode(true))}}}}}return m}function R(AE,AC,q){var p,t=c(q);if(typeof AE.id==Z){AE.id=q}if(a.ie&&a.win){var AD="";for(var z in AE){if(AE[z]!=Object.prototype[z]){if(z=="data"){AC.movie=AE[z]}else{if(z.toLowerCase()=="styleclass"){AD+=' class="'+AE[z]+'"'}else{if(z!="classid"){AD+=" "+z+'="'+AE[z]+'"'}}}}}var AB="";for(var y in AC){if(AC[y]!=Object.prototype[y]){AB+='<param name="'+y+'" value="'+AC[y]+'" />'}}t.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AD+">"+AB+"</object>";F(AE.id);p=c(AE.id)}else{if(a.webkit&&a.webkit<312){var AA=Y("embed");AA.setAttribute("type",W);for(var x in AE){if(AE[x]!=Object.prototype[x]){if(x=="data"){AA.setAttribute("src",AE[x])}else{if(x.toLowerCase()=="styleclass"){AA.setAttribute("class",AE[x])}else{if(x!="classid"){AA.setAttribute(x,AE[x])}}}}}for(var w in AC){if(AC[w]!=Object.prototype[w]){if(w!="movie"){AA.setAttribute(w,AC[w])}}}t.parentNode.replaceChild(AA,t);p=AA}else{var s=Y(P);s.setAttribute("type",W);for(var v in AE){if(AE[v]!=Object.prototype[v]){if(v.toLowerCase()=="styleclass"){s.setAttribute("class",AE[v])}else{if(v!="classid"){s.setAttribute(v,AE[v])}}}}for(var u in AC){if(AC[u]!=Object.prototype[u]&&u!="movie"){E(s,u,AC[u])}}t.parentNode.replaceChild(s,t);p=s}}return p}function E(k,i,j){var l=Y("param");l.setAttribute("name",i);l.setAttribute("value",j);k.appendChild(l)}function c(i){return g.getElementById(i)}function Y(i){return g.createElement(i)}function O(k){var j=a.pv,i=k.split(".");i[0]=parseInt(i[0],10);i[1]=parseInt(i[1],10);i[2]=parseInt(i[2],10);return(j[0]>i[0]||(j[0]==i[0]&&j[1]>i[1])||(j[0]==i[0]&&j[1]==i[1]&&j[2]>=i[2]))?true:false}function A(m,j){if(a.ie&&a.mac){return }var l=g.getElementsByTagName("head")[0],k=Y("style");k.setAttribute("type","text/css");k.setAttribute("media","screen");if(!(a.ie&&a.win)&&typeof g.createTextNode!=Z){k.appendChild(g.createTextNode(m+" {"+j+"}"))}l.appendChild(k);if(a.ie&&a.win&&typeof g.styleSheets!=Z&&g.styleSheets.length>0){var i=g.styleSheets[g.styleSheets.length-1];if(typeof i.addRule==P){i.addRule(m,j)}}}function X(k,i){var j=i?"visible":"hidden";if(S){c(k).style.visibility=j}else{A("#"+k,"visibility:"+j)}}return{registerObject:function(l,i,k){if(!a.w3cdom||!l||!i){return }var j={};j.id=l;j.swfVersion=i;j.expressInstall=k?k:false;H[H.length]=j;X(l,false)},getObjectById:function(l){var i=null;if(a.w3cdom&&S){var j=c(l);if(j){var k=j.getElementsByTagName(P)[0];if(!k||(k&&typeof j.SetVariable!=Z)){i=j}else{if(typeof k.SetVariable!=Z){i=k}}}}return i},embedSWF:function(n,u,r,t,j,m,k,p,s){if(!a.w3cdom||!n||!u||!r||!t||!j){return }r+="";t+="";if(O(j)){X(u,false);var q=(typeof s==P)?s:{};q.data=n;q.width=r;q.height=t;var o=(typeof p==P)?p:{};if(typeof k==P){for(var l in k){if(k[l]!=Object.prototype[l]){if(typeof o.flashvars!=Z){o.flashvars+="&"+l+"="+k[l]}else{o.flashvars=l+"="+k[l]}}}}J(function(){R(q,o,u);if(q.id==u){X(u,true)}})}else{if(m&&!C&&O("6.0.65")&&(a.win||a.mac)){X(u,false);J(function(){var i={};i.id=i.altContentId=u;i.width=r;i.height=t;i.expressInstall=m;D(i)})}}},getFlashPlayerVersion:function(){return{major:a.pv[0],minor:a.pv[1],release:a.pv[2]}},hasFlashPlayerVersion:O,createSWF:function(k,j,i){if(a.w3cdom&&S){return R(k,j,i)}else{return undefined}},createCSS:function(j,i){if(a.w3cdom){A(j,i)}},addDomLoadEvent:J,addLoadEvent:M,getQueryParamValue:function(m){var l=g.location.search||g.location.hash;if(m==null){return l}if(l){var k=l.substring(1).split("&");for(var j=0;j<k.length;j++){if(k[j].substring(0,k[j].indexOf("="))==m){return k[j].substring((k[j].indexOf("=")+1))}}}return""},expressInstallCallback:function(){if(C&&L){var i=c(K);if(i){i.parentNode.replaceChild(L,i);if(T){X(T,true);if(a.ie&&a.win){L.style.display="block"}}L=null;T=null;C=false}}}}}(); \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/assets/open-flash-chart.swf =================================================================== (Binary files differ) Property changes on: trunk/server/vendor/plugins/open_flash_chart/assets/open-flash-chart.swf ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/server/vendor/plugins/open_flash_chart/init.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/init.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/init.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,9 @@ +require 'open_flash_chart' + +ActionView::Base.send :include, OpenFlashChart::View +OpenFlashChart::Base.send :include, OpenFlashChart::View +ActionController::Base.send :include, OpenFlashChart::Controller +ActionController::Base.send :include, OpenFlashChart +ActiveRecord::Base.send :include, OpenFlashChart::View +ActiveRecord::Base.send :include, OpenFlashChart::Controller +ActiveRecord::Base.send :include, OpenFlashChart \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/install.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/install.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/install.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,17 @@ +# Workaround a problem with script/plugin and http-based repos. +# See http://dev.rubyonrails.org/ticket/8189 +Dir.chdir(Dir.getwd.sub(/vendor.*/, '')) do + + ## + ## Copy over asset files (javascript/css/images) from the plugin directory to public/ + ## + + def copy_files(source_path, destination_path, directory) + source, destination = File.join(directory, source_path), File.join(RAILS_ROOT, destination_path) + # FileUtils.mkdir(destination) unless File.exist?(destination) + FileUtils.cp_r(Dir.glob(source+'/*.*'), destination) + end + + directory = File.dirname(__FILE__) + copy_files("/assets", "/public", directory) +end Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/area_base.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/area_base.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/area_base.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,17 @@ +module OpenFlashChart + class AreaBase < Base + def initialize args={} + super + @fill_alpha = 0.35 + @values = [] + end + + def set_fill_colour(color) + @fill = color + end + + def set_loop + @loop = true + end + end +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/area_hollow.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/area_hollow.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/area_hollow.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,10 @@ +module OpenFlashChart + + class AreaHollow < AreaBase + def initialize args={} + super + @type = "area_hollow" + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/area_line.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/area_line.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/area_line.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,10 @@ +module OpenFlashChart + + class AreaLine < AreaBase + def initialize args={} + super + @type = "area_line" + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,18 @@ +module OpenFlashChart + + class Bar < BarBase + def initialize args={} + super + @type = "bar" + end + end + + class BarValue < Base + def initialize( top, bottom=nil, args={} ) + @top = top + @bottom = bottom + super args + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_3d.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_3d.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_3d.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,17 @@ +module OpenFlashChart + + class Bar3d < BarBase + def initialize args={} + super + @type = "bar_3d" + end + end + + class Bar3dValue < Base + def initialize(top, args={}) + @top = top + super args + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_base.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_base.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_base.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,3 @@ +module OpenFlashChart + class BarBase < Base; end +end Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_filled.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_filled.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_filled.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,18 @@ +module OpenFlashChart + + class BarFilled < BarBase + def initialize(colour=nil, outline_colour=nil, args={}) + super args + @type = "bar_filled" + @colour = colour + @outline_colour = outline_colour + end + end + + class BarFilledValue < BarValue + def initialize(top, bottom=nil, args={}) + super + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_glass.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_glass.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_glass.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,17 @@ +module OpenFlashChart + + class BarGlass < BarBase + def initialize args={} + super + @type = "bar_glass" + end + end + + class BarGlassValue < Base + def initialize(top, args={}) + @top = top + super args + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_sketch.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_sketch.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_sketch.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,13 @@ +module OpenFlashChart + + class BarSketch < BarBase + def initialize(colour, outline_colour, fun_factor, args = {} ) + super args + @type = "bar_sketch" + @colour = colour + @outline_colour = outline_colour + @offset = fun_factor + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_stack.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_stack.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/bar_stack.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,20 @@ +module OpenFlashChart + + class BarStack < BarBase + def initialize args={} + super + @type = "bar_stack" + end + + alias_method :append_stack, :append_value + end + + class BarStackValue < Base + def initialize(val,colour, args={}) + @val = val + @colour = colour + super + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/base.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/base.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/base.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,102 @@ +module OpenFlashChart + class Base + + def initialize(args={}) + # set all the instance variables we want + # assuming something like this OpenFlashChart.new(:x_axis => 5, :y_axis => 10, :elements => ["one", "two"], ...) + args.each do |k,v| + self.instance_variable_set("@#{k}", v) + end + yield self if block_given? # magic pen pattern + end + + # same as to_s but won't stack overflow ... use this instead of to_s + def render + # need to return the following like this + # 1) font_size as font-size + # 2) dot_size as dot-size + # 3) outline_colour as outline-colour + # 4) halo_size as halo-size + # 5) start_angle as start-angle + # 6) tick_height as tick-height + # 7) grid_colour as grid-colour + # 8) threed as 3d + # 9) tick_length as tick-length + returning self.to_json2 do |output| + output.gsub!("threed","3d") + %w(font_size dot_size outline_colour halo_size start_angle tick_height grid_colour tick_length no_labels label_colour gradient_fill fill_alpha on_click spoke_labels).each do |replace| + output.gsub!(replace, replace.gsub("_", "-")) + end + end + end + + def to_json2 + self.instance_values.to_json + end + + alias_method :to_s, :render + + def add_element(element) + @elements ||= [] + @elements << element + end + + def <<(e) + add_element e + end + + def set_key(text, size) + @text = text + @font_size = size + end + + def append_value(v) + @values ||= [] + @values << v + end + + def set_range(min,max,steps=1) + @min = min + @max = max + @steps = steps + end + + def set_offset(v) + @offset = v ? true : false + end + + def set_colours(colour, grid_colour) + @colour = colour + @grid_colour = grid_colour + end + + def set_tooltip(tip) + if tip.is_a?(Tooltip) + #we have a style for our chart's tooltips + @tooltip = tip + else + # the user could just use set_tip(tip) or tip=(tip) to just set the text of the tooltip + @tip = tip + end + end + alias_method "tooltip=", :set_tooltip + + + + def method_missing(method_name, *args, &blk) + case method_name.to_s + when /(.*)=/ # i.e., if it is something x_legend= + # if the user wants to set an instance variable then let them + # the other args (args[0]) are ignored since it is a set method + self.instance_variable_set("@#{$1}", args[0]) + when /^set_(.*)/ + # backwards compatible ... the user can still use the same set_y_legend methods if they want + self.instance_variable_set("@#{$1}", args[0]) + else + # if the method/attribute is missing and it is not a set method then hmmmm better let the user know + super + end + end + + end +end Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/candle.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/candle.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/candle.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,20 @@ +module OpenFlashChart + + class Candle < Base + def initialize(args={}) + super args + @type = "candle" + end + end + + class CandleValue < Base + def initialize( top, bottom, low, high, args={} ) + @top = top + @bottom = bottom + @low = low + @high = high + super args + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/chart.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/chart.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/chart.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,13 @@ +module OpenFlashChart + + class Chart < Base + def initialize( title=nil, args={}) + super args + @title = Title.new( title ) if title + end + end + + class OpenFlashChart < Chart + end + +end Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/h_bar.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/h_bar.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/h_bar.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,26 @@ +module OpenFlashChart + + class HBarValue < Base + def initialize(left,right=nil, args={}) + super args + @left = left + @right = right || left + end + end + + class HBar < Base + def initialize(colour="#9933CC", args={}) + super args + @type = "hbar" + @colour = colour + @values = [] + end + + def set_values(v) + v.each do |val| + append_value(HBarValue.new(val)) + end + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/line.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/line.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/line.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,10 @@ +module OpenFlashChart + + class Line < LineBase + def initialize args={} + super + @type = "line" + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/line_base.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/line_base.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/line_base.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,17 @@ +module OpenFlashChart + + class LineBase < Base + def initialize args={} + super + @type = "line_dot" + @text = "Page Views" + @font_size = 10 + @values = [9,6,7,9,5,7,6,9,7] + end + + def loop + @loop = true + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/line_dot.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/line_dot.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/line_dot.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,17 @@ +module OpenFlashChart + + class LineDot < LineBase + def initialize args={} + super + @type = "line_dot" + end + end + + class DotValue < Base + def initialize(value, colour, args={}) + @value = value + @colour = colour + super(args) + end + end +end Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/line_hollow.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/line_hollow.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/line_hollow.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,10 @@ +module OpenFlashChart + + class LineHollow < LineBase + def initialize args={} + super + @type = "line_hollow" + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/linear_regression.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/linear_regression.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/linear_regression.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,39 @@ +# by David Lowenfels @ InternautDesign.com +# example usage: fitted_data = LinearRegression.new(data).fit + +class LinearRegression + attr_accessor :slope, :offset + + def initialize dx, dy=nil + @size = dx.size + if @size == 1 + @slope, @offset = 1,0 + return + end + dy,dx = dx,axis() unless dy # make 2D if given 1D + raise "arguments not same length!" unless @size == dy.size + sxx = sxy = sx = sy = 0 + dx.zip(dy).each do |x,y| + sxy += x*y + sxx += x*x + sx += x + sy += y + end + @slope = ( @size * sxy - sx*sy ) / ( @size * sxx - sx * sx ) + @offset = (sy - @slope*sx) / @size + end + + def fit + return axis.map{|data| predict(data) } + end + + private + + def predict( x ) + y = @slope * x + @offset + end + + def axis + (0...@size).to_a + end +end Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/ofc_ajax.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/ofc_ajax.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/ofc_ajax.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,90 @@ +module OpenFlashChart + module View + def periodically_call_function(function, options = {}) + frequency = options[:frequency] || 10 # every ten seconds by default + code = "new PeriodicalExecuter(function() {#{function}}, #{frequency})" + ActionView::Base.new.javascript_tag(code) + end + + def js_open_flash_chart_object(div_name, width, height, base="/") + <<-OUTPUT + <script type="text/javascript"> + swfobject.embedSWF("#{base}open-flash-chart.swf", "#{div_name}", "#{width}", "#{height}", "9.0.0"); + </script> + #{self.to_open_flash_chart_data} + <div id="#{div_name}"></div> + OUTPUT + end + + def link_to_ofc_load(link_text, div_name) + data_name = "#{link_text.gsub(" ","_")}_#{div_name.gsub(" ","_")}" + <<-OUTPUT + <script type="text/javascript"> + function load_#{data_name}() { + tmp_#{div_name} = findSWF("#{div_name}"); + x = tmp_#{div_name}.load(Object.toJSON(data_#{data_name})); + } + var data_#{data_name} = #{self.render}; + </script> + #{ActionView::Base.new.link_to_function link_text, "load_#{data_name}()"} + OUTPUT + end + + def link_to_remote_ofc_load(link_text, div_name, url) + fx_name = "#{link_text.gsub(" ","_")}_#{div_name.gsub(" ","_")}" + <<-OUTPUT + <script type="text/javascript"> + function reload_#{fx_name}() { + tmp_#{div_name} = findSWF("#{div_name}"); + new Ajax.Request('#{url}', { + method : 'get', + onSuccess : function(obj) {tmp_#{div_name}.load(obj.responseText);}, + onFailure : function(obj) {alert("Failed to request #{url}");}}); + } + </script> + #{ActionView::Base.new.link_to_function link_text, "reload_#{fx_name}()"} + OUTPUT + end + + def periodically_call_to_remote_ofc_load(div_name, url, options={}) + fx_name = "#{div_name.gsub(" ","_")}" + # fix a bug in rails with url_for + url = url.gsub("&","&") + <<-OUTPUT + <script type="text/javascript"> + function reload_#{fx_name}() { + tmp_#{div_name} = findSWF("#{div_name}"); + new Ajax.Request('#{url}', { + method : 'get', + onSuccess : function(obj) {tmp_#{div_name}.load(obj.responseText);}, + onFailure : function(obj) {alert("Failed to request #{url}");}}); + } + </script> + #{periodically_call_function("reload_#{fx_name}()", options)} + OUTPUT + end + + + def to_open_flash_chart_data + # this builds the open_flash_chart_data js function + <<-OUTPUT + <script type="text/javascript"> + function ofc_ready() { + } + function open_flash_chart_data() { + return Object.toJSON(data); + } + function findSWF(movieName) { + if (navigator.appName.indexOf("Microsoft")!= -1) { + return window[movieName]; + } else { + return document[movieName]; + } + } + var data = #{self.render}; + </script> + OUTPUT + end + + end +end Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/open_flash_chart_object.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/open_flash_chart_object.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/open_flash_chart_object.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,36 @@ +require 'digest/sha1' + +module OpenFlashChart + module Controller + def open_flash_chart_object(width, height, url, use_swfobject=true, base="/") + url = CGI::escape(url) + # need something that will not be repeated on the same request + special_hash = Base64.encode64(Digest::SHA1.digest("#{rand(1<<64)}/#{Time.now.to_f}/#{Process.pid}/#{url}"))[0..7] + # only good characters for our div + special_hash = special_hash.gsub(/[^a-zA-Z0-9]/,rand(10).to_s) + obj_id = "chart_#{special_hash}" # some sequencing without all the work of tracking it + div_name = "flash_content_#{special_hash}" + protocol = "http" # !request.nil? ? request.env["HTTPS"] || "http" : "http" + + # NOTE: users should put this in the <head> section themselves: + ## <script type="text/javascript" src="#{base}/javascripts/swfobject.js"></script> + + <<-HTML + <div id="#{div_name}"></div> + <script type="text/javascript"> + swfobject.embedSWF("#{base}open-flash-chart.swf", "#{div_name}", "#{width}", "#{height}", "9.0.0", "expressInstall.swf",{"data-file":"#{url}"}, {"wmode":"transparent"}); + </script> + <noscript> + <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="#{protocol}://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="#{width}" height="#{height}" id="#{obj_id}" align="middle" wmode="transparent"> + <param name="allowScriptAccess" value="sameDomain" /> + <param name="movie" value="#{base}open-flash-chart.swf?data=#{url}" /> + <param name="quality" value="high" /> + <param name="bgcolor" value="#FFFFFF" /> + <embed src="#{base}open-flash-chart.swf?data=#{url}" quality="high" bgcolor="#FFFFFF" width="#{width}" height="#{height}" name="#{obj_id}" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="#{protocol}://www.macromedia.com/go/getflashplayer" id="#{obj_id}" /> + </object> + </noscript> + HTML + end + end + +end Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/pie.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/pie.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/pie.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,38 @@ +module OpenFlashChart + + class PieValue < Base + def initialize(value, label, args={}) + super args + @value = value + @label = label + end + + def set_label(label, label_color, font_size) + self.label = label + self.label_colour = label_color + self.font_size = font_size + end + + def on_click(event) + @on_click = event + end + end + + class Pie < Base + def initialize args={} + @type = "pie" + @colours = ["#d01f3c","#356aa0","#C79810"] + @border = 2 + super + end + + def set_no_labels + self.no_labels = true + end + + def on_click(event) + @on_click = event + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/radar_axis.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/radar_axis.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/radar_axis.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,10 @@ +module OpenFlashChart + + class RadarAxis < Base + def initialize(max, args={}) + super args + @max = max + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/radar_axis_labels.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/radar_axis_labels.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/radar_axis_labels.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,10 @@ +module OpenFlashChart + + class RadarAxisLabels < Base + def initialize(labels, args={}) + super args + @labels = labels + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/radar_spoke_labels.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/radar_spoke_labels.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/radar_spoke_labels.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,10 @@ +module OpenFlashChart + + class RadarSpokeLabels < Base + def initialize(labels, args={}) + super args + @labels = labels + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/scatter.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/scatter.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/scatter.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,21 @@ +module OpenFlashChart + + class ScatterValue < Base + def initialize(x,y,dot_size=nil, args={}) + super args + @x = x + @y = y + @dot_size = dot_size if dot_size.to_i > 0 + end + end + + class Scatter < Base + def initialize(colour, dot_size, args={}) + @type = "scatter" + @colour = colour + @dot_size = dot_size + super args + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/scatter_line.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/scatter_line.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/scatter_line.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,12 @@ +module OpenFlashChart + + class ScatterLine < Base + def initialize(colour, dot_size, args={}) + super args + @type = 'scatter_line' + @colour = colour + @dot_size = dot_size + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/shape.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/shape.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/shape.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,20 @@ +module OpenFlashChart + + class ShapePoint < Base + def initialize(x, y, args={}) + super args + @x = x + @y = y + end + end + + class Shape < Base + def initialize(colour, args={}) + @type = "shape" + @colour = colour + @values = [] + super args + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/title.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/title.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/title.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,10 @@ +module OpenFlashChart + + class Title < Base + def initialize(text='', args = {}) + super args + @text = text + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/tooltip.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/tooltip.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/tooltip.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,25 @@ +module OpenFlashChart + + class Tooltip < Base + def set_body_style(style) + @body = style + end + + def set_title_style(style) + @title = style + end + + def set_background_colour(bg) + @background = bg + end + + def set_proximity + @mouse = 1 + end + + def set_hover + @mouse = 2 + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/upload_image.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/upload_image.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/upload_image.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1 @@ +# TODO Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/x_axis.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/x_axis.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/x_axis.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,18 @@ +module OpenFlashChart + + class XAxis < Base + def set_3d(v) + @threed = v + end + # for some reason the json that needs to be produced is like this: + # "x_axis": { "offset": false, "labels": { "labels": [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] } } + # note the "labels":{"labels": ....} + def set_labels(labels) + @labels = labels + @labels = {:labels => labels} unless labels.is_a?(XAxisLabels) + end + + alias_method :labels=, :set_labels + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/x_axis_label.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/x_axis_label.rb (rev 0) +++ trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/x_axis_label.rb 2009-02-06 17:39:44 UTC (rev 69) @@ -0,0 +1,21 @@ +module OpenFlashChart + + class XAxisLabel < Base + def initialize(text, colour, size, rotate, args={}) + super args + @text = text + @colour = colour + @size = size + @rotate = rotate + end + + def set_vertical + @rotate = "vertical" + end + + def set_visible + @visible = true + end + end + +end \ No newline at end of file Added: trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/x_axis_labels.rb =================================================================== --- trunk/server/vendor/plugins/open_flash_chart/lib/open_flash_chart/x_axis_labels.rb ... [truncated message content] |