# Dynamic Line Chart - plz read

**URL:** <https://forum.kirupa.com/t/dynamic-line-chart-plz-read/119282>\
**Category:** Uncategorized\
**Created:** [August 13, 2004, 5:03am UTC](https://forum.kirupa.com/t/dynamic-line-chart-plz-read/119282 "2004-08-13T05:03:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![h00ligan](https://avatars.discourse-cdn.com/v4/letter/h/eb8c5e/32.png) [@h00ligan](https://forum.kirupa.com/u/h00ligan)\
**Post date:** [August 13, 2004, 5:03am UTC](https://forum.kirupa.com/t/dynamic-line-chart-plz-read/119282/1 "2004-08-13T05:03:01Z")

</div>

Thanks for reading this post, I am trying to get this line chart to work however it doesnt want to plot the vertical points. I think it maybe with the var ‘ha’… Any help would be greatly appreciated.

linea = new Array(“3”, “24”, “12”, “6”, “4”);  
counta = linea.length;  
maxa = 0;  
for (indexx=0; indexx\<counta; indexx++) {  
maxa = math.max(maxa, linea[indexx]);  
}  
highval = math.max(maxa);  
var stageheight = 250;  
var stagewidth = 440;  
var marginleft = 50;  
var marginright = 50;  
var marginbottom = 50;  
var margintop = 50;  
// set limits  
var originx = marginleft;  
var originy = stageheight-marginbottom;  
var availx = (stagewidth-marginleft)-marginright;  
var availy = (stageheight-marginbottom)-margintop;  
var maxx = stagewidth-marginright;  
// get each value in each array and translate it to ratio of  
// highval to make max use of space. // hr = height ratio  
var hr = availy/highval;  
ha = new Array();  
for (i=0; i\<counta; i++) {  
if (hr\>1) {  
ha\* = linea\*\*hr;  
} else {  
ha\* = linea\*/hr;  
}  
}  
// increments  
// x is available width / count + 1;  
xinc = availx/(counta);  
\_root.createEmptyMovieClip(“amovie”, 1);  
with (\_root.amovie) {  
// first set up inital values  
var x\_a = originx;  
var y\_a = originy;

// draw grid  
// horizontal lines  
for (i=0; i\<9; i++) {  
lineStyle(1, 0xcccccc, 100);  
moveTo(x\_a, y\_a);  
lineTo(maxx, y\_a);  
y\_a = y\_a-(availy/8);  
}  
// reset up inital values  
var x\_a = originx;  
var y\_a = originy;  
// height of the chart  
for (indexa=0; indexa\<(counta+1); indexa++) {  
lineStyle(1, 0xcccccc, 100);  
moveTo(x\_a, y\_a);  
lineTo(x\_a, margintop);  
x\_a = x\_a+xinc;  
}  
// reset up inital values  
var x\_a = originx;  
var y\_a = originy;

// now get each result from the arrays  
for (indexa=0; indexa\<counta; indexa++) {  
lineStyle(2, 0xE49111, 100);  
moveTo(x\_a, y\_a);  
x\_a = x\_a+xinc;  
y\_a = originy-ha[indexa];  
lineTo(x\_a, y\_a);  
}  
}
