zbcx_ckyc 1.0.0

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 (249) hide show
  1. package/README.md +3 -0
  2. package/package.json +90 -0
  3. package/src/plugins/app/com/CesiumTool.js +730 -0
  4. package/src/plugins/app/com/MapMethods.js +355 -0
  5. package/src/plugins/app/com/MapTool.vue +772 -0
  6. package/src/plugins/app/com/MenuRouter.vue +157 -0
  7. package/src/plugins/app/com/ParamsDes.vue +35 -0
  8. package/src/plugins/app/com/SelCoorSys.vue +235 -0
  9. package/src/plugins/app/com/WebProj4.js +32 -0
  10. package/src/plugins/app/com/measure.js +127 -0
  11. package/src/plugins/app/com/yx.js +238 -0
  12. package/src/plugins/app/modelmanagement/D3DrawGraph.js +708 -0
  13. package/src/plugins/app/modelmanagement/MineralGo.vue +241 -0
  14. package/src/plugins/app/modelmanagement/MineralModel.vue +1203 -0
  15. package/src/plugins/app/modelmanagement/ModelCloudmap.vue +69 -0
  16. package/src/plugins/app/modelmanagement/ModelMst.vue +60 -0
  17. package/src/plugins/app/modelmanagement/ModelSy.vue +173 -0
  18. package/src/plugins/app/modelmanagement/ModelTp.vue +51 -0
  19. package/src/plugins/app/modelmanagement/ModelUpload.vue +774 -0
  20. package/src/plugins/app/znycpjxt/Api.js +714 -0
  21. package/src/plugins/app/znycpjxt/Bf/AttFactory.js +25 -0
  22. package/src/plugins/app/znycpjxt/Bf/IAnomalyhandle.js +102 -0
  23. package/src/plugins/app/znycpjxt/Bf/IComposeanomaly.js +140 -0
  24. package/src/plugins/app/znycpjxt/Bf/IContinueanaly.js +138 -0
  25. package/src/plugins/app/znycpjxt/Bf/IContrastanaly.js +138 -0
  26. package/src/plugins/app/znycpjxt/Bf/ICustomNode.js +145 -0
  27. package/src/plugins/app/znycpjxt/Bf/IDerivanaly.js +139 -0
  28. package/src/plugins/app/znycpjxt/Bf/IFilterananly.js +141 -0
  29. package/src/plugins/app/znycpjxt/Bf/IMeananaly.js +137 -0
  30. package/src/plugins/app/znycpjxt/Bf/IModelNodeBase.js +135 -0
  31. package/src/plugins/app/znycpjxt/Bf/IMoveaverage.js +135 -0
  32. package/src/plugins/app/znycpjxt/Bf/IReducepole.js +141 -0
  33. package/src/plugins/app/znycpjxt/Bf/ISmoothanaly.js +135 -0
  34. package/src/plugins/app/znycpjxt/Bf/ITrendanaly.js +144 -0
  35. package/src/plugins/app/znycpjxt/Bf/IVector2grd.js +144 -0
  36. package/src/plugins/app/znycpjxt/Bf/IYcfj.js +84 -0
  37. package/src/plugins/app/znycpjxt/Bf/IYcxxjs.js +105 -0
  38. package/src/plugins/app/znycpjxt/Bf/IYgsbtq.js +112 -0
  39. package/src/plugins/app/znycpjxt/Bf/IYgtxrh.js +112 -0
  40. package/src/plugins/app/znycpjxt/Bf/Iinteranaly.js +135 -0
  41. package/src/plugins/app/znycpjxt/Bf/index.js +44 -0
  42. package/src/plugins/app/znycpjxt/Bf/input/InputData.js +21 -0
  43. package/src/plugins/app/znycpjxt/Bf/input/InputExcel.js +28 -0
  44. package/src/plugins/app/znycpjxt/Bf/input/InputKd.js +31 -0
  45. package/src/plugins/app/znycpjxt/Bqqd/Bqqd.vue +380 -0
  46. package/src/plugins/app/znycpjxt/Bqqd/BqqdMap.vue +1046 -0
  47. package/src/plugins/app/znycpjxt/Bqqd/SetOpacity.vue +101 -0
  48. package/src/plugins/app/znycpjxt/Bqqd/SjzxTree.vue +244 -0
  49. package/src/plugins/app/znycpjxt/Bqqd/YclsjjTree.vue +212 -0
  50. package/src/plugins/app/znycpjxt/Bqqd/api/DsjzxApi.js +37 -0
  51. package/src/plugins/app/znycpjxt/Ckycmx/Ckycmx.vue +161 -0
  52. package/src/plugins/app/znycpjxt/Ckycmx/Ckycmxgl/CfgGloalParams.vue +92 -0
  53. package/src/plugins/app/znycpjxt/Ckycmx/Ckycmxgl/CfgNodeFlds.vue +102 -0
  54. package/src/plugins/app/znycpjxt/Ckycmx/Ckycmxgl/CfgNodeParams.vue +277 -0
  55. package/src/plugins/app/znycpjxt/Ckycmx/Ckycmxgl/Ckycmxgl.vue +303 -0
  56. package/src/plugins/app/znycpjxt/Ckycmx/Ckycmxgl/SetLabelParam.vue +68 -0
  57. package/src/plugins/app/znycpjxt/Ckycmx/Ckycmxgl/SetModelParam.vue +69 -0
  58. package/src/plugins/app/znycpjxt/Ckycmx/Ckycmxtab/Ckycmxtab.vue +107 -0
  59. package/src/plugins/app/znycpjxt/Ckycmx/Ckycmxtab/Dtzzylwl.vue +156 -0
  60. package/src/plugins/app/znycpjxt/Ckycmx/Ckycmxtab/Jjsjwl.vue +230 -0
  61. package/src/plugins/app/znycpjxt/Ckycmx/Ckycmxtab/Sjsl.vue +126 -0
  62. package/src/plugins/app/znycpjxt/Ckycmx/Ckycmxtab/Zcxlj.vue +128 -0
  63. package/src/plugins/app/znycpjxt/Ckycmx/Ckycmxtab/Zjq.vue +123 -0
  64. package/src/plugins/app/znycpjxt/Ckycmx/Ckycmxtab/Zstp.vue +271 -0
  65. package/src/plugins/app/znycpjxt/Ckycmx/Ckycmxtab/Zzylwl.vue +149 -0
  66. package/src/plugins/app/znycpjxt/Ckycmx/Ckycmxtab/coms/ParamsData.vue +323 -0
  67. package/src/plugins/app/znycpjxt/Ckycmx/Ckycmxtab/coms/ParamsDataNew.vue +336 -0
  68. package/src/plugins/app/znycpjxt/Ckycmx/Ckycmxtab/coms/QqtEcharts.vue +137 -0
  69. package/src/plugins/app/znycpjxt/Ckycmx/Ckycrwgl/Ckycrwgl.vue +290 -0
  70. package/src/plugins/app/znycpjxt/CusTools/CodeApi.js +83 -0
  71. package/src/plugins/app/znycpjxt/CusTools/CodeEditor/CodeEditor.md +36 -0
  72. package/src/plugins/app/znycpjxt/CusTools/CodeEditor/CodeEditor.vue +227 -0
  73. package/src/plugins/app/znycpjxt/CusTools/CodeEditor/PlugCodeEditor.vue +78 -0
  74. package/src/plugins/app/znycpjxt/CusTools/CodeEditor/demo/basic.png +0 -0
  75. package/src/plugins/app/znycpjxt/CusTools/CodeEditor/demo/basic.vue +27 -0
  76. package/src/plugins/app/znycpjxt/CusTools/DmbjForm.vue +76 -0
  77. package/src/plugins/app/znycpjxt/CusTools/DmfbForm.vue +351 -0
  78. package/src/plugins/app/znycpjxt/CusTools/GjForm.vue +206 -0
  79. package/src/plugins/app/znycpjxt/CusTools/Gjbjyfb.vue +200 -0
  80. package/src/plugins/app/znycpjxt/CusTools/ParamSelect.vue +222 -0
  81. package/src/plugins/app/znycpjxt/CusTools/ParamSelect2.vue +204 -0
  82. package/src/plugins/app/znycpjxt/CusTools/Zngjj.vue +105 -0
  83. package/src/plugins/app/znycpjxt/DataAnlyModel/DataAnlyModel.vue +134 -0
  84. package/src/plugins/app/znycpjxt/DataAnlyModel/Hgfx/HgfxEcharts.vue +98 -0
  85. package/src/plugins/app/znycpjxt/DataAnlyModel/Hgfx/HgfxTab.vue +73 -0
  86. package/src/plugins/app/znycpjxt/DataAnlyModel/Hgfx.vue +101 -0
  87. package/src/plugins/app/znycpjxt/DataAnlyModel/Jctj/JctjjgTab.vue +70 -0
  88. package/src/plugins/app/znycpjxt/DataAnlyModel/Jctj/Plzft.vue +154 -0
  89. package/src/plugins/app/znycpjxt/DataAnlyModel/Jctj.vue +118 -0
  90. package/src/plugins/app/znycpjxt/DataAnlyModel/Jlfx/JlfxImg.vue +80 -0
  91. package/src/plugins/app/znycpjxt/DataAnlyModel/Jlfx.vue +91 -0
  92. package/src/plugins/app/znycpjxt/DataAnlyModel/PCAfx/PcaTab.vue +161 -0
  93. package/src/plugins/app/znycpjxt/DataAnlyModel/PCAfx.vue +101 -0
  94. package/src/plugins/app/znycpjxt/DataAnlyModel/Qqt/QqtEcharts.vue +202 -0
  95. package/src/plugins/app/znycpjxt/DataAnlyModel/Qqt.vue +88 -0
  96. package/src/plugins/app/znycpjxt/DataAnlyModel/Xgxfx/XgxfxImg.vue +80 -0
  97. package/src/plugins/app/znycpjxt/DataAnlyModel/Xgxfx.vue +96 -0
  98. package/src/plugins/app/znycpjxt/DatasetMan/CreateDataset.vue +296 -0
  99. package/src/plugins/app/znycpjxt/DatasetMan/DatasetMan.vue +141 -0
  100. package/src/plugins/app/znycpjxt/DatasetMan/PreData.js +91 -0
  101. package/src/plugins/app/znycpjxt/DatasetMan/PreData.vue +545 -0
  102. package/src/plugins/app/znycpjxt/DatasetMan/PreDataApi.js +101 -0
  103. package/src/plugins/app/znycpjxt/DatasetMan/SelData.vue +186 -0
  104. package/src/plugins/app/znycpjxt/DatasetMan/SjTree.vue +130 -0
  105. package/src/plugins/app/znycpjxt/DatasetMan/Sjj.vue +478 -0
  106. package/src/plugins/app/znycpjxt/DatasetMan/Yclsjj.vue +445 -0
  107. package/src/plugins/app/znycpjxt/DatasetMan/Yssjj.vue +389 -0
  108. package/src/plugins/app/znycpjxt/DocList/DocList.vue +496 -0
  109. package/src/plugins/app/znycpjxt/DocList/unit/DocItem.vue +137 -0
  110. package/src/plugins/app/znycpjxt/ExceptHandlModel/AnomalyExtraction/Dchj.vue +107 -0
  111. package/src/plugins/app/znycpjxt/ExceptHandlModel/AnomalyExtraction/GeophysicalAnomaly.vue +115 -0
  112. package/src/plugins/app/znycpjxt/ExceptHandlModel/AnomalyExtraction/Jxyt.vue +98 -0
  113. package/src/plugins/app/znycpjxt/ExceptHandlModel/AnomalyExtraction/Lbjs.vue +127 -0
  114. package/src/plugins/app/znycpjxt/ExceptHandlModel/AnomalyExtraction/Pjcjs.vue +103 -0
  115. package/src/plugins/app/znycpjxt/ExceptHandlModel/AnomalyExtraction/Qdjs.vue +103 -0
  116. package/src/plugins/app/znycpjxt/ExceptHandlModel/ExceptHandlModel.vue +163 -0
  117. package/src/plugins/app/znycpjxt/ExceptHandlModel/GeneralCalculation/Cdjs.vue +102 -0
  118. package/src/plugins/app/znycpjxt/ExceptHandlModel/GeneralCalculation/Czfx.vue +163 -0
  119. package/src/plugins/app/znycpjxt/ExceptHandlModel/GeneralCalculation/GetFormData.vue +343 -0
  120. package/src/plugins/app/znycpjxt/ExceptHandlModel/GeneralCalculation/Hdpj.vue +100 -0
  121. package/src/plugins/app/znycpjxt/ExceptHandlModel/GeneralCalculation/Pjtd.vue +90 -0
  122. package/src/plugins/app/znycpjxt/ExceptHandlModel/GeneralCalculation/Qsfx.vue +109 -0
  123. package/src/plugins/app/znycpjxt/ExceptHandlModel/GeneralCalculation/ResultOnlyData.vue +121 -0
  124. package/src/plugins/app/znycpjxt/ExceptHandlModel/GeneralCalculation/ResultTable.vue +231 -0
  125. package/src/plugins/app/znycpjxt/ExceptHandlModel/GeneralCalculation/UniversalComputing.vue +139 -0
  126. package/src/plugins/app/znycpjxt/ExceptHandlModel/GeneralCalculation/Xgxsjs.vue +93 -0
  127. package/src/plugins/app/znycpjxt/ExceptHandlModel/GeneralCalculation/Xxsjs.vue +90 -0
  128. package/src/plugins/app/znycpjxt/ExceptHandlModel/GeneralCalculation/Ycfj.vue +116 -0
  129. package/src/plugins/app/znycpjxt/ExceptHandlModel/GeneralCalculation/Yhcl.vue +100 -0
  130. package/src/plugins/app/znycpjxt/ExceptHandlModel/extgeoanomalies/AnomalsGard.vue +91 -0
  131. package/src/plugins/app/znycpjxt/ExceptHandlModel/extgeoanomalies/Dqhxycht.vue +113 -0
  132. package/src/plugins/app/znycpjxt/ExceptHandlModel/extgeoanomalies/GeocAnomalies.vue +99 -0
  133. package/src/plugins/app/znycpjxt/ExceptHandlModel/extgeoanomalies/JgTableList.vue +203 -0
  134. package/src/plugins/app/znycpjxt/ExceptHandlModel/extgeoanomalies/Lszcl.vue +110 -0
  135. package/src/plugins/app/znycpjxt/ExceptHandlModel/extgeoanomalies/Ycxxjs.vue +116 -0
  136. package/src/plugins/app/znycpjxt/ExceptHandlModel/geoAnomalyExtraction/GeoAnomalyExtraction.vue +108 -0
  137. package/src/plugins/app/znycpjxt/ExceptHandlModel/geoAnomalyExtraction/coms/AttWeight.vue +99 -0
  138. package/src/plugins/app/znycpjxt/ExceptHandlModel/geoAnomalyExtraction/coms/Ckdctq.vue +98 -0
  139. package/src/plugins/app/znycpjxt/ExceptHandlModel/geoAnomalyExtraction/coms/LeftForm.vue +266 -0
  140. package/src/plugins/app/znycpjxt/ExceptHandlModel/ygyctq/Ygsbtq.vue +150 -0
  141. package/src/plugins/app/znycpjxt/ExceptHandlModel/ygyctq/Ygtxrh.vue +107 -0
  142. package/src/plugins/app/znycpjxt/ExceptHandlModel/ygyctq/ygyctq.vue +98 -0
  143. package/src/plugins/app/znycpjxt/Index/DataCard.vue +45 -0
  144. package/src/plugins/app/znycpjxt/Index/Index.vue +123 -0
  145. package/src/plugins/app/znycpjxt/Rzgl/Rzgl.vue +156 -0
  146. package/src/plugins/app/znycpjxt/coms/CmapColor.vue +70 -0
  147. package/src/plugins/app/znycpjxt/coms/CustomFileView.vue +343 -0
  148. package/src/plugins/app/znycpjxt/coms/CustomForm.vue +220 -0
  149. package/src/plugins/app/znycpjxt/coms/GrdView.vue +355 -0
  150. package/src/plugins/app/znycpjxt/coms/LeftForm.vue +195 -0
  151. package/src/plugins/app/znycpjxt/coms/MakeData.js +472 -0
  152. package/src/plugins/app/znycpjxt/coms/PreView.js +55 -0
  153. package/src/plugins/app/znycpjxt/coms/RightContent.vue +71 -0
  154. package/src/plugins/app/znycpjxt/coms/TableEarth.vue +259 -0
  155. package/src/plugins/app/znycpjxt/intellPred/ModelList.vue +200 -0
  156. package/src/plugins/app/znycpjxt/intellPred/coms/D3DrawGraph.js +634 -0
  157. package/src/plugins/app/znycpjxt/intellPred/coms/MineralGo.vue +249 -0
  158. package/src/plugins/app/znycpjxt/intellPred/coms/ModelCard.vue +298 -0
  159. package/src/plugins/app/znycpjxt/intellPred/coms/ModelEdit.vue +292 -0
  160. package/src/plugins/app/znycpjxt/intellPred/coms/ModelSpecif.vue +46 -0
  161. package/src/plugins/app/znycpjxt/intellPred/intellPred.vue +71 -0
  162. package/src/plugins/bf/BfApi.js +92 -0
  163. package/src/plugins/bf/BfColAdd.vue +78 -0
  164. package/src/plugins/bf/BfColEdit.vue +68 -0
  165. package/src/plugins/bf/BfColFilter.vue +112 -0
  166. package/src/plugins/bf/BfDataGroup.vue +80 -0
  167. package/src/plugins/bf/BfDataPreview.vue +118 -0
  168. package/src/plugins/bf/BfDataStat.vue +81 -0
  169. package/src/plugins/bf/BfDuplicateDel.vue +82 -0
  170. package/src/plugins/bf/BfProcCall.vue +82 -0
  171. package/src/plugins/bf/BfRunHis.vue +289 -0
  172. package/src/plugins/bf/BfRunParams.vue +94 -0
  173. package/src/plugins/bf/BfSaveFlow.vue +186 -0
  174. package/src/plugins/bf/BfSelFlow.vue +123 -0
  175. package/src/plugins/bf/BfTabCombine.vue +127 -0
  176. package/src/plugins/bf/BfTabJoin.vue +108 -0
  177. package/src/plugins/bf/BfTabMerge.vue +68 -0
  178. package/src/plugins/bf/BfTabReader.vue +126 -0
  179. package/src/plugins/bf/BfValFormat.vue +68 -0
  180. package/src/plugins/bf/BfValNumber.vue +68 -0
  181. package/src/plugins/bf/BfValProc.vue +78 -0
  182. package/src/plugins/bf/BfValSort.vue +78 -0
  183. package/src/plugins/bf/BiFlow.vue +1177 -0
  184. package/src/plugins/bf/IBfPlug.js +205 -0
  185. package/src/plugins/bf/coms/ColAdd.vue +75 -0
  186. package/src/plugins/bf/coms/ColEdit.vue +52 -0
  187. package/src/plugins/bf/coms/ColList.vue +91 -0
  188. package/src/plugins/bf/coms/DataGroup.vue +90 -0
  189. package/src/plugins/bf/coms/DataStat.vue +67 -0
  190. package/src/plugins/bf/coms/EditTable.vue +161 -0
  191. package/src/plugins/bf/coms/NodeTree.vue +105 -0
  192. package/src/plugins/bf/coms/PlugCmd.vue +95 -0
  193. package/src/plugins/bf/coms/RunParams.vue +68 -0
  194. package/src/plugins/bf/coms/TabCombine.vue +60 -0
  195. package/src/plugins/bf/coms/TabJoin.vue +69 -0
  196. package/src/plugins/bf/coms/ValFormat.vue +53 -0
  197. package/src/plugins/bf/coms/ValProc.vue +77 -0
  198. package/src/plugins/bf/coms/ValSort.vue +89 -0
  199. package/src/plugins/bf/parts/Icon.vue +105 -0
  200. package/src/plugins/bf/parts/Rect.vue +98 -0
  201. package/src/plugins/bf/parts/index.js +11 -0
  202. package/src/plugins/cxMixin/IAttBase.js +78 -0
  203. package/src/plugins/cxMixin/IAttDlg.js +45 -0
  204. package/src/plugins/cxMixin/IAttProc.js +98 -0
  205. package/src/plugins/cxMixin/IComBase.js +42 -0
  206. package/src/plugins/cxMixin/IContextMenu.js +74 -0
  207. package/src/plugins/cxMixin/IDataAcce.js +1106 -0
  208. package/src/plugins/cxMixin/IDataList.js +775 -0
  209. package/src/plugins/cxMixin/IDataMan.js +1670 -0
  210. package/src/plugins/cxMixin/IDataMan2.js +2561 -0
  211. package/src/plugins/cxMixin/IDataProc.js +379 -0
  212. package/src/plugins/cxMixin/IDatagrid.js +234 -0
  213. package/src/plugins/cxMixin/IEditableDg.js +477 -0
  214. package/src/plugins/cxMixin/IExpBase.js +51 -0
  215. package/src/plugins/cxMixin/IFormBase.js +29 -0
  216. package/src/plugins/cxMixin/IGridBpm.js +732 -0
  217. package/src/plugins/cxMixin/IGridData.js +109 -0
  218. package/src/plugins/cxMixin/IOperMore.js +323 -0
  219. package/src/plugins/cxMixin/IPlugBase.js +341 -0
  220. package/src/plugins/cxMixin/ISendCode.js +86 -0
  221. package/src/plugins/cxMixin/ISinglePage.js +112 -0
  222. package/src/plugins/cxMixin/ITags.js +81 -0
  223. package/src/plugins/cxe/CxeMap.vue +61 -0
  224. package/src/plugins/home/HeadNav.vue +194 -0
  225. package/src/plugins/home/Home.vue +59 -0
  226. package/src/plugins/home/HomePage.vue +237 -0
  227. package/src/plugins/home/Login.vue +139 -0
  228. package/src/plugins/zbcxCesium/coms/GraDrawBarWgt.vue +176 -0
  229. package/src/plugins/zbcxCesium/coms/baseMapSwitch/BaseMap.scss +42 -0
  230. package/src/plugins/zbcxCesium/coms/baseMapSwitch/BaseMap.vue +59 -0
  231. package/src/plugins/zbcxCesium/coms/dataPreview/DataPreview.vue +526 -0
  232. package/src/plugins/zbcxCesium/coms/dataPreview/DataPreviewPlug.vue +79 -0
  233. package/src/plugins/zbcxCesium/coms/dataPreview/ReadShpFile.js +42 -0
  234. package/src/plugins/zbcxCesium/coms/legend/Legend.vue +78 -0
  235. package/src/plugins/zbcxCesium/coms/popup/dialog-left-bg.png +0 -0
  236. package/src/plugins/zbcxCesium/coms/popup/index.js +88 -0
  237. package/src/plugins/zbcxCesium/coms/popup/index.vue +93 -0
  238. package/src/plugins/zbcxCesium/pub/LoadGeojson.js +44 -0
  239. package/src/plugins/zbcxCesium/pub/LoadModel.js +128 -0
  240. package/src/plugins/zbcxCesium/pub/LoadOgc.js +226 -0
  241. package/src/plugins/zbcxCesium/pub/Opacity.vue +139 -0
  242. package/src/plugins/zbcxCesium/pub/PubCxe.js +97 -0
  243. package/src/plugins/zbcxCesium/pub/SceneSet.vue +178 -0
  244. package/src/plugins/zbcxCesium/pub/ShowEffect.vue +216 -0
  245. package/src/plugins/zbcxCesium/pub/TMeasure.vue +122 -0
  246. package/src/plugins/zbcxCesium/pub/ToDefView3.vue +109 -0
  247. package/src/plugins/zbcxCesium/pub/getWmsGetCapabilities.js +127 -0
  248. package/src/plugins/zbcxCesium/utils/ShpToGeoJson.js +24 -0
  249. package/src/plugins/zbcxCesium/utils/WebProj4.js +32 -0
