var labelType, useGradients, nativeTextSupport, animate; (function() { var ua = navigator.userAgent, iStuff = ua.match(/iPhone/i) || ua.match(/iPad/i), typeOfCanvas = typeof HTMLCanvasElement, nativeCanvasSupport = (typeOfCanvas == 'object' || typeOfCanvas == 'function'), textSupport = nativeCanvasSupport && (typeof document.createElement('canvas').getContext('2d').fillText == 'function'); //I'm setting this based on the fact that ExCanvas provides text support for IE //and that as of today iPhone/iPad current text support is lame labelType = (!nativeCanvasSupport || (textSupport && !iStuff))? 'Native' : 'HTML'; nativeTextSupport = labelType == 'Native'; useGradients = nativeCanvasSupport; animate = !(iStuff || !nativeCanvasSupport); })(); var Log = { elem: false, write: function(text){ if (!this.elem) this.elem = document.getElementById('log'); this.elem.innerHTML = text; this.elem.style.left = (500 - this.elem.offsetWidth / 2) + 'px'; } }; function init(){ //init data var json = { "children": [ { "data":{"cap":"$14,418,875,000","sec": "Yes","$area": 11392016384,"$color":"#009900"}, "id": "Transocean Ltd", "name": "Transocean Ltd" }, { "data":{"cap":"$11,597,102,000","sec": "Yes","$area": 9162599424,"$color":"#009900"}, "id": "Weatherford Intl Ltd", "name": "Weatherford Intl Ltd" }, { "data":{"cap":"$136,651,000","sec": "No","$area": 107964440,"$color":"#192B4F"}, "id": "Petroplus Holdings Ag", "name": "Petroplus Holdings Ag" }, { "data":{"cap":"","sec": "No","$area": 1,"$color":"#1C2D47"}, "id": "Alumina Ltd-ch Certificate *", "name": "Alumina Ltd-ch Certificate *" }, { "data":{"cap":"$790,940,000","sec": "No","$area": 624902912,"$color":"#1A2E45"}, "id": "Schmolz+bickenbach Ag-reg", "name": "Schmolz+bickenbach Ag-reg" }, { "data":{"cap":"$41,129,000","sec": "No","$area": 32494954,"$color":"#142B4A"}, "id": "Zwahlen & Mayr Sa-br", "name": "Zwahlen & Mayr Sa-br" }, { "data":{"cap":"$11,227,000","sec": "No","$area": 8870192,"$color":"#1B3158"}, "id": "Swissmetal Holding Ag", "name": "Swissmetal Holding Ag" }, { "data":{"cap":"$648,403,000","sec": "No","$area": 512287744,"$color":"#182A38"}, "id": "International Minerals Corp *", "name": "International Minerals Corp *" }, { "data":{"cap":"$99,263,691,000","sec": "Yes","$area": 78425923584,"$color":"#009900"}, "id": "Schlumberger Ltd *", "name": "Schlumberger Ltd *" }, { "data":{"cap":"$11,548,468,000","sec": "Yes","$area": 9124174848,"$color":"#009900"}, "id": "Gold Fields Ltd *", "name": "Gold Fields Ltd *" }, { "data":{"cap":"$20,376,523,000","sec": "Yes","$area": 16099014656,"$color":"#009900"}, "id": "Baker Hughes Inc *", "name": "Baker Hughes Inc *" }, { "data":{"cap":"$54,721,560,000","sec": "No","$area": 43234226176,"$color":"#1B2E4E"}, "id": "Anglo American Plc *", "name": "Anglo American Plc *" }, { "data":{"cap":"$50,241,339,000","sec": "No","$area": 39694508032,"$color":"#1D2833"}, "id": "Xstrata Plc *", "name": "Xstrata Plc *" }, { "data":{"cap":"$86,172,886,000","sec": "No","$area": 68083183616,"$color":"#182D62"}, "id": "China Shenhua Energy Co-h *", "name": "China Shenhua Energy Co-h *" }, { "data":{"cap":"","sec": "No","$area": 1,"$color":"#142945"}, "id": "Transocean Ltd - 2nd Line *", "name": "Transocean Ltd - 2nd Line *" } ] }; //end //init TreeMap var tm = new $jit.TM.Squarified({ //where to inject the visualization injectInto: 'infovis', //parent box title heights titleHeight: 0, //enable animations animate: false, //box offsets offset: 1, //Attach left and right click events Events: { enable: false }, duration: 1000, //Enable tips Tips: { enable: true, //add positioning offsets offsetX: 20, offsetY: 20, //implement the onShow method to //add content to the tooltip when a node //is hovered onShow: function(tip, node, isLeaf, domElement) { var html = "