(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(treeMapInfos) { const colorMapping = {}; let colors = ColorPalette.otherChartLib.treeMapChart; function getColorForName(name) { if (!colorMapping[name]) { const selectedColor = colors.shift(); colorMapping[name] = selectedColor; colors = colors.filter(color => color !== selectedColor); } return colorMapping[name]; } treeMapInfos.children.forEach((worker) => { worker.children.forEach((task) => { const color = getColorForName(task.name); task.data.$color = color; task.id = task.id + "-" + worker.id; task.data.$area = task.data.involvedCount; }); worker.data.$area = worker.data.totalInvolvedCount; }); //init TreeMap var tm = new $jit.TM.Squarified({ //where to inject the visualization injectInto: "chart-manpower-requirement", //parent box title heights titleHeight: 22, //enable animations animate: animate, //box offsets offset: 2.5, //Attach left and right click events Events: { enable: true, onClick: function (node) { if (node) tm.enter(node); }, onRightClick: function () { tm.out(); } }, duration: 300, //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 = '