|
@@ -1,11 +1,44 @@
|
|
define(["chroma-js", "virtual-dom", "numeral-intl"],
|
|
define(["chroma-js", "virtual-dom", "numeral-intl"],
|
|
function (Chroma, V, numeral) {
|
|
function (Chroma, V, numeral) {
|
|
|
|
|
|
- return function () {
|
|
|
|
|
|
+ return function (config) {
|
|
var self = this
|
|
var self = this
|
|
var fwTable, hwTable, autoTable, gwTable
|
|
var fwTable, hwTable, autoTable, gwTable
|
|
var scale = Chroma.scale("YlGnBu").mode("lab")
|
|
var scale = Chroma.scale("YlGnBu").mode("lab")
|
|
|
|
|
|
|
|
+ function showStatGlobal(o) {
|
|
|
|
+ var content, caption
|
|
|
|
+
|
|
|
|
+ if (o.thumbnail) {
|
|
|
|
+ content = document.createElement("img")
|
|
|
|
+ content.src = o.thumbnail
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (o.caption) {
|
|
|
|
+ caption = o.caption
|
|
|
|
+
|
|
|
|
+ if (!content)
|
|
|
|
+ content = document.createTextNode(caption)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var p = document.createElement("p")
|
|
|
|
+
|
|
|
|
+ if (o.href) {
|
|
|
|
+ var link = document.createElement("a")
|
|
|
|
+ link.target = "_blank"
|
|
|
|
+ link.href = o.href
|
|
|
|
+ link.appendChild(content)
|
|
|
|
+
|
|
|
|
+ if (caption && o.thumbnail)
|
|
|
|
+ link.title = caption
|
|
|
|
+
|
|
|
|
+ p.appendChild(link)
|
|
|
|
+ } else
|
|
|
|
+ p.appendChild(content)
|
|
|
|
+
|
|
|
|
+ return p
|
|
|
|
+ }
|
|
|
|
+
|
|
function count(nodes, key, f) {
|
|
function count(nodes, key, f) {
|
|
var dict = {}
|
|
var dict = {}
|
|
|
|
|
|
@@ -123,6 +156,15 @@ define(["chroma-js", "virtual-dom", "numeral-intl"],
|
|
gwTable = document.createElement("table")
|
|
gwTable = document.createElement("table")
|
|
gwTable.classList.add("proportion")
|
|
gwTable.classList.add("proportion")
|
|
el.appendChild(gwTable)
|
|
el.appendChild(gwTable)
|
|
|
|
+
|
|
|
|
+ if (config.globalInfos)
|
|
|
|
+ config.globalInfos.forEach( function (globalInfo) {
|
|
|
|
+ h2 = document.createElement("h2")
|
|
|
|
+ h2.textContent = globalInfo.name
|
|
|
|
+ el.appendChild(h2)
|
|
|
|
+
|
|
|
|
+ el.appendChild(showStatGlobal(globalInfo))
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
return self
|
|
return self
|