dcim-topology2d 2.0.5 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/chart-diagram/src/echarts/index.js +21 -13
  2. package/chart-diagram/src/utils/changeOptions.js +7 -1
  3. package/chart-diagram/src/utils/conversion.d.ts +1 -0
  4. package/chart-diagram/src/utils/conversion.js +117 -23
  5. package/chart-diagram/src/utils/formatter.d.ts +1 -0
  6. package/chart-diagram/src/utils/formatter.js +129 -0
  7. package/chart-diagram/src/utils/index.d.ts +1 -0
  8. package/chart-diagram/src/utils/index.js +1 -0
  9. package/chart-diagram/src/utils/render.d.ts +3 -1
  10. package/chart-diagram/src/utils/render.js +83 -8
  11. package/core/src/common.js +53 -18
  12. package/core/src/core.js +25 -0
  13. package/core/src/divLayer.js +1 -1
  14. package/core/src/element/common.js +4 -2
  15. package/core/src/element/select.js +29 -0
  16. package/core/src/element/tab.js +5 -1
  17. package/core/src/healps/changeData.js +1 -1
  18. package/core/src/middles/nodes/formoverflow.js +61 -0
  19. package/core/src/middles/nodes/formselect.js +16 -8
  20. package/core/src/middles/nodes/index.d.ts +2 -1
  21. package/core/src/middles/nodes/index.js +1 -0
  22. package/core/src/models/node.js +7 -0
  23. package/core/src/options.d.ts +1 -1
  24. package/core/src/preview.js +28 -1
  25. package/core/src/store/data.d.ts +7 -0
  26. package/core/src/store/data.js +17 -1
  27. package/core/src/utils/assignment.js +2 -2
  28. package/core/src/utils/construction.d.ts +2 -0
  29. package/core/src/utils/construction.js +1 -0
  30. package/core/src/utils/conversion.d.ts +2 -1
  31. package/core/src/utils/conversion.js +52 -0
  32. package/core/src/utils/params.js +3 -0
  33. package/myShape-diagram/index.js +155 -152
  34. package/package.json +1 -1
  35. package/static/echartsDefaultData.js +11 -3
@@ -6,6 +6,9 @@ export function getParams(id, data) {
6
6
  if (item.children && item.children.length) {
7
7
  getParams(id, item.children);
8
8
  }
9
+ if (item.formData && item.formData.detailPageData && item.formData.detailPageData.pens && item.formData.detailPageData.pens.length) {
10
+ getParams(id, item.formData.detailPageData.pens);
11
+ }
9
12
  });
10
13
  }
11
14
  // 过滤出参数
@@ -1,5 +1,7 @@
1
1
  // 源码版写法
2
2
  import { registerNode } from '../core'
3
+ import { formOverflow } from '../core/src/middles/nodes/formoverflow'
4
+
3
5
 
4
6
  // 组件版写法和bundle一致
5
7
  // window.Le5leTopology.registerNode
@@ -7,87 +9,87 @@ import { registerNode } from '../core'
7
9
  // 画骨架
8
10
 
9
11
  function drawOuterLine(ctx, node) {
10
- const R = Math.floor((node.rect.width - 6) / 2);
11
- const r = Math.round((R * 1) / 2);
12
-
13
- ctx.beginPath();
14
- // 上半个圆形
15
- ctx.arc(node.rect.x + R, node.rect.y + r, r, 0, Math.PI, true);
16
- // 下半个圆形
17
- const theta = Math.acos((r * 1.0) / R);
18
- ctx.arc(
19
- node.rect.x + R,
20
- node.rect.y + node.rect.height - R,
21
- R,
22
- theta + Math.PI,
23
- -theta,
24
- true
25
- ); // 逆时针
26
- ctx.closePath();
27
- ctx.stroke();
12
+ const R = Math.floor((node.rect.width - 6) / 2);
13
+ const r = Math.round((R * 1) / 2);
14
+
15
+ ctx.beginPath();
16
+ // 上半个圆形
17
+ ctx.arc(node.rect.x + R, node.rect.y + r, r, 0, Math.PI, true);
18
+ // 下半个圆形
19
+ const theta = Math.acos((r * 1.0) / R);
20
+ ctx.arc(
21
+ node.rect.x + R,
22
+ node.rect.y + node.rect.height - R,
23
+ R,
24
+ theta + Math.PI,
25
+ -theta,
26
+ true
27
+ ); // 逆时针
28
+ ctx.closePath();
29
+ ctx.stroke();
28
30
  }
