Commit 83502dce7bdd98d64bf1f8a3042386efd072b4a5
Merge branch 'ww' into 'main'
feat: implement chart component render && fix some problem See merge request huang/thingskit-drawio!26
Showing
9 changed files
with
135 additions
and
123 deletions
Too many changes to show.
To preserve performance only 9 of 10 files are displayed.
src/main/webapp/images/thingskit/empty.png
0 → 100644
2.41 KB
src/main/webapp/images/thingskit/empty.svg
0 → 100644
1 | +<svg viewBox="0 0 79 86" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><linearGradient id="linearGradient-1-1" x1="38.8503086%" y1="0%" x2="61.1496914%" y2="100%"><stop stop-color="#FCFCFD" offset="0%"></stop><stop stop-color="#EEEFF3" offset="100%"></stop></linearGradient><linearGradient id="linearGradient-2-1" x1="0%" y1="9.5%" x2="100%" y2="90.5%"><stop stop-color="#FCFCFD" offset="0%"></stop><stop stop-color="#E9EBEF" offset="100%"></stop></linearGradient><rect id="path-3-1" x="0" y="0" width="17" height="36"></rect></defs><g id="Illustrations" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="B-type" transform="translate(-1268.000000, -535.000000)"><g id="Group-2" transform="translate(1268.000000, 535.000000)"><path id="Oval-Copy-2" d="M39.5,86 C61.3152476,86 79,83.9106622 79,81.3333333 C79,78.7560045 57.3152476,78 35.5,78 C13.6847524,78 0,78.7560045 0,81.3333333 C0,83.9106622 17.6847524,86 39.5,86 Z" fill="#F7F8FC"></path><polygon id="Rectangle-Copy-14" fill="#E5E7E9" transform="translate(27.500000, 51.500000) scale(1, -1) translate(-27.500000, -51.500000) " points="13 58 53 58 42 45 2 45"></polygon><g id="Group-Copy" transform="translate(34.500000, 31.500000) scale(-1, 1) rotate(-25.000000) translate(-34.500000, -31.500000) translate(7.000000, 10.000000)"><polygon id="Rectangle-Copy-10" fill="#E5E7E9" transform="translate(11.500000, 5.000000) scale(1, -1) translate(-11.500000, -5.000000) " points="2.84078316e-14 3 18 3 23 7 5 7"></polygon><polygon id="Rectangle-Copy-11" fill="#EDEEF2" points="-3.69149156e-15 7 38 7 38 43 -3.69149156e-15 43"></polygon><rect id="Rectangle-Copy-12" fill="url(#linearGradient-1-1)" transform="translate(46.500000, 25.000000) scale(-1, 1) translate(-46.500000, -25.000000) " x="38" y="7" width="17" height="36"></rect><polygon id="Rectangle-Copy-13" fill="#F8F9FB" transform="translate(39.500000, 3.500000) scale(-1, 1) translate(-39.500000, -3.500000) " points="24 7 41 7 55 -3.63806207e-12 38 -3.63806207e-12"></polygon></g><rect id="Rectangle-Copy-15" fill="url(#linearGradient-2-1)" x="13" y="45" width="40" height="36"></rect><g id="Rectangle-Copy-17" transform="translate(53.000000, 45.000000)"><mask id="mask-4-1" fill="white"><use xlink:href="#path-3-1"></use></mask><use id="Mask" fill="#E0E3E9" transform="translate(8.500000, 18.000000) scale(-1, 1) translate(-8.500000, -18.000000) " xlink:href="#path-3-1"></use><polygon id="Rectangle-Copy" fill="#D5D7DE" mask="url(#mask-4-1)" transform="translate(12.000000, 9.000000) scale(-1, 1) translate(-12.000000, -9.000000) " points="7 0 24 0 20 18 -1.70530257e-13 16"></polygon></g><polygon id="Rectangle-Copy-18" fill="#F8F9FB" transform="translate(66.000000, 51.500000) scale(-1, 1) translate(-66.000000, -51.500000) " points="62 45 79 45 70 58 53 58"></polygon></g></g></g></svg> | ... | ... |
... | ... | @@ -5030,6 +5030,9 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { |
5030 | 5030 | lastModifiedDate: new Date() |
5031 | 5031 | }; |
5032 | 5032 | this.openFileHandle(Editor.defaultContent, Editor.configurationName, file, false, fileHandle); |
5033 | + // TODO thingsKit 初始化图表 | |
5034 | + const graph = this.editor.graph | |
5035 | + Sidebar.prototype.initChartInstance(graph) | |
5033 | 5036 | //加载数据结束 |
5034 | 5037 | |
5035 | 5038 | // if (id == null || id.length == 0) | ... | ... |
... | ... | @@ -8,10 +8,9 @@ |
8 | 8 | * @param {number} x X-coordinate of the point. |
9 | 9 | * @param {number} y Y-coordinate of the point. |
10 | 10 | */ |
11 | -LocalFile = function(ui, data, title, temp, fileHandle, desc) | |
12 | -{ | |
11 | +LocalFile = function (ui, data, title, temp, fileHandle, desc) { | |
13 | 12 | DrawioFile.call(this, ui, data); |
14 | - | |
13 | + | |
15 | 14 | this.title = title; |
16 | 15 | this.mode = (temp) ? null : App.MODE_DEVICE; |
17 | 16 | this.fileHandle = fileHandle; |
... | ... | @@ -27,8 +26,7 @@ mxUtils.extend(LocalFile, DrawioFile); |
27 | 26 | * @param {number} dx X-coordinate of the translation. |
28 | 27 | * @param {number} dy Y-coordinate of the translation. |
29 | 28 | */ |
30 | -LocalFile.prototype.isAutosave = function() | |
31 | -{ | |
29 | +LocalFile.prototype.isAutosave = function () { | |
32 | 30 | return this.fileHandle != null && !this.invalidFileHandle && DrawioFile.prototype.isAutosave.apply(this, arguments); |
33 | 31 | }; |
34 | 32 | |
... | ... | @@ -36,8 +34,7 @@ LocalFile.prototype.isAutosave = function() |
36 | 34 | * Specifies if the autosave checkbox should be shown in the document |
37 | 35 | * properties dialog. Default is false. |
38 | 36 | */ |
39 | -LocalFile.prototype.isAutosaveOptional = function() | |
40 | -{ | |
37 | +LocalFile.prototype.isAutosaveOptional = function () { | |
41 | 38 | return this.fileHandle != null; |
42 | 39 | }; |
43 | 40 | |
... | ... | @@ -47,8 +44,7 @@ LocalFile.prototype.isAutosaveOptional = function() |
47 | 44 | * @param {number} dx X-coordinate of the translation. |
48 | 45 | * @param {number} dy Y-coordinate of the translation. |
49 | 46 | */ |
50 | -LocalFile.prototype.getMode = function() | |
51 | -{ | |
47 | +LocalFile.prototype.getMode = function () { | |
52 | 48 | return this.mode; |
53 | 49 | }; |
54 | 50 | |
... | ... | @@ -58,8 +54,7 @@ LocalFile.prototype.getMode = function() |
58 | 54 | * @param {number} dx X-coordinate of the translation. |
59 | 55 | * @param {number} dy Y-coordinate of the translation. |
60 | 56 | */ |
61 | -LocalFile.prototype.getTitle = function() | |
62 | -{ | |
57 | +LocalFile.prototype.getTitle = function () { | |
63 | 58 | return this.title; |
64 | 59 | }; |
65 | 60 | |
... | ... | @@ -69,8 +64,7 @@ LocalFile.prototype.getTitle = function() |
69 | 64 | * @param {number} dx X-coordinate of the translation. |
70 | 65 | * @param {number} dy Y-coordinate of the translation. |
71 | 66 | */ |
72 | -LocalFile.prototype.isRenamable = function() | |
73 | -{ | |
67 | +LocalFile.prototype.isRenamable = function () { | |
74 | 68 | return true; |
75 | 69 | }; |
76 | 70 | |
... | ... | @@ -80,8 +74,7 @@ LocalFile.prototype.isRenamable = function() |
80 | 74 | * @param {number} dx X-coordinate of the translation. |
81 | 75 | * @param {number} dy Y-coordinate of the translation. |
82 | 76 | */ |
83 | -LocalFile.prototype.save = function(revision, success, error) | |
84 | -{ | |
77 | +LocalFile.prototype.save = function (revision, success, error) { | |
85 | 78 | this.saveAs(this.title, success, error); |
86 | 79 | }; |
87 | 80 | |
... | ... | @@ -91,8 +84,7 @@ LocalFile.prototype.save = function(revision, success, error) |
91 | 84 | * @param {number} dx X-coordinate of the translation. |
92 | 85 | * @param {number} dy Y-coordinate of the translation. |
93 | 86 | */ |
94 | -LocalFile.prototype.saveAs = function(title, success, error) | |
95 | -{ | |
87 | +LocalFile.prototype.saveAs = function (title, success, error) { | |
96 | 88 | this.saveFile(title, false, success, error); |
97 | 89 | }; |
98 | 90 | |
... | ... | @@ -102,24 +94,21 @@ LocalFile.prototype.saveAs = function(title, success, error) |
102 | 94 | * @param {number} dx X-coordinate of the translation. |
103 | 95 | * @param {number} dy Y-coordinate of the translation. |
104 | 96 | */ |
105 | -LocalFile.prototype.saveAs = function(title, success, error) | |
106 | -{ | |
97 | +LocalFile.prototype.saveAs = function (title, success, error) { | |
107 | 98 | this.saveFile(title, false, success, error); |
108 | 99 | }; |
109 | 100 | |
110 | 101 | /** |
111 | 102 | * Adds all listeners. |
112 | 103 | */ |
113 | -LocalFile.prototype.getDescriptor = function() | |
114 | -{ | |
104 | +LocalFile.prototype.getDescriptor = function () { | |
115 | 105 | return this.desc; |
116 | 106 | }; |
117 | 107 | |
118 | 108 | /** |
119 | 109 | * Updates the descriptor of this file with the one from the given file. |
120 | 110 | */ |
121 | -LocalFile.prototype.setDescriptor = function(desc) | |
122 | -{ | |
111 | +LocalFile.prototype.setDescriptor = function (desc) { | |
123 | 112 | this.desc = desc; |
124 | 113 | }; |
125 | 114 | |
... | ... | @@ -129,14 +118,11 @@ LocalFile.prototype.setDescriptor = function(desc) |
129 | 118 | * @param {number} dx X-coordinate of the translation. |
130 | 119 | * @param {number} dy Y-coordinate of the translation. |
131 | 120 | */ |
132 | -LocalFile.prototype.getLatestVersion = function(success, error) | |
133 | -{ | |
134 | - if (this.fileHandle == null) | |
135 | - { | |
121 | +LocalFile.prototype.getLatestVersion = function (success, error) { | |
122 | + if (this.fileHandle == null) { | |
136 | 123 | success(null); |
137 | 124 | } |
138 | - else | |
139 | - { | |
125 | + else { | |
140 | 126 | this.ui.loadFileSystemEntry(this.fileHandle, success, error); |
141 | 127 | } |
142 | 128 | }; |
... | ... | @@ -147,69 +133,60 @@ LocalFile.prototype.getLatestVersion = function(success, error) |
147 | 133 | * @param {number} dx X-coordinate of the translation. |
148 | 134 | * @param {number} dy Y-coordinate of the translation. |
149 | 135 | */ |
150 | -LocalFile.prototype.saveFile = function(title, revision, success, error, useCurrentData) | |
151 | -{ | |
152 | - if (title != this.title) | |
153 | - { | |
136 | +LocalFile.prototype.saveFile = function (title, revision, success, error, useCurrentData) { | |
137 | + if (title != this.title) { | |
154 | 138 | this.fileHandle = null; |
155 | 139 | this.desc = null; |
156 | 140 | } |
157 | - | |
141 | + | |
158 | 142 | this.title = title; |
159 | 143 | |
160 | 144 | // Updates data after changing file name |
161 | - if (!useCurrentData) | |
162 | - { | |
145 | + if (!useCurrentData) { | |
163 | 146 | this.updateFileData(); |
164 | 147 | } |
165 | - | |
148 | + | |
166 | 149 | var binary = this.ui.useCanvasForExport && /(\.png)$/i.test(this.getTitle()); |
167 | 150 | this.setShadowModified(false); |
168 | 151 | var savedData = this.getData(); |
169 | - | |
170 | - var done = mxUtils.bind(this, function() | |
171 | - { | |
152 | + | |
153 | + var done = mxUtils.bind(this, function () { | |
172 | 154 | this.setModified(this.getShadowModified()); |
173 | 155 | this.contentChanged(); |
174 | - | |
175 | - if (success != null) | |
176 | - { | |
156 | + | |
157 | + if (success != null) { | |
177 | 158 | success(); |
178 | 159 | } |
179 | 160 | }); |
180 | - | |
181 | - var doSave = mxUtils.bind(this, function(data) | |
182 | - { | |
183 | - if (this.fileHandle != null) | |
184 | - { | |
161 | + | |
162 | + var doSave = mxUtils.bind(this, function (data) { | |
163 | + if (this.fileHandle != null) { | |
185 | 164 | // Sets shadow modified state during save |
186 | - if (!this.savingFile) | |
187 | - { | |
165 | + if (!this.savingFile) { | |
188 | 166 | this.savingFileTime = new Date(); |
189 | 167 | this.savingFile = true; |
190 | - | |
191 | - var errorWrapper = mxUtils.bind(this, function(e) | |
192 | - { | |
168 | + | |
169 | + var errorWrapper = mxUtils.bind(this, function (e) { | |
193 | 170 | this.savingFile = false; |
194 | - | |
195 | - if (error != null) | |
196 | - { | |
171 | + | |
172 | + if (error != null) { | |
197 | 173 | // Wraps error object to offer save status option |
198 | - error({error: e}); | |
174 | + error({ error: e }); | |
199 | 175 | } |
200 | 176 | }); |
201 | - | |
177 | + | |
202 | 178 | // Saves a copy as a draft while saving |
203 | 179 | this.saveDraft(); |
204 | 180 | // 修改开始 |
205 | - try | |
206 | - { | |
181 | + try { | |
207 | 182 | //调用API,保存数据到数据库 |
208 | - var desc = {name: Editor.configurationName, | |
209 | - type: "", | |
210 | - webkitRelativePath: "", | |
211 | - lastModified: new Date().getTime(), | |
212 | - lastModifiedDate: new Date()}; | |
183 | + var desc = { | |
184 | + name: Editor.configurationName, | |
185 | + type: "", | |
186 | + webkitRelativePath: "", | |
187 | + lastModified: new Date().getTime(), | |
188 | + lastModifiedDate: new Date() | |
189 | + }; | |
213 | 190 | this.savingFile = false; |
214 | 191 | this.desc = desc; |
215 | 192 | this.fileSaved(savedData, this.desc, done, errorWrapper); |
... | ... | @@ -217,17 +194,25 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr |
217 | 194 | // Deletes draft after saving |
218 | 195 | this.removeDraft(); |
219 | 196 | Editor.defaultContent = savedData; |
220 | - var configurationContentList=[]; | |
221 | - var configurationContent = {"name":"第 1 页", | |
222 | - "id":Editor.configurationContentId,"content":savedData,"type":1}; | |
197 | + var configurationContentList = []; | |
198 | + const basicAttr = Sidebar.prototype.enumCellBasicAttribute | |
199 | + const allCell = (this.ui.editor.graph.getDefaultParent().children || []).filter(item => item.getAttribute(basicAttr.COMPONENT_TYPE)) | |
200 | + const contentId = this.ui.currentPage.node.id | |
201 | + var configurationContent = { | |
202 | + name: "第 1 页", | |
203 | + id: Editor.configurationContentId, | |
204 | + contentId, | |
205 | + content: savedData, | |
206 | + type: 1, | |
207 | + nodeIds: allCell.map(item => item.id) | |
208 | + }; | |
223 | 209 | configurationContentList.push(configurationContent); |
224 | - var parmam = {"configurationId":Editor.configurationId,"configurationContentList":configurationContentList}; | |
225 | - defHttp.put("/yt/configuration/content",parmam).then(res=>{ | |
210 | + var parmam = { configurationId: Editor.configurationId, configurationContentList }; | |
211 | + defHttp.put("/yt/configuration/content", parmam).then(res => { | |
226 | 212 | console.log(res) |
227 | 213 | }) |
228 | 214 | } |
229 | - catch (e) | |
230 | - { | |
215 | + catch (e) { | |
231 | 216 | errorWrapper(e); |
232 | 217 | } |
233 | 218 | // 修改结束 |
... | ... | @@ -277,20 +262,16 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr |
277 | 262 | // }), errorWrapper); |
278 | 263 | } |
279 | 264 | } |
280 | - else | |
281 | - { | |
282 | - if (this.ui.isOfflineApp() || this.ui.isLocalFileSave()) | |
283 | - { | |
265 | + else { | |
266 | + if (this.ui.isOfflineApp() || this.ui.isLocalFileSave()) { | |
284 | 267 | this.ui.doSaveLocalFile(data, title, (binary) ? |
285 | 268 | 'image/png' : 'text/xml', binary); |
286 | 269 | } |
287 | - else | |
288 | - { | |
289 | - if (data.length < MAX_REQUEST_SIZE) | |
290 | - { | |
270 | + else { | |
271 | + if (data.length < MAX_REQUEST_SIZE) { | |
291 | 272 | var dot = title.lastIndexOf('.'); |
292 | 273 | var format = (dot > 0) ? title.substring(dot + 1) : 'xml'; |
293 | - | |
274 | + | |
294 | 275 | // Do not update modified flag |
295 | 276 | new mxXmlRequest(SAVE_URL, 'format=' + format + |
296 | 277 | '&xml=' + encodeURIComponent(data) + |
... | ... | @@ -298,31 +279,26 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr |
298 | 279 | ((binary) ? '&binary=1' : '')). |
299 | 280 | simulate(document, '_blank'); |
300 | 281 | } |
301 | - else | |
302 | - { | |
303 | - this.ui.handleError({message: mxResources.get('drawingTooLarge')}, mxResources.get('error'), mxUtils.bind(this, function() | |
304 | - { | |
282 | + else { | |
283 | + this.ui.handleError({ message: mxResources.get('drawingTooLarge') }, mxResources.get('error'), mxUtils.bind(this, function () { | |
305 | 284 | mxUtils.popup(data); |
306 | 285 | })); |
307 | 286 | } |
308 | 287 | } |
309 | - | |
288 | + | |
310 | 289 | done(); |
311 | 290 | } |
312 | 291 | }); |
313 | - | |
314 | - if (binary) | |
315 | - { | |
292 | + | |
293 | + if (binary) { | |
316 | 294 | var p = this.ui.getPngFileProperties(this.ui.fileNode); |
317 | 295 | |
318 | - this.ui.getEmbeddedPng(mxUtils.bind(this, function(imageData) | |
319 | - { | |
296 | + this.ui.getEmbeddedPng(mxUtils.bind(this, function (imageData) { | |
320 | 297 | doSave(imageData); |
321 | 298 | }), error, (this.ui.getCurrentFile() != this) ? |
322 | 299 | savedData : null, p.scale, p.border); |
323 | 300 | } |
324 | - else | |
325 | - { | |
301 | + else { | |
326 | 302 | doSave(savedData); |
327 | 303 | } |
328 | 304 | }; |
... | ... | @@ -333,13 +309,11 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr |
333 | 309 | * @param {number} dx X-coordinate of the translation. |
334 | 310 | * @param {number} dy Y-coordinate of the translation. |
335 | 311 | */ |
336 | -LocalFile.prototype.rename = function(title, success, error) | |
337 | -{ | |
312 | +LocalFile.prototype.rename = function (title, success, error) { | |
338 | 313 | this.title = title; |
339 | 314 | this.descriptorChanged(); |
340 | - | |
341 | - if (success != null) | |
342 | - { | |
315 | + | |
316 | + if (success != null) { | |
343 | 317 | success(); |
344 | 318 | } |
345 | 319 | }; |
... | ... | @@ -348,8 +322,7 @@ LocalFile.prototype.rename = function(title, success, error) |
348 | 322 | * Returns the location as a new object. |
349 | 323 | * @type mx.Point |
350 | 324 | */ |
351 | -LocalFile.prototype.open = function() | |
352 | -{ | |
325 | +LocalFile.prototype.open = function () { | |
353 | 326 | this.ui.setFileData(this.getData()); |
354 | 327 | this.installListeners(); |
355 | 328 | }; | ... | ... |
... | ... | @@ -993,6 +993,14 @@ EditorUi.prototype.selectPage = function(page, quiet, viewState) |
993 | 993 | catch (e) |
994 | 994 | { |
995 | 995 | this.handleError(e); |
996 | + } finally { | |
997 | + // TODO thingskit instance chart | |
998 | + Sidebar.prototype.chartsInstanceMapping.forEach(item => { | |
999 | + item.dispose() | |
1000 | + }) | |
1001 | + Sidebar.prototype.chartsInstanceMapping.clear() | |
1002 | + const graph = this.editor.graph | |
1003 | + Sidebar.prototype.initChartInstance(graph) | |
996 | 1004 | } |
997 | 1005 | }; |
998 | 1006 | |
... | ... | @@ -2079,4 +2087,4 @@ EditorUi.prototype.createPageMenu = function(page, label) |
2079 | 2087 | }; |
2080 | 2088 | |
2081 | 2089 | mxCodecRegistry.register(codec); |
2082 | -})(); | |
\ No newline at end of file | ||
2090 | +})(); | ... | ... |
... | ... | @@ -166,7 +166,12 @@ |
166 | 166 | /** |
167 | 167 | * @description 组件类型 |
168 | 168 | */ |
169 | - COMPONENT_TYPE: 'componentType' | |
169 | + COMPONENT_TYPE: 'componentType', | |
170 | + | |
171 | + /** | |
172 | + * @description 图表实例ID | |
173 | + */ | |
174 | + CHART_INSTANCE_ID: 'chartInstanceId' | |
170 | 175 | } |
171 | 176 | |
172 | 177 | /** |
... | ... | @@ -248,7 +253,9 @@ |
248 | 253 | */ |
249 | 254 | Sidebar.prototype.enumPermissionPanel = { |
250 | 255 | DATA_SOURCE: 'dataSource', |
251 | - DISPLAY_TYPE: 'displayType', | |
256 | + // DISPLAY_TYPE: 'displayType', | |
257 | + LINE_CHART_EXPAND: 'lineChartExpandDataSource', | |
258 | + BAR_CHART_EXPAND: 'barChartExpandDataSource', | |
252 | 259 | INTERACTION: 'interaction', |
253 | 260 | DYNAMIC_EFFECT: 'dynamicEffect', |
254 | 261 | VAR_IMAGE: 'variableImage' |
... | ... | @@ -596,6 +603,7 @@ |
596 | 603 | // Defines all entries for the sidebar. This is used in the MoreShapes dialog. Create screenshots using the savesidebar URL parameter and |
597 | 604 | // http://www.alderg.com/merge.html for creating a vertical stack of PNG images if multiple sidebars are part of an entry. |
598 | 605 | //更多图形里面的加载,可以加载自己定义的图形库,同时要提供对应的图片 |
606 | + var stdEntries = [] | |
599 | 607 | // var stdEntries = [{title: mxResources.get('general'), id: 'general', image: IMAGE_PATH + '/sidebar-general.png'}, |
600 | 608 | // {title: mxResources.get('basic'), id: 'basic', image: IMAGE_PATH + '/sidebar-basic.png'}, |
601 | 609 | // {title: mxResources.get('arrows'), id: 'arrows2', image: IMAGE_PATH + '/sidebar-arrows2.png'}, |
... | ... | @@ -604,7 +612,7 @@ |
604 | 612 | //更多图形,显示出来的的标题跟id,同时包括图片 |
605 | 613 | |
606 | 614 | // TODO thingsKit 设置数据绑定展示面板 |
607 | - const { DISPLAY_TYPE, DYNAMIC_EFFECT, DATA_SOURCE, VAR_IMAGE, INTERACTION } = this.enumPermissionPanel | |
615 | + const { LINE_CHART_EXPAND, BAR_CHART_EXPAND, DYNAMIC_EFFECT, DATA_SOURCE, VAR_IMAGE, INTERACTION } = this.enumPermissionPanel | |
608 | 616 | const { LINE, LINE_CHART, REAL_TIME, TITLE, VARIABLE, DEFAULT, BAR_CHART } = this.enumComponentType |
609 | 617 | this.setComponentPermission(LINE, [DYNAMIC_EFFECT]) |
610 | 618 | this.setComponentPermission(DEFAULT, [DYNAMIC_EFFECT]) |
... | ... | @@ -612,8 +620,8 @@ |
612 | 620 | this.setComponentPermission(TITLE, [INTERACTION, DYNAMIC_EFFECT]) |
613 | 621 | this.setComponentPermission(VAR_IMAGE, [DATA_SOURCE, INTERACTION, VAR_IMAGE]) |
614 | 622 | this.setComponentPermission(VARIABLE, [DATA_SOURCE, INTERACTION, DYNAMIC_EFFECT]) |
615 | - this.setComponentPermission(BAR_CHART, [DATA_SOURCE, DISPLAY_TYPE, DYNAMIC_EFFECT]) | |
616 | - this.setComponentPermission(LINE_CHART, [DATA_SOURCE, DISPLAY_TYPE, DYNAMIC_EFFECT]) | |
623 | + this.setComponentPermission(BAR_CHART, [DATA_SOURCE, BAR_CHART_EXPAND, DYNAMIC_EFFECT]) | |
624 | + this.setComponentPermission(LINE_CHART, [DATA_SOURCE, LINE_CHART_EXPAND, DYNAMIC_EFFECT]) | |
617 | 625 | |
618 | 626 | var thingskitEntries = [ |
619 | 627 | { title: "风机", id: 'fan', image: IMAGE_PATH + '/thingskit/风机.png' }, | ... | ... |
... | ... | @@ -36,7 +36,7 @@ |
36 | 36 | return this.createEdgeTemplateFromCells([ cell ], 60, 40, '线条'); |
37 | 37 | })), |
38 | 38 | this.addEntry('real time', mxUtils.bind(this, function () { |
39 | - const template = `<div class="thingKit-component__real-time"><div class="real-time__date"></div> <div style="font-size:30px" class="real-time__now">时间</div></div>` | |
39 | + const template = `<div class="thingKit-component__real-time"><div class="real-time__date">%currentDate%</div> <div style="font-size:30px" class="real-time__now">HH:mm:ss</div></div>` | |
40 | 40 | const cell = new mxCell(template, new mxGeometry(0, 0, 180, 60), 'text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;overflow=hidden;'); |
41 | 41 | cell.vertex = true; |
42 | 42 | this.setCellAttributes(cell, { | ... | ... |
... | ... | @@ -24,7 +24,7 @@ |
24 | 24 | /** |
25 | 25 | * @description cell id key |
26 | 26 | */ |
27 | - CHART_CELL_ID: 'chartInstanceId', | |
27 | + CHART_INSTANCE_ID: 'chartInstanceId', | |
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @description 图表容器 class name |
... | ... | @@ -143,7 +143,7 @@ |
143 | 143 | const basicAttr = this.enumCellBasicAttribute |
144 | 144 | this.setCellAttributes(cell, { |
145 | 145 | [basicAttr.COMPONENT_TYPE]: chartType, |
146 | - [enumConst.CHART_CELL_ID]: id, | |
146 | + [basicAttr.CHART_INSTANCE_ID]: id, | |
147 | 147 | [enumConst.CHART_CELL_WIDTH]: width, |
148 | 148 | [enumConst.CHART_CELL_HEIGHT]: height, |
149 | 149 | }) |
... | ... | @@ -194,6 +194,7 @@ |
194 | 194 | const chartOptionMapping = this.chartOptionMapping |
195 | 195 | const chartsInstanceMapping = this.chartsInstanceMapping |
196 | 196 | const chartDom = document.getElementById(id); |
197 | + if (!chartDom) return | |
197 | 198 | chartDom.style.width = `${width}px` |
198 | 199 | chartDom.style.height = `${height}px` |
199 | 200 | const myChart = echarts.init(chartDom); |
... | ... | @@ -208,7 +209,8 @@ |
208 | 209 | * @returns {*} |
209 | 210 | */ |
210 | 211 | Sidebar.prototype.getCellId = function (cell) { |
211 | - return this.graph.getAttributeForCell(cell, enumConst.CHART_CELL_ID) | |
212 | + const basicAttr = this.enumCellBasicAttribute | |
213 | + return this.graph.getAttributeForCell(cell, basicAttr.CHART_INSTANCE_ID) | |
212 | 214 | } |
213 | 215 | |
214 | 216 | /** |
... | ... | @@ -238,7 +240,7 @@ |
238 | 240 | const id = self.generatorChartsId() |
239 | 241 | const geo = Object.assign(graph.model.getGeometry(cell), { width: 400, height: 400 }) |
240 | 242 | cell.setGeometry(geo) |
241 | - self.graph.setAttributeForCell(cell, enumConst.CHART_CELL_ID, id); | |
243 | + self.graph.setAttributeForCell(cell, basicAttr.CHART_INSTANCE_ID, id); | |
242 | 244 | self.graph.setAttributeForCell(cell, enumConst.CHART_CELL_WIDTH, enumConst.CHART_CELL_DEFAULT_WIDTH); |
243 | 245 | self.graph.setAttributeForCell(cell, enumConst.CHART_CELL_HEIGHT, enumConst.CHART_CELL_DEFAULT_HEIGHT); |
244 | 246 | self.graph.setAttributeForCell(cell, 'label', self.createChartsNode(id)) |
... | ... | @@ -281,7 +283,8 @@ |
281 | 283 | self.graph.setAttributeForCell(cell, enumConst.CHART_CELL_WIDTH, width) |
282 | 284 | self.graph.setAttributeForCell(cell, enumConst.CHART_CELL_HEIGHT, height) |
283 | 285 | const instance = chartsInstanceMapping.get(id) |
284 | - instance.resize() | |
286 | + | |
287 | + instance && instance.resize() | |
285 | 288 | } |
286 | 289 | cellResized.apply(this, arguments) |
287 | 290 | } |
... | ... | @@ -327,10 +330,10 @@ |
327 | 330 | */ |
328 | 331 | Sidebar.prototype.initChartInstance = function (graph) { |
329 | 332 | const basicAttr = this.enumCellBasicAttribute |
330 | - const allCell = graph.getDefaultParent().children | |
333 | + const allCell = graph.getDefaultParent().children || [] | |
331 | 334 | const domIdMapping = new Map() |
332 | 335 | for (const cell of allCell) { |
333 | - const chartInstanceId = graph.getAttributeForCell(cell, enumConst.CHART_CELL_ID) | |
336 | + const chartInstanceId = graph.getAttributeForCell(cell, basicAttr.CHART_INSTANCE_ID) | |
334 | 337 | if (Sidebar.prototype.isChartCell(cell) && chartInstanceId) { |
335 | 338 | const width = graph.getAttributeForCell(cell, enumConst.CHART_CELL_WIDTH) |
336 | 339 | const height = graph.getAttributeForCell(cell, enumConst.CHART_CELL_HEIGHT) |
... | ... | @@ -352,15 +355,17 @@ |
352 | 355 | /** |
353 | 356 | * @description 初始化图表 |
354 | 357 | */ |
355 | - const openFileHandle = EditorUi.prototype.openFileHandle | |
356 | - EditorUi.prototype.openFileHandle = function () { | |
357 | - try { | |
358 | - openFileHandle.apply(this, arguments) | |
359 | - } finally { | |
360 | - const graph = this.editor.graph | |
361 | - Sidebar.prototype.initChartInstance(graph) | |
362 | - } | |
363 | - } | |
358 | + // const openFileHandle = EditorUi.prototype.openFileHandle | |
359 | + // EditorUi.prototype.openFileHandle = function () { | |
360 | + // console.log('enter open file') | |
361 | + // try { | |
362 | + // openFileHandle.apply(this, arguments) | |
363 | + // } finally { | |
364 | + // console.log('openFileHandle') | |
365 | + // const graph = this.editor.graph | |
366 | + // Sidebar.prototype.initChartInstance(graph) | |
367 | + // } | |
368 | + // } | |
364 | 369 | |
365 | 370 | /** |
366 | 371 | * @description 实例化 echarts |
... | ... | @@ -372,5 +377,17 @@ |
372 | 377 | Sidebar.prototype.initChartInstance(this) |
373 | 378 | } |
374 | 379 | } |
380 | + | |
381 | + // const selectPage = EditorUi.prototype.selectPage | |
382 | + // EditorUi.prototype.selectPage = function () { | |
383 | + // try { | |
384 | + // selectPage.apply(this, arguments) | |
385 | + | |
386 | + // } finally { | |
387 | + // Sidebar.prototype.chartsInstanceMapping.clear() | |
388 | + // const graph = this.editor.graph | |
389 | + // Sidebar.prototype.initChartInstance(graph) | |
390 | + // } | |
391 | + // } | |
375 | 392 | })(); |
376 | 393 | ... | ... |
... | ... | @@ -3379,6 +3379,8 @@ EditorUi.prototype.lightboxFit = function(maxHeight) |
3379 | 3379 | this.editor.graph.maxFitScale = this.lightboxMaxFitScale; |
3380 | 3380 | this.editor.graph.fit(border, null, null, null, null, null, maxHeight); |
3381 | 3381 | this.editor.graph.maxFitScale = null; |
3382 | + // TODO thingsKit lightbox 默认缩放为1 | |
3383 | + this.editor.graph.view.setScale(1); | |
3382 | 3384 | } |
3383 | 3385 | }; |
3384 | 3386 | ... | ... |