Commit 2217c83da623c04c05a398b0ecd4c2546ef6880c

Authored by lucvic
1 parent addc5f69

Support for meta information in Dataset Explorer Datalet

datalets/datasetexplorer-datalet/datasetexplorer-datalet.html
... ... @@ -188,12 +188,38 @@ Example:
188 188 var xyz = function(url) {
189 189 me.selectResource(url);
190 190 }
191   - build(this.map, "treemap_placeholder", xyz, this._component.width, this._component.height);
  191 + build(this.map, this.meta, "treemap_placeholder", xyz, this._component.width, this._component.height);
192 192 },
193 193  
194 194 selectResource: function(url) {
195 195 this._component.fire("datasetexplorer-datalet_data-url", { url: url });
196   - }
  196 + },
  197 +
  198 + selectData : function() {
  199 + this.data = [];
  200 + this.meta = this.properties.json_results.value.result.providers;
  201 +
  202 + //Deal the fields with "'" char
  203 + //this._component.fields = this._component.fields.replace(/#/g,"'");
  204 +
  205 + this._component.fields = JSON.parse(this._component.fields);
  206 +
  207 + for (var i = 0; i < this._component.fields.length; i++) {
  208 + var query = "$";
  209 + var query_elements = this._component.fields[i].split(',');
  210 + for (var j = 0; j < query_elements.length; j++) {
  211 + query += "['" + query_elements[j] + "']";
  212 + if (this.isFieldArray(query_elements.slice(0, j + 1))) {
  213 + query += "[*]";
  214 + }
  215 + }
  216 + this.data.push({
  217 + name: query_elements[query_elements.length - 1],
  218 + data: jsonPath(this.properties.json_results.value, query)
  219 + });
  220 + }
  221 + this.deleteWaitImage();
  222 + },
197 223 };
198 224  
199 225  
... ...
datalets/datasetexplorer-datalet/js/buildtreemap.js
... ... @@ -2,7 +2,7 @@
2 2 * Created by Utente on 17/07/2015.
3 3 */
4 4  
5   -function build(root, place_holder, select_listener, width, height) {
  5 +function build(root, meta, place_holder, select_listener, width, height) {
6 6  
7 7 var plwidth = width >= 0 ? width : $("#" + place_holder).width(),
8 8 plheight = height >= 0 ? height : $("#" + place_holder).height();
... ... @@ -223,6 +223,17 @@ function build(root, place_holder, select_listener, width, height) {
223 223 text.call(wrap);
224 224 }
225 225  
  226 + function checkProviderName(name) {
  227 + console.log(name);
  228 + if (name.substr(0, 2) == 'p:') {
  229 + console.log("in");
  230 + var pid = name.substr(2);
  231 + name = meta[pid].title;
  232 + }
  233 + console.log(name);
  234 + return name;
  235 + }
  236 +
226 237 function wrap(d) {
227 238 var wwidth = width;
228 239 var hheight = height;
... ... @@ -230,7 +241,7 @@ function build(root, place_holder, select_listener, width, height) {
230 241 d.each(function(){
231 242 var text = d3.select(this),
232 243 d = text[0][0].__data__,
233   - name = d.name.trim(),
  244 + name = checkProviderName(d.name.trim());
234 245 words = name.search(/\s+/) >= 0 ? name.split(/\s+/).reverse() : [name],
235 246 word = words.pop(),
236 247 line = [word],
... ...