Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id CDF7A200D14 for ; Tue, 19 Sep 2017 06:32:44 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id CC8191609DE; Tue, 19 Sep 2017 04:32:44 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 1DE8F1609DB for ; Tue, 19 Sep 2017 06:32:43 +0200 (CEST) Received: (qmail 5093 invoked by uid 500); 19 Sep 2017 04:32:43 -0000 Mailing-List: contact commits-help@superset.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@superset.incubator.apache.org Delivered-To: mailing list commits@superset.incubator.apache.org Received: (qmail 5084 invoked by uid 99); 19 Sep 2017 04:32:43 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Sep 2017 04:32:43 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 8810A8184F; Tue, 19 Sep 2017 04:32:41 +0000 (UTC) Date: Tue, 19 Sep 2017 04:32:41 +0000 To: "commits@superset.apache.org" Subject: [incubator-superset] branch master updated: [heatmap] account for bounds = 0 (#3474) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <150579556100.8587.13290985283039648132@gitbox.apache.org> From: maximebeauchemin@apache.org Reply-To: "commits@superset.apache.org" X-Git-Host: gitbox.apache.org X-Git-Repo: incubator-superset X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: ede143293622fea1a87e9778d350dc37a800ea17 X-Git-Newrev: c5252d0f43621999030d3dcf3d2e8bfee5452510 X-Git-Rev: c5252d0f43621999030d3dcf3d2e8bfee5452510 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated archived-at: Tue, 19 Sep 2017 04:32:45 -0000 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 c5252d0 [heatmap] account for bounds = 0 (#3474) c5252d0 is described below commit c5252d0f43621999030d3dcf3d2e8bfee5452510 Author: Maxime Beauchemin AuthorDate: Mon Sep 18 21:32:39 2017 -0700 [heatmap] account for bounds = 0 (#3474) * [heatmap] account for bounds = 0 * Fix sorting * linting --- .../assets/javascripts/explore/stores/controls.jsx | 8 ++++---- superset/assets/visualizations/heatmap.js | 18 +++++++++++++----- superset/viz.py | 4 ++-- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/superset/assets/javascripts/explore/stores/controls.jsx b/superset/assets/javascripts/explore/stores/controls.jsx index b87e988..c226f66 100644 --- a/superset/assets/javascripts/explore/stores/controls.jsx +++ b/superset/assets/javascripts/explore/stores/controls.jsx @@ -37,10 +37,10 @@ const timeColumnOption = { 'account'), }; const sortAxisChoices = [ - ['alpha_asc', 'Alphabetical ascending'], - ['alpha_desc', 'Alphabetical descending'], - ['value_asc', 'Value ascending'], - ['value_desc', 'Value descending'], + ['alpha_asc', 'Axis ascending'], + ['alpha_desc', 'Axis descending'], + ['value_asc', 'sum(value) ascending'], + ['value_desc', 'sum(value) descending'], ]; const groupByControl = { diff --git a/superset/assets/visualizations/heatmap.js b/superset/assets/visualizations/heatmap.js index 1f76a3a..002af8a 100644 --- a/superset/assets/visualizations/heatmap.js +++ b/superset/assets/visualizations/heatmap.js @@ -7,6 +7,10 @@ import { colorScalerFactory } from '../javascripts/modules/colors'; import '../stylesheets/d3tip.css'; import './heatmap.css'; +function cmp(a, b) { + return a > b ? 1 : -1; +} + // Inspired from http://bl.ocks.org/mbostock/3074470 // https://jsfiddle.net/cyril123/h0reyumq/ function heatmapVis(slice, payload) { @@ -52,17 +56,21 @@ function heatmapVis(slice, payload) { function ordScale(k, rangeBands, sortMethod) { let domain = {}; + const actualKeys = {}; // hack to preserve type of keys when number data.forEach((d) => { - domain[d[k]] = domain[d[k]] || 0 + d.v; + domain[d[k]] = (domain[d[k]] || 0) + d.v; + actualKeys[d[k]] = d[k]; }); + // Not usgin object.keys() as it converts to strings + const keys = Object.keys(actualKeys).map(s => actualKeys[s]); if (sortMethod === 'alpha_asc') { - domain = Object.keys(domain).sort(); + domain = keys.sort(cmp); } else if (sortMethod === 'alpha_desc') { - domain = Object.keys(domain).sort().reverse(); + domain = keys.sort(cmp).reverse(); } else if (sortMethod === 'value_desc') { - domain = Object.keys(domain).sort((d1, d2) => domain[d2] - domain[d1]); + domain = Object.keys(domain).sort((a, b) => domain[a] > domain[b] ? -1 : 1); } else if (sortMethod === 'value_asc') { - domain = Object.keys(domain).sort((d1, d2) => domain[d1] - domain[d2]); + domain = Object.keys(domain).sort((a, b) => domain[b] > domain[a] ? -1 : 1); } if (k === 'y' && rangeBands) { diff --git a/superset/viz.py b/superset/viz.py index 1f844ed..b22af08 100644 --- a/superset/viz.py +++ b/superset/viz.py @@ -1484,9 +1484,9 @@ class HeatmapViz(BaseViz): max_ = df.v.max() min_ = df.v.min() bounds = fd.get('y_axis_bounds') - if bounds and bounds[0]: + if bounds and bounds[0] is not None: min_ = bounds[0] - if bounds and bounds[1]: + if bounds and bounds[1] is not None: max_ = bounds[1] if norm == 'heatmap': overall = True -- To stop receiving notification emails like this one, please contact ['"commits@superset.apache.org" '].