@@ -0,0 +1,708 @@
1
+ import * as d3 from 'd3'
2
+
3
+ /**
4
+ * 类名:DrawGraph
5
+ * 描述:D3绘导向图组织类
6
+ * 作者:王卫
7
+ * 时间:20230601
8
+ */
9
+ class DrawGraph
10
+ {
11
+ /**
12
+ * 构造函数
13
+ * @param {视图} chart
14
+ */
15
+ constructor(chart)
16
+ {
17
+ this.g = null
18
+ this.svg = d3.select(chart)
19
+ .append('svg')
20
+ .attr('width', '100%')
21
+ .attr('height', '100%')
22
+ .attr('preserveAspectRatio', 'xMidYMid meet') // 控制缩放形式
23
+ .on('click', this.clickCancel.bind(this))
24
+ .on('mousedown', (event) =>
25
+ {
26
+ if (event.button === 1)
27
+
28
+ this.resetCentor()
29
+ })
30
+
31
+ this.zoom = d3.zoom()
32
+ this.simulation = null
33
+ this.table = null
34
+ this.id = ''
35
+ this.color = d3.scaleOrdinal().range(d3.schemeCategory10)
36
+ this.strength = 2000
37
+ }
38
+
39
+ /**
40
+ * 清空视图
41
+ */
42
+ clearChart()
43
+ {
44
+ // 重置缩放事件
45
+ this.zoom.scaleTo(this.svg, 1)
46
+ this.zoom.translateTo(this.svg, 0, 0)
47
+ this.svg.call(this.zoom.transform, d3.zoomTransform(this.svg).scale(1))
48
+
49
+ // 移除所有内容
50
+ this.svg.selectAll('*').remove()
51
+ this.g = null
52
+ this.id = ''
53
+ this.table = null
54
+ }
55
+
56
+ /**
57
+ * 获得当前激活节点
58
+ * @returns 返回节点id
59
+ */
60
+ getCurNode()
61
+ {
62
+ return this.id
63
+ }
64
+
65
+ /**
66
+ * 设置斥力
67
+ * @param {} strength 斥力参数
68
+ */
69
+ setStrength(strength)
70
+ {
71
+ this.strength = strength
72
+ }
73
+
74
+ /**
75
+ * 获取连接线数据
76
+ * @returns {Array} 连接线数据数组
77
+ */
78
+ getLinkData()
79
+ {
80
+ const links = this.g.selectAll('line').data()
81
+ const data = []
82
+
83
+ for (const link of links)
84
+ {
85
+ data.push(link.source.id)
86
+ data.push(link.target.id)
87
+ }
88
+
89
+ return data
90
+ }
91
+
92
+ /**
93
+ * 获取所有节点
94
+ * @returns {Array} 节点ID数组
95
+ */
96
+ getAllNode()
97
+ {
98
+ const nodes = this.g.selectAll('.node')
99
+ const data = []
100
+ for (const node of nodes)
101
+
102
+ data.push(node.id)
103
+
104
+ return data
105
+ }
106
+
107
+ /**
108
+ * 绘图接口
109
+ * @param {} nodes 顶点集合
110
+ * @param {} links 顶点关系集合
111
+ */
112
+ drawChart(nodes, links)
113
+ {
114
+ if (!this.g)
115
+
116
+ this.g = this.svg.append('g')
117
+
118
+
119
+ const color = this.color
120
+ this.simulation = d3
121
+ .forceSimulation(nodes)
122
+ .force(
123
+ 'link',
124
+ d3.forceLink(links).id((d) => d.id)
125
+ )
126
+ .force('charge', d3.forceManyBody().strength(-this.strength))
127
+ .force('center', d3.forceCenter())
128
+ const simulation = this.simulation
129
+
130
+ // 绘制svg
131
+ this.setSvg()
132
+
133
+ // 绘制连接线标签
134
+ const linkLabel = this.drawLinkLabel(links)
135
+
136
+ // 绘制连接线
137
+ const link = this.drawLink(links)
138
+
139
+ // 绘制表格
140
+ this.table = this.drawTable()
141
+
142
+ // 绘制节点
143
+ const node = this.drawNode(simulation, color, nodes)
144
+
145
+ // 位置计算
146
+ simulation.on('tick', () =>
147
+ {
148
+ this.drawSimulation(node, link, linkLabel)
149
+ })
150
+
151
+ // 绘制图例
152
+ const nodeLabels = Array.from(new Set(nodes.map((node) => node.label)))
153
+ this.drawLegend(color, nodeLabels)
154
+
155
+ // 设置缩放
156
+ this.setZoom()
157
+ }
158
+
159
+ /**
160
+ * 新增顶点
161
+ * @param {} nodes 顶点集合
162
+ * @param {} links 顶点关系集合
163
+ * @returns 是否添加成功
164
+ */
165
+ addChart(nodes, links)
166
+ {
167
+ const color = this.color
168
+ const simulation = this.simulation
169
+
170
+ // 计算未加载的连接线
171
+ const haslinks = this.g.selectAll('line').data()
172
+ const haslinkdata = haslinks.map(d => ({ source: d.source, target: d.target }))
173
+
174
+ let filterlink = links.filter(d =>
175
+ {
176
+ const exists = haslinkdata.find(hd =>
177
+ {
178
+ return hd.source.id != d.source || hd.target.id != d.target
179
+ })
180
+ return exists
181
+ })
182
+
183
+ if (haslinks.length === 0)
184
+
185
+ filterlink = links
186
+
187
+
188
+ // 计算未加载的顶点
189
+ const hasNodes = this.g.selectAll('.node').nodes()
190
+ const hasnodedata = hasNodes.map(node => node.id)
191
+ const filternodes = []
192
+ for (const curnode of nodes)
193
+ {
194
+ if (!hasnodedata.includes(curnode.id))
195
+
196
+ filternodes.push(curnode)
197
+ }
198
+
199
+ if (filternodes.length === 0)
200
+
201
+ return false
202
+
203
+
204
+ // 绘制标签
205
+ this.drawLinkLabel(filterlink)
206
+
207
+ // 绘制连接线
208
+ this.drawLink(filterlink)
209
+
210
+ // 绘制顶点
211
+ this.drawNode(simulation, color, filternodes)
212
+
213
+ // 将所有节点重新添加到力学模拟中
214
+ const allnode = this.g.selectAll('.node')
215
+ const alllinkLabel = this.g.selectAll('.link-label')
216
+ const alllink = this.g.selectAll('line')
217
+ const nodedata = allnode.data()
218
+ const linkdata = alllink.data()
219
+
220
+ // 并重新绑定tick事件
221
+ simulation.nodes(nodedata)
222
+ .force('link', d3.forceLink(linkdata).id(d => d.id))
223
+ .on('tick', () =>
224
+ {
225
+ this.drawSimulation(allnode, alllink, alllinkLabel)
226
+ })
227
+ .alpha(1)
228
+ .restart()
229
+
230
+ // 绘制图例
231
+ const nodeLabels = Array.from(new Set(nodedata.map((node) => node.label)))
232
+ this.drawLegend(color, nodeLabels)
233
+
234
+ return true
235
+ }
236
+
237
+ /**
238
+ * 定位顶点
239
+ * @param {} name 顶点名称
240
+ * @returns
241
+ */
242
+ locateNode(name)
243
+ {
244
+ if (!this.g)
245
+ return false
246
+
247
+ const nodes = this.g.selectAll('.node').nodes()
248
+ const targetNode = nodes.find(node => node.id === name)
249
+
250
+ if (targetNode)
251
+ {
252
+ const data = targetNode.__data__
253
+ const x = -data.x
254
+ const y = -data.y
255
+ const id = targetNode.id
256
+ this.zoom.transform(this.svg, d3.zoomIdentity.translate(x, y))
257
+
258
+ const allnode = this.g.selectAll('.node')
259
+ allnode.classed('highlighted', d => d.id === id)
260
+ .select('circle')
261
+ .style('stroke-width', d => (d.id === id ? '8px' : '0px'))
262
+
263
+ return true
264
+ }
265
+ else
266
+
267
+ return false
268
+ }
269
+
270
+ /**
271
+ * 重置中心点
272
+ */
273
+ resetCentor()
274
+ {
275
+ this.zoom.transform(this.svg, d3.zoomIdentity.translate(0, 0))
276
+ }
277
+
278
+ /**
279
+ * 设置缩放功能
280
+ */
281
+ setZoom()
282
+ {
283
+ const svg = this.svg
284
+ const g = this.g
285
+
286
+ // 1. 获取 SVG 图形的宽度和高度
287
+ const svgWidth = svg.node().getBoundingClientRect().width
288
+ const svgHeight = svg.node().getBoundingClientRect().height
289
+
290
+ // 2.设置缩放范围和初始缩放比例
291
+ this.zoom.scaleExtent([0.1, 10]).on('zoom', zoomed)
292
+ svg.call(this.zoom)
293
+ this.resetCentor()
294
+
295
+ function zoomed()
296
+ {
297
+ const transform = d3.zoomTransform(svg.node())
298
+ const scale = transform.k
299
+ const translateX = transform.x + (svgWidth * scale) / 2
300
+ const translateY = transform.y + (svgHeight * scale) / 2
301
+ g.attr('transform', d3.zoomIdentity.translate(translateX, translateY).scale(scale))
302
+ }
303
+ }
304
+
305
+ /**
306
+ * 设置svg属性
307
+ */
308
+ setSvg()
309
+ {
310
+ this.g
311
+ .append('defs')
312
+ .selectAll('marker')
313
+ .data(['arrow'])
314
+ .enter()
315
+ .append('marker')
316
+ .attr('id', (d) => d)
317
+ .attr('markerWidth', 10)
318
+ .attr('markerHeight', 10)
319
+ .attr('markerUnits', 'userSpaceOnUse')
320
+ .attr('viewBox', '0 -5 10 10')
321
+ .attr('refX', 45)
322
+ .attr('refY', 0)
323
+ .attr('orient', 'auto')
324
+ .append('path')
325
+ .attr('d', 'M0,-5L10,0L0,5')
326
+ .attr('fill', 'gray')
327
+ .attr('transform', 'translate(0,0)')
328
+ }
329
+
330
+ /**
331
+ * 绘制图例
332
+ * @param {} color 颜色集合
333
+ * @param {} nodeLabels 标签集合
334
+ */
335
+ drawLegend(color, nodeLabels)
336
+ {
337
+ this.svg.selectAll('.legend').remove()
338
+ const legend = this.svg
339
+ .append('g')
340
+ .attr('class', 'legend')
341
+ .attr('transform', 'translate(10,10)')
342
+
343
+ // 循环添加每个图例项
344
+ nodeLabels.forEach((label, index) =>
345
+ {
346
+ const legendItem = legend
347
+ .append('g')
348
+ .attr('class', 'legend-item')
349
+ .attr('transform', `translate(0,${index * 30})`)
350
+
351
+ legendItem
352
+ .append('rect')
353
+ .attr('x', 0)
354
+ .attr('y', 0)
355
+ .attr('width', 60)
356
+ .attr('height', 20)
357
+ .attr('selected', 1)
358
+ .attr('label', label)
359
+ .attr('color', color(label))
360
+ .style('fill', color(label))
361
+ .style('stroke', 'black')
362
+ .on('click', handleLegendItemClick)
363
+
364
+ legendItem
365
+ .append('text')
366
+ .attr('x', 65)
367
+ .attr('y', 15)
368
+ .text(label)
369
+ .attr('text-anchor', 'start')
370
+ .attr('font-size', 15)
371
+ })
372
+
373
+ const g = this.g
374
+ function handleLegendItemClick()
375
+ {
376
+ const itemRect = d3.select(this)
377
+ const isSelect = itemRect.attr('selected')
378
+ const label = itemRect.attr('label')
379
+ const nodes = g.selectAll('.node')
380
+ const links = g.selectAll('line')
381
+ const linkLabels = g.selectAll('.link-label')
382
+
383
+ if (isSelect == 1)
384
+ {
385
+ itemRect
386
+ .style('fill', 'white')
387
+ .attr('selected', 0)
388
+ nodes.filter(d => d.label === label).style('display', 'none')
389
+ links.filter(d => d.source.label === label || d.target.label === label).style('display', 'none')
390
+ linkLabels.filter(d => d.source.label === label || d.target.label === label).style('display', 'none')
391
+ }
392
+ else
393
+ {
394
+ const color = itemRect.attr('color')
395
+ itemRect
396
+ .style('fill', color)
397
+ .attr('selected', 1)
398
+ nodes.filter(d => d.label === label).style('display', 'block')
399
+ links.filter(d => d.source.label === label || d.target.label === label).style('display', 'block')
400
+ linkLabels.filter(d => d.source.label === label || d.target.label === label).style('display', 'block')
401
+ }
402
+ }
403
+ }
404
+
405
+ /**
406
+ * 绘制顶点
407
+ * @param {} simulation 模拟器
408
+ * @param {} color 颜色集合
409
+ * @param {} nodes 顶点集合
410
+ * @returns 顶点
411
+ */
412
+ drawNode(simulation, color, nodes)
413
+ {
414
+ const table = this.table
415
+ const node = this.g
416
+ .append('g')
417
+ .selectAll('g')
418
+ .data(nodes)
419
+ .enter()
420
+ .append('g')
421
+ .attr('class', 'node')
422
+ .attr('id', (d) => d.id)
423
+ .attr('label', (d) => d.label)
424
+ .call(this.drag(simulation))
425
+ .on('click', (event, d) => handClick.call(this, event, d))
426
+
427
+ node
428
+ .append('circle')
429
+ .attr('r', 35)
430
+ .attr('fill', (d) => color(d.label))
431
+ .attr('class', 'circle')
432
+ .style('stroke', 'rgba(255, 210, 0)')
433
+ .style('stroke-width', '0px')
434
+
435
+ node
436
+ .append('text')
437
+ .attr('dx', 0)
438
+ .attr('dy', '.35em')
439
+ .style('fill', 'white')
440
+ .style('font-size', '12px')
441
+ .style('text-anchor', 'middle')
442
+ .text((d) => this.truncateText(d.name, 5))
443
+
444
+ function handClick(event, target)
445
+ {
446
+ const id = target.id
447
+ const name = target.name
448
+ const label = target.label
449
+ const properties = JSON.parse(target.properties)
450
+ this.id = target.id
451
+ this.orinode = name
452
+ const data = [
453
+ { key: '名称:', value: name },
454
+ { key: '标签:', value: label },
455
+ { key: 'x:', value: Math.round(target.x) },
456
+ { key: 'y:', value: Math.round(target.y) }
457
+ ]
458
+
459
+ // 遍历properties并添加到data
460
+ for (let key in properties)
461
+
462
+ data.push({ key: `${key}:`, value: properties[key] })
463
+
464
+
465
+ table.selectAll('g.row').remove()
466
+
467
+ // 创建表格行
468
+ const rows = table
469
+ .selectAll('g.row')
470
+ .data(data)
471
+ .enter()
472
+ .append('g')
473
+ .attr('class', 'row')
474
+ .attr('transform', (d, i) => `translate(0, ${i * 30 + 20})`)
475
+
476
+ // 创建单元格并填充数据
477
+ rows
478
+ .selectAll('text')
479
+ .data((d) => [d.key, d.value])
480
+ .enter()
481
+ .append('text')
482
+ .attr('x', (d, i) => i * 120)
483
+ .text((d) => d)
484
+ .style('font-size', '16px')
485
+ .style('font-weight', 'bold')
486
+
487
+ const allnode = this.g.selectAll('.node')
488
+ allnode.classed('highlighted', d => d.id === id)
489
+ .select('circle')
490
+ .style('stroke-width', d => (d.id === id ? '8px' : '0px'))
491
+
492
+ const alllink = this.g.selectAll('line')
493
+ alllink
494
+ .attr('stroke', (link) =>
495
+ {
496
+ if (link.source.id == id)
497
+
498
+ return 'red'
499
+
500
+ else if (link.target.id == id)
501
+
502
+ return 'blue'
503
+
504
+ else
505
+
506
+ return 'gray'
507
+ })
508
+
509
+ event.stopPropagation() // 阻止事件冒泡
510
+ }
511
+
512
+ return node
513
+ }
514
+
515
+ /**
516
+ * 绘制连接线
517
+ * @param {} links 顶点关系集合
518
+ * @returns 连接线
519
+ */
520
+ drawLink(links)
521
+ {
522
+ const link = this.g
523
+ .insert('g', ':first-child')
524
+ .selectAll('line')
525
+ .data(links)
526
+ .enter()
527
+ .append('line')
528
+ .attr('stroke', 'gray')
529
+ .attr('marker-end', 'url(#arrow)')
530
+
531
+ return link
532
+ }
533
+
534
+ /**
535
+ * 添加连接线
536
+ * @param {Array} links 连接线数据
537
+ * @returns {Object} 连接线元素
538
+ */
539
+ addLink(links)
540
+ {
541
+ const link = this.drawlinks(links)
542
+ link
543
+ .filter((d, i, arr) =>
544
+ {
545
+ // 判断是否有重复线
546
+ const source = d.source.id
547
+ const target = d.target.id
548
+ for (let j = 0; j < i; j++)
549
+ {
550
+ const link = arr[j]
551
+ if ((link.source.id === source && link.target.id === target) ||
552
+ (link.source.id === target && link.target.id === source))
553
+
554
+ return false
555
+ }
556
+ return true
557
+ })
558
+ return link
559
+ }
560
+
561
+ /**
562
+ * 绘制顶点标签
563
+ * @param {} links 顶点关系集合
564
+ * @returns 顶点标签
565
+ */
566
+ drawLinkLabel(links)
567
+ {
568
+ const linkLabel = this.g
569
+ .insert('g', ':first-child')
570
+ .selectAll('linklabel')
571
+ .data(links)
572
+ .enter()
573
+ .append('g')
574
+ .attr('class', 'link-label')
575
+
576
+ linkLabel
577
+ .append('rect')
578
+ .attr('width', 60)
579
+ .attr('height', 20)
580
+ .attr('fill', 'white')
581
+ .attr('stroke', 'white')
582
+ .attr('alignment-baseline', 'central')
583
+ .attr('transform', 'translate(-30,-10)')
584
+
585
+ linkLabel
586
+ .append('text')
587
+ .text((d) => d.label)
588
+ .attr('x', 0)
589
+ .attr('y', 5)
590
+ .attr('text-anchor', 'middle')
591
+ .attr('font-size', 12)
592
+ .attr('fill', 'blue')
593
+
594
+ return linkLabel
595
+ }
596
+
597
+ /**
598
+ * 位置计算
599
+ * @param {} simulation 模拟器
600
+ * @param {} node 顶点
601
+ * @param {} link 连接线
602
+ * @param {} linkLabel 连接线标签
603
+ */
604
+ drawSimulation(node, link, linkLabel)
605
+ {
606
+ link
607
+ .attr('x1', (d) => d.source.x)
608
+ .attr('y1', (d) => d.source.y)
609
+ .attr('x2', (d) => d.target.x)
610
+ .attr('y2', (d) => d.target.y)
611
+ node.attr('transform', (d) => `translate(${d.x},${d.y})`)
612
+
613
+ linkLabel.attr('transform', (d) =>
614
+ {
615
+ let x = (d.source.x + d.target.x) / 2
616
+ let y = (d.source.y + d.target.y) / 2
617
+ const angle =
618
+ (Math.atan2(d.target.y - d.source.y, d.target.x - d.source.x) *
619
+ 180) /
620
+ Math.PI
621
+ return `translate(${x}, ${y}) rotate(${angle})`
622
+ })
623
+ }
624
+
625
+ /**
626
+ * 绘制表格
627
+ * @returns {Object} 表格元素
628
+ */
629
+ drawTable()
630
+ {
631
+ // 添加一个包含表格的 g 元素
632
+ const table = this.svg
633
+ .append('g')
634
+ .attr('transform', `translate(200, 5)`)
635
+
636
+ return table
637
+ }
638
+
639
+ /**
640
+ * 替换标签,控制标签显示长度
641
+ * @param {} text 标签
642
+ * @param {} maxLength 最大长度
643
+ * @returns 替换标签
644
+ */
645
+ truncateText(text, maxLength)
646
+ {
647
+ let truncated = text
648
+ if (text.length > maxLength)
649
+
650
+ truncated = text.slice(0, maxLength - 1) + '...'
651
+
652
+ return truncated
653
+ }
654
+
655
+ /**
656
+ * 拖拽捕捉
657
+ * @param {} simulation 模拟器
658
+ * @returns 拖拽位置
659
+ */
660
+ drag(simulation)
661
+ {
662
+ function dragstarted(event)
663
+ {
664
+ if (!event.active) simulation.alphaTarget(0.3).restart()
665
+ event.subject.fx = event.subject.x
666
+ event.subject.fy = event.subject.y
667
+ }
668
+ function dragged(event)
669
+ {
670
+ event.subject.fx = event.x
671
+ event.subject.fy = event.y
672
+ }
673
+ function dragended(event)
674
+ {
675
+ if (!event.active) simulation.alphaTarget(0)
676
+ event.subject.fx = null
677
+ event.subject.fy = null
678
+ }
679
+ return d3
680
+ .drag()
681
+ .on('start', dragstarted)
682
+ .on('drag', dragged)
683
+ .on('end', dragended)
684
+ }
685
+
686
+ /**
687
+ * 取消点击选中状态
688
+ */
689
+ clickCancel()
690
+ {
691
+ if (this.g)
692
+ {
693
+ this.g.selectAll('line').attr('stroke', 'gray')
694
+ this.g.selectAll('.circle').style('stroke-width', '0px')
695
+ }
696
+
697
+ if (this.table)
698
+
699
+ this.table.selectAll('g.row').remove()
700
+
701
+
702
+ this.id = ''
703
+ }
704
+ }
705
+
706
+
707
+ export default DrawGraph
708
+