Skip to content

Commit

Permalink
add range store values to match domain values, fix svgSsr layout
Browse files Browse the repository at this point in the history
  • Loading branch information
mhkeller committed Apr 8, 2020
1 parent 734e449 commit bd18a5a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Expand Up @@ -33,6 +33,7 @@
"import/no-extraneous-dependencies": ["error", {"devDependencies": true}],
"no-underscore-dangle": 0,
"camelcase": 0,
"max-len": 0
"max-len": 0,
"no-console": 0
}
}
10 changes: 10 additions & 0 deletions src/LayerCake.svelte
Expand Up @@ -7,6 +7,7 @@
import calcDomain from './helpers/calcDomain.js';
import createScale from './helpers/createScale.js';
import createGetter from './helpers/createGetter.js';
import getRange from './helpers/getRange.js';
import defaultScales from './settings/defaultScales.js';
import defaultReverses from './settings/defaultReverses.js';
Expand Down Expand Up @@ -221,6 +222,11 @@
const rScale_d = derived([_rScale, extents_d, rDomain_d, _rPadding, _rNice, _rReverse, width_d, height_d, _rRange], createScale('r'));
const rGet_d = derived([_r, rScale_d], createGetter);
const xRange_d = derived([xScale_d], getRange);
const yRange_d = derived([yScale_d], getRange);
const zRange_d = derived([zScale_d], getRange);
const rRange_d = derived([rScale_d], getRange);
$: context = {
activeGetters: activeGetters_d,
width: width_d,
Expand Down Expand Up @@ -252,6 +258,10 @@
yDomain: yDomain_d,
zDomain: zDomain_d,
rDomain: rDomain_d,
xRange: xRange_d,
yRange: yRange_d,
zRange: zRange_d,
rRange: rRange_d,
originalSettings: _originalSettings, // Keep this for legacy compatibility
config: _originalSettings,
xScale: xScale_d,
Expand Down
6 changes: 2 additions & 4 deletions src/Layouts/SvgSsr.svelte
Expand Up @@ -12,11 +12,9 @@
<svg
viewBox="0 0 100 100"
preserveAspectRatio="none"
style="top: {$padding.top}px; right:0px; bottom:0px; left:{$padding.left}px;width:calc(100% - {($padding.left + $padding.right)}px);height:calc(100% - {($padding.top + $padding.bottom)}px);'{zIndexStyle}"
style="top: {$padding.top}px; right:0px; bottom:0px; left:{$padding.left}px;width:calc(100% - {($padding.left + $padding.right)}px);height:calc(100% - {($padding.top + $padding.bottom)}px);{zIndexStyle}"
>
<g transform="translate({$padding.left}px, {$padding.top}px)">
<slot></slot>
</g>
<slot></slot>
</svg>

<style>
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/createScale.js
Expand Up @@ -29,7 +29,7 @@ export default function createScale (s) {
if (typeof scale.nice === 'function') {
scale.nice();
} else {
console.error(`Layer Cake warning: You set \`${s}Nice: true\` but the ${s}Scale does not have a \`.nice\` method. Ignoring...`);
console.error(`[Layer Cake] You set \`${s}Nice: true\` but the ${s}Scale does not have a \`.nice\` method. Ignoring...`);
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/helpers/getRange.js
@@ -0,0 +1,9 @@
export default function getRange([$scale]) {
if (typeof $scale === 'function') {
if (typeof $scale.range === 'function') {
return $scale.range();
}
console.error('[LayerCake] Your scale doesn\'t have a `.range` method?');
}
return null;
}

0 comments on commit bd18a5a

Please sign in to comment.