Procházet zdrojové kódy

调整词云图,引入echarts-wordcloud插件

qianming před 7 měsíci
rodič
revize
69485759e3

+ 2 - 0
report-ui/package.json

@@ -21,6 +21,8 @@
     "crypto-js": "^3.1.9-1",
     "crypto-js": "^3.1.9-1",
     "echarts": "^5.5.1",
     "echarts": "^5.5.1",
     "echarts-gl": "^2.0.9",
     "echarts-gl": "^2.0.9",
+    "echarts-liquidfill": "^3.1.0",
+    "echarts-wordcloud": "^2.1.0",
     "element-ui": "^2.15.14",
     "element-ui": "^2.15.14",
     "js-cookie": "2.2.0",
     "js-cookie": "2.2.0",
     "jsbarcode": "^3.11.4",
     "jsbarcode": "^3.11.4",

+ 29 - 6
report-ui/src/views/bigscreenDesigner/designer/tools/configure/wordcloudCharts/widget-word-cloud.js

@@ -197,7 +197,7 @@ export const widgetWordCloud = {
           ],
           ],
         },
         },
         {
         {
-          name: '词云范围',
+          name: '词云设置',
           list: [
           list: [
             {
             {
               type: 'el-input-number',
               type: 'el-input-number',
@@ -215,11 +215,6 @@ export const widgetWordCloud = {
               placeholder: '',
               placeholder: '',
               value: 2
               value: 2
             },
             },
-          ],
-        },
-        {
-          name: '词云角度',
-          list: [
             {
             {
               type: 'el-input-number',
               type: 'el-input-number',
               label: '最大角度',
               label: '最大角度',
@@ -236,6 +231,34 @@ export const widgetWordCloud = {
               placeholder: '',
               placeholder: '',
               value: -45
               value: -45
             },
             },
+            {
+              type: 'el-select',
+              label: '字体粗细',
+              name: 'textFontWeight',
+              required: false,
+              placeholder: '',
+              selectOptions: [
+                {code: 'normal', name: '正常'},
+                {code: 'bold', name: '粗体'},
+                {code: 'bolder', name: '特粗体'},
+                {code: 'lighter', name: '细体'}
+              ],
+              value: 'normal'
+            },
+            {
+              type: 'el-select',
+              label: '字体系列',
+              name: 'textFontFamily',
+              required: false,
+              placeholder: '',
+              selectOptions: [
+                {code: 'sans-serif', name: 'sans-serif'},
+                {code: 'serif', name: 'serif'},
+                {code: 'Arial', name: 'Arial'},
+                {code: 'Courier New', name: 'Courier New'},
+              ],
+              value: 'sans-serif'
+            },
           ],
           ],
         },
         },
         {
         {

+ 48 - 30
report-ui/src/views/bigscreenDesigner/designer/widget/wordcloud/widgetWordCloud.vue

@@ -1,10 +1,11 @@
 <template>
 <template>
-  <div :style="styleObj">
+  <div :style="styleObj" :ref="word-cloud" class="flex can-class">
     <v-chart ref="myVChart" :option="options" autoresize />
     <v-chart ref="myVChart" :option="options" autoresize />
   </div>
   </div>
 </template>
 </template>
 <script>
 <script>
-import wordCloud from "../../../../../../static/wordCloud/echarts-wordcloud.min.js";
+import * as echarts from "echarts";
+import 'echarts-wordcloud';
 import { targetWidgetLinkageLogic } from "@/views/bigscreenDesigner/designer/linkageLogic";
 import { targetWidgetLinkageLogic } from "@/views/bigscreenDesigner/designer/linkageLogic";
 
 
 export default {
 export default {
@@ -34,18 +35,16 @@ export default {
               minSize: 6,
               minSize: 6,
             },
             },
             textStyle: {
             textStyle: {
-              normal: {
-                color: function () {
-                  return (
-                    "rgb(" +
-                    [
-                      Math.round(Math.random() * 160),
-                      Math.round(Math.random() * 160),
-                      Math.round(Math.random() * 160),
-                    ].join(",") +
-                    ")"
-                  );
-                },
+              fontFamily: 'sans-serif',
+              color: function () {
+                return (
+                  'rgb(' +
+                  [
+                    Math.round(Math.random() * 160),
+                    Math.round(Math.random() * 160),
+                    Math.round(Math.random() * 160),
+                  ].join(',') + ')'
+                );
               },
               },
             },
             },
             data: [],
             data: [],
@@ -97,8 +96,7 @@ export default {
     // 修改图标options属性
     // 修改图标options属性
     editorOptions() {
     editorOptions() {
       this.setOptionsTitle();
       this.setOptionsTitle();
-      this.setOptionsSizeRange();
-      this.setOptionsRotationRange();
+      this.setOptionsWordCloud();
       this.setOptionsTooltip();
       this.setOptionsTooltip();
       this.setOptionsData();
       this.setOptionsData();
     },
     },
@@ -129,21 +127,41 @@ export default {
       };
       };
       this.options.title = title;
       this.options.title = title;
     },
     },
-    // 词云字体范围
-    setOptionsSizeRange() {
+    // 词云设置
+    setOptionsWordCloud() {
       const optionsSetup = this.optionsSetup;
       const optionsSetup = this.optionsSetup;
-      this.options.series[0].sizeRange = [
-        optionsSetup.minRangeSize,
-        optionsSetup.maxRangeSize,
-      ];
-    },
-    // 文字角度
-    setOptionsRotationRange() {
-      const optionsSetup = this.optionsSetup;
-      this.options.series[0].rotationRange = [
-        optionsSetup.minRotationRange,
-        optionsSetup.maxRotationRange,
-      ];
+      const series = {
+        type: "wordCloud",
+        size: ["9%", "99%"],
+        sizeRange: [
+          optionsSetup.minRangeSize,
+          optionsSetup.maxRangeSize,
+        ],
+        textRotation: [0, 45, 90, -45],
+        rotationRange: [
+          optionsSetup.minRotationRange,
+          optionsSetup.maxRotationRange,
+        ],
+        shape: "circle",
+        textPadding: 0,
+        autoSize: {
+          enable: true,
+          minSize: 6,
+        },
+        textStyle: {
+          fontWeight: optionsSetup.textFontWeight,
+          color: function () {
+            return (
+              'rgb(' +
+              [
+                Math.round(Math.random() * 160),
+                Math.round(Math.random() * 160),
+                Math.round(Math.random() * 160),
+              ].join(',') + ')'
+            );
+          },
+        },
+      }
     },
     },
     // tooltip 设置
     // tooltip 设置
     setOptionsTooltip() {
     setOptionsTooltip() {

+ 1 - 1
report-ui/src/views/screenDesigner/widget/wordcloudCharts/widgetWordCloud.vue

@@ -4,7 +4,7 @@
   </div>
   </div>
 </template>
 </template>
 <script>
 <script>
-import wordCloud from "../../../../../static/wordCloud/echarts-wordcloud.min.js";
+import 'echarts-wordcloud';
 
 
 export default {
 export default {
   name: "widgetWordCloud",
   name: "widgetWordCloud",