|
15 | 15 | import { Button, Breadcrumb } from 'svelte-ux'; |
16 | 16 | import { format } from '@layerstack/utils'; |
17 | 17 | import { cls } from '@layerstack/tailwind'; |
18 | | - import { Chart, Group, Rect, RectClipPath, Layer, Treemap, findAncestor } from 'layerchart'; |
| 18 | + import { Chart, Group, Rect, RectClipPath, Layer, Text, Treemap, findAncestor } from 'layerchart'; |
19 | 19 |
|
20 | 20 | let config = $state({ |
21 | 21 | tile: 'squarify' as ComponentProps<typeof Treemap>['tile'], |
|
160 | 160 | height={nodeHeight} |
161 | 161 | motion={{ type: 'tween', delay: 600 }} |
162 | 162 | > |
163 | | - <text |
| 163 | + <Text |
| 164 | + segments={[ |
| 165 | + { |
| 166 | + value: node.data[0] ?? 'Overall', |
| 167 | + class: cls( |
| 168 | + 'text-[10px] font-medium', |
| 169 | + config.colorBy === 'children' |
| 170 | + ? 'fill-primary-content' |
| 171 | + : 'fill-black' |
| 172 | + ), |
| 173 | + }, |
| 174 | + ...(node.children |
| 175 | + ? [ |
| 176 | + { |
| 177 | + value: ` ${format(node.value ?? 0, 'integer')}`, |
| 178 | + class: cls( |
| 179 | + 'text-[8px] font-extralight', |
| 180 | + config.colorBy === 'children' |
| 181 | + ? 'fill-primary-content' |
| 182 | + : 'fill-black' |
| 183 | + ), |
| 184 | + }, |
| 185 | + ] |
| 186 | + : []), |
| 187 | + ]} |
| 188 | + verticalAnchor="start" |
| 189 | + lineHeight="10px" |
164 | 190 | x={4} |
165 | | - y={16 * 0.6 + 4} |
166 | | - class={cls( |
167 | | - 'text-[10px] font-medium', |
168 | | - config.colorBy === 'children' ? 'fill-primary-content' : 'fill-black' |
169 | | - )} |
170 | | - > |
171 | | - <tspan>{node.data[0] ?? 'Overall'}</tspan> |
172 | | - {#if node.children} |
173 | | - <tspan class="text-[8px] font-extralight" |
174 | | - >{format(node.value ?? 0, 'integer')}</tspan |
175 | | - > |
176 | | - {/if} |
177 | | - </text> |
| 191 | + y={3.6} |
| 192 | + /> |
| 193 | + |
178 | 194 | {#if !node.children} |
179 | | - <!-- <Text |
180 | | - value={format(node.value ?? 0, 'integer')} |
181 | | - class="text-[8px] font-extralight" |
182 | | - verticalAnchor="start" |
183 | | - x={4} |
184 | | - y={16} |
185 | | - /> --> |
| 195 | + <Text |
| 196 | + value={format(node.value ?? 0, 'integer')} |
| 197 | + class={cls( |
| 198 | + 'text-[8px] font-extralight', |
| 199 | + config.colorBy === 'children' ? 'fill-primary-content' : 'fill-black' |
| 200 | + )} |
| 201 | + verticalAnchor="start" |
| 202 | + lineHeight="8px" |
| 203 | + x={4} |
| 204 | + y={16} |
| 205 | + /> |
186 | 206 | {/if} |
187 | 207 | </RectClipPath> |
188 | 208 | </Group> |
|
0 commit comments