29
31
 
30
32
  // 画底色
31
33
  function drawBasic(ctx, node) {
32
- const lingrad = ctx.createLinearGradient(
33
- node.rect.x,
34
- node.rect.y,
35
- node.rect.width,
36
- node.rect.height
37
- );
38
- lingrad.addColorStop(0, 'mediumvioletred');
39
- lingrad.addColorStop(0.2, 'darkorange');
40
- lingrad.addColorStop(0.4, 'gold');
41
- lingrad.addColorStop(0.6, 'limegreen');
42
- lingrad.addColorStop(0.8, 'navy');
43
- lingrad.addColorStop(1, 'purple');
44
- ctx.fillStyle = lingrad;
45
- ctx.fill('evenodd');
34
+ const lingrad = ctx.createLinearGradient(
35
+ node.rect.x,
36
+ node.rect.y,
37
+ node.rect.width,
38
+ node.rect.height
39
+ );
40
+ lingrad.addColorStop(0, 'mediumvioletred');
41
+ lingrad.addColorStop(0.2, 'darkorange');
42
+ lingrad.addColorStop(0.4, 'gold');
43
+ lingrad.addColorStop(0.6, 'limegreen');
44
+ lingrad.addColorStop(0.8, 'navy');
45
+ lingrad.addColorStop(1, 'purple');
46
+ ctx.fillStyle = lingrad;
47
+ ctx.fill('evenodd');
46
48
  }
47
49
 
48
50
  function getYByValue(node, i) {
49
- const R = Math.floor((node.rect.width - 6) / 2);
50
- const r = Math.round((R * 1) / 2);
51
-
52
- const min = 0;
53
- const max = 40;
54
-
55
- // 刻度线总高度
56
- const scale_height = node.rect.height - 2 * R - 2 * r;
57
- // 0刻度线所在位置
58
- const zero_scale_y = node.rect.height - 2 * R;
59
- const dy_dtem = scale_height / (max - min);
60
- return zero_scale_y - dy_dtem * node.value;
51
+ const R = Math.floor((node.rect.width - 6) / 2);
52
+ const r = Math.round((R * 1) / 2);
53
+
54
+ const min = 0;
55
+ const max = 40;
56
+
57
+ // 刻度线总高度
58
+ const scale_height = node.rect.height - 2 * R - 2 * r;
59
+ // 0刻度线所在位置
60
+ const zero_scale_y = node.rect.height - 2 * R;
61
+ const dy_dtem = scale_height / (max - min);
62
+ return zero_scale_y - dy_dtem * node.value;
61
63
  }
62
64
 
63
65
  // 画刻度线
