can data be fetched from Postgres database and displayed?

1,700 views
Skip to first unread message

manish

unread,
Feb 26, 2009, 3:43:52 AM2/26/09
to Google Visualization API
Hi, I just wanted to know if data can be fetched from a database in
POSTGRE and then data sent to the visualization package and displayed
as a line chart. If you could give me a example then it would be
really helpful. Thanks.

VizBoy

unread,
Feb 26, 2009, 8:25:58 AM2/26/09
to google-visua...@googlegroups.com
Hi,

As with any source of data, you have a few ways to visualize it:
1. If you render your html on a server that has access to the postgre database, and you're rendering your html using, say, php, asp, jsp, servlets, or whatnot, you can create the html already with javascript that has the data in it.
See for example here:
http://code.google.com/apis/visualization/documentation/reference.html#DataTable

You can read under "should I create my DataTable in JavaScript or object literal notation?"

2. Use the query mechanism. This means you expose your data in some url, say using java Servlets, or another mechanism.
You can read about it here:
http://code.google.com/apis/visualization/documentation/dev/implementing_data_source.html
If you use python for this, you can use the gviz_api python library to assist you in creating the proper format of the response.
Read about it here:
http://code.google.com/apis/visualization/documentation/dev/gviz_api_lib.html

To summarize, usually option (1) i gave above is the easiest, if you're controlling the html on the same server that can access the data.

Other people on the group are welcome to share their thoughts and experience with using these different methods..

If you have further questions, ask and I will gladly elaborate.

Regards,
    Vizboy.

Olemis Lang

unread,
Feb 26, 2009, 9:00:15 AM2/26/09
to google-visua...@googlegroups.com
On Thu, Feb 26, 2009 at 8:25 AM, VizBoy <viz...@google.com> wrote:
> Hi,

>
> 1. If you render your html on a server that has access to the postgre
> database, you can create the html already with javascript that

> has the data in it.
>
> 2. Use the query mechanism. This means you expose your data in some url, say
> using java Servlets, or another mechanism.
>
> To summarize,
[...]

... you can feed any data to any widget built on GViz API ... using
JSON format. Things that matter ...

- If your data is «stored» in an RDBMS you cannot access it directly
... you should implement a piece of code to retrieve the data from
your specific tables (i.e. in your Postgre DB) and convert this data
to JSON ... GViz API is about open access (directly from your web
browser) to data, therefore it is based on Internet stds ... and there
is no std way you can access traditional RDBMS directly ... AFAIK

- Take care about how to structure the data so that the visualization
be able to render the information you want to show ...

- The data should be accessible using HTTP protocol ... AFAIK

- In case choice (2.) is the one you prefer, if the end users cannot
access the URL where you have published your data, they wont see the
results rendered in the web pages ... perhaps a visualization gadget
or option (1.) is better in this case ... ;)

- If the end users cannot access the URL to visualization code then
they wont see it ... ;) ... I know, this is obvious, but I tell you
anyway ;).

--
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:

Максим Барбул

unread,
Feb 26, 2009, 9:05:42 AM2/26/09
to google-visua...@googlegroups.com
Hi, and I'm using another way, but it is very close to (2):
When client sends request to backend (PHP), I'm generating associative array with PHP and send it in response with another parameters to client and calling JS callback function to redraw or create chart.

I'm creating dataTable using

data = new google.visualization.DataTable(response.data, 0.5);

where response.data it is those generated associative array.
and then I call

chart.draw(data, options);

I'm using this way because there is request-response mechanism in our system.

2009/2/26 VizBoy <viz...@google.com>



--
С уважением,
Максим Барбул

manish

unread,
Feb 26, 2009, 11:37:30 AM2/26/09
to Google Visualization API
Hi, thank you for your reply. I really appreciate the contribution.
However, if you are interested please go to www.rids-nepal.org. I am
the web admin for this non profit ngo which helps the poorest of poor
people in Nepal. You can find more in the site above. We have many
Renewable Energy related systems in many villages of Humla, a district
of Nepal. And we gather a lot of data each month. We have uploaded
those data in a POSTGRE DB and also built a application to cpm[are the
data and show the graphs. You can access this software by clicking on
the DataBank (www.lannet.com.au/mall/datalog) you will reach to a log
in page. But due to the limitation of the present graphing system we
were thinking of using Google;s Visualization package. If you are
interested then please let me know, my email add is
manish...@gmail.com. I will gladly grant you a access to the
Databank and you can see what i really mean. These data and graph will
help our organization to optimize the design, improve reliability,
reduce cost and increase system output, which all in turn allow the
building of more sustainable, context related energy generation
systems.

You will be helping the poorest of poor people in the world by helping
in this project. But i totally understand if you dont want to do it. I
respect your decision. Thank you again.

Best Regards
Manish

On Feb 26, 8:25 am, VizBoy <viz...@google.com> wrote:
> Hi,
>
> As with any source of data, you have a few ways to visualize it:
> 1. If you render your html on a server that has access to the postgre
> database, and you're rendering your html using, say, php, asp, jsp,
> servlets, or whatnot, you can create the html already with javascript that
> has the data in it.
> See for example here:http://code.google.com/apis/visualization/documentation/reference.htm...
>
> You can read under "should I create my DataTable in JavaScript or object
> literal notation?"
>
> 2. Use the query mechanism. This means you expose your data in some url, say
> using java Servlets, or another mechanism.
> You can read about it here:http://code.google.com/apis/visualization/documentation/dev/implement...
> If you use python for this, you can use the gviz_api python library to
> assist you in creating the proper format of the response.
> Read about it here:http://code.google.com/apis/visualization/documentation/dev/gviz_api_...
>
> To summarize, usually option (1) i gave above is the easiest, if you're
> controlling the html on the same server that can access the data.
>
> Other people on the group are welcome to share their thoughts and experience
> with using these different methods..
>
> If you have further questions, ask and I will gladly elaborate.
>
> Regards,
>     Vizboy.
>

VizBoy

unread,
Mar 2, 2009, 11:14:50 AM3/2/09
to google-visua...@googlegroups.com
Hi,

I wish you the best of luck in your project. Helping the poor is indeed a worthy goal.
And if the Google Visualization API helps such worthy goals, I'm even happier.

Unfortunately, neither me nor my team have the resources to actively participate in your development process.

Feel free to continue to ask questions on this group.
And again, good luck!

Regards,
   VizBoy.

Tzvika

unread,
Mar 9, 2009, 9:28:08 AM3/9/09
to Google Visualization API
Hi Manish,

I am the owner of www.GVStreamer.com. GVStreamer API converts an
entire database query (MySql or PostgreSql) into google visualization
compliant data source by a single function call. Please check the
website (especially the demo page) and if you think that you can use
the API in your development, contact me via the contact form in the
website and I will send you the unlimited version of the extended API
for free.

Regards,
Tzvika
Reply all
Reply to author
Forward
0 new messages