Skip to content

Commit

Permalink
Tunning
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Sep 13, 2017
1 parent 2feaa42 commit 2774a5d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
6 changes: 4 additions & 2 deletions superset/assets/javascripts/explore/stores/controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,16 @@ export const controls = {
type: 'SelectControl',
label: 'Sort X Axis',
choices: sortAxisChoices,
default: 'stack',
clearable: false,
default: 'alpha_asc',
},

sort_y_axis: {
type: 'SelectControl',
label: 'Sort Y Axis',
choices: sortAxisChoices,
default: 'stack',
clearable: false,
default: 'alpha_asc',
},

linear_color_scheme: {
Expand Down
5 changes: 5 additions & 0 deletions superset/assets/javascripts/explore/stores/visTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,11 @@ export const visTypes = {
y_axis_bounds: {
label: 'Value bounds',
renderTrigger: false,
description: (
'Hard value bounds applied for color coding. Is only relevant ' +
'and applied when the normalization is applied against the whole ' +
'heatmap.'
),
},
y_axis_format: {
label: 'Value Format',
Expand Down
8 changes: 6 additions & 2 deletions superset/assets/visualizations/heatmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@ function heatmapVis(slice, payload) {
domain = Object.keys(domain).sort();
} else if (sortMethod === 'alpha_desc') {
domain = Object.keys(domain).sort().reverse();
} else if (sortMethod === 'value_asc') {
domain = Object.keys(domain).sort((d1, d2) => domain[d1] - domain[d2]);
} else if (sortMethod === 'value_desc') {
domain = Object.keys(domain).sort((d1, d2) => domain[d2] - domain[d1]);
} else if (sortMethod === 'value_asc') {
domain = Object.keys(domain).sort((d1, d2) => domain[d1] - domain[d2]);
}

if (k === 'y' && rangeBands) {
domain.reverse();
}

if (rangeBands) {
Expand Down
19 changes: 8 additions & 11 deletions superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,13 @@ def get_data(self, df):
df.columns = ['x', 'y', 'v']
norm = fd.get('normalize_across')
overall = False
max_ = df.v.max()
min_ = df.v.min()
bounds = fd.get('y_axis_bounds')
if bounds and bounds[0]:
min_ = bounds[0]
if bounds and bounds[1]:
max_ = bounds[1]
if norm == 'heatmap':
overall = True
else:
Expand All @@ -1486,18 +1493,8 @@ def get_data(self, df):
gb.apply(
lambda x: (x.v - x.v.min()) / (x.v.max() - x.v.min()))
)
bounds = fd.get('y_axis_bounds')
if overall:
v = df.v
if bounds and bounds[0]:
min_ = bounds[0]
else:
min_ = v.min()
if bounds and bounds[1]:
max_ = bounds[1]
else:
max_ = v.max()
df['perc'] = (v - min_) / (max_ - min_)
df['perc'] = (df.v - min_) / (max_ - min_)
return {
'records': df.to_dict(orient="records"),
'extents': [min_, max_],
Expand Down

0 comments on commit 2774a5d

Please sign in to comment.