Skip to content

Commit 4b5ade2

Browse files
sean-zlaitechniq
andauthored
Add legend to lineage DAG (#418)
## Summary https://github.com/user-attachments/assets/c0e2ddc7-1ebb-40c1-a541-281153c8f1a9 ## Checklist - [ ] Added Unit Tests - [ ] Covered by existing CI - [ ] Integration tested - [ ] Documentation update --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1209437960912821 - https://app.asana.com/0/0/1209445122069294 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added a dedicated chart legend displaying distinct "Streaming" and "Batch" items for improved clarity. - **Refactor** - Updated the main chart layout to utilize a grid structure for better organization of elements. - Streamlined tooltip rendering to enhance visual consistency. - **Chores** - Updated the `layerchart` dependency to version `^0.99.4` for potential improvements and new features. <!-- end of auto-generated comment: release notes by coderabbit.ai --> <!-- av pr metadata This information is embedded by the av CLI when creating PRs to track the status of stacks when using Aviator. Please do not delete or edit this section of the PR. ``` {"parent":"main","parentHead":"","trunk":"main"} ``` --> --------- Co-authored-by: Sean Lynch <[email protected]>
1 parent 89767d4 commit 4b5ade2

File tree

3 files changed

+67
-7
lines changed

3 files changed

+67
-7
lines changed

frontend/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"clsx": "^2.1.1",
6868
"d3": "^7.9.0",
6969
"dotenv": "^16.4.7",
70-
"layerchart": "^0.99.2",
70+
"layerchart": "^0.99.4",
7171
"lodash": "^4.17.21",
7272
"svelte-inspect-value": "0.2.0",
7373
"tailwind-merge": "^2.6.0",

frontend/src/routes/[conf]/[name]/overview/+page.svelte

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
Dagre,
77
Group,
88
Html,
9+
Line,
10+
Rect,
911
Spline,
1012
Svg,
13+
Text,
1114
Tooltip,
1215
ancestors,
1316
descendants
@@ -156,7 +159,7 @@
156159
<Separator fullWidthExtend={true} wide={true} />
157160

158161
<div class="flex-1 flex py-4">
159-
<div class="flex-1 border rounded">
162+
<div class="flex-1 border rounded grid grid-stack">
160163
<Chart
161164
data={chartData}
162165
transform={{
@@ -166,6 +169,8 @@
166169
}}
167170
padding={{ top: 60, bottom: 20, left: 20, right: 20 }}
168171
let:tooltip
172+
let:width
173+
let:height
169174
>
170175
<TransformControls />
171176

@@ -308,6 +313,62 @@
308313
</Dagre>
309314
</div>
310315

316+
<!-- Put legend in separate SVG layer to not be affected by transform (pan/zoom) -->
317+
<Svg ignoreTransform>
318+
{@const legendWidth = 200}
319+
{@const legendHeight = 90}
320+
{@const legendPadding = 20}
321+
{@const legendLabelWidth = 72}
322+
{@const legendItems = [
323+
{
324+
label: 'Batch',
325+
class:
326+
'stroke-purple-500 stroke-[2] [stroke-dasharray:30_100] [stroke-dashoffset:130] animate-dashoffset-0.5x'
327+
},
328+
{
329+
label: 'Streaming',
330+
class:
331+
'stroke-blue-500 stroke-[2] [stroke-dasharray:10_10] [stroke-dashoffset:20] animate-dashoffset-2x'
332+
}
333+
]}
334+
335+
<Group x={width - legendWidth} y={height - legendHeight}>
336+
<Rect
337+
x={0}
338+
y={0}
339+
width={legendWidth}
340+
height={legendHeight}
341+
class="fill-neutral-100 stroke-border"
342+
rx={8}
343+
/>
344+
<Text
345+
value="Legend"
346+
x={legendPadding}
347+
y={24}
348+
width={legendWidth}
349+
textAnchor="start"
350+
class="text-sm fill-surface-content font-bold"
351+
/>
352+
<Group y={24}>
353+
{#each legendItems as item, i (item.label)}
354+
<Text
355+
value={item.label}
356+
x={legendPadding}
357+
y={24 + i * 24}
358+
class="text-xs fill-surface-content/50"
359+
/>
360+
<Line
361+
x1={legendPadding + legendLabelWidth}
362+
y1={20 + i * 24}
363+
x2={legendWidth - legendPadding}
364+
y2={20 + i * 24}
365+
class={item.class}
366+
/>
367+
{/each}
368+
</Group>
369+
</Group>
370+
</Svg>
371+
311372
{#if !hideTooltip}
312373
<Tooltip.Root {...tooltipProps.root} contained="window" xOffset={0} yOffset={30} let:data>
313374
<Tooltip.List {...tooltipProps.list}>
@@ -338,7 +399,6 @@
338399
{/if}
339400

340401
<!-- EntitySource -->
341-
342402
{#each ['table', 'snapshotTable', 'mutationTable', 'mutationTopic'] as prop}
343403
{#if data.value.conf[prop] !== undefined}
344404
<Tooltip.Item

0 commit comments

Comments
 (0)