mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-04 09:39:23 +00:00
Add user-experience chart (need to put it in a modal or popover or something)
This commit is contained in:
parent
626b44bc66
commit
97478120ff
2 changed files with 31 additions and 2 deletions
|
|
@ -117,6 +117,13 @@ ready (model) ->
|
|||
task.set('completed', false) if type == 'daily'
|
||||
model.push '_user.history.todos', { date: new Date(), value: todoTally }
|
||||
|
||||
# tally experience
|
||||
expTally = user.get 'exp'
|
||||
_(user.get('lvl')-1).times ->
|
||||
expTally += 50 * Math.pow(lvl, 2) - 150 * lvl + 200
|
||||
model.push '_user.history.exp', { date: new Date(), value: expTally }
|
||||
|
||||
|
||||
#TODO: remove when cron implemented
|
||||
poormanscron = ->
|
||||
lastCron = model.get('_user.lastCron')
|
||||
|
|
@ -306,6 +313,24 @@ ready (model) ->
|
|||
chart = new google.visualization.LineChart(document.getElementById( 'todos-chart' ))
|
||||
chart.draw(data, options)
|
||||
|
||||
exports.toggleExpChart = (e, el) ->
|
||||
$('#exp-chart').toggle()
|
||||
|
||||
matrix = [['Date', 'Score']]
|
||||
for obj in model.get('_user.history.exp')
|
||||
date = new Date(obj.date)
|
||||
readableDate = "#{date.getMonth()}/#{date.getDate()}/#{date.getFullYear()}"
|
||||
matrix.push [ readableDate, obj.value ]
|
||||
data = google.visualization.arrayToDataTable matrix
|
||||
|
||||
options = {
|
||||
title: 'History'
|
||||
backgroundColor: 'whiteSmoke'
|
||||
}
|
||||
|
||||
chart = new google.visualization.LineChart(document.getElementById( 'exp-chart' ))
|
||||
chart.draw(data, options)
|
||||
|
||||
exports.vote = (e, el, next) ->
|
||||
direction = $(el).attr('data-direction')
|
||||
direction = 'up' if direction == 'true/'
|
||||
|
|
|
|||
|
|
@ -18,12 +18,16 @@
|
|||
</div>
|
||||
|
||||
<div class="progress progress-warning">
|
||||
<span class="progress-text">Exp: {round(_user.exp)} / {_tnl}</span>
|
||||
<span class="progress-text"><a x-bind=click:toggleExpChart><i class=icon-signal></i></a> Exp: {round(_user.exp)} / {_tnl}</span>
|
||||
<div class="bar" style="width: {percent(_user.exp,_tnl)}%;"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<div id="exp-chart" style="display:none;height:95px;width:300px;"></div>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
<!--<% else %>
|
||||
|
|
|
|||
Loading…
Reference in a new issue