修改哈希数值disable的样式

This commit is contained in:
cjc 2022-03-07 17:17:58 +08:00
parent b3060b0e27
commit 391ccff882
4 changed files with 62 additions and 137 deletions

View File

@ -1,17 +1,14 @@
SV.registerLayout('HashTable', { SV.registerLayout('HashTable', {
sourcesPreprocess(sources) { sourcesPreprocess(sources) {
const firstElement = sources[0]; const firstElement = sources[0];
if(firstElement.external) { if (firstElement.external) {
firstElement.headExternal = firstElement.external; firstElement.headExternal = firstElement.external;
delete firstElement.external; delete firstElement.external;
} }
if(firstElement.cursor) { if (firstElement.cursor) {
firstElement.headCursor = firstElement.cursor; firstElement.headCursor = firstElement.cursor;
delete firstElement.cursor; delete firstElement.cursor;
} }
@ -23,7 +20,7 @@ SV.registerLayout('HashTable', {
return { return {
element: { element: {
default: { default: {
type: 'indexed-node', type: 'array-node',
label: '[data]', label: '[data]',
size: [60, 30], size: [60, 30],
style: { style: {
@ -71,25 +68,29 @@ SV.registerLayout('HashTable', {
layout(elements) { layout(elements) {
let arr = 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]; let width = arr[i].get('size')[0];
if(i > 0) { if (i > 0) {
arr[i].set('x', arr[i - 1].get('x') + width); arr[i].set('x', arr[i - 1].get('x') + width);
} }
if(arr[i].empty) { if (arr[i].empty) {
arr[i].set('style', { arr[i].set('style', {
fill: null fill: null
}); });
} }
if(arr[i].disable) { if (arr[i].disable) {
arr[i].set('style', { arr[i].set('style', {
fill: '#ccc' fill: null
}); });
arr[i].set('labelCfg', {
style: {
opacity: 0.4
}
})
} }
} }
} }
}); });

View File

@ -1,120 +1,45 @@
const SOURCES_DATA = [ const SOURCES_DATA = [{
{ "HashTable": {
LinkList0: { "data": [{
data: [ "id": "0x616eb0",
{ "index": 0,
id: '0x617eb0', "external": "H",
data: 'Z', "data": "",
next: '0x617ef0', "disable": true,
rootExternal: ['L'], "empty": true
type: 'default',
}, },
{ {
id: '0x617ef0', "id": "0x616ec0",
data: 'A', "index": 1,
next: '0x617f10', "data": "UV",
type: 'default', "disable": true,
}, },
{ {
id: '0x617f10', "id": "0x616ed0",
data: 'B', "index": 2,
next: '0x617f30', "data": "FI"
type: 'default',
}, },
{ {
id: '0x617f30', "id": "0x616ee0",
data: 'C', "index": 3,
external: ['r', 't'], "data": "",
next: null, "disable": true,
type: 'default', "empty": true
}, },
{
"id": "0x616ef0",
"index": 4,
"data": "SO"
},
{
"id": "0x616f00",
"index": 5,
"data": "",
"disable": true,
"empty": true
}
], ],
layouter: 'LinkList', "layouter": "HashTable"
}, },
LinkList1: { "isEnterFunction": false
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,
},
];

View File

@ -64,7 +64,6 @@ export class SVNode extends SVModel {
label: this.label as string, label: this.label as string,
style: { style: {
...style, ...style,
fill: this.disable ? '#ccc' : style.fill,
}, },
labelCfg: Util.objectClone<NodeLabelOption>(options.labelOptions), labelCfg: Util.objectClone<NodeLabelOption>(options.labelOptions),
}; };

View File

@ -3,7 +3,7 @@
"target": "ES2015", "target": "ES2015",
"module": "commonJS", "module": "commonJS",
"removeComments": true, "removeComments": true,
"lib": ["DOM", "ES2015", "ES2016"] "lib": ["DOM", "ES2015", "ES2016", "ES2017"]
}, },
"exclude": [ "exclude": [
"node_modules" "node_modules"