From 391ccff8829889c178a31c82b99abf0d4551d275 Mon Sep 17 00:00:00 2001 From: cjc <431909623@qq.com> Date: Mon, 7 Mar 2022 17:17:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=93=88=E5=B8=8C=E6=95=B0?= =?UTF-8?q?=E5=80=BCdisable=E7=9A=84=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/Layouter/HashTable.js | 29 +++---- demo/data.js | 165 ++++++++++--------------------------- src/Model/SVNode.ts | 3 +- tsconfig.json | 2 +- 4 files changed, 62 insertions(+), 137 deletions(-) diff --git a/demo/Layouter/HashTable.js b/demo/Layouter/HashTable.js index 14cd15f..f510d17 100644 --- a/demo/Layouter/HashTable.js +++ b/demo/Layouter/HashTable.js @@ -1,17 +1,14 @@ - - - SV.registerLayout('HashTable', { sourcesPreprocess(sources) { const firstElement = sources[0]; - if(firstElement.external) { + if (firstElement.external) { firstElement.headExternal = firstElement.external; delete firstElement.external; } - if(firstElement.cursor) { + if (firstElement.cursor) { firstElement.headCursor = firstElement.cursor; delete firstElement.cursor; } @@ -21,9 +18,9 @@ SV.registerLayout('HashTable', { defineOptions() { return { - element: { + element: { default: { - type: 'indexed-node', + type: 'array-node', label: '[data]', size: [60, 30], style: { @@ -71,25 +68,29 @@ SV.registerLayout('HashTable', { layout(elements) { let arr = elements; - for(let i = 0; i < arr.length; i++) { + for (let i = 0; i < arr.length; i++) { let width = arr[i].get('size')[0]; - if(i > 0) { + if (i > 0) { arr[i].set('x', arr[i - 1].get('x') + width); } - if(arr[i].empty) { + if (arr[i].empty) { arr[i].set('style', { fill: null }); } - if(arr[i].disable) { + if (arr[i].disable) { arr[i].set('style', { - fill: '#ccc' + fill: null }); + arr[i].set('labelCfg', { + style: { + opacity: 0.4 + } + }) } } } -}); - +}); \ No newline at end of file diff --git a/demo/data.js b/demo/data.js index 40d5929..17c4d38 100644 --- a/demo/data.js +++ b/demo/data.js @@ -1,120 +1,45 @@ -const SOURCES_DATA = [ - { - LinkList0: { - data: [ - { - id: '0x617eb0', - data: 'Z', - next: '0x617ef0', - rootExternal: ['L'], - type: 'default', - }, - { - id: '0x617ef0', - data: 'A', - next: '0x617f10', - type: 'default', - }, - { - id: '0x617f10', - data: 'B', - next: '0x617f30', - type: 'default', - }, - { - id: '0x617f30', - data: 'C', - external: ['r', 't'], - next: null, - type: 'default', - }, - ], - layouter: 'LinkList', - }, - LinkList1: { - data: [ - { - id: '0x617ed0', - data: 'Y', - next: '0x617f50', - rootExternal: ['L2'], - type: 'default', - }, - { - id: '0x617f50', - data: 'a', - next: '0x617f70', - type: 'default', - }, - { - id: '0x617f70', - data: 'b', - external: ['r2', 't2'], - loopNext: 'LinkList0#0x617f30', - type: 'default', - }, - ], - layouter: 'LinkList', - }, - isEnterFunction: false, - }, - { - LinkList0: { - data: [ - { - id: '0x617eb0', - data: 'Z', - next: '0x617ef0', - rootExternal: ['L'], - type: 'default', - }, - { - id: '0x617ef0', - data: 'A', - next: '0x617f10', - type: 'default', - }, - { - id: '0x617f10', - data: 'B', - next: '0x617f30', - type: 'default', - }, - { - id: '0x617f30', - data: 'C', - external: ['r', 't'], - next: null, - type: 'default', - }, - ], - layouter: 'LinkList', - }, - LinkList1: { - data: [ - { - id: '0x617ed0', - data: 'Y', - next: '0x617f50', - rootExternal: ['L2'], - type: 'default', - }, - { - id: '0x617f50', - data: 'a', - next: '0x617f70', - type: 'default', - }, - { - id: '0x617f70', - data: 'b', - external: ['r2', 't2'], - next: null, - type: 'default', - }, - ], - layouter: 'LinkList', - }, - isEnterFunction: false, - }, -]; +const SOURCES_DATA = [{ + "HashTable": { + "data": [{ + "id": "0x616eb0", + "index": 0, + "external": "H", + "data": "", + "disable": true, + "empty": true + }, + { + "id": "0x616ec0", + "index": 1, + "data": "UV", + "disable": true, + }, + { + "id": "0x616ed0", + "index": 2, + "data": "FI" + }, + { + "id": "0x616ee0", + "index": 3, + "data": "", + "disable": true, + "empty": true + }, + { + "id": "0x616ef0", + "index": 4, + "data": "SO" + }, + { + "id": "0x616f00", + "index": 5, + "data": "", + "disable": true, + "empty": true + } + ], + "layouter": "HashTable" + }, + "isEnterFunction": false +}]; \ No newline at end of file diff --git a/src/Model/SVNode.ts b/src/Model/SVNode.ts index ab30753..b736e45 100644 --- a/src/Model/SVNode.ts +++ b/src/Model/SVNode.ts @@ -41,7 +41,7 @@ export class SVNode extends SVModel { this.sourceNode = sourceNode; this.sourceId = sourceNode.id.toString(); - + this.links = { inDegree: [], outDegree: [] }; this.appendages = {}; this.sourceNode = sourceNode; @@ -64,7 +64,6 @@ export class SVNode extends SVModel { label: this.label as string, style: { ...style, - fill: this.disable ? '#ccc' : style.fill, }, labelCfg: Util.objectClone(options.labelOptions), }; diff --git a/tsconfig.json b/tsconfig.json index 8a797fb..8829df6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "target": "ES2015", "module": "commonJS", "removeComments": true, - "lib": ["DOM", "ES2015", "ES2016"] + "lib": ["DOM", "ES2015", "ES2016", "ES2017"] }, "exclude": [ "node_modules"