|
2 | 2 | import { getContext } from 'svelte';
|
3 | 3 | import Mark from '../Mark.svelte';
|
4 | 4 | import type { PlotContext, BaseMarkProps, RawValue, DataRecord } from '../types.js';
|
5 |
| - import { resolveChannel, resolveScaledStyles } from '../helpers/resolve.js'; |
| 5 | + import { resolveChannel, resolveStyles } from '../helpers/resolve.js'; |
6 | 6 | import { autoTicks } from '$lib/helpers/autoTicks.js';
|
7 |
| - import { getUsedScales } from '$lib/helpers/scales.js'; |
8 | 7 | import { testFilter } from '$lib/helpers/index.js';
|
| 8 | + import { RAW_VALUE } from '$lib/transforms/recordize.js'; |
9 | 9 |
|
10 | 10 | type GridYMarkProps = BaseMarkProps & { data?: RawValue[]; automatic?: boolean };
|
11 | 11 |
|
12 | 12 | let { data = [], automatic = false, ...options }: GridYMarkProps = $props();
|
13 | 13 |
|
14 | 14 | const { getPlotState } = getContext<PlotContext>('svelteplot');
|
15 |
| - let plot = $derived(getPlotState()); |
| 15 | + const plot = $derived(getPlotState()); |
16 | 16 |
|
17 |
| - let autoTickCount = $derived( |
| 17 | + const autoTickCount = $derived( |
18 | 18 | Math.max(2, Math.round(plot.facetHeight / plot.options.y.tickSpacing))
|
19 | 19 | );
|
20 | 20 |
|
21 |
| - let ticks: RawValue[] = $derived( |
| 21 | + const ticks: RawValue[] = $derived( |
22 | 22 | data.length > 0
|
23 | 23 | ? // use custom tick values if user passed any as prop
|
24 | 24 | data
|
|
51 | 51 | {@const x2_ = resolveChannel('x2', tick, options)}
|
52 | 52 | {@const x1 = options.x1 != null ? plot.scales.x.fn(x1_) : 0}
|
53 | 53 | {@const x2 = options.x2 != null ? plot.scales.x.fn(x2_) : plot.facetWidth}
|
| 54 | + {@const [style, styleClass] = resolveStyles( |
| 55 | + plot, |
| 56 | + { datum: { [RAW_VALUE]: tick } }, |
| 57 | + options, |
| 58 | + 'stroke', |
| 59 | + usedScales, |
| 60 | + true |
| 61 | + )} |
54 | 62 | <line
|
| 63 | + {style} |
| 64 | + class={styleClass} |
55 | 65 | transform="translate({plot.options.marginLeft},{y})"
|
56 |
| - style={resolveScaledStyles(tick, options, usedScales, plot, 'stroke')} |
57 | 66 | {x1}
|
58 | 67 | {x2} />
|
59 | 68 | {/if}
|
|
0 commit comments