Commit 66b25e28 authored by delanoe's avatar delanoe

Merge branch 'unstable-201511-advancedcharts' into unstable

parents 2a60c72f a41833eb
...@@ -96,6 +96,7 @@ class NodeNgramsQueries(APIView): ...@@ -96,6 +96,7 @@ class NodeNgramsQueries(APIView):
'str': str, 'str': str,
} }
def post(self, request, project_id): def post(self, request, project_id):
# example only # example only
...@@ -158,7 +159,7 @@ class NodeNgramsQueries(APIView): ...@@ -158,7 +159,7 @@ class NodeNgramsQueries(APIView):
# build query: prepare columns # build query: prepare columns
column_x = func.date_trunc(input['x']['resolution'], Node_Hyperdata.value_datetime) column_x = func.date_trunc(input['x']['resolution'], Node_Hyperdata.value_datetime)
column_y = { column_y = {
'documents_count': func.count(Node.id), 'documents_count': func.count(Node.id.distinct()),
'ngrams_count': func.sum(Node_Ngram.weight), 'ngrams_count': func.sum(Node_Ngram.weight),
# 'ngrams_tfidf': func.sum(Node_Node_Ngram.weight), # 'ngrams_tfidf': func.sum(Node_Node_Ngram.weight),
}[input['y']['value']] }[input['y']['value']]
...@@ -218,6 +219,7 @@ class NodeNgramsQueries(APIView): ...@@ -218,6 +219,7 @@ class NodeNgramsQueries(APIView):
.filter(NH.hyperdata_id == hyperdata_id) .filter(NH.hyperdata_id == hyperdata_id)
.filter(operator(NH_column, value)) .filter(operator(NH_column, value))
) )
# build result: prepare data # build result: prepare data
date_value_list = query_result.all() date_value_list = query_result.all()
if date_value_list: if date_value_list:
...@@ -238,7 +240,7 @@ class NodeNgramsQueries(APIView): ...@@ -238,7 +240,7 @@ class NodeNgramsQueries(APIView):
query_normalize = None query_normalize = None
if date_value_list and 'divided_by' in input['y'] and input['y']['divided_by']: if date_value_list and 'divided_by' in input['y'] and input['y']['divided_by']:
if input['y']['divided_by'] == 'total_documents_count': if input['y']['divided_by'] == 'total_documents_count':
query_normalize = query_base.add_column(func.count(Node.id)) query_normalize = query_base.add_column(func.count(Node.id.distinct()))
elif input['y']['divided_by'] == 'total_ngrams_count': elif input['y']['divided_by'] == 'total_ngrams_count':
query_normalize = query_base.add_column(func.sum(Node_Ngram.weight)) query_normalize = query_base.add_column(func.sum(Node_Ngram.weight))
if query_normalize is not None: if query_normalize is not None:
......
...@@ -177,17 +177,17 @@ angular.module('Gargantext').run(function($rootScope, $http, $cookies){ ...@@ -177,17 +177,17 @@ angular.module('Gargantext').run(function($rootScope, $http, $cookies){
// Controller for datasets // Controller for datasets
gargantext.controller('DatasetController', function($scope, $http) { gargantext.controller('DatasetController', function($scope, $http) {
// are we loading data from the server right now? // are we loading data from the server right now?
$scope.is_loading = false; $scope.is_loading = false;
// initital parameters for the y-axis of the query // initital parameters for the y-axis of the query
$scope.query_y = { $scope.query_y = {
'value': 'ngrams_count', 'value': 'documents_count',
'is_relative': false, 'is_relative': false,
'divided_by': 'total_ngrams_count', 'divided_by': 'total_ngrams_count',
}; };
// filters: corpora retrieval // filters: corpora retrieval
$scope.corpora = []; $scope.corpora = [];
if (/^\/project\/\d+\/corpus\/\d+/.test(location.pathname)) { if (/^\/project\/\d+\/corpus\/\d+/.test(location.pathname)) {
...@@ -209,7 +209,7 @@ gargantext.controller('DatasetController', function($scope, $http) { ...@@ -209,7 +209,7 @@ gargantext.controller('DatasetController', function($scope, $http) {
} }
}); });
}; };
var getSelectedCorporaIdList = function() { var getSelectedCorporaIdList = function() {
var corpus_id_list = []; var corpus_id_list = [];
$.each($scope.corpora, function(c, corpus) { $.each($scope.corpora, function(c, corpus) {
if (corpus.is_selected) { if (corpus.is_selected) {
...@@ -316,7 +316,7 @@ gargantext.controller('DatasetController', function($scope, $http) { ...@@ -316,7 +316,7 @@ gargantext.controller('DatasetController', function($scope, $http) {
// Controller for graphs // Controller for graphs
gargantext.controller('GraphController', function($scope, $http, $element) { gargantext.controller('GraphController', function($scope, $http, $element) {
// initial values // initial values
$scope.query_x = { $scope.query_x = {
...@@ -360,7 +360,8 @@ gargantext.controller('GraphController', function($scope, $http, $element) { ...@@ -360,7 +360,8 @@ gargantext.controller('GraphController', function($scope, $http, $element) {
// remove a dataset // remove a dataset
$scope.removeDataset = function(datasetIndex) { $scope.removeDataset = function(datasetIndex) {
if ($scope.datasets.length > 1) { if ($scope.datasets.length > 1) {
$scope.datasets.shift(datasetIndex); $scope.datasets.splice(datasetIndex, 1);
dataset_results.splice(datasetIndex, 1);
$scope.updateDatasets(); $scope.updateDatasets();
} else { } else {
alert('You can not remove the last dataset.') alert('You can not remove the last dataset.')
......
...@@ -71,10 +71,10 @@ ...@@ -71,10 +71,10 @@
<button ng-click="removeDataset($index)">Remove dataset</button> <button ng-click="removeDataset($index)">Remove dataset</button>
<!-- description of Y values --> <!-- description of Y values -->
Evolution of the Evolution of the
<select ng-model="query_y.value" ng-options="value as key for (key, value) in {'ngrams count': 'ngrams_count', 'documents count': 'documents_count'}" ng-change="updateDataset()"></select> <select ng-model="query_y.value" ng-options="value as key for (key, value) in {'documents count': 'documents_count', 'expressions count': 'ngrams_count'}" ng-change="updateDataset()"></select>
<select ng-model="query_y.is_relative" ng-options="value as key for (key, value) in {'in absolute terms': false, 'relative to the': true}" ng-change="updateDataset()"></select> <select ng-model="query_y.is_relative" ng-options="value as key for (key, value) in {'in absolute terms': false, 'relative to the': true}" ng-change="updateDataset()"></select>
<span ng-if="query_y.is_relative"> <span ng-if="query_y.is_relative">
<select ng-model="query_y.divided_by" ng-options="value as key for (key, value) in {'total ngrams count': 'total_ngrams_count', 'total documents count': 'total_documents_count'}" ng-change="updateDataset()"></select> <select ng-model="query_y.divided_by" ng-options="value as key for (key, value) in {'total expressions count': 'total_ngrams_count', 'total documents count': 'total_documents_count'}" ng-change="updateDataset()"></select>
</span> </span>
</div> </div>
<!-- filters --> <!-- filters -->
...@@ -95,8 +95,8 @@ ...@@ -95,8 +95,8 @@
</li> </li>
<!-- filter ngrams --> <!-- filter ngrams -->
<li class="ngrams"> <li class="ngrams">
...only consider documents containing the following ngrams: ...only consider documents containing the following expressions:
<tags-input ng-model="query_y.ngrams" display-property="terms" placeholder="Add an ngram" on-tag-added="updateDataset()" on-tag-removed="updateDataset()" add-from-autocomplete-only="true"> <tags-input ng-model="query_y.ngrams" display-property="terms" placeholder="Add an expression" on-tag-added="updateDataset()" on-tag-removed="updateDataset()" add-from-autocomplete-only="true">
<auto-complete source="getNgrams($query)"></auto-complete> <auto-complete source="getNgrams($query)"></auto-complete>
</tags-input ng-model="tags"> </tags-input ng-model="tags">
</li> </li>
...@@ -104,18 +104,12 @@ ...@@ -104,18 +104,12 @@
<li> <li>
<ul> <ul>
<li ng-repeat="hyperdata in hyperdataList"> <li ng-repeat="hyperdata in hyperdataList">
...where ...where the value of
<span ng-if="!hyperdata.operator &amp;&amp; (!hyperdata.values || !hyperdata.value)">"{{ hyperdata.key }}"</span> <span ng-if="!hyperdata.operator">"{{ hyperdata.key }}"</span>
<strong ng-if="hyperdata.operator || (hyperdata.values &amp;&amp; hyperdata.value)">{{ hyperdata.key }}</strong> <strong ng-if="hyperdata.operator">{{ hyperdata.key }}</strong>
<span ng-if="hyperdata.values"> <select ng-model="hyperdata.operator" ng-options="operator.key as operator.label for operator in operators[hyperdata.type]"></select>
is <input type="text" ng-if="hyperdata.operator" ng-model="hyperdata.value" ng-change="updateDataset()" placeholder="type a value here..." />
<select ng-model="hyperdata.value" ng-options="value for value in hyperdata.values" ng-change="updateDataset()"></select>
</span>
<span ng-if="!hyperdata.values">
<select ng-model="hyperdata.operator" ng-options="operator.key as operator.label for operator in operators[hyperdata.type]"></select>
<input type="text" ng-if="hyperdata.operator" ng-model="hyperdata.value" ng-change="updateDataset()" placeholder="type a value here..." />
</span>
</li> </li>
</ul> </ul>
</li> </li>
......
Markdown is supported
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