Skip to content

Pass data type through mark components #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 45 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
146e305
docs: add cell example, figure out solution for passing thru types
gka Jun 6, 2025
bb808d1
improve typing of BarX
gka Jun 6, 2025
baf71cd
improve typing of BarY
gka Jun 6, 2025
1fbf3d8
ts: improve typing of Geo mark
gka Jun 8, 2025
d5b4e18
ts: improve dotx and doty
gka Jun 9, 2025
e6d013f
ts: improve frame
gka Jun 9, 2025
8498487
ts: improve line
gka Jun 9, 2025
89e47b2
ts: line marks
gka Jun 9, 2025
1a5789f
ts: bollinger marks
gka Jun 9, 2025
cabc2d8
ts: brush marks
gka Jun 9, 2025
8ff916c
ts: cell marks
gka Jun 9, 2025
2c0614b
ts: custom mark, screenshots
gka Jun 9, 2025
97b7462
fix
gka Jun 9, 2025
19658b4
fix brush mark
gka Jun 9, 2025
bfad61c
..
gka Jun 9, 2025
3f7bf76
ts: rect mark props
gka Jun 9, 2025
9077f34
fix axis marks
gka Jun 9, 2025
4f60da8
add rect examples
gka Jun 9, 2025
635db6d
increase title margin on axisY
gka Jun 9, 2025
6ee6ea7
ensure that interval ticks stay within domain
gka Jun 9, 2025
165b38b
..
gka Jun 9, 2025
8527c72
tests
gka Jun 10, 2025
8188532
ts: improve area prop type
gka Jun 10, 2025
b263fe6
..
gka Jun 10, 2025
8fcd536
add streamgraph example
gka Jun 10, 2025
5668cbc
docs
gka Jun 10, 2025
6135445
ts: improve arrow prop type
gka Jun 10, 2025
de86fae
remove unused css
gka Jun 11, 2025
114cbab
ts: improve link mark props
gka Jun 11, 2025
2e02df0
ts: improve pointer mark props
gka Jun 11, 2025
225ffff
docs: add link examples
gka Jun 11, 2025
76dc86b
chore: break types into separate files
gka Jun 11, 2025
7f90ed2
fix imports
gka Jun 11, 2025
cd7fc42
ts: improve rule mark props
gka Jun 11, 2025
a952693
fix aapl type
gka Jun 11, 2025
031fa05
docs: add rule examples
gka Jun 11, 2025
5a6edbb
ts: improve sphere mark props
gka Jun 11, 2025
edc97ea
ts: improve spike and vector mark props
gka Jun 11, 2025
17f45dd
ts: improve tick mark props
gka Jun 11, 2025
361043a
docs: add exmaples
gka Jun 11, 2025
df21c51
docs: add spike map example
gka Jun 11, 2025
c17157c
bump dependencies
gka Jun 11, 2025
bb39db8
add ssr
gka Jun 11, 2025
0a1fbb0
add screenshot
gka Jun 11, 2025
75edbb7
more examples
gka Jun 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ts: improve spike and vector mark props
  • Loading branch information
gka committed Jun 11, 2025
commit edc97eadd15164925da77cc6a18af18b54945b0c
15 changes: 6 additions & 9 deletions src/lib/marks/Spike.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
@component
Wrapper around the vector mark with presets suitable for spike maps
-->
<script module lang="ts">
export type SpikeMarkProps = VectorMarkProps;
</script>

<script lang="ts">
import Vector, { type VectorMarkProps } from './Vector.svelte';
import type { PlotDefaults } from '../types/index.js';
import { getContext } from 'svelte';
<script lang="ts" generics="Datum extends DataRecord">
interface SpikeMarkProps extends ComponentProps<typeof Vector> {}
import Vector from './Vector.svelte';
import type { DataRecord, PlotDefaults } from '../types/index.js';
import { getContext, type ComponentProps } from 'svelte';

let markProps: SpikeMarkProps = $props();

Expand All @@ -24,7 +21,7 @@
...getContext<PlotDefaults>('svelteplot/_defaults').spike
};

const { data = [{}], ...options }: SpikeMarkProps = $derived({
const { data = [{} as Datum], ...options }: SpikeMarkProps = $derived({
...DEFAULTS,
...markProps
});
Expand Down
40 changes: 18 additions & 22 deletions src/lib/marks/Vector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,44 @@
The vector mark lets you place shapes (like arrows) on your plot.
-->
<script lang="ts" module>
import type {
PlotContext,
DataRecord,
BaseMarkProps,
ConstantAccessor,
ChannelAccessor,
FacetContext,
PlotDefaults
} from '../types/index.js';

type D3Path = ReturnType<typeof import('d3-path').path>;

export type ShapeRenderer = {
draw(context: D3Path, l: number, r: number): void;
};
</script>

export type VectorMarkProps = BaseMarkProps & {
data: DataRecord[];
x: ChannelAccessor;
y: ChannelAccessor;
<script lang="ts" generics="Datum extends DataRecord">
interface VectorMarkProps extends BaseMarkProps<Datum> {
data: Datum[];
x: ChannelAccessor<Datum>;
y: ChannelAccessor<Datum>;
r?: number;
length?: ChannelAccessor;
rotate?: ChannelAccessor;
length?: ChannelAccessor<Datum>;
rotate?: ChannelAccessor<Datum>;
/**
* Controls where the vector is anchored in relation to the x, y position.
* If set to 'start', the arrow will start at the x, y position. If set to
* 'middle', the arrow will be centered at the x, y position. If set to
* 'end', the arrow will end at the x, y position.
*/
anchor: 'start' | 'middle' | 'end';
anchor?: 'start' | 'middle' | 'end';
shape?: 'arrow' | 'spike' | 'arrow-filled' | ShapeRenderer;
children?: Snippet;
canvas?: boolean;
};
</script>
}
import type {
PlotContext,
DataRecord,
BaseMarkProps,
ChannelAccessor,
FacetContext,
PlotDefaults
} from '../types/index.js';

<script lang="ts">
import { getContext, type Snippet } from 'svelte';
import { pathRound as path } from 'd3-path';

import { resolveChannel, resolveProp, resolveStyles } from '../helpers/resolve.js';
import { projectXY } from '../helpers/scales.js';
import { sort } from 'svelteplot';
import Mark from '../Mark.svelte';
//import DotCanvas from './helpers/DotCanvas.svelte';
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy