entities-chart.html 7.19 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-icons/iron-icons.html">
<link rel="import" href="../paper-button/paper-button.html">

<dom-module id="entities-chart">

<style is="custom-style">
  @import url("../../styles/app-theme.html");
</style>
<link rel="import" type="css" href="entities-chart.css">

  <template>

    <style type="text/css">

      #chart {
        width: 100%;
      }

      .number {
        padding: 1px 3px;
        border: 1px solid #9e5c26;
        border-radius: 5px;
        box-shadow: inset 0 1px 0 #f5bf8c;
        margin-left: 7px;
        color: white;
      }

      .active .number {
        background-color: #ed943f;
        background-image: linear-gradient(bottom, rgb(211,95,32) 0%, rgb(223,131,45) 100%);
        background-image: -o-linear-gradient(bottom, rgb(211,95,32) 0%, rgb(223,131,45) 100%);
        background-image: -moz-linear-gradient(bottom, rgb(211,95,32) 0%, rgb(223,131,45) 100%);
        background-image: -webkit-linear-gradient(bottom, rgb(211,95,32) 0%, rgb(223,131,45) 100%);
        background-image: -ms-linear-gradient(bottom, rgb(211,95,32) 0%, rgb(223,131,45) 100%);
      }

      .idle .number {
        background-color: #666;
        background-image: linear-gradient(bottom, rgb(102,102,102) 0%, rgb(123,123,123) 100%);
        background-image: -o-linear-gradient(bottom, rgb(102,102,102) 0%, rgb(123,123,123) 100%);
        background-image: -moz-linear-gradient(bottom, rgb(102,102,102) 0%, rgb(123,123,123) 100%);
        background-image: -webkit-linear-gradient(bottom, rgb(102,102,102) 0%, rgb(123,123,123) 100%);
        background-image: -ms-linear-gradient(bottom, rgb(102,102,102) 0%, rgb(123,123,123) 100%);
      }

      .tag {
        display: inline-block;
        margin: 0 0 7px 20px;
        position: relative;
        font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
        font-size: 0.9em;
        font-weight: bold;
        text-decoration: none;
        text-shadow: 0px 2px 0px rgba(255,255,255,.4);
        height: 2em;
        line-height: 2em;
        padding: 0 0.5em 0 1em;
        border-top: 0.0625em solid #d99d38;
        border-right: 0.0625em solid #d99d38;
        border-bottom: 0.0625em solid #d99d38;
        -webkit-border-radius: 0 0.25em 0.25em 0;
        -moz-border-radius: 0 0.25em 0.25em 0;
        border-radius: 0 0.25em 0.25em 0;
        background-image: -webkit-linear-gradient(top, rgb(254, 218, 113), rgb(254, 186, 71));
        background-image: -moz-linear-gradient(top, rgb(254, 218, 113), rgb(254, 186, 71));
        background-image: -o-linear-gradient(top, rgb(254, 218, 113), rgb(254, 186, 71));
        background-image: -ms-linear-gradient(top, rgb(254, 218, 113), rgb(254, 186, 71));
        background-image: linear-gradient(top, rgb(254, 218, 113), rgb(254, 186, 71));
        filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColorStr='#feda71', EndColorStr='#feba47');
        -webkit-box-shadow: inset 0 1px 0 #faeaba, 0 1px 1px rgba(0,0,0,.1);
        -moz-box-shadow: inset 0 1px 0 #faeaba, 0 1px 1px rgba(0,0,0,.1);
        box-shadow: inset 0 1px 0 #faeaba, 0 1px 1px rgba(0,0,0,.1);
      }

      .tag:before {
        content: '';
        width: 1.4584em;
        height: 1.4584em;
        background-image: -webkit-linear-gradient(left top, rgb(254, 218, 113), rgb(254, 186, 71));
        background-image: -moz-linear-gradient(left top, rgb(254, 218, 113), rgb(254, 186, 71));
        background-image: -o-linear-gradient(left top, rgb(254, 218, 113), rgb(254, 186, 71));
        background-image: -ms-linear-gradient(left top, rgb(254, 218, 113), rgb(254, 186, 71));
        background-image: linear-gradient(left top, rgb(254, 218, 113), rgb(254, 186, 71));
        filter: progid:DXImageTransform.Microsoft.gradient(GradientType=1,StartColorStr='#feda71', EndColorStr='#feba47');
        position: absolute;
        left: 0em;
        top: -0.0625em;
        -webkit-transform: rotate(45deg);
        -moz-transform: rotate(45deg);
        -o-transform: rotate(45deg);
        transform: rotate(45deg);
        -webkit-transform-origin: 0 0;
        -moz-transform-origin: 0 0;
        -o-transform-origin: 0 0;
        transform-origin: 0 0;
        border-left: 0.0625em solid #d99d38;
        border-bottom: 0.0625em solid #d99d38;
        -webkit-border-radius: 0 0 0 0.25em;
        -moz-border-radius: 0 0 0 0.25em;
        border-radius: 0 0 0 0.25em;
      }

      #tag-wrapper {
        margin: 10px 10px 10px 20px;
      }

      .content.paper-button {
          padding: 0 0.57em;
      }

      .tag {
        padding: 0em 0em !important;
        color:#000;
        margin-bottom: 10px;
      }
      .tag span{
        position: relative;
        top:0px;
        margin-right: 2px;
      }

    </style>

    <!-- Shadow DOM -->
    <paper-material class="entities" elevation="1">
      <div class="top-bar">
        <iron-icon icon="{{icon}}"></iron-icon>
        <span>{{title}}</span>
      </div>
      <div id="tag-wrapper">
        <template is="dom-repeat" items="{{entities}}" as="entity">
          <paper-button class="tag active" on-tap="filter"><span>{{entity.0}}</span><span class="number">{{entity.1}}</span></paper-button>
        </template>
      </div>
      <div style="float:right">
        <small>Clear Filters</small>
        <paper-icon-button icon="delete" alt="menu" class="green" on-tap="removeFilters"></paper-icon-button>
      </div>
      <div style="width:100%; clear: both"></div>
    </paper-material>

  </template>

  <script>
    var filtered = false;

    Polymer({

      is: 'entities-chart',

      properties: {

        data: {
          type: Object,
          observer: '_dataChanged'              
        },
 
        icon: {
          type: String
        },
        entities: {
          type: Array
        },

        title: {
          type: String,
          value: "Entities Chart"
        },

        query: {
          type: String,
          observer: '_queryChanged'
        },

        index: {
          type: String
        },

        subindex: {
          type: String
        },

        fields: {
          type: Array,
          value: function() { return []; }
        },

        field: {
          type: String
        },

        host: {
          type: String
        },

        param: {
          type: String,
          notify: true
        },

        filters: {
          type: Array,
          notify: true,
          value: function() { return []; }
        }
      },

      _dataChanged: function() {
        var that = this
        var aggs = 0
Alberto Pascual's avatar
Alberto Pascual committed
212
        console.log(this.field)
213
214
215
216
217
218
219
220
        try{
          var hits = this.data.aggregations[this.field].buckets;
        }
        catch(err){
          var hits = []
        }
        var data = [];
        hits.forEach(function(entry) {
Alberto Pascual's avatar
Alberto Pascual committed
221
          data.push([entry.key.toUpperCase().split("/")[4], entry.doc_count]);
222
223
224
225
226
227
228
229
230
231
232
        });
        that.entities = data;
        filtered = true;
      },

      removeFilters: function(){
        this.filters = [];
      },
     
      filter: function(e) {
        var myfilters = e.model.__data__.entity[0].toLowerCase().split(" ")
Alberto Pascual's avatar
Alberto Pascual committed
233
        this.push('filters', { terms: { 'entities.dbps:anyURI': myfilters}})
234
235
236
237
238
239
      }

    });
  </script>

</dom-module>