diff options
author | emkael <emkael@tlen.pl> | 2021-01-19 13:11:14 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2021-01-19 13:11:24 +0100 |
commit | 4aa41c8ad9b41ce15cfd9a2e533f1cc2e7ed3dbf (patch) | |
tree | 0260f934a8a6a051df6c12082b7312182ddfe8f4 /result | |
parent | 5545d87ba4e7a59ef0e5d128d16b4bde9b716cbc (diff) |
Consistent axis configuration
Diffstat (limited to 'result')
-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] } } }); |