Link to home
Start Free TrialLog in
Avatar of dbelmans
dbelmans

asked on

Line Chart in flash

I need to create a line chart in flash. The points of the line chart should come from a java servlet. I know how to get variables from the servlet into flash, but I can't seem to figure out a way to dynamically make my chart. Does anybody know how this could be done?
Thanks!

Davy
Avatar of RoyKruyshaar
RoyKruyshaar

Make a movieclip (movChart) with only a box in it.
Than when you get the variables from your servlet, use the following command:
Set Property ("movChart", Y Scale) = "200"
Now your movieclip's height is 200% of his original size.
After then you say        
Set Property ("movChart", X Scale) = "50", your movieclip will be 50% of hir original height.
Good Luck and when you have further questions, feel free to ask.

Roy


I understand what you are trying to acheive...  But unfortunately yuo cannot specify a begin point and an end point of a line in flash...  So this may be difficult.

It would however be very easy to produce a bar chart.

Rich.

P.S.  RoyKruyshaar, What do you mean?  
It sounds like you were beginning to explain a bar chart.
to coopa: Whoops, You're right! I misunderstand the question.
Avatar of dbelmans

ASKER

It really needs to be a line chart. Are there any other tools available to accomplish it? I believe generator could make charts, but generator is a bit to pricy for me.
there are alternatives to generator.

http://www.swift-tools.com/
http://www.blue-pac.com/

you should also check out
http://www.popchart.com/

I have had a re-think....
This is very possible using some heavy maths.

Here is a simplified example:

a) create a symbol

b) from the centre draw a line upwards... Close symbol.

c) create an instance of the line symbol, position line in the correct location of the first point on the graph

d) Rotate and scale the line so that it connects with the next point (to do this you must use the x and y distances between the two points to calculate the angle and length of hypotenuse using Pythagoras' theorum)

e) create another instance of the line symbol, position line in the correct location of the next point on the graph

I can work up an example for you but it will take a while.
Let me know...
I've thought of a way of making this dynamic as well...  (i.e. looping through all the variables until there are none left).
If you could make a small example of it, that would be great.
Here is the start....

now all i need to do is the rotation and size (the difficult bit)

www.coopa.demon.co.uk/ee/graph/grapth.html
www.coopa.demon.co.uk/ee/graph/grapth.swf
www.coopa.demon.co.uk/ee/graph/grapth.fla
almost done...  Going to lunch now, will give you the finished example in about 3 hours.
Take another look....

It now works for downward lines....

www.coopa.demon.co.uk/ee/graph/graph.html 

Just have to make it work for lines going in the other direction.
Finished !

I'm off home now but I'll explain how it was done tomorrow...

www.coopa.demon.co.uk/ee/graph/graph.html 


It looks great, it is exactly what I need. If you answer the question, instead of commenting I can give you the points.
ASKER CERTIFIED SOLUTION
Avatar of coopa
coopa

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The graph is fine for me, I should be able to work with it myself now. Thanks!
Okay...

If you want to see the latest version... (which includes more comments and useful stuff)

Have a look at
www.coopa.demon.co.uk/ee/graph/graph2.swf 
www.coopa.demon.co.uk/ee/graph/graph2.fla

Thanks again.
Coopa, I have incororated the graph into my flash movie. Works really great, only one problem. When I have too much points (sometimes even with 20 points) on the x axis, the movie stops with the error:
More than 200000 actions were executed in one action list.
This is probably an infinite loop.
Further execution of actions has been disabled in this movie.

Is there anything that can be done against this?

I'll also ask this question as a separate question, so that some points can be earned :)
please post your sample in a place i can access your fla...  Then i can attempt to trace when this error is occuring.
please post your sample in a place i can access your fla...  Then i can attempt to trace when this error is occuring.