a508f993
isisadmin
added datalet doc...
|
1
|
<!--
|
5e6ba8af
isisadmin
datalet doc update
|
2
3
4
|
@license
The MIT License (MIT)
|
3c812cc9
Renato De Donato
title-desciption ...
|
5
|
Copyright (c) 2015 Dipartimento di Informatica - Universit� di Salerno - Italy
|
5e6ba8af
isisadmin
datalet doc update
|
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
|
a508f993
isisadmin
added datalet doc...
|
24
25
|
-->
|
ae17a8dc
Luigi Serra
Controllet and da...
|
26
|
<!--
|
950d181d
Luigi Serra
license updates
|
27
28
|
* Developed by :
* ROUTE-TO-PA Project - grant No 645860. - www.routetopa.eu
|
ae17a8dc
Luigi Serra
Controllet and da...
|
29
30
31
|
*
-->
|
98d9d8a5
Renato De Donato
filters+groupby
|
32
|
<link rel="import" href="../base-ajax-json-alasql-datalet/base-ajax-json-alasql-datalet.html">
|
73bcce88
luigser
COMPONENTS
|
33
|
|
5e6ba8af
isisadmin
datalet doc update
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
<!--
`treemap-datalet` is a treemap datalet based on d3js treemap project http://bl.ocks.org/mbostock/4063582
A treemap recursively subdivides area into rectangles; the area of any node in the tree corresponds to its value.
Example:
<treemap-datalet
data-url="http://ckan.routetopa.eu/api/action/datastore_search?resource_id=#"
fields='["field1","field2"]'>
</treemap-datalet>
@element barchart-datalet
@status v0.1
@demo demo/index.html
@group datalets
-->
|
73bcce88
luigser
COMPONENTS
|
52
53
|
<dom-module id="treemap-datalet">
<template>
|
74249687
Luigi Serra
Cross browser con...
|
54
|
<style is="custom-style">
|
73bcce88
luigser
COMPONENTS
|
55
|
|
9819a403
Renato De Donato
bubble scatter tr...
|
56
57
58
|
/*:host ::content h6 {*/
/*color: red;*/
/*}*/
|
73bcce88
luigser
COMPONENTS
|
59
|
|
74249687
Luigi Serra
Cross browser con...
|
60
|
:host ::content #treemap_placeholder {
|
73bcce88
luigser
COMPONENTS
|
61
62
|
width: 100%;
height: 70%;
|
25201c03
Renato De Donato
spinner, geojsonPure
|
63
|
min-height: 400px;
|
9819a403
Renato De Donato
bubble scatter tr...
|
64
65
|
background: #bbb;
/*position: relative;*/
|
73bcce88
luigser
COMPONENTS
|
66
67
|
}
|
74249687
Luigi Serra
Cross browser con...
|
68
|
:host ::content text {
|
73bcce88
luigser
COMPONENTS
|
69
70
71
|
pointer-events: none;
}
|
74249687
Luigi Serra
Cross browser con...
|
72
|
:host ::content .grandparent text {
|
73bcce88
luigser
COMPONENTS
|
73
74
75
|
font-weight: bold;
}
|
74249687
Luigi Serra
Cross browser con...
|
76
|
:host ::content rect {
|
73bcce88
luigser
COMPONENTS
|
77
78
79
80
|
fill: none;
stroke: #fff;
}
|
9819a403
Renato De Donato
bubble scatter tr...
|
81
|
:host ::content rect.parent {
|
73bcce88
luigser
COMPONENTS
|
82
83
84
|
stroke-width: 2px;
}
|
74249687
Luigi Serra
Cross browser con...
|
85
|
:host ::content .grandparent rect {
|
73bcce88
luigser
COMPONENTS
|
86
87
88
|
fill: orange;
}
|
74249687
Luigi Serra
Cross browser con...
|
89
|
:host ::content .grandparent:hover rect {
|
73bcce88
luigser
COMPONENTS
|
90
91
92
|
fill: #ee9700;
}
|
9819a403
Renato De Donato
bubble scatter tr...
|
93
94
95
96
97
98
|
:host ::content .children rect.parent {
cursor: pointer;
}
:host ::content .grandparent rect {
stroke-width: 2px;
|
73bcce88
luigser
COMPONENTS
|
99
100
101
|
cursor: pointer;
}
|
74249687
Luigi Serra
Cross browser con...
|
102
|
:host ::content .children rect.parent {
|
73bcce88
luigser
COMPONENTS
|
103
|
fill: #bbb;
|
9819a403
Renato De Donato
bubble scatter tr...
|
104
105
|
-fill-opacity: .5;
fill-opacity: 1;
|
73bcce88
luigser
COMPONENTS
|
106
107
|
}
|
74249687
Luigi Serra
Cross browser con...
|
108
|
:host ::content .children:hover rect.child {
|
73bcce88
luigser
COMPONENTS
|
109
110
111
112
|
fill: #bbb;
}
</style>
<div id="treemap_placeholder"></div>
|
498cdf34
Andrea Petta
leafletjs
|
113
|
<base-ajax-json-alasql-datalet data-url="{{dataUrl}}" fields="{{fields}}" data="{{data}}" title="{{title}}" description="{{description}}" export_menu="{{export_menu}}"></base-ajax-json-alasql-datalet>
|
73bcce88
luigser
COMPONENTS
|
114
115
116
117
118
|
</template>
<script src="../shared_js/d3.js"></script>
<script src="js/buildtreemap.js"></script>
<script>
|
a1f0799c
isisadmin
datalet global re...
|
119
|
|
73bcce88
luigser
COMPONENTS
|
120
|
var TreemapBehavior = {
|
5bc002a2
isisadmin
datalet refactoring
|
121
|
|
73bcce88
luigser
COMPONENTS
|
122
|
map : {
|
4e7eacf4
Luigi Serra
Controllets and d...
|
123
|
name : "",
|
73bcce88
luigser
COMPONENTS
|
124
125
|
children : []
},
|
5bc002a2
isisadmin
datalet refactoring
|
126
|
|
9819a403
Renato De Donato
bubble scatter tr...
|
127
|
transformData: function()
|
a1f0799c
isisadmin
datalet global re...
|
128
129
|
{
var treemapData = [];
|
73bcce88
luigser
COMPONENTS
|
130
|
|
9819a403
Renato De Donato
bubble scatter tr...
|
131
|
// if(this.data.length > 1) {
|
a1f0799c
isisadmin
datalet global re...
|
132
133
|
for (i = 0; i < this.data.length; i++) {
var propName = this.data[i].name;
|
73bcce88
luigser
COMPONENTS
|
134
|
|
a1f0799c
isisadmin
datalet global re...
|
135
136
|
for (var j = 0; j < this.data[i].data.length; j++) {
if (i == 0) treemapData[j] = {};
|
73bcce88
luigser
COMPONENTS
|
137
|
currObj = {};
|
a1f0799c
isisadmin
datalet global re...
|
138
139
|
currObj[propName] = this.data[i].data[j];
jQuery.extend(treemapData[j], currObj);
|
73bcce88
luigser
COMPONENTS
|
140
141
|
}
}
|
9819a403
Renato De Donato
bubble scatter tr...
|
142
143
144
|
// }else{
// treemapData = this.data[0].data;
// }
|
73bcce88
luigser
COMPONENTS
|
145
146
147
|
this.map.children = [];
|
a1f0799c
isisadmin
datalet global re...
|
148
|
for(var i = 0; i < treemapData.length; i++){
|
9bb60e44
Luigi Serra
updates
|
149
|
this.checkAggragationField(treemapData[i], this.data.length , this.data.length - 1);
|
73bcce88
luigser
COMPONENTS
|
150
|
}
|
5bc002a2
isisadmin
datalet refactoring
|
151
|
|
73bcce88
luigser
COMPONENTS
|
152
|
},
|
5bc002a2
isisadmin
datalet refactoring
|
153
|
|
73bcce88
luigser
COMPONENTS
|
154
155
156
157
158
159
160
161
162
163
|
findChild: function(child, category){
var children = child.children;
for (var i=0; i<children.length; i++) {
if (children[i].name == category)
return children[i];
}
var nchild = {name : category , children : []};
children.push(nchild);
return nchild;
},
|
5bc002a2
isisadmin
datalet refactoring
|
164
|
|
f974e824
Luigi Serra
Bugs fix
|
165
|
checkAggragationField: function(object, levels, value_index){
|
73bcce88
luigser
COMPONENTS
|
166
167
|
var curchild = this.map;
var keys = Object.keys(object);
|
f974e824
Luigi Serra
Bugs fix
|
168
|
for(var level= 0; level < levels; level++){
|
73bcce88
luigser
COMPONENTS
|
169
|
|
f974e824
Luigi Serra
Bugs fix
|
170
|
var child = this.findChild(curchild, object[keys[level]]);
|
73bcce88
luigser
COMPONENTS
|
171
172
173
174
175
176
177
178
179
180
|
curchild = child;
}
if (curchild.value === undefined)
curchild.value = 0;
var value = curchild.value + parseFloat(object[keys[value_index]]);
curchild.children = null;
curchild.value = value;
},
|
5bc002a2
isisadmin
datalet refactoring
|
181
|
|
59e45d36
Luigi Serra
treemap and leafl...
|
182
|
presentData: function(){
|
9819a403
Renato De Donato
bubble scatter tr...
|
183
|
this.map.name = this._component.title;
|
8fcc0f36
Luigi Serra
treeview bug fixing
|
184
|
build(this.map, this._component.$.treemap_placeholder);
|
73bcce88
luigser
COMPONENTS
|
185
186
187
|
}
};
|
73bcce88
luigser
COMPONENTS
|
188
189
|
Polymer({
is : 'treemap-datalet' ,
|
a1f0799c
isisadmin
datalet global re...
|
190
|
|
035bbee3
Luigi Serra
Datalets and cont...
|
191
|
properties: {
|
413bc541
Renato De Donato
data cache
|
192
193
194
195
|
data: {
type: Array,
value: undefined
},
|
035bbee3
Luigi Serra
Datalets and cont...
|
196
|
/**
|
e5b73e81
isisadmin
addded behavior p...
|
197
198
199
200
201
202
203
204
205
|
* It's the component behavior
*
* @attribute behavior
* @type Object
* @default {}
*/
behavior : {
type : Object,
value : {}
|
498cdf34
Andrea Petta
leafletjs
|
206
207
208
209
210
211
212
213
214
215
216
217
|
},
/**
* Control the export menu
* xxxx BITMASK. FROM RIGHT : HTML, PNG, RTF, MY SPACE (eg. 1111 show all, 0000 hide all)
*
* @attribute export_menu
* @type Number
* @default 15
*/
export_menu : {
type : Number,
value : 15 // xxxx BITMASK. FROM RIGHT : HTML, PNG, RTF, MY SPACE (eg. 1111 show all, 0000 hide all)
|
035bbee3
Luigi Serra
Datalets and cont...
|
218
219
220
|
}
},
|
73bcce88
luigser
COMPONENTS
|
221
|
ready: function(){
|
98d9d8a5
Renato De Donato
filters+groupby
|
222
|
this.behavior = $.extend(true, {}, BaseDataletBehavior, WorkcycleBehavior, AjaxJsonAlasqlBehavior, TreemapBehavior);
|
b4accc86
Renato De Donato
datalet improved
|
223
|
this.async(function(){this.behavior.init(this)},0);
|
59e45d36
Luigi Serra
treemap and leafl...
|
224
225
226
227
228
229
|
},
refresh : function(){
$(this.$.treemap_placeholder).html("");
this.behavior.transformData(null);
this.behavior.presentData();
|
73bcce88
luigser
COMPONENTS
|
230
231
232
233
234
|
}
});
</script>
</dom-module>
|