Skip to content

Commit 725b276

Browse files
committed
feat: add href support to dot,bars,cell, and rect
1 parent 26dba29 commit 725b276

File tree

6 files changed

+58
-47
lines changed

6 files changed

+58
-47
lines changed

src/lib/marks/BarX.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
PlotContext,
88
BaseMarkProps,
99
BaseRectMarkProps,
10-
ChannelAccessor
10+
ChannelAccessor,
11+
LinkableMarkProps
1112
} from '../types.js';
1213
1314
export type BarXMarkProps = BaseMarkProps &
15+
LinkableMarkProps &
1416
BaseRectMarkProps & {
1517
data: DataRow[];
1618
x?: ChannelAccessor;

src/lib/marks/BarY.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
} from '../types.js';
1313
1414
export type BarYMarkProps = BaseMarkProps &
15+
LinkableMarkProps &
1516
BaseRectMarkProps & {
1617
data: DataRow[];
1718
x?: ChannelAccessor;

src/lib/marks/Cell.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
} from '../types.js';
1313
1414
export type CellMarkProps = BaseMarkProps &
15+
LinkableMarkProps &
1516
BaseRectMarkProps & {
1617
data: DataRecord[];
1718
x?: ChannelAccessor;

src/lib/marks/Dot.svelte

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
symbol?: ChannelAccessor | Snippet<[number, string]>;
1111
canvas?: boolean;
1212
dotClass?: ConstantAccessor<string>;
13-
};
13+
} & LinkableMarkProps;
1414
</script>
1515

1616
<script lang="ts">
@@ -21,8 +21,8 @@
2121
BaseMarkProps,
2222
ConstantAccessor,
2323
ChannelAccessor,
24-
FacetContext,
25-
PlotDefaults
24+
PlotDefaults,
25+
LinkableMarkProps
2626
} from '../types.js';
2727
import { resolveProp, resolveStyles } from '../helpers/resolve.js';
2828
import { maybeSymbol } from '$lib/helpers/symbols.js';
@@ -33,6 +33,7 @@
3333
import { maybeData, isValid } from '$lib/helpers/index.js';
3434
import { recordizeXY } from '$lib/transforms/recordize.js';
3535
import { addEventHandlers } from './helpers/events.js';
36+
import Anchor from './helpers/Anchor.svelte';
3637
3738
let {
3839
data = [{}],
@@ -95,19 +96,21 @@
9596
'stroke',
9697
usedScales
9798
)}
98-
<path
99-
transform="translate({d.x}, {d.y})"
100-
d={getSymbolPath(d.symbol, d.r ** 2 * Math.PI)}
101-
class={[
102-
dotClass ? resolveProp(dotClass, d.datum, null) : null,
103-
styleClass
104-
]}
105-
{style}
106-
use:addEventHandlers={{
107-
getPlotState,
108-
options: args,
109-
datum: d.datum
110-
}} />
99+
<Anchor {options} datum={d.datum}>
100+
<path
101+
transform="translate({d.x}, {d.y})"
102+
d={getSymbolPath(d.symbol, d.r ** 2 * Math.PI)}
103+
class={[
104+
dotClass ? resolveProp(dotClass, d.datum, null) : null,
105+
styleClass
106+
]}
107+
{style}
108+
use:addEventHandlers={{
109+
getPlotState,
110+
options: args,
111+
datum: d.datum
112+
}} />
113+
</Anchor>
111114
{/if}
112115
{/each}
113116
{/if}

src/lib/marks/Rect.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
y2?: ChannelAccessor;
1414
interval?: number | string;
1515
} & BaseMarkProps &
16+
LinkableMarkProps &
1617
BaseRectMarkProps;
1718
</script>
1819

src/lib/marks/helpers/RectPath.svelte

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Helper component for rendering rectangular marks in SVG
1414
} from 'svelteplot/types';
1515
import { addEventHandlers } from './events';
1616
import { getContext } from 'svelte';
17+
import Anchor from './Anchor.svelte';
1718
1819
let {
1920
datum,
@@ -101,33 +102,35 @@ Helper component for rendering rectangular marks in SVG
101102
);
102103
</script>
103104

104-
{#if hasBorderRadius}
105-
<path
106-
transform="translate({x + dx + insetLeft},{y + insetBottom + dy})"
107-
d={roundedRect(
108-
0,
109-
0,
110-
width - insetLeft - insetRight,
111-
height - insetTop - insetBottom,
112-
borderRadius
113-
)}
114-
class={[styleClass, className]}
115-
{style}
116-
use:addEventHandlers={{
117-
getPlotState,
118-
options,
119-
datum: datum?.datum
120-
}} />
121-
{:else}
122-
<rect
123-
transform="translate({x + dx + insetLeft},{y + insetBottom + dy})"
124-
width={width - insetLeft - insetRight}
125-
height={height - insetTop - insetBottom}
126-
class={[styleClass, className]}
127-
{style}
128-
use:addEventHandlers={{
129-
getPlotState,
130-
options,
131-
datum: datum?.datum
132-
}} />
133-
{/if}
105+
<Anchor {options} datum={datum?.datum}>
106+
{#if hasBorderRadius}
107+
<path
108+
transform="translate({x + dx + insetLeft},{y + insetBottom + dy})"
109+
d={roundedRect(
110+
0,
111+
0,
112+
width - insetLeft - insetRight,
113+
height - insetTop - insetBottom,
114+
borderRadius
115+
)}
116+
class={[styleClass, className]}
117+
{style}
118+
use:addEventHandlers={{
119+
getPlotState,
120+
options,
121+
datum: datum?.datum
122+
}} />
123+
{:else}
124+
<rect
125+
transform="translate({x + dx + insetLeft},{y + insetBottom + dy})"
126+
width={width - insetLeft - insetRight}
127+
height={height - insetTop - insetBottom}
128+
class={[styleClass, className]}
129+
{style}
130+
use:addEventHandlers={{
131+
getPlotState,
132+
options,
133+
datum: datum?.datum
134+
}} />
135+
{/if}
136+
</Anchor>

0 commit comments

Comments
 (0)
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