64
66
  function drawScale(ctx, node) {
65
- const min = 0;
66
- const max = 40;
67
- const R = Math.floor((node.rect.width - 6) / 2);
68
- const r = Math.round((R * 1) / 2);
69
-
70
- for (let i = min; i <= max; i++) {
71
- // 画刻度线
72
- const y = getYByValue(node, i);
73
- ctx.beginPath();
74
- ctx.moveTo(R + r, y);
75
- if (i % 10 == 0) {
76
- ctx.lineWidth = 2;
77
- ctx.lineTo(R + r - (r * 2) / 3, y);
78
- // ctx.font = "15px bold";
79
- ctx.fillText(i + '', R + r, y + 6);
80
- ctx.stroke();
81
- } else {
82
- ctx.lineWidth = 1;
83
- if (i % 5 == 0) {
84
- ctx.lineTo(R + r - r / 2, y);
85
- } else {
86
- ctx.lineTo(R + r - r / 3, y);
87
- }
88
- ctx.stroke();
89
- }
67
+ const min = 0;
68
+ const max = 40;
69
+ const R = Math.floor((node.rect.width - 6) / 2);
70
+ const r = Math.round((R * 1) / 2);
71
+
72
+ for (let i = min; i <= max; i++) {
73
+ // 画刻度线
74
+ const y = getYByValue(node, i);
75
+ ctx.beginPath();
76
+ ctx.moveTo(R + r, y);
77
+ if (i % 10 == 0) {
78
+ ctx.lineWidth = 2;
79
+ ctx.lineTo(R + r - (r * 2) / 3, y);
80
+ // ctx.font = "15px bold";
81
+ ctx.fillText(i + '', R + r, y + 6);
82
+ ctx.stroke();
83
+ } else {
84
+ ctx.lineWidth = 1;
85
+ if (i % 5 == 0) {
86
+ ctx.lineTo(R + r - r / 2, y);
87
+ } else {
88
+ ctx.lineTo(R + r - r / 3, y);
89
+ }
90
+ ctx.stroke();
90
91
  }
92
+ }
91
93
  }
92
94
 
93
95
  /////////////////////
@@ -96,101 +98,102 @@ function drawScale(ctx, node) {
96
98
 
97
99
  // 自定义图形库绘画函数
98
100
  export function thermometer(ctx, node) {
99
- ctx.beginPath();
100
-
101
- drawOuterLine(ctx, node);
102
- drawBasic(ctx, node);
103
- ctx.clearRect(
104
- node.rect.x,
105
- node.rect.y,
106
- node.rect.width,
107
- getYByValue(node, node.value)
108
- );
109
- drawOuterLine(ctx, node);
110
- drawScale(ctx, node);
101
+ ctx.beginPath();
102
+
103
+ drawOuterLine(ctx, node);
104
+ drawBasic(ctx, node);
105
+ ctx.clearRect(
106
+ node.rect.x,
107
+ node.rect.y,
108
+ node.rect.width,
109
+ getYByValue(node, node.value)
110
+ );
111
+ drawOuterLine(ctx, node);
112
+ drawScale(ctx, node);
111
113
  }
112
114
 
113
115
  // 自定义图形库绘画函数
114
116
  export function pool(ctx, node) {
115
- var wr = node.borderRadius;
116
- var hr = node.borderRadius;
117
- if (node.borderRadius < 1) {
118
- wr = node.rect.width * node.borderRadius;
119
- hr = node.rect.height * node.borderRadius;
120
- }
121
- var r = wr < hr ? wr : hr;
122
- if (node.rect.width < 2 * r) {
123
- r = node.rect.width / 2;
124
- }
125
- if (node.rect.height < 2 * r) {
126
- r = node.rect.height / 2;
127
- }
128
- ctx.beginPath();
129
- ctx.strokeStyle = "rgba(0,0,0,.0)"
130
- var value = (1-node.value) * (node.rect.height - node.lineWidth/2)
131
- ctx.moveTo(node.rect.x + node.lineWidth/2, node.rect.y + value);
132
- ctx.lineTo(node.rect.ex - node.lineWidth/2, node.rect.y + value);
133
- ctx.arcTo(node.rect.ex - node.lineWidth/2, node.rect.y + node.rect.height - node.lineWidth/2, node.rect.x + node.lineWidth/2, node.rect.y + node.rect.height - node.lineWidth/2, r);
134
- ctx.arcTo(node.rect.x + node.lineWidth/2, node.rect.y + node.rect.height - node.lineWidth/2, node.rect.x + node.lineWidth/2, node.rect.y, r);
135
- ctx.lineTo(node.rect.x + node.lineWidth/2, node.rect.y + value);
136
- ctx.closePath();
137
- (node.fillStyle || node.bkType) && ctx.fill();
138
- ctx.stroke();
139
-
140
- ctx.beginPath();
141
- ctx.strokeStyle = node.strokeStyle
142
- ctx.lineWidth = node.lineWidth
143
- ctx.moveTo(node.rect.x + node.rect.width, node.rect.y);
144
- ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r);
145
- ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r);
146
- ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r);
147
- // ctx.closePath();
148
- (node.fillStyle || node.bkType);
149
- ctx.stroke();
117
+ var wr = node.borderRadius;
118
+ var hr = node.borderRadius;
119
+ if (node.borderRadius < 1) {
120
+ wr = node.rect.width * node.borderRadius;
121
+ hr = node.rect.height * node.borderRadius;
122
+ }
123
+ var r = wr < hr ? wr : hr;
124
+ if (node.rect.width < 2 * r) {
125
+ r = node.rect.width / 2;
126
+ }
127
+ if (node.rect.height < 2 * r) {
128
+ r = node.rect.height / 2;
129
+ }
130
+ ctx.beginPath();
131
+ ctx.strokeStyle = "rgba(0,0,0,.0)"
132
+ var value = (1-node.value) * (node.rect.height - node.lineWidth/2)
133
+ ctx.moveTo(node.rect.x + node.lineWidth/2, node.rect.y + value);
134
+ ctx.lineTo(node.rect.ex - node.lineWidth/2, node.rect.y + value);
135
+ ctx.arcTo(node.rect.ex - node.lineWidth/2, node.rect.y + node.rect.height - node.lineWidth/2, node.rect.x + node.lineWidth/2, node.rect.y + node.rect.height - node.lineWidth/2, r);
136
+ ctx.arcTo(node.rect.x + node.lineWidth/2, node.rect.y + node.rect.height - node.lineWidth/2, node.rect.x + node.lineWidth/2, node.rect.y, r);
137
+ ctx.lineTo(node.rect.x + node.lineWidth/2, node.rect.y + value);
138
+ ctx.closePath();
139
+ (node.fillStyle || node.bkType) && ctx.fill();
140
+ ctx.stroke();
141
+
142
+ ctx.beginPath();
143
+ ctx.strokeStyle = node.strokeStyle
144
+ ctx.lineWidth = node.lineWidth
145
+ ctx.moveTo(node.rect.x + node.rect.width, node.rect.y);
146
+ ctx.arcTo(node.rect.x + node.rect.width, node.rect.y + node.rect.height, node.rect.x, node.rect.y + node.rect.height, r);
147
+ ctx.arcTo(node.rect.x, node.rect.y + node.rect.height, node.rect.x, node.rect.y, r);
148
+ ctx.arcTo(node.rect.x, node.rect.y, node.rect.x + node.rect.width, node.rect.y, r);
149
+ // ctx.closePath();
150
+ (node.fillStyle || node.bkType);
151
+ ctx.stroke();
150
152
  }
