a508f993
isisadmin
added datalet doc...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
<!--
The MIT License (MIT)
Copyright (c) 2015 ROUTE-TO-PA CONSORTIUM
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.
-->
|
a1f0799c
isisadmin
datalet global re...
|
25
|
<link rel="import" href="../base-ajax-json-jsonpath-datalet/base-ajax-json-jsonpath-datalet.html">
|
73bcce88
luigser
COMPONENTS
|
26
27
28
|
<dom-module id="treemap-datalet">
<template>
|
74249687
Luigi Serra
Cross browser con...
|
29
|
<style is="custom-style">
|
73bcce88
luigser
COMPONENTS
|
30
|
|
74249687
Luigi Serra
Cross browser con...
|
31
|
:host ::content h6 {
|
73bcce88
luigser
COMPONENTS
|
32
33
34
|
color: red;
}
|
74249687
Luigi Serra
Cross browser con...
|
35
|
:host ::content #treemap_placeholder {
|
73bcce88
luigser
COMPONENTS
|
36
37
|
width: 100%;
height: 70%;
|
f974e824
Luigi Serra
Bugs fix
|
38
|
min-height: 500px;
|
73bcce88
luigser
COMPONENTS
|
39
40
41
|
background: #ddd;
}
|
74249687
Luigi Serra
Cross browser con...
|
42
|
:host ::content text {
|
73bcce88
luigser
COMPONENTS
|
43
44
45
|
pointer-events: none;
}
|
74249687
Luigi Serra
Cross browser con...
|
46
|
:host ::content .grandparent text {
|
73bcce88
luigser
COMPONENTS
|
47
48
49
|
font-weight: bold;
}
|
74249687
Luigi Serra
Cross browser con...
|
50
|
:host ::content rect {
|
73bcce88
luigser
COMPONENTS
|
51
52
53
54
|
fill: none;
stroke: #fff;
}
|
74249687
Luigi Serra
Cross browser con...
|
55
|
:host ::content rect.parent,
|
73bcce88
luigser
COMPONENTS
|
56
57
58
59
|
.grandparent rect {
stroke-width: 2px;
}
|
74249687
Luigi Serra
Cross browser con...
|
60
|
:host ::content .grandparent rect {
|
73bcce88
luigser
COMPONENTS
|
61
62
63
|
fill: orange;
}
|
74249687
Luigi Serra
Cross browser con...
|
64
|
:host ::content .grandparent:hover rect {
|
73bcce88
luigser
COMPONENTS
|
65
66
67
|
fill: #ee9700;
}
|
74249687
Luigi Serra
Cross browser con...
|
68
|
:host ::content .children rect.parent,
|
73bcce88
luigser
COMPONENTS
|
69
70
71
72
|
.grandparent rect {
cursor: pointer;
}
|
74249687
Luigi Serra
Cross browser con...
|
73
|
:host ::content .children rect.parent {
|
73bcce88
luigser
COMPONENTS
|
74
75
76
77
|
fill: #bbb;
fill-opacity: .5;
}
|
74249687
Luigi Serra
Cross browser con...
|
78
|
:host ::content .children:hover rect.child {
|
73bcce88
luigser
COMPONENTS
|
79
80
81
82
|
fill: #bbb;
}
</style>
<div id="treemap_placeholder"></div>
|
a1f0799c
isisadmin
datalet global re...
|
83
|
<base-ajax-json-jsonpath-datalet data-url="{{dataUrl}}" fields="{{fields}}"></base-ajax-json-jsonpath-datalet>
|
73bcce88
luigser
COMPONENTS
|
84
85
86
87
88
|
</template>
<script src="../shared_js/d3.js"></script>
<script src="js/buildtreemap.js"></script>
<script>
|
a1f0799c
isisadmin
datalet global re...
|
89
|
|
73bcce88
luigser
COMPONENTS
|
90
91
92
93
94
|
var TreemapBehavior = {
map : {
name : "Expenses",
children : []
},
|
a1f0799c
isisadmin
datalet global re...
|
95
96
97
98
|
selectData: function(e)
{
var treemapData = [];
|
73bcce88
luigser
COMPONENTS
|
99
|
|
a1f0799c
isisadmin
datalet global re...
|
100
101
102
|
if(this.data.length > 1) {
for (i = 0; i < this.data.length; i++) {
var propName = this.data[i].name;
|
73bcce88
luigser
COMPONENTS
|
103
|
|
a1f0799c
isisadmin
datalet global re...
|
104
105
|
for (var j = 0; j < this.data[i].data.length; j++) {
if (i == 0) treemapData[j] = {};
|
73bcce88
luigser
COMPONENTS
|
106
|
currObj = {};
|
a1f0799c
isisadmin
datalet global re...
|
107
108
|
currObj[propName] = this.data[i].data[j];
jQuery.extend(treemapData[j], currObj);
|
73bcce88
luigser
COMPONENTS
|
109
110
111
|
}
}
}else{
|
a1f0799c
isisadmin
datalet global re...
|
112
|
treemapData = this.data[0].data;
|
73bcce88
luigser
COMPONENTS
|
113
114
115
116
|
}
this.map.children = [];
|
a1f0799c
isisadmin
datalet global re...
|
117
118
|
for(var i = 0; i < treemapData.length; i++){
this.checkAggragationField(treemapData[i], this._component.fields.length , this._component.fields.length - 1);
|
73bcce88
luigser
COMPONENTS
|
119
|
}
|
74249687
Luigi Serra
Cross browser con...
|
120
|
var json = JSON.stringify(this.map);
|
73bcce88
luigser
COMPONENTS
|
121
122
123
124
125
126
127
128
129
130
131
|
},
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;
},
|
f974e824
Luigi Serra
Bugs fix
|
132
|
checkAggragationField: function(object, levels, value_index){
|
73bcce88
luigser
COMPONENTS
|
133
134
|
var curchild = this.map;
var keys = Object.keys(object);
|
f974e824
Luigi Serra
Bugs fix
|
135
|
for(var level= 0; level < levels; level++){
|
73bcce88
luigser
COMPONENTS
|
136
|
|
f974e824
Luigi Serra
Bugs fix
|
137
|
var child = this.findChild(curchild, object[keys[level]]);
|
73bcce88
luigser
COMPONENTS
|
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
curchild = child;
}
if (curchild.value === undefined)
curchild.value = 0;
var value = curchild.value + parseFloat(object[keys[value_index]]);
curchild.children = null;
curchild.value = value;
},
transformData: function(){
build(this.map, "treemap_placeholder");
}
};
Polymer({
is : 'treemap-datalet' ,
|
a1f0799c
isisadmin
datalet global re...
|
156
|
|
73bcce88
luigser
COMPONENTS
|
157
|
ready: function(){
|
a1f0799c
isisadmin
datalet global re...
|
158
|
var TreemapComponentBehavior = $.extend(true, {}, BaseDataletBehavior, WorkcycleBehavior, AjaxJsonJsonPathBehavior, TreemapBehavior);
|
73bcce88
luigser
COMPONENTS
|
159
160
161
162
163
164
|
TreemapComponentBehavior.init(this);
}
});
</script>
</dom-module>
|