superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maximebeauche...@apache.org
Subject [incubator-superset] branch master updated: Fix off-by-one error with linear color scales (#3452)
Date Tue, 12 Sep 2017 16:05:29 GMT
This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 90e46cb  Fix off-by-one error with linear color scales (#3452)
90e46cb is described below

commit 90e46cb39c4ab5712240c2231382952f36d39c35
Author: Maxime Beauchemin <maximebeauchemin@gmail.com>
AuthorDate: Tue Sep 12 09:05:26 2017 -0700

    Fix off-by-one error with linear color scales (#3452)
    
    * Fix off-by-one error with linear color scales
    
    * linting
---
 superset/assets/javascripts/explore/stores/controls.jsx | 1 +
 superset/assets/javascripts/modules/colors.js           | 8 ++------
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/superset/assets/javascripts/explore/stores/controls.jsx b/superset/assets/javascripts/explore/stores/controls.jsx
index 9cce394..f2d68a4 100644
--- a/superset/assets/javascripts/explore/stores/controls.jsx
+++ b/superset/assets/javascripts/explore/stores/controls.jsx
@@ -166,6 +166,7 @@ export const controls = {
       ['black_white', 'black/white'],
     ],
     default: 'blue_white_yellow',
+    clearable: false,
     description: '',
     renderTrigger: true,
     schemes: spectrums,
diff --git a/superset/assets/javascripts/modules/colors.js b/superset/assets/javascripts/modules/colors.js
index 9897e4c..8594e17 100644
--- a/superset/assets/javascripts/modules/colors.js
+++ b/superset/assets/javascripts/modules/colors.js
@@ -1,4 +1,3 @@
-import $ from 'jquery';
 import d3 from 'd3';
 
 // Color related utility functions go in this object
@@ -127,10 +126,7 @@ export const colorScalerFactory = function (colors, data, accessor) {
   if (data !== undefined) {
     ext = d3.extent(data, accessor);
   }
-  const points = [];
-  const chunkSize = (ext[1] - ext[0]) / colors.length;
-  $.each(colors, function (i) {
-    points.push(i * chunkSize);
-  });
+  const chunkSize = (ext[1] - ext[0]) / (colors.length - 1);
+  const points = colors.map((col, i) => i * chunkSize);
   return d3.scale.linear().domain(points).range(colors);
 };

-- 
To stop receiving notification emails like this one, please contact
['"commits@superset.apache.org" <commits@superset.apache.org>'].

Mime
View raw message