Helpful Information
 
 
Category: Flash Help
Line and/or Bar Charts

Is it possible to create a line and/or bar chart in Flash using data from a database?

I know about the LoadVariables stuff but I want the line to gradually make its way from left to right, or I want the bars to grow. I dont want a static graph, but rather with movement.

I haven't been able to find any tutorials on this and was wondering if it is possible, and if so, how can it be done.

Thanks

sorry but only half my post shows ??@#$?
so i'll put the code in when a moderator tells me what the hell is going on

Thanks, I'd appreciate it

didn't work again - just pm me and i'll email you the solution

drGiggles sent this solution to me in my e-mail. Here's my try at posting it:



Is it possible to create a line and/or bar
chart in Flash using data from a database?

yes, you can. you can experiment this to get a basic
idea how this works:

create text file containing nothing but:
&surveyResults=5|4|1|3|2

make a new movie, on the first frame add the AS:

loadVariablesNum ("viewerSurvey.txt", 0);

create a button, named splitter, containing the AS:

on(press) {
surveyArray = surveyResults.split("|");
element0=surveyArray[0];// element 0
element1=surveyArray[1];
element2=surveyArray[2];
element3=surveyArray[3];
element4=surveyArray[4];
}

unfortunately the rest of the code wasnot there either. i suspect it is because of the multiple 'code' inserts. if this doesn't show, i don't know what to tell you....here it is without any vB markup:

Is it possible to create a line and/or bar chart in Flash using data from a database?

yes, you can. you can experiment this to get a basic idea how this works:

create text file containing nothing but:
&surveyResults=5|4|1|3|2

make a new movie, on the first frame add the AS:
loadVariablesNum ("viewerSurvey.txt", 0);

create a button, splitter, containing the AS:
on(press) {
surveyArray = surveyResults.split("|");
element0=surveyArray[0];// element 0
element1=surveyArray[1];
element2=surveyArray[2];
element3=surveyArray[3];
element4=surveyArray[4];
}

create a dynamic text box labeled surveyResults

create 5 dynamic text boxes labeled element0...element4.

add a second button, showMe, with the AS:

on (release) {
setProperty (dynamicBar, _height, element0 * 10);
}

now make a new movie symbol called dynamicBar, and draw a box h=1, w=50, make the x=0, y=-1.

now play the movie, hit the splitter first, then the showMe button.

Congrats! what you've done is take in a datasource, split the array it contains, show what was in it, and then make the dynamicBar resize according to the datasource!

this should give you the idea how to get started - good luck!

there's a cheesy bargraph tutorial that would work with a database here:

http://www.flashkit.com/tutorials/Dynamic_Content/Creating-Zoubin_Z-61/index.shtml

it can be quite easy to draw dynamic charts in flash mx.
my first experience with flash was to create such graphics and not to forget how it works, i made a tutorial on it.
the source is downloadable. it runs out of the box but is also highly configurable, even on the fly.

i used mysql, perl, flash mx and xml. can also be static or read from a file. xml nothing special, just tagged name-value pairs.

see for more details
http://www.2question.com/demo and follow the dynamic pie chart link.

theo theunissen
www.2question.com

or just download the flash charting components from the flash exchange . . .

try this http://www.4guysfromrolla.com/webtech/111302-1.shtml
for a line graph drawn from an xml file.










privacy (GDPR)