Explorar el Código

Merge branch 'main' of https://git.sxidc.com/kingdee_large_screen/pc_kingdee_large_screen

l1448442195@163.com hace 1 año
padre
commit
25a9f17a88
Se han modificado 3 ficheros con 231 adiciones y 4 borrados
  1. 2 2
      manpower/js/data2.js
  2. 2 2
      manpower/js/fjx.js
  3. 227 0
      manpower/libs/echarts-tooltip-carousel.js

+ 2 - 2
manpower/js/data2.js

@@ -97,12 +97,12 @@ const dataR4 = [
   [19, 62, 70, 3, 347, 23, 50, 2, 566]
 ]
 const dataR5 = [
-  [17831.10, 13336.00, 15555.43, 11688.30, 9896.79, 13159.86, 9287.77, 9850.18, 7685.91],
+  [23923.1, 0, 14081.1, 0, 6077.7, 0, 8196, 10210, 10351.6],
   [17117.80, 12669.20, 14311.00, 11220.77, 9302.98, 12107.07, 8637.63, 9259.17, 7301.61]
 ]
 const dataR6 = [
   [183, 372, 221, 268, 51, -25, 676, -31, 62],
-  [4.00, 5.00, 5.26, 5.21, 4.98, 5.27, 5.28, 5.26, 5.25]
+  [-34, 0, 9, 0, 39, 0, 12, -4, -35]
 ]
 const dataR7 = [
   [100, 100, 100, 100, 100, 100, 100, 100, 100]

+ 2 - 2
manpower/js/fjx.js

@@ -1,11 +1,11 @@
 const fjxdataL1 = [
-    [10226.85, 9429.80, 7604.59, 17031.45, 7766.82, 8136.27, 14014.79, 3988.28, 7380.63, 5391.49, 6583.80, 8483.91, 10743.01, 10065.77, 8277.90, 5706.48, 16517.72, 5255.80],
+    [10399.32, 7126.2, 8643.4, 15964.2, 9733.9, 8070.8, 11564.4, 4233.6, 7927.05, 5298.9, 6001.3, 9010.1, 11370.3, 10170.1, 15123.3, 6103.5, 18555.5, 7293.3],
     [10765.11, 9926.11, 8004.83, 17927.84, 8175.60, 8564.49, 14752.41, 4198.19, 7769.08, 5675.25, 6930.32, 8930.43, 11308.43, 10595.55, 8713.58, 6006.82, 17387.07, 5532.42],
   ]
   
   const fjxdataL2 = [
     [172, 89, 80, 117, 23, 38, 99, 30, 34, -524, 64, -160,31, 53, 2, 27, -20, 109],
-    [5.26, 5.21, 4.98, 5.27, 5.28, 5.26, 5.25, 5.26, 5.25, 5.27, 5.26, 5.27, 5.28, 5.26, 5.24, 5.25, 5.28, 4.98],
+    [3.40, 28.21, -7.98, 10.95, -19.06, 5.76, 21.61, -0.84, -2.03, 6.63, 13.41, -0.89, -0.55, 4.02, -73.56, -1.61, -6.72, -31.83],
   ]
   
   const fjxdataL3 = [

+ 227 - 0
manpower/libs/echarts-tooltip-carousel.js

@@ -0,0 +1,227 @@
+/**
+ * Created by chengwb on 2016/9/3.
+ */
+(function (global) {
+  global.tools = global.tools || {};
+
+  /**
+   * echarts tooltip轮播
+   * @param chart ECharts实例
+   * @param chartOption echarts的配置信息
+   * @param options object 选项
+   * {
+   *  interval    轮播时间间隔,单位毫秒,默认为2000
+   *  loopSeries  boolean类型,默认为false。
+   *              true表示循环所有series的tooltip,false则显示指定seriesIndex的tooltip
+   * 	seriesIndex 默认为0,指定某个系列(option中的series索引)循环显示tooltip,
+   * 	            当loopSeries为true时,从seriesIndex系列开始执行。
+   *  updateData  自定义更新数据的函数,默认为null;
+   *              用于类似于分页的效果,比如总数据有20条,chart一次只显示5条,全部数据可以分4次显示。
+   * }
+   * @returns {{clearLoop: clearLoop}}
+   */
+  tools.loopShowTooltip = function (chart, chartOption, options) {
+    let defaultOptions = {
+      interval: 2000,
+      loopSeries: false,
+      seriesIndex: 0,
+      updateData: null
+    };
+
+    if (!chart || !chartOption) {
+      return;
+    }
+
+    let dataIndex = 0; // 数据索引,初始化为-1,是为了判断是否是第一次执行
+    let seriesIndex = 0; // 系列索引
+    let timeTicket = 0;
+    let seriesLen = chartOption.series.length; // 系列个数
+    let dataLen = 0; // 某个系列数据个数
+    let chartType; // 系列类型
+    let first = true;
+    let lastShowSeriesIndex = 0;
+    let lastShowDataIndex = 0;
+    if (seriesLen === 0) {
+      return;
+    }
+
+    //待处理列表
+    //不循环series时seriesIndex指定显示tooltip的系列,不指定默认为0,指定多个则默认为第一个
+    //循环series时seriesIndex指定循环的series,不指定则从0开始循环所有series,指定单个则相当于不循环,指定多个
+    //要不要添加开始series索引和开始的data索引?
+
+    if (options) {
+      options.interval = options.interval || defaultOptions.interval;
+      options.loopSeries = options.loopSeries || defaultOptions.loopSeries;
+      options.seriesIndex = options.seriesIndex || defaultOptions.seriesIndex;
+      options.updateData = options.updateData || defaultOptions.updateData;
+    } else {
+      options = defaultOptions;
+    }
+
+    //如果设置的seriesIndex无效,则默认为0
+    if (options.seriesIndex < 0 || options.seriesIndex >= seriesLen) {
+      seriesIndex = 0;
+    } else {
+      seriesIndex = options.seriesIndex;
+    }
+
+    /**
+     * 清除定时器
+     */
+    function clearLoop() {
+      if (timeTicket) {
+        clearInterval(timeTicket);
+        timeTicket = 0;
+      }
+      chart.off('mousemove', stopAutoShow);
+      zRender.off('mousemove', zRenderMouseMove);
+      zRender.off('globalout', zRenderGlobalOut);
+    }
+
+    /**
+     * 取消高亮
+     */
+    function cancelHighlight() {
+      /**
+       * 如果dataIndex为0表示上次系列完成显示,如果是循环系列,且系列索引为0则上次是seriesLen-1,否则为seriesIndex-1;
+       * 如果不是循环系列,则就是当前系列;
+       * 如果dataIndex>0则就是当前系列。
+       */
+      let tempSeriesIndex = dataIndex === 0 ?
+        (options.loopSeries ?
+          (seriesIndex === 0 ? seriesLen - 1 : seriesIndex - 1)
+          : seriesIndex)
+        : seriesIndex;
+      let tempType = chartOption.series[tempSeriesIndex].type;
+
+      if (tempType === 'pie' || tempType === 'radar') {
+        chart.dispatchAction({
+          type: 'downplay',
+          seriesIndex: lastShowSeriesIndex,
+          dataIndex: lastShowDataIndex
+        });//wait 系列序号为0且循环系列,则要判断上次的系列类型是否是pie、radar
+      }
+    }
+
+    /**
+     * 自动轮播tooltip
+     */
+    function autoShowTip() {
+      let invalidSeries = 0;
+      let invalidData = 0;
+
+      function showTip() {
+        //判断是否更新数据
+        if (dataIndex === 0 && !first && typeof options.updateData === "function") {
+          options.updateData();
+          chart.setOption(chartOption);
+        }
+
+        let series = chartOption.series;
+        let currSeries = series[seriesIndex];
+        if (!series || series.length === 0 ||
+          !currSeries || !currSeries.type || !currSeries.data ||
+          !currSeries.data.length) {
+          return;
+        }
+        chartType = currSeries.type; // 系列类型
+        dataLen = currSeries.data.length; // 某个系列的数据个数
+
+        let tipParams = {seriesIndex: seriesIndex};
+        switch (chartType) {
+          case 'pie':
+          case 'map':
+          case 'chord':
+            tipParams.name = currSeries.data[dataIndex].name;
+            break;
+          case 'radar': // 雷达图
+            tipParams.seriesIndex = seriesIndex;
+            tipParams.dataIndex = dataIndex;
+            break;
+          default:
+            tipParams.dataIndex = dataIndex;
+            break;
+        }
+
+        if (chartType === 'pie' || chartType === 'radar') {
+          if (!first) {
+            cancelHighlight();
+          }
+
+          // 高亮当前图形
+          chart.dispatchAction({
+            type: 'highlight',
+            seriesIndex: seriesIndex,
+            dataIndex: dataIndex
+          });
+        }
+
+        // 显示 tooltip
+        tipParams.type = 'showTip';
+
+        // 防止updateData时先处理tooltip后刷新数据导出tooltip显示不正确
+        setTimeout(() => {
+          chart.dispatchAction(tipParams);
+        }, 0);
+
+        lastShowSeriesIndex = seriesIndex;
+        lastShowDataIndex = dataIndex;
+        dataIndex = (dataIndex + 1) % dataLen;
+        if (options.loopSeries && dataIndex === 0) { // 数据索引归0表示当前系列数据已经循环完
+          invalidData = 0;
+          seriesIndex = (seriesIndex + 1) % seriesLen;
+          if (seriesIndex === options.seriesIndex) {
+            invalidSeries = 0;
+          }
+        }
+
+        first = false;
+      }
+
+      showTip();
+      timeTicket = setInterval(showTip, options.interval);
+    }
+
+    // 关闭轮播
+    function stopAutoShow() {
+      if (timeTicket) {
+        clearInterval(timeTicket);
+        timeTicket = 0;
+
+        if (chartType === 'pie' || chartType === 'radar') {
+          cancelHighlight();
+        }
+      }
+    }
+
+    let zRender = chart.getZr();
+
+    function zRenderMouseMove(param) {
+      if (param.event) {
+        //阻止canvas上的鼠标移动事件冒泡
+        param.event.cancelBubble = true;
+      }
+
+      stopAutoShow();
+    }
+
+    // 离开echarts图时恢复自动轮播
+    function zRenderGlobalOut() {
+      if (!timeTicket) {
+        autoShowTip();
+      }
+    }
+
+    // 鼠标在echarts图上时停止轮播
+    chart.on('mousemove', stopAutoShow);
+    zRender.on('mousemove', zRenderMouseMove);
+    zRender.on('globalout', zRenderGlobalOut);
+
+    autoShowTip();
+
+    return {
+      clearLoop: clearLoop
+    };
+  };
+})(window);