Posted by: Wildan Maulana | October 28, 2009

Watermark Support for Open Flash Chart

The following is a patch, unified diff for adding simple watermark support on Open Flash Chart Lug Wyrm Charmer :
watermark

Btw, i found this book very-very usefull when designing dashboard application that make your boss happy :

Index: /trunk/src/main.as

===================================================================

--- /trunk/src/main.as (revision 10)

+++ /trunk/src/main.as (revision 11)

@@ -88,4 +88,6 @@

 			var l:Loading = new Loading(this.chart_parameters['loading']);

 			this.addChild( l );

+			

+

 

 			this.build_right_click_menu();

@@ -96,5 +98,5 @@

 				// no data found -- debug mode?

 				try {

-					var file:String = "../data-files/bar-glass-2.txt";

+					var file:String = "data-files/bar-glass-2.txt";

 					this.load_external_file( file );

 

@@ -150,5 +152,5 @@

 			//

 			//

-			

+

 			this.set_the_stage();

 		}

@@ -452,4 +454,5 @@

 			this.stage.addEventListener(Event.MOUSE_LEAVE, this.mouseOut);

 			this.addEventListener( MouseEvent.MOUSE_OVER, this.mouseMove );

+

 		}

 		

@@ -729,4 +732,5 @@

 			g.set_tooltip_string( this.tooltip.tip_text );

 		

+            

 			//

 			// these are common to both X Y charts and PIE charts:

@@ -736,4 +740,8 @@

 			this.addChild( this.background );

 			//

+		

+            //bg-watermark

+		    var watermark:Watermark = new Watermark( );

+            this.addChild( watermark );	

 			

 			if ( JsonInspector.is_radar( json ) ) {

@@ -765,4 +773,6 @@

 			this.addChild( this.tooltip );

 

+

+            

 			if (json['menu'] != null) {

 				this.menu = new Menu('99', json['menu']);

@@ -771,7 +781,5 @@

 			

 			this.ok = true;

-			this.resize();

-			

-			

+			this.resize();        

 		}

 		

@@ -874,5 +882,5 @@

 

 			// OFC CREDITS

-			var fs:ContextMenuItem = new ContextMenuItem("Charts by Open Flash Chart [Version "+VERSION+"]" );

+			var fs:ContextMenuItem = new ContextMenuItem("Charts by Open Flash Chart [Version "+VERSION+"] Patched Applied By OpenThink Labs" );

 			fs.addEventListener(

 				ContextMenuEvent.MENU_ITEM_SELECT,

Index: /trunk/src/Watermark.as

===================================================================

--- /trunk/src/Watermark.as (revision 11)

+++ /trunk/src/Watermark.as (revision 11)

@@ -0,0 +1,24 @@

+/**

+ * @author Wildan Maulana, OpenThink labs

+ */

+package  {

+	import flash.display.Sprite;

+    import flash.display.Bitmap;

+    

+	public class Watermark extends Sprite{	

+	    private var bg:Bitmap;

+  

+		[ Embed ( source = "logo.png" ) ] private var bgImageClass:Class;

+			

+		public function Watermark() {

+            bg = new bgImageClass() ;

+            bg.x = 10 ;       

+            bg.y = 5 ; 

+            

+            addChild(bg);

+		}

+	}

+	

+	

+

+}

Index: /trunk/deploy/data-files/bar-glass-2.txt

===================================================================

--- /trunk/deploy/data-files/bar-glass-2.txt (revision 10)

+++ /trunk/deploy/data-files/bar-glass-2.txt (revision 10)

@@ -0,0 +1,59 @@

+{

+  "title":{

+    "text":  "Many data lines",

+    "style": "{font-size: 20px; color:#0000ff; font-family: Verdana; text-align: center;}"

+  },

+

+  "y_legend":{

+    "text": "Open Flash Chart",

+    "style": "{color: #736AFF; font-size: 12px;}"

+  },

+

+  "elements":[

+    {

+      "type":      "bar_glass",

+      "alpha":     0.5,

+      "colour":    "#9933CC",

+      "tip":       "Tip for purple bars<br>val=#val#, top=#top#",

+      "text--":      "Page views",

+      "font-size--": 10,

+      "values" :   [9,6,7,9,5,{"top":7,"colour":"#FF0000", "tip": "RED<br>Mooo<br>#val#"},6,9,7]

+    },

+    {

+      "type":      "bar_glass",

+      "alpha":     0.5,

+      "colour":    "#44FF44",

+      "tip":       "Tip for green bars<br>val=#val#, top=#top#",

+      "text--":      "Page views",

+      "font-size--": 10,

+      "values" :   [6,7,9,5,9,{"top":7,"colour":"#FF0000", "tip": "RED<br>W000t<br>#val#"},6,5,2]

+    }

+  ],

+

+  "x_axis":{

+    "stroke":       1,

+    "tick_height":  10,

+    "colour":      "#d000d0",

+    "grid_colour": "#00ff00",

+    "labels": {

+      "labels": ["January","February","March","April","May","June","July","August","Spetember"]

+    }

+   },

+

+  "y_axis":{

+    "stroke":      4,

+    "tick_length": 3,

+    "colour":      "#d000d0",

+    "grid_colour": "#00ff00",

+    "offset":      0,

+    "max":         20

+  },

+

+  "tooltip":{

+    "text": "Global Tooltip<br>val=#val#, top=#top#"

+  }

+

+/* &x_axis_steps=2& */

+

+}

+


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: