I was trying to use the fusioncharts in my application. So I decided why not create a plugin so that I can use it as a flash panel. Here is the code for the plugin:
Code:
Ext.ux.FlashPlugin = function() {
this.init = function(ct) {
ct.flashTemplate = new Ext.XTemplate(
'<div>',
'<object id="flash-{id}" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="{swfWidth}" height="{swfHeight}">',
'<param name="movie" value="{swf}" />',
'<param name="quality" value="high" />',
'<param name="wmode" value="transparent" />',
'<param name="flashvars" value="{computedflashvars}" />',
'<param name="allowScriptAccess" value="domain" />',
'<param name="align" value="t" />',
'<param name="salign" value="TL" />',
'<param name="swliveconnect" value="true" />',
'<param name="scale" value="showall" />',
'<embed name="flash-{id}" src="{swf}" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="{computedflashvars}" type="application/x-shockwave-flash" width="{swfWidth}" height="{swfHeight}" wmode="transparent" allowScriptAccess="always" swliveconnect="true" align="t" salign="TL" scale="showall"></embed>',
'</object>',
'</div>'
);
ct.flashTemplate.compile();
ct.renderFlash = function() {
if (this.flashvars && (typeof this.flashvars == 'object')) {
var tempflashvars = Ext.apply({}, this.flashvars);
for (var key in tempflashvars) {
if (typeof tempflashvars[key] == 'function') {
tempflashvars[key] = tempflashvars[key].call(this, true);
}
};
this.computedflashvars = Ext.urlEncode(tempflashvars);
}
this.swfHeight = this.body.getSize().height -2;
this.swfWidth = this.body.getSize().width -2;
if (this.body.first()) this.flashTemplate.overwrite(this.body.first(),this);
else this.flashTemplate.insertFirst(this.body,this);
};
ct.loadFlash = function(config) {
Ext.apply(this,config);
this.renderFlash();
};
ct.on('afterlayout',ct.renderFlash, ct);
};
};
And here is an example of the usage:
Code:
{
title: 'Performance',
layout: 'fit',
height: 400,
swf: 'flash/graph/FCF_MSLine.swf',
flashvars: {dataUrl: 'accountPerformance.xml', chartHeight: function(){ return this.body.getSize().height -5; }, chartWidth: function(){ return this.body.getSize().width -5;}},
plugins: new Ext.ux.FlashPlugin()
}
Let me know what you think.
Couple it with the maximize plugin I had submitted earlier and you could get impressive results. I have attached some screen shots.
I had a bug with the insertFirst. This was inserting multiple tags. It is fixed now.