From c805bcf8b55565cb2cfb84112a5b0593a5771af7 Mon Sep 17 00:00:00 2001 From: martintomas Date: Wed, 6 Dec 2023 11:40:59 +0100 Subject: [PATCH] refactoring: ASCOR benchmark chart Y axis always starts at 0 --- app/javascript/components/tpi/AscorRecentEmissions.js | 2 +- app/javascript/components/tpi/charts/ascor-benchmarks/Chart.js | 1 + app/services/api/ascor/benchmarks_chart.rb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/javascript/components/tpi/AscorRecentEmissions.js b/app/javascript/components/tpi/AscorRecentEmissions.js index bf608bbc1..036800076 100644 --- a/app/javascript/components/tpi/AscorRecentEmissions.js +++ b/app/javascript/components/tpi/AscorRecentEmissions.js @@ -112,7 +112,7 @@ AscorRecentEmissions.propTypes = { default_trend_filter: PropTypes.string.isRequired, data: PropTypes.arrayOf( PropTypes.shape({ - value: PropTypes.number, + value: PropTypes.string, source: PropTypes.string, year: PropTypes.number, unit: PropTypes.string.isRequired, diff --git a/app/javascript/components/tpi/charts/ascor-benchmarks/Chart.js b/app/javascript/components/tpi/charts/ascor-benchmarks/Chart.js index 7cb0c4bc3..287fddf34 100644 --- a/app/javascript/components/tpi/charts/ascor-benchmarks/Chart.js +++ b/app/javascript/components/tpi/charts/ascor-benchmarks/Chart.js @@ -54,6 +54,7 @@ const Chart = ({ data: { data, metadata } }) => { ...options, yAxis: { ...options.yAxis, + min: 0, title: { ...options.yAxis.title, text: metadata.unit } }, series: chartData diff --git a/app/services/api/ascor/benchmarks_chart.rb b/app/services/api/ascor/benchmarks_chart.rb index 972eaa456..2d63c59c0 100644 --- a/app/services/api/ascor/benchmarks_chart.rb +++ b/app/services/api/ascor/benchmarks_chart.rb @@ -38,7 +38,7 @@ def pathway end def benchmarks - @benchmarks ||= ::ASCOR::Benchmark.where(country_id: country_id) + @benchmarks ||= ::ASCOR::Benchmark.where(country_id: country_id).sort_by(&:benchmark_type).reverse end end end