layerchart 0.21.0 → 0.21.1
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.
|
@@ -5,7 +5,7 @@ const defaultContext = writable({
|
|
|
5
5
|
left: 0,
|
|
6
6
|
data: null,
|
|
7
7
|
show: () => { },
|
|
8
|
-
hide: () => { }
|
|
8
|
+
hide: () => { },
|
|
9
9
|
});
|
|
10
10
|
export function tooltipContext() {
|
|
11
11
|
return getContext(tooltipContextKey) ?? defaultContext;
|
|
@@ -27,7 +27,6 @@ import { localPoint } from '../utils/event';
|
|
|
27
27
|
import { isScaleBand, scaleInvert } from '../utils/scales';
|
|
28
28
|
import { quadtreeRects } from '../utils/quadtree';
|
|
29
29
|
import { createPropertySortFunc, createSortFunc } from 'svelte-ux/utils/sort';
|
|
30
|
-
import { firstValue } from '../utils/rect';
|
|
31
30
|
const dispatch = createEventDispatcher();
|
|
32
31
|
const { flatData, x, xScale, xGet, xRange, y, yScale, yGet, yRange, width, height, padding } = getContext('LayerCake');
|
|
33
32
|
/*
|
|
@@ -171,7 +170,7 @@ function showTooltip(event, tooltipData) {
|
|
|
171
170
|
...$tooltip,
|
|
172
171
|
left: snapToDataX ? $xGet(tooltipData) + $padding.left : localX,
|
|
173
172
|
top: snapToDataY ? $yGet(tooltipData) + $padding.top : localY,
|
|
174
|
-
data: tooltipData
|
|
173
|
+
data: tooltipData,
|
|
175
174
|
};
|
|
176
175
|
}
|
|
177
176
|
else {
|
|
@@ -204,7 +203,7 @@ $: if (mode === 'quadtree') {
|
|
|
204
203
|
quadtree = d3Quadtree()
|
|
205
204
|
.extent([
|
|
206
205
|
[0, 0],
|
|
207
|
-
[$width, $height]
|
|
206
|
+
[$width, $height],
|
|
208
207
|
])
|
|
209
208
|
.x((d) => {
|
|
210
209
|
const value = $xGet(d);
|
|
@@ -238,10 +237,10 @@ let rects = [];
|
|
|
238
237
|
$: if (mode === 'bounds' || mode === 'band') {
|
|
239
238
|
rects = $flatData
|
|
240
239
|
.map((d) => {
|
|
241
|
-
const xValue =
|
|
242
|
-
const yValue =
|
|
243
|
-
const x = Array.isArray(xValue) ?
|
|
244
|
-
const y = Array.isArray(yValue) ?
|
|
240
|
+
const xValue = $xGet(d);
|
|
241
|
+
const yValue = $yGet(d);
|
|
242
|
+
const x = Array.isArray(xValue) ? xValue[0] : xValue;
|
|
243
|
+
const y = Array.isArray(yValue) ? yValue[0] : yValue;
|
|
245
244
|
const xOffset = isScaleBand($xScale) ? ($xScale.padding() * $xScale.step()) / 2 : 0;
|
|
246
245
|
const yOffset = isScaleBand($yScale) ? ($yScale.padding() * $yScale.step()) / 2 : 0;
|
|
247
246
|
const fullWidth = max($xRange) - min($xRange);
|
|
@@ -253,7 +252,7 @@ $: if (mode === 'bounds' || mode === 'band') {
|
|
|
253
252
|
y: isScaleBand($yScale) ? y - yOffset : min($yRange),
|
|
254
253
|
width: isScaleBand($xScale) ? $xScale.step() : fullWidth,
|
|
255
254
|
height: isScaleBand($yScale) ? $yScale.step() : fullHeight,
|
|
256
|
-
data: d
|
|
255
|
+
data: d,
|
|
257
256
|
};
|
|
258
257
|
}
|
|
259
258
|
else if (mode === 'bounds') {
|
|
@@ -271,7 +270,7 @@ $: if (mode === 'bounds' || mode === 'band') {
|
|
|
271
270
|
: isScaleBand($yScale)
|
|
272
271
|
? $yScale.step()
|
|
273
272
|
: max($yRange) - y,
|
|
274
|
-
data: d
|
|
273
|
+
data: d,
|
|
275
274
|
};
|
|
276
275
|
}
|
|
277
276
|
})
|