Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Graphing with Flash

Status
Not open for further replies.

KeyserSoze1877

Programmer
Sep 6, 2001
95
US
I am attempting to create a Time Scatter graph that need to plot 10,000+ data points. Most times the data points are 3,000 to 7,000 but can go higher. I have tried PopChart from Corda, DHTML approach.... anyone tried this before? or have a direction I can go to get this completed?

Thanks.
 
You could create a graph from an array (or series of arrays) then duplicate a "point" movie clip and plot it from the array values.

Try this...


Code:
onClipEvent (load) {
	// create arrays to hold points
	xValue = new Array();
	yValue = new Array();
	// fill arrays with data - these are just any old values but you could do
	// the Math here to convert your values of 7000+ down to plottable values
	function createPoints () {
		for (i=1; i<100; i++) {
			xValue[i] = (i*5)+15;
			yValue[i] = 300-(Math.ceil(Math.random()*280));
		}
	}
	// plot the values from the arrays on the screen &quot;point&quot; is off stage
	function plotGraph () {
		for (i=1; i<100; i++) {
			duplicateMovieClip (&quot;_root.point&quot;, point, i++);
			_root[&quot;point&quot;]._x = xValue[i];
			_root[&quot;point&quot;]._y = yValue[i];
		}
	}
}
onClipEvent (mouseUp) {
	// run the graph routines on a mouseclick
	createPoints();
	plotGraph();
}
 
Uh-oh, half asleep when I posted that - still works but there's a major stupid mistake.

This is better and joins the dots too...


And here's the code:

Code:
onClipEvent (load) {
	// create arrays to hold points
	xValue = new Array();
	yValue = new Array();
	// fill arrays with data - these are just any old values but you could do
	// the Math here to convert your values of 7000+ down to plottable values
	function createPoints (number) {
		for (i=1; i<=number; i++) {
			xValue[i] = i*(500/number)+15;
			yValue[i] = 300-(Math.ceil(Math.random()*280));
		}
	}
	// plot the values from the arrays on the screen - &quot;point&quot; is off stage
	function plotGraph (number) {
		for (i=1; i<=number; i++) {
			duplicateMovieClip (_root.point, &quot;point&quot;+i, i);
			_root[&quot;point&quot;+i]._x = xValue[i];
			_root[&quot;point&quot;+i]._y = yValue[i];
			if (i>1) {
				// connect points with lines
				duplicateMovieClip (_root.line, &quot;line&quot;+i, i+100);
				_root[&quot;line&quot;+i]._x = xValue[i];
				_root[&quot;line&quot;+i]._y = yValue[i];
				_root[&quot;line&quot;+i]._xscale = xValue[i-1]-xValue[i];
				_root[&quot;line&quot;+i]._yscale = yValue[i-1]-yValue[i];
			}
		}
	}
	// number of points to be plotted
	pointsNumber = 34;
}
onClipEvent (mouseUp) {
	// run the graph routines on a mouseclick
	createPoints(pointsNumber);
	plotGraph(pointsNumber);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top