On 25 sep, 21:15, Sunny <sunnyluth...@gmail.comwrote:
Hi Is there a way to find a proper distance between large numbers.
For example, if i have a set of numbers like:
10, 40, 80, 100, 500, 10000
Now if I have to create a break points between these no.
I have to take an average & add that average to the starting number
like.
(10000 -10)/6 = 1665.
Now if I create a break point using this no. the break points will be:
10 - 1675, 1675 - 3340, 3340 - 5005, 5005 - 6670 ....
I do see all these evaluate to -1665, but I don't understand what you
further mean. I really think you should rephrase the problem in a
clearer way. Anyway, I think your algorithm would go like this:
var nrs = [10, 40, 80, 100, 500, 10000];
var breakpoints = new Array();
var f = (nrs[nrs.length-1] - nrs[0]) / nrs.length;
for (var i=0; i<nrs.length; i++)
breakpoints[i] = i * f - ((i+1) * f);
document.write(breakpoints); // -1665 for every entry
[...]
Now if i have to display this data on chart.
Line chart:
http://code.google.com/apis/chart/#line_charts
var nrs = [10, 40, 80, 100, 500, 10000];
document.write('<img src="http://chart.apis.google.com/chart?'
+ 'chxt=y'
+ '&chxl=0:|0|'
+ nrs[nrs.length-1]/2 + '|' + nrs[nrs.length-1]
+ '&chs=400x400'
+ '&cht=lc'
+ '&chds=0,' + nrs[nrs.length-1]
+ '&chd=t:' + nrs
+ '">');
Pie chart:
http://code.google.com/apis/chart/#pie_charts
var nrs = [10, 40, 80, 100, 500, 10000];
var perc = new Array();
var sum = 0;
for (var i=0; i<nrs.length; i++)
sum += nrs[i];
for (var j=0; j<nrs.length; j++)
perc[j] = nrs[j] / sum;
document.write('<img src="http://chart.apis.google.com/chart?'
+'chs=750x300'
+ '&chd=t:' + perc
+ '&cht=p3'
+ '&chl=' + nrs.join('|')
+ '">');
Hope this helps,
--
Bart