diff options
-rw-r--r-- | result/krafcik.js | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/result/krafcik.js b/result/krafcik.js index a65a73b..cdb0b9e 100644 --- a/result/krafcik.js +++ b/result/krafcik.js @@ -186,7 +186,7 @@ $(document).ready(function() { } }); var positionY = this._chart.canvas.offsetTop; - var positionX = this._chart.canvas.offsetLeft + var positionX = this._chart.canvas.offsetLeft; container.html(content).show(); container.css({ 'top': Math.min( @@ -207,6 +207,27 @@ $(document).ready(function() { }); } }); + var ratingAxis = { + type: 'logarithmic', + ticks: { + min: 15, + max: Math.ceil(Math.max.apply(null, beers.map(b => b.ratings)) / 1000) * 1000, + callback: value => value.toLocaleString() + } + }; + var averageAxis = { + ticks: { + min: Math.floor(Math.min.apply(null, beers.map(b => b.average)) * 2) * 0.5, + max: 5 + } + }; + var abvAxis = { + ticks: { + beginAtZero: true, + min: 0, + max: Math.ceil(Math.max.apply(null, beers.map(b => b.abv)) * 2) * 0.5 + } + }; var abvRatingsChart; $('a#abv-ratings-tab').on('shown.bs.tab', function() { if (!abvRatingsChart) { @@ -215,9 +236,8 @@ $(document).ready(function() { data: scatterChartData[0], options: { scales: { - yAxes: [{ - type: 'logarithmic', - }] + xAxes: [abvAxis], + yAxes: [ratingAxis] } } @@ -229,7 +249,13 @@ $(document).ready(function() { if (!abvAverageChart) { var ctx = $('#abv-average-chart')[0].getContext('2d'); abvAverageChart = new Chart.Scatter(ctx, { - data: scatterChartData[1] + data: scatterChartData[1], + options: { + scales: { + xAxis: [abvAxis], + yAxes: [averageAxis] + } + } }); } }); @@ -241,9 +267,8 @@ $(document).ready(function() { data: scatterChartData[2], options: { scales: { - xAxes: [{ - type: 'logarithmic', - }] + xAxes: [ratingAxis], + yAxes: [averageAxis] } } }); |