Skip to content

Commit

Permalink
better definition of custom ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
mhkeller committed Mar 20, 2019
1 parent ac6931f commit 7bd8bb4
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/layercake.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,11 @@ export default class LayerCakeStore extends Store {
if (domains === null) {
return null;
}
// TODO, DRYer and more explicit version of what ranges are defined as, including fallbacks
const defaultRanges = {
x: settings.reverseX ? [width, 0] : [0, width],
y: settings.reverseY ? [height, 0] : [0, height],
r: [1, 25]
x: settings.reverseX ? [width, 0] : typeof settings.xRange === 'function' ? settings.xRange({ width, height }) : [0, width],
y: settings.reverseY ? [height, 0] : typeof settings.yRange === 'function' ? settings.yRange({ width, height }) : [0, height],
r: !settings.rRange ? [1, 25] : typeof settings.rRange === 'function' ? settings.rRange({ width, height }) : settings.rRange
};
const scale = settings[thisScale] ? settings[thisScale].copy() : defaultScales[s]();
scale
Expand All @@ -214,10 +215,6 @@ export default class LayerCakeStore extends Store {
}
}

if (settings.rRange) {
scale.range(settings.rRange);
}

return scale;
});

Expand Down

0 comments on commit 7bd8bb4

Please sign in to comment.