Hi Hisham,

Thanks :-) :-)
Yes I am using dictionary. But I already got my dictionary keys and values.
I can take my dictionary keys and values using "for loops". My question is
about integration of my dictionary to Google chart inputs.
I don't know PHP or HTML well. So in the solution when you execute the
code, will the chart be displayed as output? Or should we give a path in a
program that stores as html? I don't get how this works? I created a
webpage using python for some of my other projects and I had to give my
output to a path that will have .html file and then use that path to open
up the output web page. Sorry if I am asking too many things. I am trying
to figure out the best method to do this project. If this is good maybe I
will have to do basic PHP tutorials. I did some research on word press as
well. Eventually my script automates the chart every time I run the script.
It is a dynamic program that builds charts for changing inputs. i.e.  SQL
queries, row and column field remains static but values are dynamic. If you
have suggestions please do. Thanks :-)

Raj

On Wed, Jun 24, 2015 at 3:57 PM, 'Hisham Alkilani' via Google Visualization
API <[email protected]> wrote:

> Dear Raj,
>
> Unfortunately that i know nothing about python :) sorry, i'm glad that i
> helped you i wish your charts worked with php and mysql - i ran throw this
> because i wanted to connect php with oracle database so to make charts for
> old ages products for my company, but listen you can ask your question on
> stackoverflow.com and you will get better answers there trust me and you
> can use my question as a reference and put your code with it and choose
> your tags wisely.
>
> I think your trying to make a nested loop throw python without the need to
> use php and json right?
> i can help you with the logic i guess-
> first loop that loops throw keys and inside of it the second loop that
> retrieve all values for every key, idk :/
> i tried to do this but in php, check this link too this is another
> solution it may help you ..
> http://stackoverflow.com/questions/29969054/google-charts-from-mysql/30255703#30255703
>
> Regards,
> Hisham
>
>
> On Thursday, June 25, 2015 at 1:30:22 AM UTC+3, Raj wrote:
>
>> Hi Hisham,
>>
>> Thanks for your link. I was wondering if we can take Google chart input
>> from python dictionary and dump Google visualization code in python. I did
>> go through Json and PHP. I am totally new to both languages. I am still
>> figuring out if I can make this happen without touching JSON and PHP. And
>> just go with python dictionary.
>>
>> *My Python code that gives dictionary output after connecting to the
>> database*
>>
>>
>> import sys, pkg_resources, imp
>> import os
>> import commands
>> import pyodbc
>> import MySQLdb
>> import gviz_api
>> from decimal import *
>> from datetime import *
>> import datetime
>> import time
>> #Connect to database
>> conn_ensdb = MySQLdb.Connection(db='******', host='*****', user='*****',
>> passwd='******')
>> cursor_ensdb = conn_ensdb.cursor()
>> cursor_ensdb.execute("SELECT ManagedType,TotalCount from TotalManaged_DC")
>> rows = cursor_ensdb.fetchall()
>> my_list = [data for data in rows]
>> dict_with_strs=dict(my_list)
>> dict_with_ints=dict((k,int(v)) for k,v in dict_with_strs.iteritems())
>> print dict_with_ints
>>
>>
>> My Output:-
>> {'Off-prem Core Data Center': 4, 'On-prem Remote Office DC': 14, 'On-prem
>> Core Data Center': 7, 'Total Managed Data Centers': 25}
>>
>>
>>
>>
>> I want this output to be input for Google charts:-//I will integrate this
>> html code in my python file
>>
>> This is an example Bar chart using Google Visualization
>>
>>
>> <html>
>>   <head>
>>     <script type="text/javascript" src="https://www.google.com/jsapi";
>> ></script>
>>     <script type="text/javascript">
>>       google.load("visualization", "1.1", {packages:["bar"]});
>>       google.setOnLoadCallback(drawStuff);
>>
>>       function drawStuff() {
>>         var data = new google.visualization.arrayToDataTable([
>> //want my dictionary items in here. Graph is Dictionary Keys vs Vs
>> Dictionary Values
>>           *['Galaxy', 'Distance', 'Brightness'],                    *
>>           *['Canis Major Dwarf', 8000,
>> 23.3],                                                      *
>>           *['Sagittarius Dwarf', 24000, 4.5],*
>>           *['Ursa Major II Dwarf', 30000, 14.3],*
>>           *['Lg. Magellanic Cloud', 50000, 0.9],*
>>           *['Bootes I', 60000, 13.1]*
>>         ]);
>>
>>         var options = {
>>           width: 900,
>>           chart: {
>>             title
>> ...
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Google Visualization API" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/google-visualization-api/UdOFybnvFo0/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to
> [email protected].
> Visit this group at
> http://groups.google.com/group/google-visualization-api.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to