diff --git a/packages/nc-gui/components/erd/RelationEdge.vue b/packages/nc-gui/components/erd/RelationEdge.vue
index 073d9ae64c..4cc019632c 100644
--- a/packages/nc-gui/components/erd/RelationEdge.vue
+++ b/packages/nc-gui/components/erd/RelationEdge.vue
@@ -55,23 +55,13 @@ export default {
-
-
-
-
diff --git a/packages/nc-gui/components/erd/utils.ts b/packages/nc-gui/components/erd/utils.ts
index 5b88eaed09..a6f47fa98a 100644
--- a/packages/nc-gui/components/erd/utils.ts
+++ b/packages/nc-gui/components/erd/utils.ts
@@ -5,7 +5,7 @@ import type { Edge, Elements } from '@vue-flow/core'
import type { MaybeRef } from '@vueuse/core'
import { Position, isEdge, isNode } from '@vue-flow/core'
import { scaleLinear as d3ScaleLinear } from 'd3-scale'
-import { computed, ref, unref, useMetas } from '#imports'
+import { computed, ref, unref, useMetas, useTheme } from '#imports'
export interface ErdFlowConfig {
showPkAndFk: boolean
@@ -27,7 +27,9 @@ interface Relation {
export function useErdElements(tables: MaybeRef, props: MaybeRef) {
const elements = ref([])
- const colorScale = d3ScaleLinear().domain([0, 4]).range(['#ff0072', '#0041d0'])
+ const { theme } = useTheme()
+
+ const colorScale = d3ScaleLinear().domain([0, 3]).range([theme.value.primaryColor, theme.value.accentColor])
const dagreGraph = new dagre.graphlib.Graph()
dagreGraph.setDefaultEdgeLabel(() => ({}))
@@ -212,12 +214,19 @@ export function useErdElements(tables: MaybeRef, props: MaybeRef {
if (isNode(el)) {
+ const color = colorScale(dagreGraph.predecessors(el.id)!.length)
const nodeWithPosition = dagreGraph.node(el.id)
el.targetPosition = Position.Left
el.sourcePosition = Position.Right
el.position = { x: nodeWithPosition.x, y: nodeWithPosition.y }
el.class = 'rounded-lg'
- el.style = { boxShadow: `0 0 0 2px ${colorScale(dagreGraph.predecessors(el.id)!.length)}` }
+ el.data.color = color
+ el.style = { boxShadow: `0 0 0 2px ${color}` }
+ } else if (isEdge(el)) {
+ const node = elements.value.find((nodes) => nodes.id === el.source)
+ if (node) {
+ el.style = { stroke: node.data.color }
+ }
}
})
}