{"id":249,"date":"2013-05-29T02:24:50","date_gmt":"2013-05-28T20:24:50","guid":{"rendered":"http:\/\/markwheeler.com\/wordpress\/?p=249"},"modified":"2013-05-29T02:24:50","modified_gmt":"2013-05-28T20:24:50","slug":"google-treemap-chart-from-sharepoint-list","status":"publish","type":"post","link":"https:\/\/markwheeler.com\/?p=249","title":{"rendered":"Google Treemap Chart from Sharepoint list"},"content":{"rendered":"<p>Just a little exercise to pull data from a Sharepoint list and visualize it with a Google Treemap. My Sharepoint list was a simple query to pull Support Groups from BMC Remedy and the # of tickets &#8216;In Progress.&#8217;<\/p>\n<p>The structure is [Title] (or Support Group), [Parent], [TicketsInProgress], [TotalTickets]<\/p>\n<p><strong>\/\/ Add reference to JQUERY library.<\/strong><\/p>\n<p>&lt;script type=&#8221;text\/javascript&#8221; src=&#8221;jquery-1.10.0.min.js&#8221;&gt;&lt;\/script&gt;<\/p>\n<p><strong>\/\/ Add reference to Google APIs<\/strong><\/p>\n<p>&lt;script type=&#8221;text\/javascript&#8221; src=&#8221;https:\/\/www.google.com\/jsapi&#8221;&gt;&lt;\/script&gt;<br \/>\n&lt;script type=&#8221;text\/javascript&#8221;&gt;<br \/>\ngoogle.load(&#8220;visualization&#8221;, &#8220;1&#8221;, {packages:[&#8220;treemap&#8221;]});<br \/>\ngoogle.setOnLoadCallback(drawChart);<br \/>\nfunction drawChart() {<\/p>\n<p><strong>\/\/ Go get the Sharepoint list.<\/strong><\/p>\n<p>$(document).ready(function() {<br \/>\nvar soapEnv =<br \/>\n&#8220;&lt;soapenv:Envelope xmlns:soapenv=&#8217;http:\/\/schemas.xmlsoap.org\/soap\/envelope\/&#8217;&gt;<br \/>\n&lt;soapenv:Body&gt;<br \/>\n&lt;GetListItems xmlns=&#8217;http:\/\/schemas.microsoft.com\/sharepoint\/soap\/&#8217;&gt;<br \/>\n&lt;listName&gt;<strong>TreeMapData<\/strong>&lt;\/listName&gt;<br \/>\n&lt;viewFields&gt;<br \/>\n&lt;ViewFields&gt;<br \/>\n&lt;FieldRef Name=&#8217;Title&#8217; \/&gt;<br \/>\n&lt;FieldRef Name=&#8217;Parent&#8217; \/&gt;<br \/>\n&lt;FieldRef Name=&#8217;InProgess&#8217; \/&gt;<br \/>\n&lt;\/ViewFields&gt;  &lt;\/viewFields&gt;  &lt;\/GetListItems&gt;<br \/>\n&lt;\/soapenv:Body&gt;<br \/>\n&lt;\/soapenv:Envelope&gt;&#8221;;<br \/>\n$.ajax({<br \/>\n<strong>\/\/ URL to your site or subsite.<\/strong><br \/>\nurl: &#8220;\/sandbox\/_vti_bin\/lists.asmx&#8221;,<br \/>\ntype: &#8220;POST&#8221;,<br \/>\ndataType: &#8220;xml&#8221;,<br \/>\n<em id=\"__mceDel\"><em id=\"__mceDel\"><em id=\"__mceDel\">data: soapEnv,<br \/>\n<em id=\"__mceDel\"><em id=\"__mceDel\"><em id=\"__mceDel\"><em id=\"__mceDel\"><em id=\"__mceDel\">complete: processResult,<br \/>\n<em id=\"__mceDel\"><em id=\"__mceDel\"><em id=\"__mceDel\"><em id=\"__mceDel\"><em id=\"__mceDel\"><em id=\"__mceDel\">contentType: &#8220;text\/xml; charset=&#8221;utf-8&#8243;&#8221;<\/em><\/em><\/em><\/em><\/em><\/em><\/em><\/em><\/em><\/em><\/em><\/em><\/em><\/em><\/p>\n<p><em id=\"__mceDel\"><em id=\"__mceDel\"><em id=\"__mceDel\"><em id=\"__mceDel\"><em id=\"__mceDel\"><em id=\"__mceDel\"> });<br \/>\n});<\/em><\/em><\/em><\/em><\/em><\/em><br \/>\n<strong>\/\/ Create and populate the data table.<\/strong><\/p>\n<p>var data = new google.visualization.DataTable();<br \/>\ndata.addColumn (&#8216;string&#8217;, &#8216;Title&#8217;);<br \/>\ndata.addColumn (&#8216;string&#8217;, &#8216;Parent&#8217;);<br \/>\ndata.addColumn (&#8216;number&#8217;, &#8216;InProgress&#8217;);<br \/>\ndata.addColumn (&#8216;number&#8217;, &#8216;Color&#8217;);<br \/>\ndata.addRow([&#8216;Support Group&#8217;, null,0,0]);<\/p>\n<p><strong>\/\/ First row is the Parent Node that is required to create the master container for the TreeMap<\/strong><\/p>\n<p><strong>\/\/ Append Sharepoint List<\/strong><\/p>\n<p><em id=\"__mceDel\">function processResult(xData, status) {<br \/>\n$(xData.responseXML).find(&#8220;z\\:row&#8221;).each(function() {<br \/>\n<strong>\/\/ I converted the ajax results to variables so I could format the numeric columns. This is probably necessary as I could not get the next addRow to work properly.<\/strong><br \/>\nvar title = $(this).attr(&#8220;ows_Title&#8221;);<br \/>\nvar tix = Math.floor($(this).attr(&#8220;ows_InProgess&#8221;));<br \/>\ndata.addRow([{v:title},&#8217;Support Group&#8217;, {v:tix},{v:tix}]);<br \/>\n});<\/em><\/p>\n<p><strong>\/\/ Add dummy last row in table. Probably not necessary.<\/strong><\/p>\n<p>data.addRow([&#8216;NONE&#8217;,&#8217;Support Group&#8217;,null,null]);<\/p>\n<p><strong>\/\/ Create and draw the visualization.<\/strong><\/p>\n<p>var tree = new google.visualization.TreeMap(document.getElementById(&#8216;chart_div&#8217;));<\/p>\n<p>tree.draw(data, {<\/p>\n<p>minColor: &#8216;#0d0&#8217;,<br \/>\nmidColor: &#8216;#ddd&#8217;,<br \/>\nmaxColor: &#8216;#f00&#8217;,<br \/>\nminColorValue: 1,<br \/>\nmaxColorValue: 30,<br \/>\nheaderHeight: 15,<br \/>\nfontColor: &#8216;black&#8217;,<br \/>\nshowScale: false});<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>&lt;\/script&gt;<\/p>\n<p>&lt;body&gt;<br \/>\n&lt;div id=&#8221;chart_div&#8221; style=&#8221;width: 900px; height: 500px;&#8221;&gt;&lt;\/div&gt;<br \/>\n&lt;\/body&gt;<\/p>\n<p><a href=\"\/images\/treemapdemo.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" alt=\"\" src=\"\/images\/treemapdemo.png\" width=\"538\" height=\"305\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Just a little exercise to pull data from a Sharepoint list and visualize it with a Google Treemap. My Sharepoint list was a simple query to pull Support Groups from BMC Remedy and the # of tickets &#8216;In Progress.&#8217; The structure is [Title] (or Support Group), [Parent], [TicketsInProgress], [TotalTickets] \/\/ [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[2,10,11],"tags":[51],"class_list":["post-249","post","type-post","status-publish","format-standard","hentry","category-computer","category-sharepoint","category-software","tag-google-treemap"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/markwheeler.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/markwheeler.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=249"}],"version-history":[{"count":0,"href":"https:\/\/markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/249\/revisions"}],"wp:attachment":[{"href":"https:\/\/markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}