// Generated by LiveScript 1.2.0 var ref$, map, camelize, take, keys, ggl, nestData, fontbrewer, i$, len$, itm, setupBackground, setupDrop, setupView, hideCancel, setupHightlighting, varSetHash, hashSetVar, getC, getFontC, numberWithCommas, empty, getRandom, zeroIfNaN, sortData, rvnSortData, genAttr, sbMnmx, sbSum, sbTms, substringMatcher, setUpTreemap, setUpIndustry, setUpData, setUpRange, createGrid, gridGetX, gridGetY, treemapPosition, colorscl, toTree, vAlignGetX, vAlignGetY, recolor, posPanel, shpPanel, toPanel, toIndustry, sorting, sortRectExpand, highlightingCompany, cancelHighlight, highlightingIndustry, highlighting, resetSubind, resetInd, reset, expandSubIndustry, mouseExpand, initial, changeExplain, sortAgain, setList, afterload, cleanName, navidx, navcontent; ref$ = require("prelude-ls"), map = ref$.map, camelize = ref$.camelize, take = ref$.take, keys = ref$.keys; ggl = {}; ggl.margin = { top: 121, left: 180, right: 20, bottom: 20 }; ggl.w = 1150 - ggl.margin.left - ggl.margin.right; ggl.h = 500 - ggl.margin.top - ggl.margin.bottom; ggl.cntnrw = ggl.w; ggl.sortBool = -1; ggl.delay = 1; ggl.ind = "manufacturing"; ggl.sbind = null; ggl.srt = "rvn"; ggl.hghlght = false; ggl.view = "viewtree"; ggl.data = []; ggl.node = null; ggl.rect = {}; ggl.rect.minw = 1; ggl.rect.w = 70; ggl.rect.h = 30; ggl.rect.font = 16; ggl.rect.lgscl = 1; ggl.rect.margin = 2; ggl.rect.byrow = Math.floor(ggl.cntnrw / ggl.rect.w); ggl.rect.borderw = 3; ggl.rect.xpndborderw = 2; ggl.rect.txtindent = 10; ggl.rect.ddlw = 77; ggl.rect.xpndlfmargin = ggl.rect.w * ggl.rect.lgscl + 5; ggl.bckcolor = "white"; ggl.fntcolor = "black"; ggl.colorscheme = "RdYlBu"; ggl.rect.indtxtindent = 3; ggl.highed_company = []; ggl.highed_industry = null; ggl.hashls = []; ggl.animation = true; ggl.all = {}; ggl.all.company = []; ggl.all.industry = []; ggl.treemap = null; ggl.initflag = true; console.log(ggl); nestData = { key: "Taiwan", values: ggl.data }; fontbrewer = []; for (i$ = 0, len$ = (ref$ = colorbrewer[ggl.colorscheme]["9"]).length; i$ < len$; ++i$) { itm = ref$[i$]; if (d3.hsl(itm).l > 0.7) { fontbrewer.push("black"); } else { fontbrewer.push("white"); } } setupBackground = function(){ d3.select("body").style("background-color", ggl.bckcolor); return d3.selectAll(".subhead").style("background-color", ggl.bckcolor).style("color", ggl.fntcolor); }; setupDrop = function(){ var i$, ref$, len$, itm, results$ = []; for (i$ = 0, len$ = (ref$ = industryList).length; i$ < len$; ++i$) { itm = ref$[i$]; if (ggl.ind === itm.act) { d3.select(".theindustry").text(itm.text); } } for (i$ = 0, len$ = (ref$ = questionList).length; i$ < len$; ++i$) { itm = ref$[i$]; if (ggl.srt === itm.act) { results$.push(d3.select(".thequestion").text(itm.text)); } } return results$; }; setupView = function(){ return d3.selectAll(".change-view").selectAll(".btn-default")[0].map(function(it){ var b; if (it.innerHTML.indexOf(viewRevTable[ggl.view]) > 0) { b = true; } else { b = false; } return d3.select(it).classed("active", b); }); }; hideCancel = function(){ return d3.selectAll(".cancel-highed").style({ "display": "inline" }); }; setupHightlighting = function(){ if (ggl.highed_industry !== null) { hideCancel(); highlightingIndustry(ggl.highed_industry); } if (ggl.highed_company.length !== 0) { hideCancel(); return ggl.highed_company.map(function(it){ return highlightingCompany(it); }); } }; varSetHash = function(it){ var s, f; if (arguments.length > 0) { if (ggl[it] === undefined || ggl[it] === null) { return; } if (!in$(it, ggl.hashls)) { ggl.hashls.push(it); } } s = "#"; f = true; ggl.hashls = ggl.hashls.filter(function(it){ console.log(ggl[it]); if (ggl[it] !== null && ggl[it].length !== 0) { s += (f ? "" : "&") + it + "=" + ggl[it]; f = false; return true; } else { return false; } }); return window.location.hash = s; }; hashSetVar = function(){ var s, i$, len$, itm, t; if (window.location.hash) { s = window.location.hash.split("#")[1].split("&"); for (i$ = 0, len$ = s.length; i$ < len$; ++i$) { itm = s[i$]; t = itm.split("="); if (t["0"] === "highed_company") { t["1"].split(",").map(fn$); } else if (t["0"] === "rect.borderw") { ggl.rect.borderw = t["1"]; } else { ggl[t["0"]] = t["1"]; } ggl.hashls.push(t["0"]); } } setupDrop(); setupView(); setupHightlighting(); return setupBackground(); function fn$(it){ if (ggl.highed_company.indexOf(it) <= -1 && it !== "") { return ggl.highed_company.push(it); } } }; getC = function(i){ var idx; idx = Math.floor(i / ggl.data.length * 9); return colorbrewer[ggl.colorscheme]["9"][idx]; }; getFontC = function(i){ var idx; idx = Math.floor(i / ggl.data.length * 9); return fontbrewer[8 - idx]; }; numberWithCommas = function(it){ var parts; parts = it.toString().split("."); parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); return parts.join("."); }; empty = function(obj){ return Object.keys(obj).length === 0; }; getRandom = function(range){ if (range === undefined) { return Math.random(); } else { return Math.floor( Math.random() * range); } }; zeroIfNaN = function(it){ if (isNaN(it)) { return 0; } else { return it; } }; sortData = function(a, b){ var compareInds; if (ggl.view === "viewindustry") { compareInds = (sbSum[ggl.srt][a.subindustry] - sbSum[ggl.srt][b.subindustry]) * ggl.sortBool; if (compareInds !== 0) { return compareInds; } } return zeroIfNaN(a[ggl.srt] - zeroIfNaN(b[ggl.srt])) * ggl.sortBool; }; rvnSortData = function(a, b){ return zeroIfNaN(a["rvn"] - zeroIfNaN(b["rvn"])) * ggl.sortBool; }; genAttr = function(){ return { rvn: {}, rvngrwth: {}, sst: {}, eat: {}, eps: {}, cptl: {}, mrg: {}, roa: {}, roe: {}, dta: {}, ppl: {}, cntrppl: {} }; }; sbMnmx = genAttr(); sbSum = genAttr(); sbTms = genAttr(); (function(){ return d3.select("body").select("#ind-show").append("div").style({ "top": ggl.margin.top + "px", "left": "0px", "width": 1000 + "px", "height": ggl.rect.lgscl * ggl.rect.h + "px", "z-index": "2", "position": "fixed", "background-color": ggl.bckcolor, "display": "none", "cursor": "default" }).attr({ "class": "subhead" }).selectAll("blank").data(sbExpHeader).enter().append("div").attr({ "data-toggle": "tooltip", "data-placement": "bottom", "title": function(it){ return "

