change language treemap. id in struct can be a list of lexvo references
authorymh <ymh.work@gmail.com>
Mon, 21 Mar 2016 14:04:19 +0100
changeset 142 86fcf0c837c0
parent 141 c0e8626a271c
child 143 023b6d467566
change language treemap. id in struct can be a list of lexvo references
cms/app-client/app/components/visu-langues.js
cms/app-client/app/services/constants.js
--- a/cms/app-client/app/components/visu-langues.js	Sun Mar 06 00:29:01 2016 +0100
+++ b/cms/app-client/app/components/visu-langues.js	Mon Mar 21 14:04:19 2016 +0100
@@ -71,7 +71,19 @@
       // We also take a snapshot of the original children (_children) to avoid
       // the children being overwritten when when layout is computed.
       function accumulate(d) {
-        return (d._children = d.children) ? (d.value = d.children.reduce(function(p, v) { return p + accumulate(v); }, 0)) : (d.value = (languages[d.id]?languages[d.id]:0));
+        d._children = d.children;
+        if(d.children) {
+          d.value = d.children.reduce(function(p, v) { return p + accumulate(v); }, 0);
+        } else if (_.isArray(d.id)) {
+          d.value = d.id.reduce(
+            function(s,lid) { return s + (languages[lid]?languages[lid]:0); },
+            0
+          );
+        }
+        else {
+          d.value = languages[d.id]?languages[d.id]:0;
+        }
+        return d.value;
       }
 
       // Compute the treemap layout recursively such that each group of siblings
--- a/cms/app-client/app/services/constants.js	Sun Mar 06 00:29:01 2016 +0100
+++ b/cms/app-client/app/services/constants.js	Mon Mar 21 14:04:19 2016 +0100
@@ -76,6 +76,19 @@
       {
         "id": "http://lexvo.org/id/iso639-3/cos",
         "name": "Corse",
+      },
+      {
+        "name": "Les Creoles",
+        "children": [
+          {
+            "id": "http://lexvo.org/id/iso639-3/rcf",
+            "name": "Creole de la Réunion",
+          },
+          {
+            "id": "http://lexvo.org/id/iso639-3/gcf",
+            "name": "Creole de la Guadeloupe",
+          }
+        ]
       }
     ]
   },
@@ -87,14 +100,10 @@
         "name": "Langue des signes française (LSF)",
       },
       {
-        "id": "http://lexvo.org/id/iso639-3/ber",
+        "id": "http://lexvo.org/id/iso639-3/kab",
         "name": "Berbère",
       },
       {
-        "id": "http://lexvo.org/id/iso639-3/kab",
-        "name": "Kabyle",
-      },
-      {
         "id": "http://lexvo.org/id/iso639-3/ell",
         "name": "Grec moderne"
       },
@@ -121,19 +130,6 @@
     ]
   },
   {
-    "name": "Les Creoles",
-    "children": [
-      {
-        "id": "http://lexvo.org/id/iso639-3/rcf",
-        "name": "Creole de la Réunion",
-      },
-      {
-        "id": "http://lexvo.org/id/iso639-3/gcf",
-        "name": "Creole de la Guadeloupe",
-      }
-    ]
-  },
-  {
     "name": "Guyane",
     "children": [
       {