Commit b53fef0374664d05f9e79e026966ebdb04e838f1
1 parent
4143bce6
treemap tooltip
Showing
5 changed files
with
275 additions
and
15 deletions
controllets/room-controllet/room-controllet.html
| @@ -28,7 +28,6 @@ | @@ -28,7 +28,6 @@ | ||
| 28 | transform: scaleX(-1); | 28 | transform: scaleX(-1); |
| 29 | filter: FlipH; | 29 | filter: FlipH; |
| 30 | -ms-filter: "FlipH"; | 30 | -ms-filter: "FlipH"; |
| 31 | - | ||
| 32 | } | 31 | } |
| 33 | 32 | ||
| 34 | paper-dialog { | 33 | paper-dialog { |
| @@ -52,8 +51,8 @@ | @@ -52,8 +51,8 @@ | ||
| 52 | } | 51 | } |
| 53 | 52 | ||
| 54 | p { | 53 | p { |
| 55 | - padding-top: 8px; | ||
| 56 | margin: 0px; | 54 | margin: 0px; |
| 55 | + padding: 8px 0px 0px 0px; | ||
| 57 | white-space: nowrap; | 56 | white-space: nowrap; |
| 58 | } | 57 | } |
| 59 | 58 |
datalets/datasetexplorer-datalet/datasetexplorer-datalet.html
| @@ -30,7 +30,7 @@ | @@ -30,7 +30,7 @@ | ||
| 30 | --> | 30 | --> |
| 31 | 31 | ||
| 32 | <link rel="import" href="../base-ajax-json-jsonpath-datalet/base-ajax-json-jsonpath-datalet.html"> | 32 | <link rel="import" href="../base-ajax-json-jsonpath-datalet/base-ajax-json-jsonpath-datalet.html"> |
| 33 | -<link rel="import" href="../base-ajax-json-jsonpath-datalet/base-ajax-json-jsonpath-datalet.html"> | 33 | +<link rel="import" href="treemap_tooltip.html"> |
| 34 | 34 | ||
| 35 | <!-- | 35 | <!-- |
| 36 | 36 | ||
| @@ -110,8 +110,11 @@ Example: | @@ -110,8 +110,11 @@ Example: | ||
| 110 | fill: #bbb; | 110 | fill: #bbb; |
| 111 | } | 111 | } |
| 112 | </style> | 112 | </style> |
| 113 | - <div id="treemap_placeholder"></div> | 113 | + <div id="treemap_placeholder"> |
| 114 | + <treemap-tooltip id="treemap_tooltip"></treemap-tooltip> | ||
| 115 | + </div> | ||
| 114 | <base-ajax-json-jsonpath-datalet data-url="{{dataUrl}}" fields="{{fields}}" data="{{data}}"></base-ajax-json-jsonpath-datalet> | 116 | <base-ajax-json-jsonpath-datalet data-url="{{dataUrl}}" fields="{{fields}}" data="{{data}}"></base-ajax-json-jsonpath-datalet> |
| 117 | + <!--<treemap-tooltip id="treemap_tooltip"></treemap-tooltip>--> | ||
| 115 | </template> | 118 | </template> |
| 116 | 119 | ||
| 117 | <script src="../shared_js/d3.js"></script> | 120 | <script src="../shared_js/d3.js"></script> |
datalets/datasetexplorer-datalet/demo/index.html
| @@ -10,14 +10,53 @@ | @@ -10,14 +10,53 @@ | ||
| 10 | </head> | 10 | </head> |
| 11 | <body> | 11 | <body> |
| 12 | 12 | ||
| 13 | + | ||
| 13 | <script src="https://code.jquery.com/jquery-2.1.4.min.js" type="text/javascript"></script> | 14 | <script src="https://code.jquery.com/jquery-2.1.4.min.js" type="text/javascript"></script> |
| 14 | -<link rel="import" href="../datasetexplorer-datalet.html" /> | 15 | +<script src="../../shared_js/webcomponents.min.js" type="text/javascript"></script> |
| 16 | +<!--<link rel="import" href="../datasetexplorer-datalet.html" />--> | ||
| 17 | + | ||
| 18 | +<!--<datasetexplorer-datalet--> | ||
| 19 | + <!--data-url="http://spod.routetopa.eu/openwall/api/datasetTree"--> | ||
| 20 | + <!--fields='["result,provider_name","result,organization_name","result,package_name","result,resource_name","result,url","result,w"]'--> | ||
| 21 | +<!--></datasetexplorer-datalet>--> | ||
| 22 | + | ||
| 23 | +<link rel="import" href="../treemap_tooltip.html" /> | ||
| 24 | + | ||
| 25 | +<treemap-tooltip id="treemap_tooltip" color="yellowgreen" name="CKAN" description="Ckan datasets provider bla cjaijh aiughauiha hauihauiaha djisdjdijd. Thsos jnsuihsuhs dmodjod jjjjjd dijnaiosjf saojfioasjdf!!!" logo-url="http://essi-lab.eu/twiki/pub/GIcat/CKANProfilerGuide/logo-ckan.png" datasets="151" dataset-url="http://ckan.routetopa.eu/api/action/datastore_search?resource_id=c3b52992-ba61-4a73-a637-0f2e1ca26aab"></treemap-tooltip> | ||
| 26 | + | ||
| 27 | +<div class="box" style="background-color: yellowgreen" onmousemove="showTooltip(event, 'first')" onmouseout="hideTooltip()"></div> | ||
| 28 | +<div class="box" style="background-color: aqua" onmousemove="showTooltip(event, 'middle')" onmouseout="hideTooltip()"></div> | ||
| 29 | +<div class="box" style="background-color: orchid" onmousemove="showTooltip(event, 'last')" onmouseout="hideTooltip()"></div> | ||
| 30 | + | ||
| 31 | +<style> | ||
| 32 | + .box { | ||
| 33 | + height: 200px; | ||
| 34 | + width: 200px; | ||
| 35 | + cursor: pointer; | ||
| 36 | + } | ||
| 37 | +</style> | ||
| 38 | + | ||
| 39 | +<script> | ||
| 40 | + function showTooltip(e, lvl) { | ||
| 41 | + switch (lvl) { | ||
| 42 | + case "first": | ||
| 43 | + //setta dati tooltip | ||
| 44 | + treemap_tooltip.color = "yellowgreen"; | ||
| 45 | + break; | ||
| 46 | + case "middle": | ||
| 47 | + treemap_tooltip.color = "aqua"; | ||
| 48 | + break; | ||
| 49 | + case "last": | ||
| 50 | + treemap_tooltip.color = "orchid"; | ||
| 51 | + } | ||
| 15 | 52 | ||
| 16 | -<datasetexplorer-datalet | ||
| 17 | - data-url="http://spod.routetopa.eu/openwall/api/datasetTree" | ||
| 18 | - fields='["result,provider_name","result,organization_name","result,package_name","result,resource_name","result,url","result,w"]' | ||
| 19 | -></datasetexplorer-datalet> | 53 | + treemap_tooltip.showTooltip(e, lvl); |
| 54 | + } | ||
| 20 | 55 | ||
| 56 | + function hideTooltip() { | ||
| 57 | + treemap_tooltip.hideTooltip(); | ||
| 58 | + } | ||
| 59 | +</script> | ||
| 21 | 60 | ||
| 22 | </body> | 61 | </body> |
| 23 | </html> | 62 | </html> |
| 24 | \ No newline at end of file | 63 | \ No newline at end of file |
datalets/datasetexplorer-datalet/js/buildtreemap.js
| @@ -129,8 +129,32 @@ function build(root, meta, place_holder, select_listener, width, height) { | @@ -129,8 +129,32 @@ function build(root, meta, place_holder, select_listener, width, height) { | ||
| 129 | g.append("rect") | 129 | g.append("rect") |
| 130 | .attr("class", "parent") | 130 | .attr("class", "parent") |
| 131 | .call(rect) | 131 | .call(rect) |
| 132 | - .append("title") | ||
| 133 | - .text(function(d) { return d.name; /*formatNumber(d.value);*/ }); | 132 | + .attr("onmousemove", function(d) { |
| 133 | + //var data = ["lvl", "name", "color", "description", "logoUrl", "datasets", "datasetUrl"]; | ||
| 134 | + var data = ["", d.name, d.color, "", "", "0", ""]; | ||
| 135 | + //d.name.split(':')[1]??? | ||
| 136 | + if (d.depth == 1) { | ||
| 137 | + // FIRST LVL | ||
| 138 | + data[0] = "first"; | ||
| 139 | + data[3] = "description";//??? | ||
| 140 | + data[4] = "http://essi-lab.eu/twiki/pub/GIcat/CKANProfilerGuide/logo-ckan.png";//id??? | ||
| 141 | + data[5] = "2222";//meta??? | ||
| 142 | + } else if (d._children && !d._children[0]._children) { | ||
| 143 | + // LAST LVL | ||
| 144 | + data[0] = "last"; | ||
| 145 | + data[6] = "datasert url";//??? | ||
| 146 | + } else { | ||
| 147 | + // MIDDLE LVL | ||
| 148 | + data[0] = "middle"; | ||
| 149 | + data[5] = "1111";//meta??? | ||
| 150 | + } | ||
| 151 | + //console.log(data); | ||
| 152 | + //console.log(data.toString()); | ||
| 153 | + return "showTooltip(event, '" + data + "')"; | ||
| 154 | + }) | ||
| 155 | + .attr("onmouseout", function() {return "hideTooltip()";}) | ||
| 156 | + //.append("title") | ||
| 157 | + //.text(function(d) { return d.name; /*formatNumber(d.value);*/ }); | ||
| 134 | 158 | ||
| 135 | g.append("text") | 159 | g.append("text") |
| 136 | .attr("dy", ".75em") | 160 | .attr("dy", ".75em") |
| @@ -223,13 +247,10 @@ function build(root, meta, place_holder, select_listener, width, height) { | @@ -223,13 +247,10 @@ function build(root, meta, place_holder, select_listener, width, height) { | ||
| 223 | } | 247 | } |
| 224 | 248 | ||
| 225 | function checkProviderName(name) { | 249 | function checkProviderName(name) { |
| 226 | - console.log(name); | ||
| 227 | if (name.substr(0, 2) == 'p:') { | 250 | if (name.substr(0, 2) == 'p:') { |
| 228 | - console.log("in"); | ||
| 229 | var pid = name.substr(2); | 251 | var pid = name.substr(2); |
| 230 | name = meta[pid].title; | 252 | name = meta[pid].title; |
| 231 | } | 253 | } |
| 232 | - console.log(name); | ||
| 233 | return name; | 254 | return name; |
| 234 | } | 255 | } |
| 235 | 256 | ||
| @@ -308,4 +329,22 @@ function build(root, meta, place_holder, select_listener, width, height) { | @@ -308,4 +329,22 @@ function build(root, meta, place_holder, select_listener, width, height) { | ||
| 308 | ? name(d.parent) + "." + d.name | 329 | ? name(d.parent) + "." + d.name |
| 309 | : d.name; | 330 | : d.name; |
| 310 | } | 331 | } |
| 311 | -}; | ||
| 312 | \ No newline at end of file | 332 | \ No newline at end of file |
| 333 | + | ||
| 334 | +}; | ||
| 335 | + | ||
| 336 | +function showTooltip(e, data) { | ||
| 337 | + var data = data.split(","); | ||
| 338 | + | ||
| 339 | + treemap_tooltip.name = data[1]; | ||
| 340 | + treemap_tooltip.color = data[2]; | ||
| 341 | + treemap_tooltip.description = data[3]; | ||
| 342 | + treemap_tooltip.logoUrl = data[4]; | ||
| 343 | + treemap_tooltip.datasets = data[5]; | ||
| 344 | + treemap_tooltip.datasetUrl = data[6]; | ||
| 345 | + | ||
| 346 | + treemap_tooltip.showTooltip(e, data[0]); | ||
| 347 | +} | ||
| 348 | + | ||
| 349 | +function hideTooltip() { | ||
| 350 | + treemap_tooltip.hideTooltip(); | ||
| 351 | +} | ||
| 313 | \ No newline at end of file | 352 | \ No newline at end of file |
datalets/datasetexplorer-datalet/treemap_tooltip.html
0 โ 100644
| 1 | +<link rel="import" href="../../bower_components/polymer/polymer.html" /> | ||
| 2 | + | ||
| 3 | +<link rel="import" href="../../bower_components/paper-dialog/paper-dialog.html"> | ||
| 4 | + | ||
| 5 | +<link rel="import" href="../../bower_components/iron-icons/editor-icons.html"> | ||
| 6 | +<link rel="import" href="../../bower_components/iron-icons/communication-icons.html"> | ||
| 7 | + | ||
| 8 | +<dom-module id="treemap-tooltip"> | ||
| 9 | + | ||
| 10 | + <template> | ||
| 11 | + | ||
| 12 | + <style is="custom-style"> | ||
| 13 | + | ||
| 14 | + iron-icon { | ||
| 15 | + padding: 0px; | ||
| 16 | + margin: 0px; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + iron-icon.this { | ||
| 20 | + position: absolute; | ||
| 21 | + top: -3px; | ||
| 22 | + left: -3px; | ||
| 23 | + | ||
| 24 | + -moz-transform: scaleX(-1); | ||
| 25 | + -o-transform: scaleX(-1); | ||
| 26 | + -webkit-transform: scaleX(-1); | ||
| 27 | + transform: scaleX(-1); | ||
| 28 | + filter: FlipH; | ||
| 29 | + -ms-filter: "FlipH"; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + paper-dialog { | ||
| 33 | + margin: 0px; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + .tooltip { | ||
| 37 | + font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif; | ||
| 38 | + padding: 16px; | ||
| 39 | + min-width: 200px; | ||
| 40 | + max-width: 400px; | ||
| 41 | + position: absolute; | ||
| 42 | + | ||
| 43 | + /*position: relative*/ | ||
| 44 | + /*top: 20px;*/ | ||
| 45 | + /*left: 20px;*/ | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + .tooltip_top { | ||
| 49 | + display: flex; | ||
| 50 | + margin: 0px; | ||
| 51 | + padding: 0px; | ||
| 52 | + height: 64px; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + /*.tooltip_logo {*/ | ||
| 56 | + /*}*/ | ||
| 57 | + | ||
| 58 | + .tooltip_name { | ||
| 59 | + height: 20px; | ||
| 60 | + font-weight: 700; | ||
| 61 | + padding: 22px; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + .tooltip_img { | ||
| 65 | + margin: 0px; | ||
| 66 | + padding: 0px; | ||
| 67 | + height: 64px; | ||
| 68 | + width: 64px; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + p { | ||
| 72 | + margin: 0px; | ||
| 73 | + padding: 8px 0px 0px 0px; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + .ptop{ | ||
| 77 | + padding-top: 0px; | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + </style> | ||
| 81 | + | ||
| 82 | + <paper-dialog id="first_info" class="tooltip"> | ||
| 83 | + <iron-icon icon="communication:call-made" class="this" style$="color: {{color}};"></iron-icon> | ||
| 84 | + <div class="tooltip_top"> | ||
| 85 | + <div class="tooltip_logo"><img class="tooltip_img" src$={{logoUrl}}></div> | ||
| 86 | + <div class="tooltip_name" style$="color: {{color}};">{{name}}</div> | ||
| 87 | + </div> | ||
| 88 | + <p><i>{{description}}</i></p> | ||
| 89 | + <p>There are <b>{{datasets}}</b> datasets.</p> | ||
| 90 | + </paper-dialog> | ||
| 91 | + | ||
| 92 | + <paper-dialog id="middle_info" class="tooltip"> | ||
| 93 | + <iron-icon icon="communication:call-made" class="this" style$="color: {{color}};"></iron-icon> | ||
| 94 | + <p class="ptop"><b style$="color: {{color}};">{{name}}</b></p> | ||
| 95 | + <p>There are <b>{{datasets}}</b> datasets.</p> | ||
| 96 | + </paper-dialog> | ||
| 97 | + | ||
| 98 | + <paper-dialog id="last_info" class="tooltip"> | ||
| 99 | + <iron-icon icon="communication:call-made" class="this" style$="color: {{color}};"></iron-icon> | ||
| 100 | + <p class="ptop"><b style$="color: {{color}};">{{name}}</b></p> | ||
| 101 | + <p>Dataset URL: <b>{{datasetUrl}}</b></p> | ||
| 102 | + </paper-dialog> | ||
| 103 | + | ||
| 104 | + </template> | ||
| 105 | + | ||
| 106 | + <script> | ||
| 107 | + | ||
| 108 | + Polymer({ | ||
| 109 | + | ||
| 110 | + is : 'treemap-tooltip', | ||
| 111 | + | ||
| 112 | + properties : { | ||
| 113 | + | ||
| 114 | + name : { | ||
| 115 | + type : String, | ||
| 116 | + value : "" | ||
| 117 | + }, | ||
| 118 | + | ||
| 119 | + color : { | ||
| 120 | + type : String, | ||
| 121 | + value : "#2196F3" | ||
| 122 | + }, | ||
| 123 | + | ||
| 124 | + description : { | ||
| 125 | + type : String, | ||
| 126 | + value : "" | ||
| 127 | + }, | ||
| 128 | + | ||
| 129 | + logoUrl : { | ||
| 130 | + type : String, | ||
| 131 | + value : "" | ||
| 132 | + }, | ||
| 133 | + | ||
| 134 | + datasets : { | ||
| 135 | + type : String, | ||
| 136 | + value : "0" | ||
| 137 | + }, | ||
| 138 | + | ||
| 139 | + datasetUrl : { | ||
| 140 | + type : String, | ||
| 141 | + value : "" | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + }, | ||
| 145 | + | ||
| 146 | + showTooltip: function(e, lvl) { | ||
| 147 | + var x = e.layerX + 16;//clientX | ||
| 148 | + var y = e.layerY + 16; | ||
| 149 | + | ||
| 150 | + this.hideTooltip(); | ||
| 151 | + | ||
| 152 | + switch (lvl) { | ||
| 153 | + case "first": | ||
| 154 | + $("#first_info").css("top", y); | ||
| 155 | + $("#first_info").css("left", x); | ||
| 156 | + this.$.first_info.open(); | ||
| 157 | + break; | ||
| 158 | + case "middle": | ||
| 159 | + $("#middle_info").css("top", y); | ||
| 160 | + $("#middle_info").css("left", x); | ||
| 161 | + this.$.middle_info.open(); | ||
| 162 | + break; | ||
| 163 | + case "last": | ||
| 164 | + $("#last_info").css("top", y); | ||
| 165 | + $("#last_info").css("left", x); | ||
| 166 | + this.$.last_info.open(); | ||
| 167 | + } | ||
| 168 | + }, | ||
| 169 | + | ||
| 170 | + hideTooltip: function() { | ||
| 171 | + this.$.first_info.close(); | ||
| 172 | + this.$.middle_info.close(); | ||
| 173 | + this.$.last_info.close(); | ||
| 174 | + } | ||
| 175 | + | ||
| 176 | + }); | ||
| 177 | + | ||
| 178 | + </script> | ||
| 179 | + | ||
| 180 | +</dom-module> | ||
| 0 | \ No newline at end of file | 181 | \ No newline at end of file |