From 2217c83da623c04c05a398b0ecd4c2546ef6880c Mon Sep 17 00:00:00 2001 From: lucvic Date: Mon, 21 Dec 2015 11:38:32 +0100 Subject: [PATCH] Support for meta information in Dataset Explorer Datalet --- datalets/datasetexplorer-datalet/datasetexplorer-datalet.html | 30 ++++++++++++++++++++++++++++-- datalets/datasetexplorer-datalet/js/buildtreemap.js | 15 +++++++++++++-- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/datalets/datasetexplorer-datalet/datasetexplorer-datalet.html b/datalets/datasetexplorer-datalet/datasetexplorer-datalet.html index ea88002..e759243 100755 --- a/datalets/datasetexplorer-datalet/datasetexplorer-datalet.html +++ b/datalets/datasetexplorer-datalet/datasetexplorer-datalet.html @@ -188,12 +188,38 @@ Example: var xyz = function(url) { me.selectResource(url); } - build(this.map, "treemap_placeholder", xyz, this._component.width, this._component.height); + build(this.map, this.meta, "treemap_placeholder", xyz, this._component.width, this._component.height); }, selectResource: function(url) { this._component.fire("datasetexplorer-datalet_data-url", { url: url }); - } + }, + + selectData : function() { + this.data = []; + this.meta = this.properties.json_results.value.result.providers; + + //Deal the fields with "'" char + //this._component.fields = this._component.fields.replace(/#/g,"'"); + + this._component.fields = JSON.parse(this._component.fields); + + for (var i = 0; i < this._component.fields.length; i++) { + var query = "$"; + var query_elements = this._component.fields[i].split(','); + for (var j = 0; j < query_elements.length; j++) { + query += "['" + query_elements[j] + "']"; + if (this.isFieldArray(query_elements.slice(0, j + 1))) { + query += "[*]"; + } + } + this.data.push({ + name: query_elements[query_elements.length - 1], + data: jsonPath(this.properties.json_results.value, query) + }); + } + this.deleteWaitImage(); + }, }; diff --git a/datalets/datasetexplorer-datalet/js/buildtreemap.js b/datalets/datasetexplorer-datalet/js/buildtreemap.js index b5318f0..d311b04 100755 --- a/datalets/datasetexplorer-datalet/js/buildtreemap.js +++ b/datalets/datasetexplorer-datalet/js/buildtreemap.js @@ -2,7 +2,7 @@ * Created by Utente on 17/07/2015. */ -function build(root, place_holder, select_listener, width, height) { +function build(root, meta, place_holder, select_listener, width, height) { var plwidth = width >= 0 ? width : $("#" + place_holder).width(), plheight = height >= 0 ? height : $("#" + place_holder).height(); @@ -223,6 +223,17 @@ function build(root, place_holder, select_listener, width, height) { text.call(wrap); } + function checkProviderName(name) { + console.log(name); + if (name.substr(0, 2) == 'p:') { + console.log("in"); + var pid = name.substr(2); + name = meta[pid].title; + } + console.log(name); + return name; + } + function wrap(d) { var wwidth = width; var hheight = height; @@ -230,7 +241,7 @@ function build(root, place_holder, select_listener, width, height) { d.each(function(){ var text = d3.select(this), d = text[0][0].__data__, - name = d.name.trim(), + name = checkProviderName(d.name.trim()); words = name.search(/\s+/) >= 0 ? name.split(/\s+/).reverse() : [name], word = words.pop(), line = [word], -- libgit2 0.21.4