" + it.title + "

" + it.explain + "

"; }, "rel": "tooltip", "class": "subhead" }).style("width", ggl.rect.ddlw + "px").style("height", ggl.rect.lgscl * ggl.rect.h + "px").style("line-height", ggl.rect.lgscl * ggl.rect.h + "px").style("vertical-align", "center").style("position", "fixed").style("left", function(d, i){ return ggl.margin.left + ggl.rect.xpndlfmargin + (ggl.rect.margin + ggl.rect.ddlw) * i + "px"; }).style("top", ggl.margin.top + "px").style("box-shadow", function(d, i){ return "0 0 0 " + ggl.rect.xpndborderw + "px white inset"; }).style("color", ggl.fntcolor).style("text-align", "center").style("font-family", "Noto Sans, Heiti TC, WenQuanYi Zen Hei, 微軟正黑體, Microsoft JhengHei, PMingLiU").text(function(it){ return it.shrt; }).on("mousedown", function(it){ ggl.srt = it.header; return sortAgain(); }); })(); substringMatcher = function(strs){ return function(q, cb){ var matches, substrRegex; matches = []; substrRegex = new RegExp(q, 'i'); $.each(strs, function(i, str){ if (substrRegex.test(str)) { return matches.push({ value: str }); } }); return cb(matches); }; }; setUpTreemap = function(it){ return it.each(function(it){ it.treex = it.x; return it.treey = it.y; }); }; setUpIndustry = function(it){ var crrInd, curX, curY, setScale, scaleWidth, showLess, calPosition; crrInd = null; curX = 0; curY = 0; setScale = function(rectSum, rectTime){ return function(it){ if (isNaN(it)) { return 0; } else { return d3.scale.linear().domain([0, rectSum]).range([ggl.rect.minw, ggl.cntnrw - rectTime])(it); } }; }; scaleWidth = function(cnt){ return cnt; }; showLess = function(it){ var i$, to$, i; for (i$ = 0, to$ = it.name.length; i$ <= to$; ++i$) { i = i$; if ((i + 1) * ggl.rect.font > scaleWidth(it[ggl.srt]) - ggl.rect.txtindent * 2) { break; } } if (i < 2) { return ""; } else { return take(i, it.name); } }; calPosition = function(it){ ggl.view = "viewindustry"; it.sort(sortData).each(function(d, i){ if (crrInd !== d.subindustry) { curY += ggl.rect.h + ggl.rect.margin - (i > 0 ? 0 : ggl.rect.h); curX = 0; crrInd = d.subindustry; scaleWidth = setScale(sbSum[ggl.srt][crrInd], sbTms[ggl.srt][crrInd]); } d.indx = curX; d.indy = curY; if (isNaN(d[ggl.srt])) { d.indwidth = 0; } else { d.indwidth = scaleWidth( d[ggl.srt]); curX += d.indwidth + ggl.rect.margin; } return d.shrtnm = showLess(d); }); return ggl.view = "viewpanel"; }; return it.call(calPosition); }; setUpData = function(it){ return it.call(setUpTreemap).call(setUpIndustry).sort(sortData); }; setUpRange = function(){ var itm, lresult$, sub, results$ = []; ggl.data.forEach(function(d, i){ var sub, i$, ref$, len$, itm, results$ = []; sub = d.subindustry; for (i$ = 0, len$ = (ref$ = sbExpHeader).length; i$ < len$; ++i$) { itm = ref$[i$]; if (isNaN(d[itm.header])) { continue; } else { if (sbMnmx[itm.header][sub] === undefined && !isNaN(d[itm.header])) { sbMnmx[itm.header][sub] = {}; sbMnmx[itm.header][sub]["max"] = d[itm.header]; sbMnmx[itm.header][sub]["min"] = d[itm.header]; } if (d[itm.header] < sbMnmx[itm.header][sub]["min"]) { sbMnmx[itm.header][sub]["min"] = d[itm.header]; } if (d[itm.header] > sbMnmx[itm.header][sub]["max"]) { sbMnmx[itm.header][sub]["max"] = d[itm.header]; } if (sbSum[itm.header][sub] === undefined) { sbSum[itm.header][sub] = 0; sbTms[itm.header][sub] = 0; } sbSum[itm.header][sub] += d[itm.header]; results$.push(sbTms[itm.header][sub] += ggl.rect.margin + ggl.rect.minw); } } return results$; }); for (itm in sbMnmx) { lresult$ = []; for (sub in sbMnmx[itm]) { if (sbMnmx[itm]["max"] === undefined) { sbMnmx[itm]["max"] = sbMnmx[itm][sub]["max"]; sbMnmx[itm]["min"] = sbMnmx[itm][sub]["min"]; } if (sbMnmx[itm]["max"] < sbMnmx[itm][sub]["max"]) { sbMnmx[itm]["max"] = sbMnmx[itm][sub]["max"]; } if (sbMnmx[itm]["min"] > sbMnmx[itm][sub]["min"]) { lresult$.push(sbMnmx[itm]["min"] = sbMnmx[itm][sub]["min"]); } } results$.push(lresult$); } return results$; }; console.log(nestData); console.log(ggl.data); console.log(colorbrewer); createGrid = function(_cntnrw, _rectwidth, _rectheight, _rectmargin, XorY){ var opr, mul, grid; ggl.rect.byrow = Math.floor(_cntnrw / _rectwidth); if (XorY === "x") { opr = function(a, b){ return a % b; }; mul = _rectwidth; } else { opr = function(a, b){ return a / b; }; mul = _rectheight; } grid = function(i){ return Math.floor(opr(i, ggl.rect.byrow)) * (mul + _rectmargin); }; return grid; }; gridGetX = createGrid(ggl.cntnrw, ggl.rect.w, ggl.rect.h, ggl.rect.margin, "x"); gridGetY = createGrid(ggl.cntnrw, ggl.rect.w, ggl.rect.h, ggl.rect.margin, "y"); treemapPosition = function(it){ return it.style({ "left": function(it){ return it.treex + "px"; }, "top": function(it){ return it.treey + "px"; }, "width": function(it){ return Math.max(0, it.dx - 1) + "px"; }, "height": function(it){ return it.dy + "px"; } }); }; colorscl = function(srt){ var scl, _; scl = d3.scale.linear().domain([sbMnmx[ggl.srt]["min"], sbMnmx[ggl.srt]["max"]]).range([8, 0]); _ = Math.floor( scl( srt)); return colorbrewer[ggl.colorscheme]["9"][_]; }; toTree = function(it){ ggl.view = "viewtree"; if (ggl.animation && !ggl.initflag) { return it.text(function(it){ if (it.dx > ggl.rect.font * 4) { return it.name; } }).call(setUpTreemap).transition().duration(1500).call(treemapPosition); } else { ggl.initflag = false; return it.text(function(it){ if (it.dx > ggl.rect.font * 4) { return it.name; } }).call(setUpTreemap).call(treemapPosition); } }; vAlignGetX = function(i){ return 0; }; vAlignGetY = function(i){ return (ggl.rect.h * ggl.rect.lgscl + ggl.rect.margin) * i; }; recolor = function(it){ return it.style("box-shadow", function(d, i){ return "0 0 5px " + ggl.rect.borderw + "px " + getC(i) + " inset"; }).style("color", ggl.fntcolor).style("border-radius", "4px"); }; posPanel = function(it){ return it.style("left", function(d, i){ return gridGetX(i) + "px"; }).style("top", function(d, i){ return gridGetY(i) + "px"; }); }; shpPanel = function(it){ return it.style("height", function(){ return ggl.rect.h + "px"; }).style("width", function(){ return ggl.rect.w + "px"; }).text(function(it){ return it.name; }); }; toPanel = function(it){ ggl.view = "viewpanel"; if (ggl.animation) { return it.call(shpPanel).transition().duration(2000).call(posPanel); } else { return it.call(shpPanel).call(posPanel); } }; toIndustry = function(it){ var posIndustry, shpIndustry, otherStyle, setIndName, nTran; ggl.view = "viewindustry"; posIndustry = function(it){ return it.style("position", "absolute").style("left", function(it){ return it.indx + "px"; }).style("top", function(it){ return it.indy + "px"; }); }; shpIndustry = function(it){ return it.style("width", function(it){ return it.indwidth + "px"; }).style("height", function(){ return ggl.rect.h + "px"; }); }; otherStyle = function(it){ return it.style("clear", "both").text(function(it){ return it.shrtnm; }); }; setIndName = function(){ d3.select("body").select(".overflow-holder").selectAll(".ind-tab").data(keys(sbTms[ggl.srt])).enter().append("div").attr("class", "ind-tab"); return d3.selectAll(".ind-tab").style("display", "inline").style("position", "absolute").text(function(it){ return indShrtTable[it]; }).style("color", ggl.fntcolor).each(function(it){ return d3.select(this).style("top", (+d3.select(".ids" + it).style("top").split("px")[0]) + ggl.margin.top + "px").style("left", ggl.rect.indtxtindent + "px"); }); }; nTran = it[0].length; if (ggl.animation) { return it.transition().duration(1000).call(posIndustry).call(shpIndustry).transition().duration(500).call(otherStyle).each("end", function(d, i){ if (i === nTran - 1) { return setIndName(); } }); } else { it.call(posIndustry).call(shpIndustry).call(otherStyle); return setIndName(); } }; sorting = function(selection, callback){ var nTran; nTran = selection[0].length; return selection.transition().duration(1000).delay(function(d, i){ return i * ggl.delay; }).style("left", function(it){ return it.x + "px"; }).style("top", function(it){ return it.y + "px"; }).each("end", function(d, i){ if (i === nTran - 1 && callback !== undefined) { return callback(selection); } }); }; sortRectExpand = function(){ return d3.selectAll(".ids" + ggl.sbind).sort(sortData).each(function(d, i){ return d.y = (i + 1) * (ggl.rect.h * ggl.rect.lgscl + ggl.rect.margin); }).call(sorting); }; highlightingCompany = function(name){ if (ggl.highed_company.indexOf(name) <= -1) { ggl.highed_company.push(name); varSetHash("highed_company"); } d3.selectAll(".cmpnl").filter(function(it){ if (ggl.highed_company.indexOf(it.MNMC.trim()) <= -1) { return true; } else { return false; } }).transition().style("opacity", 0.2); return d3.selectAll(".cmpnl").filter(function(it){ if (ggl.highed_company.indexOf(it.MNMC) > -1) { return true; } else { return false; } }).transition().style("opacity", 1); }; cancelHighlight = function(){ ggl.highed_industry = null; ggl.highed_company = []; d3.selectAll(".cancel-highed").style({ "display": "none" }); d3.selectAll(".cmpnl").transition().style("opacity", 1); return varSetHash(); }; highlightingIndustry = function(name){ ggl.highed_industry = name; d3.selectAll(".cmpnl:not(.ids" + name + ")").transition().style("opacity", 0.2); d3.selectAll(".ids" + name).transition().style("opacity", 1); return varSetHash("highed_industry"); }; highlighting = function(it){ d3.selectAll(".cancel-highed").style({ "display": "inline" }); if (ggl.all.industry.indexOf(it) >= 0) { return highlightingIndustry(it); } else if (ggl.all.company.indexOf(it) >= 0) { return highlightingCompany(it); } }; resetSubind = function(){ ggl.sbind = null; d3.selectAll(".btn-detail").style("display", "none"); d3.selectAll(".details").transition().style("opacity", 0).remove(); d3.selectAll(".subhead").transition().style("display", "none"); d3.selectAll(".cmpnl").style("display", "inline").style("opacity", 1).call(toPanel); d3.selectAll(".twitter-typeahead").style("display", "inline"); questionList.map(function(it){ if (it.act === ggl.srt && it.type === "viewsubind") { ggl.srt = questionList[0].act; return d3.select(".thequestion").text(questionList[0].text); } }); return d3.selectAll(".subind-able").classed("disabled", true); }; resetInd = function(){ return d3.selectAll(".ind-tab").style("display", "none"); }; reset = function(){ if (ggl.view === "viewsubind") { return resetSubind(); } else if (ggl.view === "viewindustry") { return resetInd(); } }; expandSubIndustry = function(name){ var currids, ncurids, nTran, expandAttribute, subIndustryEnlarge, subIndustrySort; reset(); ggl.sbind = name; ggl.view = "viewsubind"; varSetHash("sbind"); varSetHash("view"); d3.selectAll(".twitter-typeahead").style("display", "none"); currids = d3.selectAll(".ids" + name); ncurids = d3.selectAll(".cmpnl:not(.ids" + name + ")"); nTran = ncurids.length; expandAttribute = function(){ var cnt, i$, ref$, len$, attr, crrInd, crrScale; d3.selectAll(".subhead").style("display", "inline"); d3.selectAll(".btn-detail").style("display", "inline").text(indShrtTable[name]); d3.selectAll(".change-view").selectAll(".btn").classed("active", false); cnt = 0; for (i$ = 0, len$ = (ref$ = sbExpHeader).length; i$ < len$; ++i$) { attr = ref$[i$]; crrInd = sbMnmx[attr.header][name]; crrScale = d3.scale.linear().domain([crrInd["min"] * 1.01, crrInd["max"] * 0.99]).range([1, 6]); currids.append("div").style({ "position": "inherit", "left": ggl.rect.xpndlfmargin + (ggl.rect.ddlw + ggl.rect.margin) * cnt + "px", "top": "0px", "width": ggl.rect.ddlw + "px", "height": ggl.rect.h * ggl.rect.lgscl + "px", "padding-right": (ggl.rect.borderw + 2) + "px", "box-shadow": fn$, "color": ggl.fntcolor, "line-height": ggl.rect.h * ggl.rect.lgscl + "px", "vertical-align": "middle", "text-align": "right", "font-family": "monospace", "font-size": "12px", "text-indent": "0px", "opacity": 0 }).text(fn1$).transition().delay(cnt * 50).style("opacity", 1).attr("class", "details"); ++cnt; } return d3.selectAll(".subind-able").classed("disabled", false); function fn$(it){ var t; t = Math.floor( crrScale( it[attr.header])); return "0 0 0 " + ggl.rect.xpndborderw + "px " + (isNaN( t) ? "rgba(255, 255, 255, 0.3)" : colorbrewer["YlOrRd"]["9"][t]) + " inset"; } function fn1$(it){ if (isNaN( it[attr.header])) { return "N/A"; } else { return numberWithCommas(+it[attr.header].toFixed(0)); } } }; subIndustryEnlarge = function(){ currids.style("width", ggl.rect.w * ggl.rect.lgscl + "px").style("height", ggl.rect.h * ggl.rect.lgscl + "px").text(function(it){ return it.name; }); return expandAttribute(); }; subIndustrySort = function(){ return currids.sort(sortData).transition().duration(1500).each(function(d, i){ d.x = vAlignGetX(i); return d.y = vAlignGetY(i + 1); }).call(sorting, function(args){ return subIndustryEnlarge(); }); }; return ncurids.transition().duration(1000).style("opacity", 0).transition().duration(0).style("display", "none").each("end", function(d, i){ if (i === nTran - 1) { return subIndustrySort(); } }); }; mouseExpand = function(it){ return it.on("mousedown", function(it){ if (ggl.view !== "viewsubind") { expandSubIndustry(it.subindustry); return changeExplain(); } }).attr("data-toggle", "tooltip").attr("data-placement", "top").attr("title", function(d, i){ if (i === 0) { return; } return "

