Skip to content

Commit 9247725

Browse files
committed
Fix Canvas support for some Partition examples by using Text component instead of text elements
1 parent 226223b commit 9247725

2 files changed

Lines changed: 56 additions & 36 deletions

File tree

docs/src/examples/components/Partition/filterable.svelte

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
Partition,
2323
Rect,
2424
RectClipPath,
25+
Text,
2526
Layer,
2627
findAncestor
2728
} from 'layerchart';
@@ -141,26 +142,36 @@
141142
height={nodeHeight}
142143
motion={{ type: 'tween', delay: 600 }}
143144
>
144-
<text
145+
<Text
146+
segments={[
147+
{
148+
value: node.data[0] ?? 'Overall',
149+
class: cls(
150+
'text-[10px] font-medium',
151+
colorBy === 'children'
152+
? 'fill-primary-content'
153+
: 'fill-black'
154+
),
155+
},
156+
...(node.children
157+
? [
158+
{
159+
value: ` ${format(node.value ?? 0, 'integer')}`,
160+
class: cls(
161+
'text-[8px] font-extralight',
162+
colorBy === 'children'
163+
? 'fill-primary-content'
164+
: 'fill-black'
165+
),
166+
},
167+
]
168+
: []),
169+
]}
170+
verticalAnchor="start"
171+
lineHeight="10px"
145172
x={4}
146-
y={16 * 0.6 + 4}
147-
class={cls(
148-
'text-[10px] font-medium',
149-
colorBy === 'children' ? 'fill-primary-content' : 'fill-black'
150-
)}
151-
>
152-
<tspan>{node.data[0] ?? 'Overall'}</tspan>
153-
{#if node.children}
154-
<tspan
155-
class={cls(
156-
'text-[8px] font-extralight',
157-
colorBy === 'children' ? 'fill-primary-content' : 'fill-black'
158-
)}
159-
>
160-
{format(node.value ?? 0, 'integer')}
161-
</tspan>
162-
{/if}
163-
</text>
173+
y={3.6}
174+
/>
164175
</RectClipPath>
165176
</Group>
166177
</g>

docs/src/examples/components/Partition/horizontal.svelte

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
Rect,
2424
RectClipPath,
2525
Layer,
26+
Text,
2627
findAncestor
2728
} from 'layerchart';
2829
import { Breadcrumb, Button } from 'svelte-ux';
@@ -119,24 +120,32 @@
119120
fill={nodeColor}
120121
rx={5}
121122
/>
122-
<text
123+
<Text
124+
segments={[
125+
{
126+
value: node.data.name,
127+
class: cls(
128+
'text-[10px] font-medium',
129+
colorBy === 'children'
130+
? 'fill-primary-content'
131+
: 'fill-black'
132+
),
133+
},
134+
{
135+
value: ` ${format(node.value ?? 0, 'integer')}`,
136+
class: cls(
137+
'text-[8px] font-extralight',
138+
colorBy === 'children'
139+
? 'fill-primary-content'
140+
: 'fill-black'
141+
),
142+
},
143+
]}
144+
verticalAnchor="start"
145+
lineHeight="10px"
123146
x={4}
124-
y={16 * 0.6 + 4}
125-
class={cls(
126-
'text-[10px] font-medium',
127-
colorBy === 'children' ? 'fill-primary-content' : 'fill-black'
128-
)}
129-
>
130-
<tspan>{node.data.name}</tspan>
131-
<tspan
132-
class={cls(
133-
'text-[8px] font-extralight',
134-
colorBy === 'children' ? 'fill-primary-content' : 'fill-black'
135-
)}
136-
>
137-
{format(node.value ?? 0, 'integer')}
138-
</tspan>
139-
</text>
147+
y={3.6}
148+
/>
140149
</g>
141150
</RectClipPath>
142151
</Group>

0 commit comments

Comments
 (0)