The "p" is the key used to access the properties when creating a column 
definition from an object, so you actually don't want to use it in your 
Python code, since that is using a different approach.  You also probably 
don't need to specify type string in the properties object either.  Try 
this:

gviz_api.DataTable([("Pathway", "string"), ("Source", "string", "Source", 
{"role": "tooltip", "html": True}), ("Response Score", "number")])

On Tuesday, April 1, 2014 11:56:25 AM UTC-4, Moritz Beber wrote:
>
> Dear all,
>
> I use the Python API to generate my DataTable and it's giving me some 
> headache. I want to display one column as a custom HTML tooltip. 
> Unfortunately, the column content is simply formatted as a string instead 
> of being rendered as HTML. The Python API insists on doing the following. 
> My table description is:
>
>     gviz_api.DataTable([("Pathway", "string"), ("Source", "string", 
> "Source", {"type": "string", "role": "tooltip", "p": {"html": True}}), 
> ("Response Score", "number")])
>
> and the relevant output when I call ToJSCode is:
>
> var data = new google.visualization.DataTable();
>
> data.addColumn("string", "Pathway", "Pathway");data.addColumn("string", 
> "Source", "Source");data.setColumnProperties(1, 
> {"role":"tooltip","type":"string","p":{"html":true}});data.addColumn("number",
>  "Response Score", "Response Score");
>
> which leads to the unformatted string. When I change the "Source" column to:
>
>
> data.addColumn({"role":"tooltip","type":"string","p":{"html":true}});
>
> it works as expected.
>
> Does anyone know of a way to fix this?
>
> My whole output is:
>
> <script src="https://www.google.com/jsapi"; 
> type="text/javascript"></script><script type="text/javascript">    
> google.load('visualization', '1', {packages:['corechart']});    function 
> drawChart() {        var data = new 
> google.visualization.DataTable();data.addColumn("string", "Pathway", 
> "Pathway");data.addColumn("string", "Source", 
> "Source");data.setColumnProperties(1, 
> {"role":"tooltip","type":"string","p":{"html":true}});data.addColumn("number",
>  "Response Score", "Response Score");data.addRows(22);data.setCell(0, 0, 
> "Synthesis of epoxy (EET) and dihydroxyeicosatrienoic acids 
> (DHET)");data.setCell(0, 1, "\n<table id=\"tooltip\">\n    <tr>\n        <th 
> colspan=\"2\">\n            Synthesis of epoxy (EET) and 
> dihydroxyeicosatrienoic acids (DHET)\n        </th>\n    </tr>\n    <tr>\n    
>     <td>\n            Source:\n        </td>\n        <td>\n            
> Reactome\n        </td>\n    </tr>\n    <tr>\n        <td>\n            
> Score:\n        </td>\n        <td>\n            3.74698287477\n        
> </td>\n    </tr>\n</table>\n    ");data.setCell(0, 2, 
> 3.7469828747713798);data.setCell(1, 0, "Synthesis of 
> (16-20)-hydroxyeicosatetraenoic acids (HETE)");data.setCell(1, 1, "\n<table 
> id=\"tooltip\">\n    <tr>\n        <th colspan=\"2\">\n            Synthesis 
> of (16-20)-hydroxyeicosatetraenoic acids (HETE)\n        </th>\n    </tr>\n   
>  <tr>\n        <td>\n            Source:\n        </td>\n        <td>\n       
>      Reactome\n        </td>\n    </tr>\n    <tr>\n        <td>\n            
> Score:\n        </td>\n        <td>\n            3.58390651249\n        
> </td>\n    </tr>\n</table>\n    ");data.setCell(1, 2, 
> 3.58390651248676);data.setCell(2, 0, "Benzo(a)pyrene 
> metabolism");data.setCell(2, 1, "\n<table id=\"tooltip\">\n    <tr>\n        
> <th colspan=\"2\">\n            Benzo(a)pyrene metabolism\n        </th>\n    
> </tr>\n    <tr>\n        <td>\n            Source:\n        </td>\n        
> <td>\n            Wikipathways\n        </td>\n    </tr>\n    <tr>\n        
> <td>\n            Score:\n        </td>\n        <td>\n            
> 3.37160874728\n        </td>\n    </tr>\n</table>\n    ");data.setCell(2, 2, 
> 3.3716087472838798);data.setCell(3, 0, "Xenobiotics");data.setCell(3, 1, 
> "\n<table id=\"tooltip\">\n    <tr>\n        <th colspan=\"2\">\n            
> Xenobiotics\n        </th>\n    </tr>\n    <tr>\n        <td>\n            
> Source:\n        </td>\n        <td>\n            PID\n        </td>\n    
> </tr>\n    <tr>\n        <td>\n            Score:\n        </td>\n        
> <td>\n            3.28024821395\n        </td>\n    </tr>\n</table>\n    
> ");data.setCell(3, 2, 3.2802482139484401);data.setCell(4, 0, "Estrogen 
> metabolism");data.setCell(4, 1, "\n<table id=\"tooltip\">\n    <tr>\n        
> <th colspan=\"2\">\n            Estrogen metabolism\n        </th>\n    
> </tr>\n    <tr>\n        <td>\n            Source:\n        </td>\n        
> <td>\n            Wikipathways\n        </td>\n    </tr>\n    <tr>\n        
> <td>\n            Score:\n        </td>\n        <td>\n            
> 3.25614745919\n        </td>\n    </tr>\n</table>\n    ");data.setCell(4, 2, 
> 3.2561474591863502);data.setCell(5, 0, "Vitamin A (retinol) 
> metabolism");data.setCell(5, 1, "\n<table id=\"tooltip\">\n    <tr>\n        
> <th colspan=\"2\">\n            Vitamin A (retinol) metabolism\n        
> </th>\n    </tr>\n    <tr>\n        <td>\n            Source:\n        
> </td>\n        <td>\n            EHMN\n        </td>\n    </tr>\n    <tr>\n   
>      <td>\n            Score:\n        </td>\n        <td>\n            
> 3.07886384299\n        </td>\n    </tr>\n</table>\n    ");data.setCell(5, 2, 
> 3.0788638429905202);data.setCell(6, 0, "Fatty Acid Omega 
> Oxidation");data.setCell(6, 1, "\n<table id=\"tooltip\">\n    <tr>\n        
> <th colspan=\"2\">\n            Fatty Acid Omega Oxidation\n        </th>\n   
>  </tr>\n    <tr>\n        <td>\n            Source:\n        </td>\n        
> <td>\n            Wikipathways\n        </td>\n    </tr>\n    <tr>\n        
> <td>\n            Score:\n        </td>\n        <td>\n            
> 3.02371577651\n        </td>\n    </tr>\n</table>\n    ");data.setCell(6, 2, 
> 3.0237157765081699);data.setCell(7, 0, "Tamoxifen 
> metabolism");data.setCell(7, 1, "\n<table id=\"tooltip\">\n    <tr>\n        
> <th colspan=\"2\">\n            Tamoxifen metabolism\n        </th>\n    
> </tr>\n    <tr>\n        <td>\n            Source:\n        </td>\n        
> <td>\n            Wikipathways\n        </td>\n    </tr>\n    <tr>\n        
> <td>\n            Score:\n        </td>\n        <td>\n            
> 2.97448827603\n        </td>\n    </tr>\n</table>\n    ");data.setCell(7, 2, 
> 2.9744882760281302);data.setCell(8, 0, "Activated AMPK stimulates fatty-acid 
> oxidation in muscle");data.setCell(8, 1, "\n<table id=\"tooltip\">\n    
> <tr>\n        <th colspan=\"2\">\n            Activated AMPK stimulates 
> fatty-acid oxidation in muscle\n        </th>\n    </tr>\n    <tr>\n        
> <td>\n            Source:\n        </td>\n        <td>\n            PID\n     
>    </td>\n    </tr>\n    <tr>\n        <td>\n            Score:\n        
> </td>\n        <td>\n            2.70635126591\n        </td>\n    
> </tr>\n</table>\n    ");data.setCell(8, 2, 
> 2.7063512659144999);data.setCell(9, 0, "Xenobiotics");data.setCell(9, 1, 
> "\n<table id=\"tooltip\">\n    <tr>\n        <th colspan=\"2\">\n            
> Xenobiotics\n        </th>\n    </tr>\n    <tr>\n        <td>\n            
> Source:\n        </td>\n        <td>\n            Reactome\n        </td>\n   
>  </tr>\n    <tr>\n        <td>\n            Score:\n        </td>\n        
> <td>\n            2.68022800253\n        </td>\n    </tr>\n</table>\n    
> ");data.setCell(9, 2, 2.6802280025310199);data.setCell(10, 0, "Linoleic acid 
> (LA) metabolism");data.setCell(10, 1, "\n<table id=\"tooltip\">\n    <tr>\n   
>      <th colspan=\"2\">\n            Linoleic acid (LA) metabolism\n        
> </th>\n    </tr>\n    <tr>\n        <td>\n            Source:\n        
> </td>\n        <td>\n            Reactome\n        </td>\n    </tr>\n    
> <tr>\n        <td>\n            Score:\n        </td>\n        <td>\n         
>    2.63165923553\n        </td>\n    </tr>\n</table>\n    ");data.setCell(10, 
> 2, 2.6316592355259401);data.setCell(11, 0, "oleate biosynthesis II 
> (animals)");data.setCell(11, 1, "\n<table id=\"tooltip\">\n    <tr>\n        
> <th colspan=\"2\">\n            oleate biosynthesis II (animals)\n        
> </th>\n    </tr>\n    <tr>\n        <td>\n            Source:\n        
> </td>\n        <td>\n            HumanCyc\n        </td>\n    </tr>\n    
> <tr>\n        <td>\n            Score:\n        </td>\n        <td>\n         
>    2.45033361866\n        </td>\n    </tr>\n</table>\n    ");data.setCell(11, 
> 2, 2.4503336186639699);data.setCell(12, 0, "Sodium-coupled sulphate, di- and 
> tri-carboxylate transporters");data.setCell(12, 1, "\n<table 
> id=\"tooltip\">\n    <tr>\n        <th colspan=\"2\">\n            
> Sodium-coupled sulphate, di- and tri-carboxylate transporters\n        
> </th>\n    </tr>\n    <tr>\n        <td>\n            Source:\n        
> </td>\n        <td>\n            PID\n        </td>\n    </tr>\n    <tr>\n    
>     <td>\n            Score:\n        </td>\n        <td>\n            
> 2.41280443003\n        </td>\n    </tr>\n</table>\n    ");data.setCell(12, 2, 
> 2.4128044300301599);data.setCell(13, 0, "Sodium-coupled sulphate, di- and 
> tri-carboxylate transporters");data.setCell(13, 1, "\n<table 
> id=\"tooltip\">\n    <tr>\n        <th colspan=\"2\">\n            
> Sodium-coupled sulphate, di- and tri-carboxylate transporters\n        
> </th>\n    </tr>\n    <tr>\n        <td>\n            Source:\n        
> </td>\n        <td>\n            Reactome\n        </td>\n    </tr>\n    
> <tr>\n        <td>\n            Score:\n        </td>\n        <td>\n         
>    2.41280443003\n        </td>\n    </tr>\n</table>\n    ");data.setCell(13, 
> 2, 2.4128044300301599);data.setCell(14, 0, "Arylhydrocarbon receptor (AhR) 
> signaling pathway");data.setCell(14, 1, "\n<table id=\"tooltip\">\n    <tr>\n 
>        <th colspan=\"2\">\n            Arylhydrocarbon receptor (AhR) 
> signaling pathway\n        </th>\n    </tr>\n    <tr>\n        <td>\n         
>    Source:\n        </td>\n        <td>\n            Wikipathways\n        
> </td>\n    </tr>\n    <tr>\n        <td>\n            Score:\n        </td>\n 
>        <td>\n            2.4068884386\n        </td>\n    </tr>\n</table>\n   
>  ");data.setCell(14, 2, 2.4068884385953799);data.setCell(15, 0, "Triglyceride 
> Biosynthesis");data.setCell(15, 1, "\n<table id=\"tooltip\">\n    <tr>\n      
>   <th colspan=\"2\">\n            Triglyceride Biosynthesis\n        </th>\n  
>   </tr>\n    <tr>\n        <td>\n            Source:\n        </td>\n        
> <td>\n            PID\n        </td>\n    </tr>\n    <tr>\n        <td>\n     
>        Score:\n        </td>\n        <td>\n            2.29185264558\n       
>  </td>\n    </tr>\n</table>\n    ");data.setCell(15, 2, 
> 2.2918526455769599);data.setCell(16, 0, "Glyoxylate 
> metabolism");data.setCell(16, 1, "\n<table id=\"tooltip\">\n    <tr>\n        
> <th colspan=\"2\">\n            Glyoxylate metabolism\n        </th>\n    
> </tr>\n    <tr>\n        <td>\n            Source:\n        </td>\n        
> <td>\n            Reactome\n        </td>\n    </tr>\n    <tr>\n        
> <td>\n            Score:\n        </td>\n        <td>\n            
> 2.28677838278\n        </td>\n    </tr>\n</table>\n    ");data.setCell(16, 2, 
> 2.2867783827828698);data.setCell(17, 0, "eicosapentaenoate biosynthesis II 
> (metazoa)");data.setCell(17, 1, "\n<table id=\"tooltip\">\n    <tr>\n        
> <th colspan=\"2\">\n            eicosapentaenoate biosynthesis II (metazoa)\n 
>        </th>\n    </tr>\n    <tr>\n        <td>\n            Source:\n        
> </td>\n        <td>\n            HumanCyc\n        </td>\n    </tr>\n    
> <tr>\n        <td>\n            Score:\n        </td>\n        <td>\n         
>    2.24013447152\n        </td>\n    </tr>\n</table>\n    ");data.setCell(17, 
> 2, 2.2401344715171798);data.setCell(18, 0, "fatty acid &alpha;-oxidation 
> II");data.setCell(18, 1, "\n<table id=\"tooltip\">\n    <tr>\n        <th 
> colspan=\"2\">\n            fatty acid &alpha;-oxidation II\n        </th>\n  
>   </tr>\n    <tr>\n        <td>\n            Source:\n        </td>\n        
> <td>\n            HumanCyc\n        </td>\n    </tr>\n    <tr>\n        
> <td>\n            Score:\n        </td>\n        <td>\n            
> 2.08453543191\n        </td>\n    </tr>\n</table>\n    ");data.setCell(18, 2, 
> 2.0845354319114899);data.setCell(19, 0, "Cyclin B2 mediated 
> events");data.setCell(19, 1, "\n<table id=\"tooltip\">\n    <tr>\n        <th 
> colspan=\"2\">\n            Cyclin B2 mediated events\n        </th>\n    
> </tr>\n    <tr>\n        <td>\n            Source:\n        </td>\n        
> <td>\n            Reactome\n        </td>\n    </tr>\n    <tr>\n        
> <td>\n            Score:\n        </td>\n        <td>\n            
> 2.02388474985\n        </td>\n    </tr>\n</table>\n    ");data.setCell(19, 2, 
> 2.0238847498537198);data.setCell(20, 0, "Bile salt and organic anion SLC 
> transporters");data.setCell(20, 1, "\n<table id=\"tooltip\">\n    <tr>\n      
>   <th colspan=\"2\">\n            Bile salt and organic anion SLC 
> transporters\n        </th>\n    </tr>\n    <tr>\n        <td>\n            
> Source:\n        </td>\n        <td>\n            Reactome\n        </td>\n   
>  </tr>\n    <tr>\n        <td>\n            Score:\n        </td>\n        
> <td>\n            2.00409320451\n        </td>\n    </tr>\n</table>\n    
> ");data.setCell(20, 2, 2.0040932045128299);data.setCell(21, 0, "Oxidative 
> Stress");data.setCell(21, 1, "\n<table id=\"tooltip\">\n    <tr>\n        <th 
> colspan=\"2\">\n            Oxidative Stress\n        </th>\n    </tr>\n    
> <tr>\n        <td>\n            Source:\n        </td>\n        <td>\n        
>     Wikipathways\n        </td>\n    </tr>\n    <tr>\n        <td>\n          
>   Score:\n        </td>\n        <td>\n            2.00302885626\n        
> </td>\n    </tr>\n</table>\n    ");data.setCell(21, 2, 2.0030288562606899);   
>      var options = {            width: 800,            height: 660,           
>  legend: 'none',            backgroundColor: '#EEE',            colors: 
> ['red'],            chartArea: {left: 200, top: 22, bottom: 22},            
> focusTarget: 'category',            tooltip: {isHtml: true}        };        
> var chart = new 
> google.visualization.BarChart(document.getElementById('fig7cc3514cc4874932b512f155eb7959de'));
>         chart.draw(data, options);    }    
> google.setOnLoadCallback(drawChart);</script>
>
>

-- 
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