" + d.MNMC + "

" + d.enname + "
#" + d.totalrank + "/#" + d.subindrank + "(" + take(1, d.industry) + ")
" + "

" + d.report + "/" + d.principle + "

" + d.intro + "

"; }).attr("rel", "tooltip"); }; initial = function(){ var treediv; ggl.treemap = d3.layout.treemap().mode("squarify").sort(function(a, b){ return sortData(a, b) * ggl.sortBool; }).size([ggl.w, ggl.h]).sticky(false).value(function(it){ return it[ggl.srt]; }).children(function(it){ return it.values; }); treediv = d3.select("body").select("#ind-show").append("div").style({ "line-height": ggl.rect.h + "px", "vertical-align": "middle", "position": "absolute", "height": "95%", "width": "100%", "overflow-x": "hidden", "left": "0px", "top": "0px" }).attr({ "class": "overflow-holder" }).append("div").style({ "position": "absolute", "left": ggl.margin.left + "px", "top": ggl.margin.top + "px" }).attr({ "class": "panelBox" }); ggl.node = treediv.data([nestData]).selectAll(".cmpnl").data(ggl.treemap.nodes).sort(sortData).enter().append("div").attr("class", function(d, i){ return "cmpnl cls" + i + " ids" + d.subindustry; }).style("position", "absolute").style("cursor", "pointer").style("text-indent", ggl.rect.txtindent + "px").call(mouseExpand); d3.select("#ind-dropdown").style("height", "121px").style("width", "100%").style("position", "fixed").style("top", "0px").style("left", "0px").style("z-index", "3").style("background-color", ggl.bckcolor); d3.selectAll(".explanation-bar").style({ "position": "absolute" }).selectAll(".legends").data(colorbrewer[ggl.colorscheme]["9"]).enter().append("div").style({ "width": "10px", "height": "10px", "box-shadow": function(d, i){ return "0 0 5px " + ggl.rect.borderw + "px " + d + " inset"; }, "border-radius": "2px", "position": "absolute", "left": function(d, i){ return (-1 + i * 10) + "px"; }, "top": "4px" }); d3.selectAll(".explanation-end").style({ "left": "289px", "top": "101px", "position": "absolute" }); d3.selectAll(".cls0").remove(); return d3.selectAll(".cmpnl").sort(rvnSortData).call(recolor); }; changeExplain = function(){ d3.selectAll(".explanation-shape-start").text(explanationTable[ggl.view]); d3.selectAll(".explanation-type").text(explanationView[ggl.srt]); return d3.selectAll(".explanation-shape-end").text(explanationPost[ggl.view]); }; sortAgain = function(){ varSetHash("srt"); varSetHash("view"); changeExplain(); if (ggl.view === "viewsubind") { return sortRectExpand(); } else if (ggl.view === "viewtree") { ggl.node.data(ggl.treemap.value(function(it){ return it[ggl.srt]; }).nodes); return d3.selectAll(".cmpnl").call(toTree); } else if (ggl.view === "viewindustry") { return d3.selectAll(".cmpnl").call(setUpIndustry).call(toIndustry); } else if (ggl.view === "viewpanel") { return d3.selectAll(".cmpnl").sort(sortData).call(toPanel); } }; setList = function(holderName, listData, onClick){ var uls; uls = d3.selectAll(holderName).append("ul").attr("class", "dropdown-menu").attr("role", "menu"); return uls.selectAll("li").data(listData).enter().append("li").attr("class", function(it){ if (it.act === null) { return "divider"; } if (it.act === "header") { return "disabled dropdown-header "; } if (it.type === "viewsubind") { return "disabled subind-able"; } }).append("a").style("cursor", "pointer").style("font-style", function(it){ if (it.act === "header") { return "italic"; } else { return "normal"; } }).attr("data-target", "#").attr("class", "dropdown-action").attr("id", function(it){ return "action" + it.act; }).text(function(it){ return it.text; }).on("click", function(it){ return onClick(it); }); }; setList(".question-holder", questionList, function(it){ if (it.type === "viewsubind" && ggl.view !== "viewsubind") { return; } ggl.srt = it.act; sortAgain(); d3.select(".thequestion").text(it.text); if (d3.event.preventDefault()) {} }); setList(".industry-holder", industryList, function(it){ var s; if (ggl.view === "viewsubind") { ggl.view = "viewpanel"; ggl.sbind = null; } varSetHash("ind"); s = '#ind=' + it.act; console.log(ggl.hashls); ggl.hashls.map(function(it){ if (it !== "ind" && ggl[it] !== null && ggl[it] !== [] && ggl[it] !== "") { return s += '&' + it + '=' + ggl[it]; } }); window.open('./scale_en.html' + s, '_blank'); if (d3.event.preventDefault()) {} }); afterload = function(){ var tipoption; $(".change-view .btn").click(function(){ var option; reset(); option = $(this).text().trim(); ggl.view = viewTable[option]; return sortAgain(); }); ggl.all.company = map(function(it){ return it.MNMC; }, ggl.data); ggl.all.industry = keys(indShrtTable); tipoption = { "animation": false, "html": true, "delay": { "show": 0, "hide": 0 }, "placement": function(tip, element){ var position; position = $(element).position(); if (position.top < 200) { return "bottom"; } else { return "top"; } } }; $("div").tooltip(tipoption); $('#search-bar .typeahead').typeahead({ hint: true, highlight: true, minLength: 1 }, { name: 'industry', displayKey: 'value', source: substringMatcher(ggl.all.industry), templates: { header: '
行業:
' } }, { name: 'company', displayKey: 'value', source: substringMatcher(ggl.all.company), templates: { header: '
公司:
', empty: ['
', '無相符;試較短字串', '
'].join('\n') } }); $('input.typeahead').on('typeahead:selected', function(event, selection){ return highlighting(selection.value); }).on('typeahead:autocompleted', function(event, selection){ return $(this).keypress(function(it){ if (it.which === 13) { return highlighting(selection.value); } }); }); d3.selectAll(".cancel-highed").on("mousedown", function(){ return cancelHighlight(); }); return $(".tt-dropdown-menu").addClass("dropdown-menu"); }; cleanName = function(str){ return str.toLowerCase().trim().replace(/ ind./g, "").replace(/\(cayman islands\)/g, "").replace(/Corp./g, "").replace(/ company/g, "").replace(/co.,/g, "").replace(/ltd./g, "").replace(/, taiwan/g, "").replace(/.corp/g, "").replace(/\. /g, "").replace(/, inc./g, "").replace(/ inc./g, "").replace(/#n\/a/g, "").replace(/(taiwan)/g, ""); }; navidx = 0; navcontent = [ { "ttl": "Click Me", "txt": "The top 2,100 companies in Taiwan, visualized as a treemap: the larger the size, the larger the revenue.

