Commit cfaad5eb authored by Daniel Suarez's avatar Daniel Suarez
Browse files

Changes in visualization components for new index

parent 548139a4
......@@ -38,6 +38,11 @@
url="/queries.json"
handle-as="json"
last-response="{{queries}}"></iron-ajax>
<iron-ajax auto
url="/sources.json"
handle-as="json"
on-response="sourceResponse"></iron-ajax>
<!--
<div style="width:10%; padding: 1em; display:inline-block">
<img style="width: 100%;"src="/images/trivalent.jpg">
......@@ -75,7 +80,7 @@
<div class="col-md-4">
<number-chart
data="{{data}}"
object="cnn"
object="CNN"
aggKey="schema:author"
title="CNN"
icon="/images/cnn_blanco.svg"
......@@ -108,7 +113,7 @@
<div class="col-md-4">
<number-chart
data="{{data}}"
object="twitter"
object="Twitter"
aggKey="schema:author"
title="Twitter"
icon="/images/twitter.svg"
......@@ -119,8 +124,8 @@
<div class="col-md-4">
<number-chart
data="{{data}}"
aggKey="magazines"
object=""
aggKey="type"
object="schema:Article"
title="Magazines"
icon="/images/magazine.svg"
subtitle="Total"
......@@ -134,7 +139,8 @@
<div class="col-md-6">
<google-chart
field="schema:author"
data="{{data}}"
data="{{data}}"
sources="{{sources}}"
id='pie-chart3'
extra-id='pie-chart3'
type='pie'
......@@ -159,7 +165,7 @@
<br>
<div class="row">
<div class="col-md-6">
<!-- <google-chart
<google-chart
field="sentiment"
data="{{data}}"
id='barsentiment'
......@@ -169,18 +175,7 @@
icon='social:mood'
options='{"title": "Sentiments"}'
cols='[{"label": "Sentiment", "type": "string"},{"label": "Count", "type": "number"}]'>
</google-chart>-->
<google-chart
field="schema:datePublished"
data="{{data}}"
id='line-chart'
extra-id='line-chart'
type='area'
filters="{{filters}}"
icon='icons:trending-up'
options='{"title": "Temporal Trends"}'
cols='[{"label": "Date", "type": "string"},{"label": "Count", "type": "number"}]'>
</google-chart>
</google-chart>
</div>
<div class="col-md-6">
<people-chart
......@@ -193,8 +188,22 @@
</people-chart>
</div>
</div>
<br>
<div class="row">
<div class="col-md-12">
<google-chart
field="schema:datePublished"
data="{{data}}"
id='line-chart'
extra-id='line-chart'
type='line'
filters="{{filters}}"
icon='icons:trending-up'
options='{"title": "Temporal Trends"}'
optionsbi='{"legend": { "position": "bottom"}}'>
</google-chart>
</div>
</div>
<br>
<div class="row">
<div class="col-md-6">
<paper-tabs selected="{{selectedpage}}" style="height: 38px">
......@@ -386,6 +395,11 @@ H2020 RIA Action Grant No. 740934 under the call SEC-06-FCT-2016 — Developing
})
return places
},
sourceResponse:function(e){
//console.log(e.detail.response[0])
this.sources=e.detail.response[0]
//console.log(this.sources)
},
_search: function(){
console.log("search fired")
console.log(this.selectedentity)
......@@ -437,15 +451,6 @@ H2020 RIA Action Grant No. 740934 under the call SEC-06-FCT-2016 — Developing
}
}
},
magazines: {
terms: {
field: "schema:author.keyword",
include: ".*dbpedia.*",
order: {
_count: "desc"
}
}
},
'entities.type': {
terms: {
field: "entities.@type.keyword",
......@@ -464,43 +469,48 @@ H2020 RIA Action Grant No. 740934 under the call SEC-06-FCT-2016 — Developing
}
}
},
'topics.rdfs:subClassOf': {
sentiment: {
terms: {
field: "topics.rdfs:subClassOf.keyword",
size: 20,
field: "sentiments.marl:hasPolarity.keyword",
order: {
_count: "desc"
}
}
}
},
sentiment: {
terms: {
field: "sentiments.marl:hasPolarity.keyword",
order: {
_count: "desc"
}
}
},
'schema:datePublished': {
date_histogram : {
field : "schema:datePublished",
format: "MM-yyyy",
interval : "month"
},
'schema:datePublished': {
date_histogram : {
field : "schema:datePublished",
format: "MM-yyyy",
interval : "month"
},
aggs:{
source:{
terms: {
field: "schema:author.keyword",
order: {
_count: "desc"
}
}
}
}
}
}
}
}
}).then(function (resp) {
var myids = []
resp.hits.hits.forEach(function(entry){myids.push(entry._id)})
that.ids = myids;
//console.log(that.ids)
//console.log(that.sources)
/*var sources=that.sources
for (var i=0; i<resp['aggregations']['schema:author']['buckets'].length;i++) {
if(resp['aggregations']['schema:author']['buckets'][i]["key"]=="http://dbpedia.org/page/Dabiq_(magazine)")
resp['aggregations']['schema:author']['buckets'][i]["key"]="Dabiq"
if(resp['aggregations']['schema:author']['buckets'][i]["key"]=="http://dbpedia.org/page/Rumiyah_(magazine)")
resp['aggregations']['schema:author']['buckets'][i]["key"]="Rumiyah"
}
var key=resp['aggregations']['schema:author']['buckets'][i]["key"]
console.log(key)
if(key in sources)
console.log(sources)
resp['aggregations']['schema:author']['buckets'][i]["key"]=sources[key]
}*/
//resp['aggregations']['schema:author']['buckets'][1]["key"]="Dabiq"
//resp['aggregations']['schema:author']['buckets'][2]["key"]="Rumiyah"
that.data = resp;
......
......@@ -147,7 +147,7 @@ Data can be provided in one of three ways:
*/
cols: {
type: Array,
value: function() { return []; }
value: function() { return null; }
},
/**
* Sets the data rows for this object.
......@@ -233,6 +233,10 @@ Data can be provided in one of three ways:
type: Array,
value: function() { return []; }
},
sources: {
type:Object,
value: function() { return {}; }
},
field: {
type: String
......@@ -295,6 +299,7 @@ Data can be provided in one of three ways:
this.param = arr[sel][0]
var param = this.param
var field = this.field
var term1 = {};
console.log(field)
if (field == "schema:author"){
......@@ -308,13 +313,16 @@ Data can be provided in one of three ways:
term1[field] = param.toLowerCase().split("-");
}
if (field == 'schema:author.keyword'){
if(param == "Dabiq"){
param = "http://dbpedia.org/page/Dabiq_(magazine)"
}
if(param == "Rumiyah"){
param = "http://dbpedia.org/page/Rumiyah_(magazine)"
}
var sources=this.sources
console.log(sources)
var value=param.split(" ")[0]
for(var key in sources){
console.log(key)
if(key.search(value)>=0)
param=key
}
term1[field] = param;
}
......@@ -447,7 +455,7 @@ Data can be provided in one of three ways:
},
_loadData: function() {
//console.log("dataloaded")
console.log("dataloaded")
this._canDraw = false;
if (this._isReady) {
if (typeof this.data == 'string' || this.data instanceof String) {
......@@ -479,6 +487,7 @@ Data can be provided in one of three ways:
},
_createDataTable: function(data) {
console.log("_createDataTable")
var dataTable = null;
// If a data object was not passed to this function, default to the
// chart's data attribute. Passing a data object is necessary for
......@@ -491,25 +500,36 @@ Data can be provided in one of three ways:
}
if (!data)
data = [];
console.log(this.cols)
if (this.rows && this.rows.length > 0 && this.cols &&
this.cols.length > 0) {
// Create the data table from cols and rows.
dataTable = new google.visualization.DataTable();
dataTable.cols = this.cols;
for (var i = 0; i < this.cols.length; i++) {
dataTable.addColumn(this.cols[i]);
}
dataTable.addRows(this.rows);
} else {
// Create dataTable from the passed data or the data attribute.
// Data can be in the form of raw DataTable data or a two
// dimensional array.
if (data.rows && data.cols) {
dataTable = new google.visualization.DataTable(data);
} else if (data.length > 0) {
dataTable = google.visualization.arrayToDataTable(data);
//console.log(data)
dataTable = new google.visualization.DataTable();
dataTable.cols = this.cols;
for (var i = 0; i < this.cols.length; i++) {
dataTable.addColumn(this.cols[i]);
}
dataTable.addRows(this.rows);
} else {
// Create dataTable from the passed data or the data attribute.
// Data can be in the form of raw DataTable data or a two
// dimensional array.
console.log("_createDataTable2")
data=[
['Year', 'Sales', 'Expenses'],
['2004', 1000, 400],
['2005', 1170, 460],
['2006', 660, 1120],
['2007', 1030, 540]
];
if (data.rows && data.cols) {
dataTable = new google.visualization.DataTable(data);
} else if (data.length > 0) {
dataTable = google.visualization.arrayToDataTable(data);
}
}
}
return dataTable;
},
......@@ -527,6 +547,16 @@ Data can be provided in one of three ways:
}
var data = [];
if (this.field == "schema:datePublished") {
//We represent de data in this format in order to represent each source with one line
//data=[
// ['date', 'CNN', 'Twitter'],
// ['5-2018', 3, 10],
// ['6-2018', 5, 60],
// ['7-2018', 9, 20],
// ['8-2018', 1, 40]
// ];
var
console.log(hits)
hits.forEach(function(entry) {
data.push([entry.key_as_string, entry.doc_count]);
});
......
......@@ -200,9 +200,9 @@
/*if(news['schema:author']=='cnn'){
text=text.replace(/[ ]{2,}/g,'\n')
}*/
text=text.replace(/[ ]{2,}/g,'\n')
//text=text.replace(/[ ]{2,}/g,'\n')
//else{
text=text.replace(/\n\n/g,'\n')
//text=text.replace(/\n\n/g,'\n')
//}
//console.log(text)
......
......@@ -132,7 +132,7 @@
//console.log(hits)
hits.forEach(function(entry) {
//console.log(entry)
if(entry._source['schema:author'] == 'twitter') results.push(entry._source);
if(entry._source['@type'] == 'schema:BlogPosting') results.push(entry._source);
});
//console.log(results)
that.data = results
......
......@@ -26,7 +26,7 @@
<app-location route="{{route}}"></app-location>
<elastic-client
config='{"host": "localhost:19200"}'
config='{"host": "http://sefarad-elasticsearch.cluster.gsi.dit.upm.es"}'
client="{{client}}"
cluster-status="{{myStatus}}">
</elastic-client>
......
[{"http://dbpedia.org/page/Dabiq_(magazine)": "Dabiq", "http://dbpedia.org/page/Rumiyah_(magazine)": "Rumiyah","http://dbpedia.org/resource/Al_Jazeera":"Al Jazeera","http://dbpedia.org/resource/CNN":"CNN","http://dbpedia.org/resource/Twitter":"Twitter","http://dbpedia.org/resource/The_New_York_Times":"The New York Times"}]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment