Commit 60517996 authored by Mathieu Rodic's avatar Mathieu Rodic

[FEATURE] In `templates/tests/mvc.html`, graphs are now both prettier and customizables

parent 9287a4ae
...@@ -281,6 +281,15 @@ gargantext.controller("GraphController", function($scope, $http, $element) { ...@@ -281,6 +281,15 @@ gargantext.controller("GraphController", function($scope, $http, $element) {
// initialization // initialization
$scope.datasets = [{}]; $scope.datasets = [{}];
$scope.groupingKey = 'year'; $scope.groupingKey = 'year';
$scope.options = {
stacking: false
};
$scope.seriesOptions = {
thicknessNumber: 3,
thickness: '3px',
type: 'area',
striped: false
};
$scope.graph = { $scope.graph = {
data: [], data: [],
options: { options: {
...@@ -359,14 +368,32 @@ gargantext.controller("GraphController", function($scope, $http, $element) { ...@@ -359,14 +368,32 @@ gargantext.controller("GraphController", function($scope, $http, $element) {
// Finally, update the graph // Finally, update the graph
var series = []; var series = [];
for (var i=0, n=$scope.datasets.length; i<n; i++) { for (var i=0, n=$scope.datasets.length; i<n; i++) {
series.push({ var seriesElement = {
y: 'y'+i, id: 'series_'+ i,
y: 'y'+ i,
axis: 'y', axis: 'y',
color: $scope.getColor(i, n) color: $scope.getColor(i, n)
};
angular.forEach($scope.seriesOptions, function(value, key) {
seriesElement[key] = value;
}); });
series.push(seriesElement);
} }
$scope.graph.options.series = series; $scope.graph.options.series = series;
$scope.graph.data = linearData; $scope.graph.data = linearData;
// shall we stack?
if ($scope.options.stacking) {
var stack = {
axis: 'y',
series: []
};
angular.forEach(series, function(seriesElement) {
stack.series.push(seriesElement.id);
});
$scope.graph.options.stacks = [stack];
} else {
delete $scope.graph.options.stacks;
}
}; };
// perform a query on the server // perform a query on the server
$scope.query = function() { $scope.query = function() {
...@@ -428,7 +455,9 @@ gargantext.controller("GraphController", function($scope, $http, $element) { ...@@ -428,7 +455,9 @@ gargantext.controller("GraphController", function($scope, $http, $element) {
setTimeout(function(){ setTimeout(function(){
// first dataset // first dataset
$('div.corpus select').change(); $('div.corpus select').change();
// setTimeout(function(){ $('button.add').first().click();
setTimeout(function(){
$('div.corpus select').change();
// $('div.filters button').last().click(); // $('div.filters button').last().click();
// var d = $('li.dataset').last(); // var d = $('li.dataset').last();
// d.find('select').last().val('metadata').change(); // d.find('select').last().val('metadata').change();
...@@ -448,5 +477,5 @@ setTimeout(function(){ ...@@ -448,5 +477,5 @@ setTimeout(function(){
// // d.find('input').last().val('dea').change(); // // d.find('input').last().val('dea').change();
// // refresh // // refresh
// // $('button.refresh').first().click(); // // $('button.refresh').first().click();
// }, 500); }, 500);
}, 250); }, 250);
\ No newline at end of file
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<!-- {% load staticfiles %} --> <!-- {% load staticfiles %} -->
<link rel="stylesheet" href="{% static "css/bootstrap.css" %}"> <link rel="stylesheet" href="{% static "css/bootstrap.css" %}">
<link rel="stylesheet" href="{% static "css/bootstrap-theme.min.css" %}"> <link rel="stylesheet" href="{% static "css/bootstrap-theme.min.css" %}">
<title>GarganText: Analyze your data with graphs</title>
{% endblock %} {% endblock %}
...@@ -121,6 +122,7 @@ ...@@ -121,6 +122,7 @@
--> -->
<style type="text/css"> <style type="text/css">
div.corpus button:first-child+select {color:#FFF;}
div.list-results table {border-collapse: collapse;} div.list-results table {border-collapse: collapse;}
div.list-results th, div.list-results td {border: solid 1px #888; padding: 0.5em;} div.list-results th, div.list-results td {border: solid 1px #888; padding: 0.5em;}
div.list-results th {background: #444; color: #FFF} div.list-results th {background: #444; color: #FFF}
...@@ -266,7 +268,7 @@ ...@@ -266,7 +268,7 @@
</div> </div>
<div class="graph-parameters"> <div class="graph-parameters">
X-axis: groups the results by X-axis: groups the results by
<select ng-model="groupingKey" ng-options="key for key in ['day', 'month', 'year', 'decade', 'century']" ng-change="showResults()"> <select ng-model="groupingKey" ng-options="key for key in ['day', 'month', 'year', 'decade', 'century']" ng-change="query()">
</select> </select>
<br/> <br/>
...@@ -275,6 +277,22 @@ ...@@ -275,6 +277,22 @@
scale scale
<br/> <br/>
<hr/>
Represent data with
<select ng-model="seriesOptions.type" ng-options="type for type in ['line', 'area', 'column']" ng-change="query()"></select>
<span ng-show="seriesOptions.type == 'area'">
(<select ng-model="seriesOptions.striped" ng-options="value as key for (key, value) in {'with':true, 'without':false}" ng-change="query()"></select> stripes)
</span>
<span ng-show="seriesOptions.type == 'area' || seriesOptions.type == 'column'">
(<select ng-model="options.stacking" ng-options="value as key for (key, value) in {'with':true, 'without':false}" ng-change="query()"></select> stacking)
</span>
<br/>
<span ng-hide="seriesOptions.type == 'column'">
Line thickness:
<input ng-model="seriesOptions.thicknessNumber" type="range" min="1" max="8" ng-change="seriesOptions.thickness = seriesOptions.thicknessNumber + 'px'; query()" />
<br/>
Interpolation: Interpolation:
<select ng-model="graph.options.lineMode"> <select ng-model="graph.options.lineMode">
<option ng-repeat="mode in ['bundle', 'linear']" value="{{ mode }}">{{ mode }}</option> <option ng-repeat="mode in ['bundle', 'linear']" value="{{ mode }}">{{ mode }}</option>
...@@ -284,6 +302,7 @@ ...@@ -284,6 +302,7 @@
<input type="text" disabled="disabled" ng-model="graph.options.tension" /> <input type="text" disabled="disabled" ng-model="graph.options.tension" />
<input type="range" min="0" max="2" step=".1" ng-model="graph.options.tension" /> <input type="range" min="0" max="2" step=".1" ng-model="graph.options.tension" />
</span> </span>
</span>
</div> </div>
</div> </div>
......
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