From 9016b894a1fd8b15f4dab1082ed396d59e73f956 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Sun, 27 Jul 2014 22:02:29 +0200 Subject: [PATCH] rating charts using highcharts --- app/views/user/show.scala.html | 13 ++++++++----- modules/history/src/main/HistoryApi.scala | 21 --------------------- public/javascripts/chart2.js | 16 +++++++++------- public/stylesheets/user-show.css | 12 +++--------- todo | 4 ++++ 5 files changed, 24 insertions(+), 42 deletions(-) diff --git a/app/views/user/show.scala.html b/app/views/user/show.scala.html index 6869dd6e58..c38359beeb 100644 --- a/app/views/user/show.scala.html +++ b/app/views/user/show.scala.html @@ -6,6 +6,9 @@ @highchartsTag @highchartsMoreTag @jsTagCompiled("chart2.js") +@info.ratingChart.map { ratingChart => +@embedJs(s"var lichess_rating_series = $ratingChart;") +} } @showPerf(name: String, perf: lila.rating.Perf) = { @@ -27,6 +30,10 @@ @showPerf("standard", u.perfs.standard) @showPerf("chess960", u.perfs.chess960)
+ @showPerf("bullet", u.perfs.bullet) + @showPerf("blitz", u.perfs.blitz) + @showPerf("slow", u.perfs.slow) +
@u.perfs.pools.toList.sortBy(_._1).map { case (id, perf) => { @poolSetups.get(id).map { setup => @@ -37,10 +44,6 @@ @if(u.perfs.pools.nonEmpty) {
} - @showPerf("bullet", u.perfs.bullet) - @showPerf("blitz", u.perfs.blitz) - @showPerf("slow", u.perfs.slow) -
@showPerf("puzzle", u.perfs.puzzle) } @@ -139,7 +142,7 @@ openGraph = Map(
@info.ratingChart.map { ratingChart => -
+
Chart loading…
} diff --git a/modules/history/src/main/HistoryApi.scala b/modules/history/src/main/HistoryApi.scala index 70b3839df7..5482f746e0 100644 --- a/modules/history/src/main/HistoryApi.scala +++ b/modules/history/src/main/HistoryApi.scala @@ -43,25 +43,4 @@ final class HistoryApi(coll: Coll) { def get(userId: String): Fu[Option[History]] = coll.find(BSONDocument("_id" -> userId)).one[History] - - // def set(userId: String, history: Iterable[HistoryEntry]): Funit = - // coll.insert(BSONDocument( - // "_id" -> userId, - // "e" -> BSONArray(history map write) - // )).void - - // def addEntry(userId: String, entry: HistoryEntry): Funit = - // coll.update( - // BSONDocument("_id" -> userId), - // BSONDocument("$push" -> BSONDocument("e" -> write(entry))), - // upsert = true).void - - // def create(perfs: Perfs) = coll.insert(BSONDocument( - // "_id" -> user.id, - // "e" -> BSONArray(write(HistoryEntry( - // DateTime.now, - // user.perfs.global.glicko.intRating, - // user.perfs.global.glicko.intDeviation, - // Glicko.default.intRating))) - // )).void } diff --git a/public/javascripts/chart2.js b/public/javascripts/chart2.js index 1b94cf4ce3..90b449bbe8 100644 --- a/public/javascripts/chart2.js +++ b/public/javascripts/chart2.js @@ -35,15 +35,17 @@ $(function() { title: noText, xAxis: { type: 'datetime', - labels: disabled, - lineWidth: 0, - tickWidth: 0, - gridLineWidth: 0 + labels: { + enabled: true + }, + lineWidth: 1, + tickWidth: 1, + gridLineWidth: 1 }, yAxis: { - gridLineWidth: 0, + gridLineWidth: 1, labels: { - enabled: false, + enabled: true, x: 0, style: { font: Highcharts.makeFont(10), @@ -66,7 +68,7 @@ $(function() { } } }, - series: _.map($(this).data('series'), function(serie) { + series: _.map(lichess_rating_series, function(serie) { return { name: serie.name, type: 'line', diff --git a/public/stylesheets/user-show.css b/public/stylesheets/user-show.css index 0f7eada6d8..6e2e017346 100644 --- a/public/stylesheets/user-show.css +++ b/public/stylesheets/user-show.css @@ -59,12 +59,9 @@ div.sub_ratings h3 { font-weight: bold; } div.user_show .rating_history { - position: absolute; - top: -10px; - left: -15px; - display: block; - width: 479px; - height: 350px; + margin-left: -15px; + width: 100%; + height: 250px; } div.user_show .rating_history span { position: absolute; @@ -72,9 +69,6 @@ div.user_show .rating_history span { left: 232px; } div.user_show .user-infos { - position: absolute; - top: 0; - left: 449px; padding: 0 16px; border-left: 1px solid #c0c0c0; overflow: hidden; diff --git a/todo b/todo index 41a2bd33af..453c5964bb 100644 --- a/todo +++ b/todo @@ -1 +1,5 @@ the todo list has moved to https://etherpad.mozilla.org/ep/pad/view/ro.3bIwxJwTQYW/latest + +deploy + +db.user4.dropIndex("progress_-1_enabled_1_perfs.global.nb_1")