Commit 3104a159 authored by Daniel Suarez's avatar Daniel Suarez
Browse files

New Version of Trending Lines Component

parent cfaad5eb
......@@ -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,23 @@
</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}}"
sources="{{sources}}"
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 +396,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 +452,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,42 +470,47 @@ 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"
......
......@@ -80,7 +80,7 @@
<div class="col-md-4">
<number-chart
data="{{data}}"
object="CNN"
object="http://dbpedia.org/resource/CNN"
aggKey="schema:author"
title="CNN"
icon="/images/cnn_blanco.svg"
......@@ -90,7 +90,7 @@
<div class="col-md-4">
<number-chart
data="{{data}}"
object="The New York Times"
object="http://dbpedia.org/resource/The_New_York_Times"
aggKey="schema:author"
title="The New York Times"
icon="/images/times1.png"
......@@ -102,7 +102,7 @@
<div class="col-md-4">
<number-chart
data="{{data}}"
object="Al Jazeera"
object="http://dbpedia.org/resource/Al_Jazeera"
aggKey="schema:author"
title="Al Jazeera"
icon="/images/Aljazeera_blanco.svg"
......@@ -113,7 +113,7 @@
<div class="col-md-4">
<number-chart
data="{{data}}"
object="Twitter"
object="http://dbpedia.org/resource/Twitter"
aggKey="schema:author"
title="Twitter"
icon="/images/twitter.svg"
......@@ -197,6 +197,7 @@
extra-id='line-chart'
type='line'
filters="{{filters}}"
sources="{{sources}}"
icon='icons:trending-up'
options='{"title": "Temporal Trends"}'
optionsbi='{"legend": { "position": "bottom"}}'>
......
......@@ -292,13 +292,24 @@ Data can be provided in one of three ways:
_selectionChanged: function() {
//console.log("_selectionChanged")
//console.log(this.selection)
console.log(this.selection)
console.log(this.rows)
if(this.selection.length != 0){
var arr = this.rows;
var sel = this.selection[0].row
this.param = arr[sel][0]
var param = this.param
var field = this.field
var sel = this.selection[0].row
var object={}
if(!sel){
var col=this.selection[0].column
var param=arr[0][col]
field='schema:author.keyword'
}else{
this.param = arr[sel][0]
var param = this.param
}
var term1 = {};
console.log(field)
......@@ -307,11 +318,10 @@ Data can be provided in one of three ways:
}
if (field == "sentiment") field = 'sentiments.marl:hasPolarity'
if (field == "emotion") field = 'emotions.onyx:hasEmotion.onyx:hasEmotionCategory'
term1[field] = param.toLowerCase().split(" ");
if (field == 'datePublished'){
term1[field] = param.toLowerCase().split("-");
}
term1[field] = param.toLowerCase().split(" ");
if (field == 'schema:author.keyword'){
var sources=this.sources
console.log(sources)
......@@ -329,11 +339,14 @@ Data can be provided in one of three ways:
console.log(term1)
//console.log("param")
//console.log(param)
var object = {term: term1}
object = {term: term1}
if (field == 'schema:datePublished'){
var date = param.toLowerCase().toString().split("-");
var term = date[1]+'-'+date[0]+'-01'
object = {range: {'schema:datePublished': {gte: term, boost: 5}}}
console.log(arr)
param=arr[sel+1][0]
console.log(param)
var date = param.toLowerCase().toString().split("-");
var term = date[1]+'-'+date[0]+'-01'
object = {range: {'schema:datePublished': {gte: term, boost: 5}}}
}
var isInside = -1
......@@ -516,17 +529,23 @@ Data can be provided in one of three ways:
// Data can be in the form of raw DataTable data or a two
// dimensional array.
console.log("_createDataTable2")
data=[
/*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);
console.log(data)*/
/*this.rows.push(["8-2018", 5, 3, 1])
this.rows.push(["9-2018", 2, 5, 4])
this.rows.push(["10-2018", 5, 3, 1])
this.rows.push(["12-2018", 1, 2, 4])*/
console.log(this.rows)
if (this.rows && this.cols) {
dataTable = new google.visualization.DataTable(this.rows);
} else if (this.rows.length > 0) {
dataTable = google.visualization.arrayToDataTable(this.rows);
}
}
......@@ -555,13 +574,56 @@ Data can be provided in one of three ways:
// ['7-2018', 9, 20],
// ['8-2018', 1, 40]
// ];
var
console.log(hits)
var column_titles=['Date']
//var column_titles=["Date", "cnn", "Al Jazeera", "The New York Times"]
var sources=this.data.aggregations['schema:author'].buckets
console.log(sources)
sources.forEach(function(source){
console.log(source)
if(source.key.search("Twitter")<0 && source.key.search("Rumiyah")<0 && source.key.search("Dabiq")<0)
column_titles.push(source.key)
})
console.log(column_titles)
if(column_titles.length>1){
data.push(column_titles)
console.log(hits)
hits.forEach(function(date) {
var row=[]
row.push(date.key_as_string)
date.source.buckets.forEach(function(source){
var index=0
for(var i =1; i<column_titles.length;i++){
if(source.key==column_titles[i])
row[i]=source.doc_count
}
})
for(var i=0; i<column_titles.length;i++){
if(!row[i])
row[i]=0
}
data.push(row)
//data.push([entry.key_as_string, entry.doc_count]);
});
var source=this.sources
for(var i=1;i<data[0].length;i++){
data[0][i]=source[data[0][i]]
}
}else{
data=[]
}
console.log(data)
}
else if(this.field == "schema:author"){
var source=this.sources
hits.forEach(function(entry) {
data.push([entry.key_as_string, entry.doc_count]);
data.push([source[entry.key], entry.doc_count]);
});
}
else {
}else{
hits.forEach(function(entry) {
data.push([entry.key, entry.doc_count]);
});
......
......@@ -32,9 +32,20 @@
<div class="modal fade" id$="subitem[[index]]" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content" style="max-height: 90%; height: fit-content;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel"><a target="_blank" rel="noopener noreferrer"href$="{{getID(news)}}" style="color: #333; outline: 0 !important; text-decoration: none !important;" title="Open the new">{{getHeadline(news)}}</a></h4>
<div class="modal-header" style="height:80px;background-color: #449DD5; box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.2); border-radius: 5px 5px 0 0;">
<!-- <button type="button" class="close" data-dismiss="modal" aria-label="Close" style="color: #fff;opacity: inherit;"><span aria-hidden="true">&times;</span></button> -->
<div class="col-md-12" style="display: flex;flex-direction: row;justify-content: space-around;align-content: center;">
<div class="col-md-2 img-wrapper" style="width:13%">
<img src="{{checkSource(news)}}" style="width: 100%; display:block; position: relative;" align="left">
</div>
<div class="col-md-10">
<h4 class="modal-title" id="myModalLabel">
<a target="_blank" rel="noopener noreferrer"href$="{{getID(news)}}" style=" color: #fff; outline: 0 !important; text-decoration: none !important; display:inline-block; vertical-align: middle;" title="Open the new">{{getHeadline(news)}}</a>
</h4>
</div>
</div>
</div>
<div class="modal-body" style="height: 520px" >
......
......@@ -26,7 +26,7 @@
<app-location route="{{route}}"></app-location>
<elastic-client
config='{"host": "http://sefarad-elasticsearch.cluster.gsi.dit.upm.es"}'
config='{"host": "localhost:19200"}'
client="{{client}}"
cluster-status="{{myStatus}}">
</elastic-client>
......
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