Math equation parser/plotter

61 views
Skip to first unread message

Felipe Barone

unread,
Jan 5, 2008, 3:21:22 PM1/5/08
to Google Chart API
I know some of you guys are working on this too, but here it is my
first sample for plotting equation using google chart API:

http://www.felipebarone.com/plot-function-google.php

this is a first draft and im using PHP to get the values and parsing
into a valid GC url. For now it only takes simple functions (no
trigonometrics, for example) and only one function at a time. Also im
using text encoding data (http://code.google.com/apis/chart/#text) so
if the range is too wide, it gets over 100 points and chart is
plotted....

anyways, this is a draft as i said and any comments suggestions are
very welcome! if anyone out there playing with PHP and CG let me know
so we can exchange experiences and codes!

best regards,

Felipe

Uwe Maurer

unread,
Jan 7, 2008, 4:03:46 AM1/7/08
to Google Chart API
Hi Felipe,

thanks for doing this! It is very useful.
I have some suggestions:
- In the text encoding, instead of
13.3333333333,12.9363333333,12.5453333333,12.1603333333,11.7813333333,11.4083333333,
you can use
13.3,12.9,12.5,12.1,11.7,11.4
This makes the URL much shorter and the chart image stays the same.

- For the labels you can use the chxr parameter (it does the labels
automatically then).
I think in your current version is a bug when the x range is eg -1
to 1, it gives -1, 1, 1 as labels, instead of -1, 0, 1
- Also if the space between the x values is always the same, it is
better to use cht=lc instead of cht=lxy. Then you don't need to
specify the x values.

Thanks,
Uwe

Felipe Barone

unread,
Jan 10, 2008, 1:08:38 PM1/10/08
to Google Chart API
Hi Uwe,

thanks for replying! Thanks for the sugestion on the encoding, will
do it as soon as i get home! Im vacation in Bahia (Brazil) right now!

I see the axis issue and indeed they need some work. I let you know
when i get a new version of it.

Best regards,

Felipe

On Jan 7, 6:03 am, Uwe Maurer <uwe.mau...@google.com> wrote:
> Hi Felipe,
>
> thanks for doing this! It is very useful.
> I have some suggestions:
> - In the text encoding, instead of
> 13.3333333333,12.9363333333,12.5453333333,12.1603333333,11.7813333333,11.40­83333333,
> > Felipe- Hide quoted text -
>
> - Show quoted text -

Felipe Barone

unread,
Jan 23, 2008, 9:46:17 AM1/23/08
to Google Chart API
Greetings Uwe,

i have made some changes on the script fixing:
1 - Rounded the values to get a shorter URL.
2 - Labels for axis are fixed.
3 - For some simple functions, the roots (e.g. F(x) = 0) are marked
with a red circle.

I plan to implement some other functionalities like max and minimum
for a functions and eventually, more than one function in same
chart....

I still have an issue with points outside the chart range that
sometimes totally screw the chart, for example try:
fx: x*x*x+3*x*x-3
-4 >= x >= 3
-2 >= x >= 2

I have a couple ideas to fix this, but any suggestions are very
welcome. I still didn't get to implement your suggestion to use
cht=lc instead of cht=lxy, which indeed will make URL even shorter.

regards,

Felipe

Uwe Maurer

unread,
Jan 23, 2008, 11:50:12 AM1/23/08
to Google Chart API
Hi Felipe,

very nice updates! I added the link to your function plotter to the
links page.

Thanks,
Uwe
Reply all
Reply to author
Forward
0 new messages