[flashchart]

Description

Link: [flashchart]
Author: Jason Huck
Category: Data Type
Version: 8.x
License:
Posted: Apr. 26, 2006
Updated: Oct. 05, 2006
More by this author...
This custom type will generate an XML configuration file for use with XML/SWF Charts [more info | download]. The instance variables match the node and attribute names given in the online reference. Nodes with attributes but no children are generated from maps. Nodes with children are generated from arrays. This covers all items except series_switch, which is a boolean.

There is only one member tag, ->output, which returns the data in XML format. Be sure to switch the content type of the serving page to text/xml when using this type.

[flashchart_embed] provides a shortcut for generating the HTML code to display the flash movie and include the XML file.

Parameters

none


Sample Usage

var('myChart') = flashchart;	
$myChart->chart_type = '3d column';

$myChart->chart_value = map(
	'position' = 'top'
);

$myChart->axis_value = map(
	'max' = 100,
	'steps' = 5
);

$myChart->chart_transition = map(
	'type' = 'dissolve',
	'delay' = 1,
	'duration' = 2,
	'order' = 'series'
);

var('chartData') = array(
	array(	null,		'Column A',	'Column B',	'Column C'	),
	array(	'Row 1',	20,			40, 		60			),
	array(	'Row 2', 	10, 		30, 		50			)
);

$myChart->chart_data = $chartData;

content_type('text/xml; charset=utf8');		
$myChart->output;
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
define_type(
	'flashchart',
	-prototype,
	-description='Creates a Flash chart.'
);
	local(
		'axis_category' = map,
		'axis_ticks' = map,
		'axis_value' = map,
		'axis_value_text' = map,
		'chart_border' = map,
		'chart_data' = array,
		'chart_grid_h' = map,
		'chart_grid_v' = map,
		'chart_pref' = map,
		'chart_rect' = map,
		'chart_transition' = map,
		'chart_type' = array,
		'chart_value' = map,
		'chart_value_text' = array,
		'draw' = array,
		'legend_label' = map,
		'legend_rect' = map,
		'legend_transition' = map,
		'license' = string,
		'link' = array,
		'link_data' = map,
		'live_update' = map,
		'series_color' = array,
		'series_explode' = array,
		'series_gap' = map,
		'series_switch' = boolean
	);

	define_tag('onCreate');
		iterate(self->properties->first, local('i'));
			local_defined(#i->first) ? self->(#i->first) = #i->second;
		/iterate;
	/define_tag;
	
	define_tag('output');
		local('out' = '<chart>\n');
		
		iterate(self->properties->first, local('i'));
			select(#i->first);
				case('chart_data');
					if(#i->second->size);
						local('tmp' = '\t<chart_data>\n');
						
						iterate(#i->second, local('row'));
							#tmp += '\t\t<row>\n';
							
							iterate(#row, local('field'));
								select(true);
									case(#field == '' || #field == null);
										#tmp += '\t\t\t<null/>\n';
										
									case(#field->isa('string'));
										#tmp += '\t\t\t<string>' + encode_xml(#field) + '</string>\n';
										
									case((: 'integer', 'decimal') >> #field->type);
										#tmp += '\t\t\t<number>' + #field + '</number>\n';
										
								/select;
							/iterate;
							
							#tmp += '\t\t</row>\n';
						/iterate;
						
						#tmp += '\t</chart_data>\n';
						#out += #tmp;
					/if;
					
				case('chart_type');
					if(#i->second->isa('string'));
						#out += '\t<chart_type>' + encode_xml(#i->second) + '</chart_type>\n';
						
					else(#i->second->isa('array'));
						if(#i->second->size == 1);
							#out += '\t<chart_type>' + encode_xml(#i->second->first) + '</chart_type>\n';
							
						else;
							local('tmp') = '\t<chart_type>\n';
						
							iterate(#i->second, local('j'));
								#tmp += '\t\t<string>' + encode_xml(#j) + '</string>\n';
							/iterate;
						
							#tmp += '\t</chart_type>\n';
							#out += #tmp;
						/if;
						
					/if;
					
				case('chart_value_text');
					if(#i->second->size);
						local('tmp' = '\t<chart_value_text>\n');
						
						iterate(#i->second, local('row'));
							#tmp += '\t\t<row>\n';
							
							iterate(#row, local('field'));
								select(true);
									case(#field == null);
										#tmp += '\t\t\t<null/>\n';
										
									case(#field->isa('string'));
										#tmp += '\t\t\t<string>' + encode_xml(#field)->replace('\r\n','\r')&replace('\n','\r')& + '</string>\n';
																					
								/select;
							/iterate;
							
							#tmp += '\t\t</row>\n';
						/iterate;
						
						#tmp += '\t</chart_value_text>\n';
						#out += #tmp;
					/if;
				
				case('draw');
					if(#i->second->size);
						local('tmp' = '\t<draw>\n');
						
						iterate(#i->second, local('row'));
							#tmp += '\t\t<' + #row->first + ' ';
							
							iterate(#row->second->keys, local('j'));
								#tmp += #j + '="' + encode_xml(#row->second->find(#j)) + '" ';
							/iterate;
							
							#tmp += '/>\n';
						/iterate;
						
						#tmp += '\t</draw>\n';
						#out += #tmp;
					/if;
				
				case('license');
					local('tmp' = '\t<license>' + #i->second + '</license>\n');
					#out += #tmp;
				
				case('link');
					if(#i->second->size);
						local('tmp' = '\t<link>\n');
						
						iterate(#i->second, local('row'));
							#tmp += '\t\t<area ';
							
							iterate(#row->keys, local('j'));
								#tmp += #j + '="' + encode_xml(#row->second->find(#j)) + '" ';
							/iterate;
							
							#tmp += '/>\n';
						/iterate;
						
						#tmp += '\t</link>\n';
						#out += #tmp;
					/if;
				
				case('series_color');
					if(#i->second->size);
						local('tmp' = '\t<series_color>\n');
						
						iterate(#i->second, local('row'));
							#tmp += '\t\t<color>' + #row + '</color>\n';
						/iterate;
						
						#tmp += '\t</series_color>\n';
						#out += #tmp;
					/if;
				
				case('series_explode');
					if(#i->second->size);
						local('tmp' = '\t<series_explode>\n');
						
						iterate(#i->second, local('row'));
							#tmp += '\t\t<number>' + #row + '</number>\n';
						/iterate;
						
						#tmp += '\t</series_explode>\n';
						#out += #tmp;
					/if;
				
				case('series_switch');
					if(#i->second != null && #i->second->type == 'boolean');
						#out += '\t<series_switch>' + string(#i->second) + '</series_switch>\n';
					/if;
				
				case;
					if(#i->second->isa('map') && #i->second->size);
						local('tmp' = '\t<' + #i->first + ' ');
					
						iterate(#i->second->keys, local('j'));
							#tmp += #j + '="' + encode_xml(#i->second->find(#j)) + '" ';
						/iterate;
					
						#tmp += '/>\n';
						#out += #tmp;
					/if;
					
			/select;
		/iterate;			
		
		#out += '</chart>\n';
		return(@#out);
	/define_tag;
/define_type;

 

Related Tags



Comments

04/30/2006, Jason Huck
Bug Fix
Fixed a bug where specifying compound chart types would not generate the correct XML.
Email:


Password:



Newest

Most Popular