151
153
 
152
154
  // 自定义图形库绘画函数
153
155
  export function electricFan(ctx, node) {
154
- var wwr = node.rect.width / 2;
155
- var hwr = node.rect.height / 2;
156
- var hwr = node.rect.height / 2;
157
- var x0 = node.rect.x + node.rect.width /2
158
- var y0 = node.rect.y + node.rect.height / 2
159
- var withinRadius = wwr < hwr ? wwr : hwr;
160
- ctx.beginPath();
161
- ctx.lineWidth = node.lineWidth
162
- ctx.arc(x0,y0,withinRadius,0,2*Math.PI);
163
- ctx.closePath();
164
- ctx.stroke();
165
- ctx.beginPath();
166
- ctx.lineWidth = 1;
167
- var fanCount = node.fanCount;
168
- for(var i = 0; i < fanCount; i++){
169
- var fanAngle = 2 * Math.PI / fanCount * i;
170
- var x1 = x0 - withinRadius*Math.sin(fanAngle);
171
- var y1 = y0 - withinRadius*Math.cos(fanAngle);
172
- var xr = x0 - withinRadius*Math.sin(fanAngle)/2;
173
- var yr = y0 - withinRadius*Math.cos(fanAngle)/2;
174
- ctx.moveTo(x0, y0);
175
- ctx.lineTo(x1, y1);
176
- ctx.arc(xr, yr, withinRadius/2, Math.PI / 2 - fanAngle,3 * Math.PI / 2 - fanAngle);
177
- }
178
- ctx.closePath();
179
- (node.fillStyle || node.bkType) && ctx.fill();
180
- ctx.stroke();
181
- ctx.beginPath();
182
- ctx.lineWidth = 3;
183
- ctx.arc(x0,y0,withinRadius/5,0,2*Math.PI);
184
- ctx.closePath();
185
- (node.fillStyle || node.bkType) && ctx.fill();
186
- ctx.stroke();
156
+ var wwr = node.rect.width / 2;
157
+ var hwr = node.rect.height / 2;
158
+ var hwr = node.rect.height / 2;
159
+ var x0 = node.rect.x + node.rect.width /2
160
+ var y0 = node.rect.y + node.rect.height / 2
161
+ var withinRadius = wwr < hwr ? wwr : hwr;
162
+ ctx.beginPath();
163
+ ctx.lineWidth = node.lineWidth
164
+ ctx.arc(x0,y0,withinRadius,0,2*Math.PI);
165
+ ctx.closePath();
166
+ ctx.stroke();
167
+ ctx.beginPath();
168
+ ctx.lineWidth = 1;
169
+ var fanCount = node.fanCount;
170
+ for(var i = 0; i < fanCount; i++){
171
+ var fanAngle = 2 * Math.PI / fanCount * i;
172
+ var x1 = x0 - withinRadius*Math.sin(fanAngle);
173
+ var y1 = y0 - withinRadius*Math.cos(fanAngle);
174
+ var xr = x0 - withinRadius*Math.sin(fanAngle)/2;
175
+ var yr = y0 - withinRadius*Math.cos(fanAngle)/2;
176
+ ctx.moveTo(x0, y0);
177
+ ctx.lineTo(x1, y1);
178
+ ctx.arc(xr, yr, withinRadius/2, Math.PI / 2 - fanAngle,3 * Math.PI / 2 - fanAngle);
179
+ }
180
+ ctx.closePath();
181
+ (node.fillStyle || node.bkType) && ctx.fill();
182
+ ctx.stroke();
183
+ ctx.beginPath();
184
+ ctx.lineWidth = 3;
185
+ ctx.arc(x0,y0,withinRadius/5,0,2*Math.PI);
186
+ ctx.closePath();
187
+ (node.fillStyle || node.bkType) && ctx.fill();
188
+ ctx.stroke();
187
189
  }
