mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Fixes issue #6679, which referred to the EXP chart getting cropped.
This commit is contained in:
committed by
Blade Barringer
parent
28bb543397
commit
7f5d070ee6
@@ -705,3 +705,7 @@ form
|
|||||||
background-color:inherit !important
|
background-color:inherit !important
|
||||||
.task-checker label:hover:after
|
.task-checker label:hover:after
|
||||||
content: ''
|
content: ''
|
||||||
|
|
||||||
|
// Add padding to exp-chart
|
||||||
|
.exp-chart
|
||||||
|
padding-bottom: 10px
|
||||||
|
|||||||
@@ -186,8 +186,9 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
|||||||
}
|
}
|
||||||
|
|
||||||
$rootScope.charts = {};
|
$rootScope.charts = {};
|
||||||
|
$rootScope.resizeCharts = {};
|
||||||
$rootScope.toggleChart = function(id, task) {
|
$rootScope.toggleChart = function(id, task) {
|
||||||
var history = [], matrix, data, chart, options;
|
var history = [], matrix, data, options, container;
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 'exp':
|
case 'exp':
|
||||||
history = User.user.history.exp;
|
history = User.user.history.exp;
|
||||||
@@ -202,23 +203,70 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
|||||||
$rootScope.charts[id] = (history.length == 0) ? false : !$rootScope.charts[id];
|
$rootScope.charts[id] = (history.length == 0) ? false : !$rootScope.charts[id];
|
||||||
if (task && task._editing) task._editing = false;
|
if (task && task._editing) task._editing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($rootScope.charts[id]) {
|
||||||
|
var handleResize = _.debounce(function() {
|
||||||
|
drawChart(id, data);
|
||||||
|
}, 300);
|
||||||
|
|
||||||
|
$rootScope.resizeCharts[id] = $rootScope.resizeCharts[id] || _.once(function() { $(window).resize(handleResize) });
|
||||||
|
$rootScope.resizeCharts[id]();
|
||||||
|
}
|
||||||
|
|
||||||
matrix = [[env.t('date'), env.t('score')]];
|
matrix = [[env.t('date'), env.t('score')]];
|
||||||
_.each(history, function(obj) {
|
_.each(history, function(obj) {
|
||||||
matrix.push([moment(obj.date).format(User.user.preferences.dateFormat.toUpperCase().replace('YYYY','YY') ), obj.value]);
|
matrix.push([moment(obj.date).format(User.user.preferences.dateFormat.toUpperCase().replace('YYYY','YY') ), obj.value]);
|
||||||
});
|
});
|
||||||
data = google.visualization.arrayToDataTable(matrix);
|
data = google.visualization.arrayToDataTable(matrix);
|
||||||
|
|
||||||
|
drawChart(id, data);
|
||||||
|
};
|
||||||
|
|
||||||
|
function drawChart(id, data, options) {
|
||||||
|
var chart, width;
|
||||||
|
|
||||||
|
if(id === "exp") {
|
||||||
|
width = $(".row").width() - 20;
|
||||||
|
} else if(id === "todos") {
|
||||||
|
width = $(".task-column.todos").width();
|
||||||
|
} else {
|
||||||
|
width = $(".task-text").width() - 15;
|
||||||
|
}
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
title: window.env.t('history'),
|
title: window.env.t('history'),
|
||||||
backgroundColor: {
|
backgroundColor: {
|
||||||
fill: 'transparent'
|
fill: 'transparent'
|
||||||
},
|
},
|
||||||
hAxis: {slantedText:true, slantedTextAngle: 90},
|
hAxis: {
|
||||||
height:270,
|
slantedText: true,
|
||||||
width:300
|
slantedTextAngle: 90,
|
||||||
|
textStyle: {
|
||||||
|
fontSize: 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
vAxis: {
|
||||||
|
format: 'short',
|
||||||
|
textStyle: {
|
||||||
|
fontSize: 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
width: width,
|
||||||
|
height: 270,
|
||||||
|
chartArea: {
|
||||||
|
left: 50,
|
||||||
|
top: 30,
|
||||||
|
right: 20,
|
||||||
|
bottom: 65
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
position: 'none'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
chart = new google.visualization.LineChart($("." + id + "-chart")[0]);
|
chart = new google.visualization.LineChart($("." + id + "-chart")[0]);
|
||||||
chart.draw(data, options);
|
chart.draw(data, options);
|
||||||
};
|
}
|
||||||
|
|
||||||
$rootScope.getGearArray = function(set){
|
$rootScope.getGearArray = function(set){
|
||||||
var flatGearArray = _.toArray(Content.gear.flat);
|
var flatGearArray = _.toArray(Content.gear.flat);
|
||||||
|
|||||||
@@ -40,6 +40,8 @@
|
|||||||
.task-text(ng-dblclick='doubleClickTask(obj, task)')
|
.task-text(ng-dblclick='doubleClickTask(obj, task)')
|
||||||
markdown(text='task._editing ? task._edit.text : task.text',target='_blank')
|
markdown(text='task._editing ? task._edit.text : task.text',target='_blank')
|
||||||
|
|
||||||
|
div(class='{{obj._id}}{{task.id}}-chart', ng-show='charts[obj._id+task.id]')
|
||||||
|
|
||||||
div(ng-if='task.checklist && !$state.includes("options.social.challenges") && !task.collapseChecklist && !task._editing')
|
div(ng-if='task.checklist && !$state.includes("options.social.challenges") && !task.collapseChecklist && !task._editing')
|
||||||
fieldset.option-group.task-checklist
|
fieldset.option-group.task-checklist
|
||||||
label.checkbox(ng-repeat='item in task.checklist')
|
label.checkbox(ng-repeat='item in task.checklist')
|
||||||
|
|||||||
Reference in New Issue
Block a user