layerchart 0.36.1 → 0.36.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -33,6 +33,7 @@ $: getDimensions = createDimensionGetter(getContext('LayerCake'), {
|
|
|
33
33
|
outer: groupPaddingOuter,
|
|
34
34
|
},
|
|
35
35
|
});
|
|
36
|
+
$: dimensions = $getDimensions(bar);
|
|
36
37
|
</script>
|
|
37
38
|
|
|
38
39
|
<Rect
|
|
@@ -42,7 +43,7 @@ $: getDimensions = createDimensionGetter(getContext('LayerCake'), {
|
|
|
42
43
|
{stroke}
|
|
43
44
|
stroke-width={strokeWidth}
|
|
44
45
|
rx={radius}
|
|
45
|
-
{
|
|
46
|
+
{...dimensions}
|
|
46
47
|
{...$$restProps}
|
|
47
48
|
on:click
|
|
48
49
|
/>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { scaleCanvas } from 'layercake';
|
|
3
3
|
import { geoContext } from './GeoContext.svelte';
|
|
4
4
|
import Circle from './Circle.svelte';
|
|
5
|
+
import Group from './Group.svelte';
|
|
5
6
|
/** Latitude */
|
|
6
7
|
export let lat;
|
|
7
8
|
/** Longitude */
|
|
@@ -27,9 +28,9 @@ $: if (renderContext === 'canvas' && $ctx) {
|
|
|
27
28
|
|
|
28
29
|
{#if renderContext === 'svg'}
|
|
29
30
|
{#if $$slots.default}
|
|
30
|
-
<
|
|
31
|
+
<Group {x} {y} {...$$restProps}>
|
|
31
32
|
<slot />
|
|
32
|
-
</
|
|
33
|
+
</Group>
|
|
33
34
|
{:else}
|
|
34
35
|
<Circle cx={x} cy={y} {...$$restProps} />
|
|
35
36
|
{/if}
|
|
@@ -147,7 +147,7 @@ else {
|
|
|
147
147
|
x={xScale(tick) + tickLabelOffset}
|
|
148
148
|
y={height + tickLength + tickFontSize}
|
|
149
149
|
style:font-size={tickFontSize}
|
|
150
|
-
class={cls('fill-surface-content', classes.label)}
|
|
150
|
+
class={cls('fill-surface-content text-[10px]', classes.label)}
|
|
151
151
|
>
|
|
152
152
|
{tickFormat ? format(tick, tickFormat) : tick}
|
|
153
153
|
</text>
|
package/dist/utils/rect.js
CHANGED
|
@@ -3,10 +3,13 @@ import { max, min } from 'd3-array';
|
|
|
3
3
|
import { groupScaleBand, isScaleBand } from './scales.js';
|
|
4
4
|
// TOOD: Pass in overrides for `x` and `y` accessors
|
|
5
5
|
export function createDimensionGetter(context, options) {
|
|
6
|
-
const { flatData, xGet, yGet,
|
|
6
|
+
const { flatData, xGet, yGet, xScale, yScale, x: xAccessor, y: yAccessor } = context;
|
|
7
7
|
const groupBy = options?.groupBy;
|
|
8
8
|
const inset = options?.inset ?? 0;
|
|
9
|
-
return derived([flatData, xGet, yGet,
|
|
9
|
+
return derived([flatData, xGet, yGet, xScale, yScale, xAccessor, yAccessor], ([$flatData, $xGet, $yGet, $xScale, $yScale, $xAccessor, $yAccessor]) => {
|
|
10
|
+
// Use `xscale.domain()` instead of `$xDomain` to include `nice()` being applied
|
|
11
|
+
const [minXDomain, maxXDomain] = $xScale.domain();
|
|
12
|
+
const [minYDomain, maxYDomain] = $yScale.domain();
|
|
10
13
|
return function getter(item) {
|
|
11
14
|
if (isScaleBand($yScale)) {
|
|
12
15
|
// Horizontal band
|
|
@@ -35,13 +38,13 @@ export function createDimensionGetter(context, options) {
|
|
|
35
38
|
}
|
|
36
39
|
else if (xValue > 0) {
|
|
37
40
|
// Positive value
|
|
38
|
-
left =
|
|
41
|
+
left = max([0, minXDomain]);
|
|
39
42
|
right = xValue;
|
|
40
43
|
}
|
|
41
44
|
else {
|
|
42
45
|
// Negative value
|
|
43
46
|
left = xValue;
|
|
44
|
-
right = min(
|
|
47
|
+
right = min([0, maxXDomain]);
|
|
45
48
|
}
|
|
46
49
|
return {
|
|
47
50
|
x: $xScale(left),
|
|
@@ -78,11 +81,11 @@ export function createDimensionGetter(context, options) {
|
|
|
78
81
|
else if (yValue > 0) {
|
|
79
82
|
// Positive value
|
|
80
83
|
top = yValue;
|
|
81
|
-
bottom =
|
|
84
|
+
bottom = max([0, minYDomain]);
|
|
82
85
|
}
|
|
83
86
|
else {
|
|
84
87
|
// Negative value
|
|
85
|
-
top = min(
|
|
88
|
+
top = min([0, maxYDomain]);
|
|
86
89
|
bottom = yValue;
|
|
87
90
|
}
|
|
88
91
|
return {
|