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