svelteplot 0.9.0-pr-311.5 → 0.9.0-pr-312.0
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.
- package/dist/core/FacetAxes.svelte +14 -3
- package/dist/core/FacetGrid.svelte +15 -4
- package/dist/marks/helpers/BaseAxisX.svelte +3 -1
- package/dist/marks/helpers/BaseAxisX.svelte.d.ts +1 -0
- package/dist/marks/helpers/BaseAxisY.svelte +4 -2
- package/dist/marks/helpers/BaseAxisY.svelte.d.ts +1 -0
- package/dist/types/scale.d.ts +14 -14
- package/package.json +1 -1
|
@@ -21,10 +21,16 @@
|
|
|
21
21
|
|
|
22
22
|
// create band scales for fx and fy
|
|
23
23
|
const facetXScale = $derived(
|
|
24
|
-
scaleBand()
|
|
24
|
+
scaleBand()
|
|
25
|
+
.paddingInner(plot.options.fx?.paddingInner ?? plot.options.fx?.padding ?? 0.1)
|
|
26
|
+
.domain(fxValues)
|
|
27
|
+
.rangeRound([0, plot.plotWidth])
|
|
25
28
|
);
|
|
26
29
|
const facetYScale = $derived(
|
|
27
|
-
scaleBand()
|
|
30
|
+
scaleBand()
|
|
31
|
+
.paddingInner(plot.options.fy?.paddingInner ?? plot.options.fy?.padding ?? 0.1)
|
|
32
|
+
.domain(fyValues)
|
|
33
|
+
.rangeRound([0, plot.plotHeight])
|
|
28
34
|
);
|
|
29
35
|
</script>
|
|
30
36
|
|
|
@@ -32,13 +38,17 @@
|
|
|
32
38
|
{#if fxValues.length > 1 && plot.options.fx.axis}
|
|
33
39
|
<g transform="translate({plot.options.marginLeft}, 0)">
|
|
34
40
|
<BaseAxisX
|
|
41
|
+
class="facet-axis-x"
|
|
35
42
|
scaleFn={facetXScale}
|
|
36
43
|
scaleType="band"
|
|
37
44
|
ticks={fxValues}
|
|
38
45
|
tickFormat={plot.options.fx.tickFormat || ((d) => d)}
|
|
39
46
|
tickFontSize={11}
|
|
40
47
|
tickSize={0}
|
|
41
|
-
tickPadding={
|
|
48
|
+
tickPadding={plot.options.x.axis === plot.options.fx.axis ||
|
|
49
|
+
plot.options.x.axis === 'both'
|
|
50
|
+
? 25
|
|
51
|
+
: 5}
|
|
42
52
|
anchor={plot.options.fx.axis}
|
|
43
53
|
options={plot.options.fx.axisOptions || {}}
|
|
44
54
|
{...plot.options.fx.axisProps || {}}
|
|
@@ -50,6 +60,7 @@
|
|
|
50
60
|
{#if fyValues.length > 1 && plot.options.fy.axis}
|
|
51
61
|
<g transform="translate(0, {plot.options.marginTop})">
|
|
52
62
|
<BaseAxisY
|
|
63
|
+
class="facet-axis-y"
|
|
53
64
|
scaleFn={facetYScale}
|
|
54
65
|
scaleType="band"
|
|
55
66
|
ticks={fyValues}
|
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
import { scaleBand } from 'd3-scale';
|
|
10
10
|
import Facet from './Facet.svelte';
|
|
11
11
|
import { getEmptyFacets } from '../helpers/facets.js';
|
|
12
|
+
import { usePlot } from '../hooks/usePlot.svelte.js';
|
|
12
13
|
|
|
13
|
-
const {
|
|
14
|
+
const { updateDimensions } = getContext<PlotContext>('svelteplot');
|
|
14
15
|
// we need the plot context for the overall width & height
|
|
15
|
-
const plot =
|
|
16
|
+
const plot = usePlot();
|
|
16
17
|
|
|
17
18
|
let {
|
|
18
19
|
children,
|
|
@@ -36,13 +37,23 @@
|
|
|
36
37
|
// create band scales for fx and fy
|
|
37
38
|
const facetXScale = $derived(
|
|
38
39
|
scaleBand()
|
|
39
|
-
.
|
|
40
|
+
.paddingOuter(0)
|
|
41
|
+
.paddingInner(
|
|
42
|
+
fxValues.length > 1
|
|
43
|
+
? (plot.options.fx?.paddingInner ?? plot.options.fx?.padding ?? 0.1)
|
|
44
|
+
: 0
|
|
45
|
+
)
|
|
40
46
|
.domain(fxValues)
|
|
41
47
|
.rangeRound([0, plot.plotWidth])
|
|
42
48
|
);
|
|
43
49
|
const facetYScale = $derived(
|
|
44
50
|
scaleBand()
|
|
45
|
-
.
|
|
51
|
+
.paddingOuter(0)
|
|
52
|
+
.paddingInner(
|
|
53
|
+
fyValues.length > 1
|
|
54
|
+
? (plot.options.fy?.paddingInner ?? plot.options.fy?.padding ?? 0.1)
|
|
55
|
+
: 0
|
|
56
|
+
)
|
|
46
57
|
.domain(fyValues)
|
|
47
58
|
.rangeRound([0, plot.plotHeight])
|
|
48
59
|
);
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
};
|
|
43
43
|
text: boolean;
|
|
44
44
|
plot: PlotState;
|
|
45
|
+
class: string;
|
|
45
46
|
};
|
|
46
47
|
|
|
47
48
|
let {
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
options,
|
|
60
61
|
plot,
|
|
61
62
|
title,
|
|
63
|
+
class: className = 'axis-x',
|
|
62
64
|
text = true
|
|
63
65
|
}: BaseAxisXProps = $props();
|
|
64
66
|
|
|
@@ -176,7 +178,7 @@
|
|
|
176
178
|
});
|
|
177
179
|
</script>
|
|
178
180
|
|
|
179
|
-
<g class=
|
|
181
|
+
<g class={className}>
|
|
180
182
|
{#each positionedTicks as tick, t (tick[RAW_VALUE])}
|
|
181
183
|
{#if testFilter(tick, options) && !tick.hidden}
|
|
182
184
|
{@const tickClass_ = resolveProp(tickClass, tick)}
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
};
|
|
37
37
|
plot: PlotState;
|
|
38
38
|
text: boolean | null;
|
|
39
|
+
class: string;
|
|
39
40
|
};
|
|
40
41
|
|
|
41
42
|
let {
|
|
@@ -54,7 +55,8 @@
|
|
|
54
55
|
title,
|
|
55
56
|
plot,
|
|
56
57
|
options,
|
|
57
|
-
text = true
|
|
58
|
+
text = true,
|
|
59
|
+
class: className = 'axis-y'
|
|
58
60
|
}: BaseAxisYProps = $props();
|
|
59
61
|
|
|
60
62
|
const LINE_ANCHOR = {
|
|
@@ -153,7 +155,7 @@
|
|
|
153
155
|
});
|
|
154
156
|
</script>
|
|
155
157
|
|
|
156
|
-
<g class=
|
|
158
|
+
<g class={className}>
|
|
157
159
|
{#each positionedTicks as tick, t (tick[RAW_VALUE])}
|
|
158
160
|
{#if testFilter(tick, options) && !tick.hidden}
|
|
159
161
|
{@const tickClass_ = resolveProp(tickClass, tick)}
|
package/dist/types/scale.d.ts
CHANGED
|
@@ -12,17 +12,17 @@ export type ScaleOptions = {
|
|
|
12
12
|
* Set a custom domain for the scale instead of auto-computing the domain
|
|
13
13
|
* from the mark data channels.
|
|
14
14
|
*/
|
|
15
|
-
domain
|
|
15
|
+
domain: RawValue[];
|
|
16
16
|
/**
|
|
17
17
|
* Set a custom range for the scale.
|
|
18
18
|
*/
|
|
19
|
-
range
|
|
19
|
+
range: RawValue[];
|
|
20
20
|
/**
|
|
21
21
|
* Reverse the scale.
|
|
22
22
|
*/
|
|
23
23
|
reverse: boolean;
|
|
24
|
-
label
|
|
25
|
-
interval
|
|
24
|
+
label: string | false;
|
|
25
|
+
interval: string | number;
|
|
26
26
|
clamp: boolean;
|
|
27
27
|
/**
|
|
28
28
|
* Extend the domain to nice round numbers (applicable to quantitative scales only)
|
|
@@ -46,23 +46,23 @@ export type ScaleOptions = {
|
|
|
46
46
|
/**
|
|
47
47
|
* set the inner padding for band scales
|
|
48
48
|
*/
|
|
49
|
-
paddingInner
|
|
49
|
+
paddingInner: number;
|
|
50
50
|
/**
|
|
51
51
|
* set the outer padding for band scales
|
|
52
52
|
*/
|
|
53
|
-
paddingOuter
|
|
54
|
-
insetLeft
|
|
55
|
-
insetRight
|
|
56
|
-
insetTop
|
|
57
|
-
insetBottom
|
|
58
|
-
ticks
|
|
53
|
+
paddingOuter: number;
|
|
54
|
+
insetLeft: number;
|
|
55
|
+
insetRight: number;
|
|
56
|
+
insetTop: number;
|
|
57
|
+
insetBottom: number;
|
|
58
|
+
ticks: (number | Date)[];
|
|
59
59
|
tickSpacing: number;
|
|
60
|
-
base
|
|
61
|
-
sort
|
|
60
|
+
base: number;
|
|
61
|
+
sort: ChannelAccessor | ((a: RawValue, b: RawValue) => number) | {
|
|
62
62
|
channel: string;
|
|
63
63
|
order: 'ascending' | 'descending';
|
|
64
64
|
};
|
|
65
|
-
constant
|
|
65
|
+
constant: number;
|
|
66
66
|
};
|
|
67
67
|
export type ColorScaleOptions = ScaleOptions & {
|
|
68
68
|
legend: boolean;
|