mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
charts: port toggleChart back in (functional, but it's not getting the
right width)
This commit is contained in:
@@ -61,5 +61,37 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$rootScope.charts = {};
|
||||
$rootScope.toggleChart = function(id, task) {
|
||||
var history = [], matrix, data, chart, options;
|
||||
switch (id) {
|
||||
case 'exp':
|
||||
$rootScope.charts.exp = !$rootScope.charts.exp;
|
||||
history = User.user.history.exp;
|
||||
break;
|
||||
case 'todos':
|
||||
$rootScope.charts.todos = !$rootScope.charts.todos;
|
||||
history = User.user.history.todos;
|
||||
break;
|
||||
default:
|
||||
$rootScope.charts[id] = !$rootScope.charts[id];
|
||||
history = task.history;
|
||||
if (task) task._editing = false;
|
||||
}
|
||||
matrix = [['Date', 'Score']];
|
||||
_.each(history, function(obj) {
|
||||
matrix.push([moment(obj.date).format('MM/DD/YY'), obj.value]);
|
||||
});
|
||||
data = google.visualization.arrayToDataTable(matrix);
|
||||
options = {
|
||||
title: 'History',
|
||||
backgroundColor: {
|
||||
fill: 'transparent'
|
||||
}
|
||||
};
|
||||
chart = new google.visualization.LineChart($("." + id + "-chart")[0]);
|
||||
chart.draw(data, options);
|
||||
};
|
||||
}
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user