(Click me to start navigation)", "act": function(){ $(".cls1").tooltip("hide"); return $(".cls2058").tooltip("hide"); } }, { "ttl": "Among Giants, Size Differs", "txt": "Even within the top 2,100 companies, size differs greatly. In highlighting Hon Hai Precision (also known as Foxconn), and Advanced Ceramic Xoration near the bottom of this list, their sizes differ by 3,500 times). (Click here to continue)", "act": function(){ highlightingCompany("鴻海精密"); highlightingCompany("璟德電子工業"); $(".cls1").tooltip("show"); return $(".cls1229").tooltip("show"); } }, { "ttl": "Apples to Apples", "txt": "Yet it's unfair to compare without context: Let's use the By Sector button to highlight different sectors within the list (Currently not available in English).

Here is the Computer System sector, with Hon Hai/Foxconn as sector leader. (Click here to continue)", "act": function(){ $(".cls1").tooltip("hide"); $(".cls1229").tooltip("hide"); return highlightingIndustry("電腦系統"); } }, { "ttl": "Oranges to Oranges", "txt": "And here is Chemistry-Material, with Chang Chun Plastics as leader. You can see that the revenue of this sector is smaller overall.", "act": function(){ return highlightingIndustry("化學材料"); } }, { "ttl": "Oranges to Oranges", "txt": "And here are the Semi-Conductor sector, with TSMC as market leader.

