pie from textarea

Posted by jirkaz 
pie from textarea
October 16, 2008 02:30PM
I have my data in textarea and I wish to make a pie chart from them.
What to do?
Re: pie from textarea
October 17, 2008 05:52AM
Can you please give us more information? What is the actual data you have in the textareas?

Thanks,
Sabin
Re: pie from textarea
October 17, 2008 09:57AM
I have in <textarea id=mypye>"dogs",50;"cats",30;"rats",30</textarea>
I translate value in Javascript to " ['dogs',50],['cats',30],['rats',20] " and used
pom="['IE7', 26], ['IE6', 24.6], ['Firefox', 44.2], ['Safari', 2.6], ['Opera', 2.1]"
but var myData = new Array(pom) gives "Data in wrong format."
var myData = new Array(['IE7', 26], ['IE6', 24.6], ['Firefox', 44.2], ['Safari', 2.6], ['Opera', 2.1]); works fine.
Is there a way, how to overcome this?
Ji
Re: pie from textarea
October 17, 2008 10:19AM
Keeping the quotes arround ['dogs',50],['cats',30],['rats',20] will transform the data into a string.
pom = "['dogs',50],['cats',30],['rats',20]";
pom will be a string, but you will need a list of arrays (the brackets here are equivalent to new Array() ).
You have a few options here, you can use the next code:
pom = new Array(['dogs',50],['cats',30],['rats',20]);
var myData = pom;
or the simplest would be to use:
var myData = new Array(['dogs',50],['cats',30],['rats',20]);

Sabin
Re: pie from textarea
October 17, 2008 03:50PM
Thanks.
Ïs it possible to generate array myData from 2 known arrays (names and values with n elements)?
Re: pie from textarea
October 17, 2008 04:01PM
for example
var myData = new Array([names[0],values[0]],[names[1],values[1]],[names[2],values[2]] )
gives again wrong Format.
Re: pie from textarea
October 20, 2008 05:02AM
It is possible, but It also depends on the type of names[] and values[]. For line charts, both must be numbers (integers or floating numbers). For bar and pie charts, names[] can be a string, and values[] must be a number again.
Sorry, you do not have permission to post/reply in this forum.