Skip to content

Commit d596235

Browse files
committed
fix(style): remove spec-level defaults that override per-node data styles
G6 v5's getElementComputedStyle merges styles as Object.assign({}, theme, palette, dataStyle, specDefault, stateStyle), so spec-level node/edge type and style always override per-node data. Remove them from the Graph constructor and use halo-only selection indicator to avoid overriding user-customizable border properties. Add 26 regression tests guarding against reintroduction.
1 parent 701f817 commit d596235

2 files changed

Lines changed: 516 additions & 14 deletions

File tree

src/graph/core.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -224,31 +224,22 @@ class GraphCoreManager {
224224
autoResize: true,
225225
padding: 10,
226226
data: this.createSimplifiedDataForGraphObject(),
227+
// NOTE: Do NOT add `type` or `style` here. In G6 v5, spec-level
228+
// node/edge options override per-node data styles (Object.assign
229+
// order in getComputedStyle: ...dataStyle, ...specDefault...).
230+
// All per-node type/style is provided via createSimplifiedDataForGraphObject().
227231
node: {
228-
type: this.cache.DEFAULTS.NODE.TYPE,
229-
style: {
230-
size: this.cache.DEFAULTS.NODE.SIZE,
231-
fill: this.cache.DEFAULTS.NODE.FILL_COLOR,
232-
stroke: this.cache.DEFAULTS.NODE.STROKE_COLOR,
233-
lineWidth: this.cache.DEFAULTS.NODE.LINE_WIDTH,
234-
},
235232
state: {
236233
selected: {
237-
stroke: "#C33D35",
238-
lineWidth: 2,
239234
halo: true,
240235
haloStroke: "#C33D35",
236+
haloLineWidth: 12,
241237
},
242238
highlight: { fill: "#C33D35", halo: true, lineWidth: 0 },
243239
dim: { fill: "#E4E3EA" },
244240
},
245241
},
246242
edge: {
247-
type: this.cache.DEFAULTS.EDGE.TYPE,
248-
style: {
249-
stroke: this.cache.DEFAULTS.EDGE.COLOR,
250-
lineWidth: this.cache.DEFAULTS.EDGE.LINE_WIDTH,
251-
},
252243
state: {
253244
highlight: { stroke: "#C33D35" },
254245
selected: { halo: true, haloStroke: "#C33D35", haloLineWidth: 6 },

0 commit comments

Comments
 (0)