This graph gives us a lot of information, but what if we use Assets instead of Revenue? (Click here to continue)", "act": function(){ return highlightingIndustry("半導體"); } }, { "ttl": "New Perspective", "txt": "The Fix-Asset metric better reflects the high investment within the Semi-Conductor sector.

What if you are more interested in the competition within each sector? (Click here to continue)", "act": function(){ ggl.srt = "cptl"; sortAgain(); return questionList.map(function(it){ if (it.act === "cptl") { return d3.select(".thequestion").text(it.text); } }); } }, { "ttl": "Peer Pressure", "txt": "Now each row representing different industry. It's easier to compare market share of TSMC within the Semi-Conductor industry.", "act": function(){ ggl.view = "viewindustry"; return sortAgain(); } }, { "ttl": "Peer Pressure", "txt": "Now each row represents different industries. It's easy to compare market share of TSMC within the Semi-Conductor industry. (Click here to continue)", "act": function(){ return cancelHighlight(); } }, { "ttl": "Dive into", "txt": "With the big picture in mind, here are the detailed financial statements. Each cell’s border color represents value (Red Max – Yellow Min).

Sort by clicking on the metrics. (Click here for next screen)", "act": function(){ return expandSubIndustry("電腦系統"); } }, { "ttl": "Dive into", "txt": "Here, the companies are ranked by Profit. (Click for next screen)", "act": function(){ ggl.srt = "eat"; return sortAgain(); } }, { "ttl": "Dive into", "txt": "And here, they are ranked by Equity. (Click here to continue)", "act": function(){ ggl.srt = "eps"; return sortAgain(); } }, { "ttl": "Explore & Share", "txt": "Explore on your own by clicking around. Feel free to share your current URL with colleagues. Your current progress is saved in the URL.", "act": function(){ reset(); cancelHighlight(); ggl.srt = "rvn"; ggl.view = "viewtree"; sortAgain(); return setupView(); } } ]; d3.selectAll(".navigation").style({ "box-shadow": "rgb(0, 0, 0) 0px 0px 17px 2px" }); (ggl.nav = function(){ var ctn, l; ctn = navcontent[navidx]; l = navcontent.length - 1; if (navidx > l) { return d3.selectAll(".navigation").transition().style({ "opacity": 0 }); } else { d3.selectAll(".navttl").text(ctn.ttl); d3.selectAll(".navidx").text(navidx + "/" + l); d3.selectAll(".navtxt").html(ctn.txt); return ctn.act(); } })(); d3.selectAll(".navigation").on("mousedown", function(){ ++navidx; return ggl.nav(); }); d3.tsv("./2014_all_w_en.tsv", function(err, tsvBody){ hashSetVar(); console.log(tsvBody); ggl.data = tsvBody.filter(function(d, i){ var i$, ref$, len$, it; d.name = d.shrtname; d.enname = cleanName(d.enname); if (d.shrtname === "台積電") { d.enname = "TSMC"; } for (i$ = 0, len$ = (ref$ = sbExpHeader).length; i$ < len$; ++i$) { it = ref$[i$]; d[it.header] = +d[it.header]; } return ggl.ind !== "all" ? ch2en[d.industry] === indNameTable[ggl.ind] : true; }); nestData = { key: "Taiwan", values: ggl.data.sort(sortData) }; setUpRange(); initial(); if (ggl.sbind !== null) { expandSubIndustry(ggl.sbind); } sortAgain(); setupHightlighting(); return afterload(); }); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; }