188
190
 
189
191
  // 注册自定义图形库
190
192
  export function registerMyShape() {
191
- registerNode('electricFan', electricFan);
192
- registerNode('pool', pool);
193
- registerNode('thermometer', thermometer);
193
+ registerNode('electricFan', electricFan);
194
+ registerNode('pool', pool);
195
+ registerNode('thermometer', thermometer);
196
+ registerNode('formOverflow', formOverflow);
194
197
  }
195
198
 
196
199
  // src\views\data.ts 里面加载到工具栏,第一个就是此自定义图形库
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dcim-topology2d",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "",
5
5
  "main": "-",
6
6
  "scripts": {
@@ -3,7 +3,7 @@ export const echartsLegendDefaultData = {
3
3
  icon: 'rect', // 图标类型:'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow', 'none'
4
4
  itemWidth: 12, // 图标宽
5
5
  itemHeight: 12, // 图标高
6
- itemGap: 8, // 图例之间的间隔 number
6
+ itemGap: 8, // 图例之间的间隔
7
7
  top: '0%', // 图例距离容器上边位置
8
8
  right: 'auto', // 图例距离容器右边位置
9
9
  bottom: 'auto', // 图例距离容器下边位置
@@ -155,5 +155,13 @@ export const echartsColorData = [
155
155
  'rgb(68, 237, 146)',
156
156
  'rgb(251, 94, 45)',
157
157
  'rgb(18, 255, 113)',
158
- 'rgb(18, 255, 113)']
159
-
158
+ 'rgb(18, 255, 113)'];
159
+ // TOP排行榜默认颜色
160
+ export const rankingTopColorList = [
161
+ 'rgba(239, 120, 66, .6)',
162
+ 'rgba(255, 225, 65, .5)',
163
+ 'rgba(55, 240, 151, .5)',
164
+ 'rgba(72, 211, 255, .6)',
165
+ 'rgba(67, 153, 255, .5)'
166
+ ];
167
+ export const rankingTopImageName = ['orange', 'yellow', 'ching', 'lightBlue', 'blue'];