diff --git a/server/sonar-web/src/main/js/components/charts/ColorGradientLegend.js b/server/sonar-web/src/main/js/components/charts/ColorGradientLegend.js
index <HASH>..<HASH> 100644
--- a/server/sonar-web/src/main/js/components/charts/ColorGradientLegend.js
+++ b/server/sonar-web/src/main/js/components/charts/ColorGradientLegend.js
@@ -43,13 +43,12 @@ export default function ColorGradientLegend(
     width
   } /*: Props */
 ) {
-  let colorDomain = colorScale.domain();
-  let colorRange = colorScale.range();
-  if (direction !== 1) {
-    colorDomain = colorDomain.reverse();
-    colorRange = colorRange.reverse();
+  const colorRange = colorScale.range();
+  if (direction === 1) {
+    colorRange.reverse();
   }
 
+  const colorDomain = colorScale.domain();
   const lastColorIdx = colorRange.length - 1;
   const lastDomainIdx = colorDomain.length - 1;
   const widthNoPadding = width - padding[1];
Fix wrong treemap legend for coverage measure